承接 jbboehr/phpstan-array-merge 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jbboehr/phpstan-array-merge

最新稳定版本:v0.1.0

Composer 安装命令:

composer require jbboehr/phpstan-array-merge

包简介

README 文档

README

ci License: AGPL v3+ stability-experimental

Installation

To use this extension, require it in Composer:

composer require --dev jbboehr/phpstan-array-merge

If you also install phpstan/extension-installer then you're all set!

Manual installation

If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:

includes:
    - vendor/jbboehr/phpstan-array-merge/extension.neon

Usage

Have you ever wanted to have a function that performs an array_merge()-like operation but want that generic goodness PHPStan has to offer? WAIT NO MORE!

<?php

class ConstFixture
{
    public const ARRAY = ['foo' => 'bar'];

    /**
     * @template T of array<mixed>
     * @param T $a
     * @phpstan-return array-merge<self::ARRAY, T>
     */
    public static function constMerge(array $a): array
    {
        return array_merge(self::ARRAY, $a);
    }
}
<?php

\PHPStan\dumpType(ConstFixture::constMerge(['baz' => 'bat']));
$ phpstan

 ------ --------------------------------------------
  Line   tmp.php
 ------ --------------------------------------------
  3      Dumped type: array{foo: 'bar', baz: 'bat'}
 ------ --------------------------------------------

If you mix generic arrays and array shapes, you get what is coming to you (or open an issue).

License

This project is licensed under the AGPL v3+ License - see the LICENSE.md file for details.

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2025-06-07