slam/phpstan-extensions
Composer 安装命令:
composer require slam/phpstan-extensions
包简介
Slam extension of phpstan
README 文档
README
Extensions for PHPStan
Installation
To use this extension, require it in Composer:
composer require --dev slam/phpstan-extensions
Usage
When you are using phpstan/extension-installer,
conf/slam-rules.neon will be automatically included.
Otherwise you need to include conf/slam-rules.neon in your phpstan.neon:
includes: - vendor/slam/phpstan-extensions/conf/slam-rules.neon
Rules
SlamPhpStan\UnusedVariableRule: check for variable inside functions never used after initial assignmentSlamPhpStan\MissingClosureParameterTypehintRule: requires parameter typehints for closures; WARNING: no PhpDoc allowed, seephpstan/phpstan-strict-rules#87SlamPhpStan\StringToClassRule: requires strings that refer to classes to be expressed with::classnotationSlamPhpStan\GotoRule: no goto allowedSlamPhpStan\ClassNotationRule:- Interfaces must end with "Interface"
- Traits must end with "Trait"
- Abstract classes must start with "Abstract"
- Exceptions must end with "Exception"
SlamPhpStan\PhpUnitFqcnAnnotationRule: classes found in following PHPUnit annotations must exist:@expectedException@covers@coversDefaultClass@uses
SlamPhpStan\AccessGlobalVariableWithinContextRule: inhibit the access to globals within classes that extend or implement a certain class/interfaceSlamPhpStan\AccessStaticPropertyWithinModelContextRule: inhibit the access to static attributes of a class within classes that extend or implement a certain class/interface, useful to prohibit usage of singletons in models
Not-NOW config
A not-now-rules.neon config is present for forbidding raw date system calls:
includes: - vendor/slam/phpstan-extensions/conf/not-now-rules.neon
These rules forbid:
new DateTimeImmutable()new DateTime('yesterday')date('Y-m-d')time(),microtime()strtotime('noon')
You should instead rely on a clock abstraction like lcobucci/clock.
WARNING: the rules are not perfect, a user can tricks them easily; they are meant only to help the transition to a proper clock abstraction.
Symfony-specific config
A symfony-rules.neon config is present for Symfony projects:
includes: - vendor/slam/phpstan-extensions/conf/symfony-rules.neon
With the following configurations:
SlamPhpStan\SymfonyFilesystemRule: forbid calls to raw filesystem functions well wrapped bysymfony/filesystemcomponentSlamPhpStan\SymfonyProcessRule: forbid calls to raw system functions well wrapped bysymfony/processcomponent
Yii-specific config
A yii-rules.neon config is present for Yii projects:
includes: - vendor/slam/phpstan-extensions/conf/yii-rules.neon
With the following configurations:
SlamPhpStan\AccessGlobalVariableWithinContextRuleto deny the usage of$_GET,$_POSTand other global variables in models implementingyii\db\ActiveRecordInterface: accessing to singletons in models is considered an anti-patternSlamPhpStan\AccessStaticPropertyWithinModelContextRuleto deny the usage ofyii\BaseYiistatic variables like$appin models implementingyii\db\ActiveRecordInterface: accessing to singletons in models is considered an anti-pattern
slam/phpstan-extensions 适用场景与选型建议
slam/phpstan-extensions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.57M 次下载、GitHub Stars 达 71, 最近一次更新时间为 2018 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 slam/phpstan-extensions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 slam/phpstan-extensions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.57M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 71
- 点击次数: 15
- 依赖项目数: 107
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-05