jetbrains/phpstorm-attributes
Composer 安装命令:
composer require jetbrains/phpstorm-attributes
包简介
PhpStorm specific attributes
README 文档
README
PhpStorm attributes
Use these PHP 8 attributes in PhpStorm to get more advanced code completion and analysis.
Learn more in the blog post.
Installation
The attributes are available in PhpStorm 2020.3 and later. They are bundled with PhpStorm so you don’t need to install them separately.
If you are using other static analysis tools and don’t want to get Class not found issues, then you might want to add the attributes package to your composer.json as a dev dependency:
composer require --dev jetbrains/phpstorm-attributes
#[Deprecated]
Use this attribute when you want to notify users that an entity will be removed in the future.
Provide the explanation tip in reason and updating suggestion in replacement.
#[Deprecated(
reason: 'since Symfony 5.2, use setPublic() instead',
replacement: '%class%->setPublic(!%parameter0%)'
)]
#[ArrayShape]
Use Array Shape when you deal with object-like arrays and want to specify the keys’ names and types for values to get better coding assistance.
#[ArrayShape([ // 'key' => 'type', 'key1' => 'int', 'key2' => 'string', 'key3' => 'Foo', 'key3' => App\PHP8\Foo::class, ])] function functionName(...): array
The attribute works with PHP ≤ 7.4 if specified in one line.
#[ObjectShape]
The attribute specifies possible object field names and their types. If applied, an IDE will suggest the specified field names and infer the specified types.
#[ObjectShape(["age" => "int", "name" => "string"])] function functionName(): object {...} $obj = functionName();
This usage effectively means that the $obj has 2 fields, the names are age and name, and the corresponding types are int and string.
#[Immutable]
Mark properties or entire objects with this attribute if you want to guarantee they won't be changed after initialization.
#[Immutable] class DTO { public string $val; public function __construct(string $val) { $this->val = $val; } }
The attribute works with PHP ≤ 7.4 if specified in one line.
#[Pure]
Use this attribute for functions that do not produce any side effects. All such PHP internal functions are already marked in PhpStorm.
#[Pure] function compare(Foo $a, Foo $b): int { return $a->a <=> $b->b; }
#[ExpectedValues]
Use this attribute to specify which values exactly a function accepts as parameters and which it can return. This will improve coding assistance.
function response( #[ExpectedValues(valuesFromClass: Response::class)] $httpStatusCode, //... ) { //... }
#[NoReturn]
Mark functions that terminate script execution as exit points with this attribute to get a more accurate control flow analysis.
#[NoReturn] function redirect(): void { //... exit(); }
#[Language]
Add this attribute to mark string parameters that contain text in some other [programming] language, for example, RegExp, SQL, and so on. This will improve highlighting and reveal additional features of PhpStorm for you.
Bugs and feature requests
Please report any issues to the PhpStorm issue tracker https://youtrack.jetbrains.com/newIssue?project=WI.
Pull requests are also welcome.
jetbrains/phpstorm-attributes 适用场景与选型建议
jetbrains/phpstorm-attributes 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.66M 次下载、GitHub Stars 达 411, 最近一次更新时间为 2020 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「attributes」 「phpstorm」 「jetbrains」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jetbrains/phpstorm-attributes 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jetbrains/phpstorm-attributes 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jetbrains/phpstorm-attributes 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Cassandra php driver library IDE stubs which enables autocompletion in modern IDEs.
PhpStorm meta data for expected arguments completion in Doctrine projects.
A library that allows you to easily use the PHP-VCR library in your PHPUnit tests.
This Package provides some usefully console features like the attribute syntax for arguments and options, validation, auto ask and casting.
Yii2 component stubs generator for Yii::$app
Install pre-configured guides for Jetbrains Junie
统计信息
- 总下载量: 17.66M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 414
- 点击次数: 31
- 依赖项目数: 728
- 推荐数: 4
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2020-11-17