承接 php-standard-library/phpstan-extension 相关项目开发

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

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

php-standard-library/phpstan-extension

最新稳定版本:2.0.2

Composer 安装命令:

composer require php-standard-library/phpstan-extension

包简介

PHPStan PSL extension

README 文档

README

Build Latest Stable Version License

Description

The main goal of this extension is to help PHPStan to detect the types after using Psl\Type\shape.

Given the following example:

use Psl\Type;

$specification = Type\shape([
    'name' => Type\string(),
    'age' => Type\int(),
    'location' => Type\optional(Type\shape([
        'city' => Type\string(),
        'state' => Type\string(),
        'country' => Type\string(),
    ]))
]);

$input = $specification->coerce($_GET['user']);

PHPStan assumes that $input is of type array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>.

If we enable the extension, you will get a more specific and correct type of array{name: string, age: int, location?: array{city: string, state: string, country: string}}.

Besides coerce, this extension also supports matches() and assert() methods.

Installation

To use this extension, require it in Composer:

composer require --dev php-standard-library/phpstan-extension

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/php-standard-library/phpstan-extension/extension.neon

统计信息

  • 总下载量: 1.04M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 2
  • 依赖项目数: 16
  • 推荐数: 1

GitHub 信息

  • Stars: 17
  • Watchers: 4
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-10