phpstan/phpstan-deprecation-rules
Composer 安装命令:
composer require --dev phpstan/phpstan-deprecation-rules
包简介
PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.
关键字:
README 文档
README
Installation
To use this extension, require it in Composer:
composer require --dev phpstan/phpstan-deprecation-rules
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 rules.neon in your project's PHPStan config:
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
Deprecating code you don't own
This extension emits deprecation warnings on code, which uses properties/functions/methods/classes which are annotated as @deprecated.
In case you don't own the code which you want to be considered deprecated, use PHPStan Stub Files to declare deprecations for vendor files like:
/** @deprecated */
class ThirdPartyClass {}
Custom deprecation markers
You can implement extensions to support even e.g. custom #[MyDeprecated] attribute. Learn more.
Custom deprecated scopes
Usage of deprecated code is not reported in code that is also deprecated:
/** @deprecated */ function doFoo(): void { // not reported: anotherDeprecatedFunction(); }
If you have a different way of marking code that calls deprecated symbols on purpose and you don't want these calls to be reported either, you can write an extension by implementing the DeprecatedScopeResolver interface.
For example if you mark your PHPUnit tests that test deprecated code with @group legacy, you can implement the extension this way:
class GroupLegacyScopeResolver implements DeprecatedScopeResolver { public function isScopeDeprecated(Scope $scope): bool { $function = $scope->getFunction(); return $function !== null && $function->getDocComment() !== null && strpos($function->getDocComment(), '@group legacy') !== false; } }
And register it in your configuration file:
services: - class: GroupLegacyScopeResolver tags: - phpstan.deprecations.deprecatedScopeResolver
Learn more about Scope, a core concept for implementing custom PHPStan extensions.
phpstan/phpstan-deprecation-rules 适用场景与选型建议
phpstan/phpstan-deprecation-rules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87.06M 次下载、GitHub Stars 达 454, 最近一次更新时间为 2018 年 06 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「static analysis」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpstan/phpstan-deprecation-rules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpstan/phpstan-deprecation-rules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpstan/phpstan-deprecation-rules 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
TwigStan is a static analyzer for Twig templates powered by PHPStan
Sentiment analysis library for PHP.
Database Standardization and Analysis Tool for Laravel
Enforce architecture by defining modules with allowed dependencies. Detects forbidden, uncovered, missing and unused module dependencies in PHP projects.
Arc5 provides a set of static classes for the Mvc5 Framework
统计信息
- 总下载量: 87.06M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 459
- 点击次数: 21
- 依赖项目数: 6812
- 推荐数: 8
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-24