struggle-for-php / sfp-psalm-dont-operation-inside-constructor-plugin
在构造函数内不执行操作
0.1.0
2023-03-18 13:58 UTC
Requires
- php: ~8.1.0 || ~8.2.0
- ext-simplexml: *
- nikic/php-parser: ^4.10
- struggle-for-php/resource-operations: ^4.0.1
- vimeo/psalm: ^5
Requires (Dev)
- doctrine/coding-standard: ^10
- infection/infection: ^0.26.19
- phpunit/phpunit: ^10
- slevomat/coding-standard: ^8
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-09-22 09:08:22 UTC
README
$ ./vendor/bin/psalm
Scanning files...
Analyzing files...
░░░░░░░░░░░░░
ERROR: MethodOperationInsideConstructorIssue - src/app/Controllers/BlogController.php:15:9 - 'SplFileInfo::openfile' not allowed inside __construct()
$log->openFile('w+');
ERROR: MethodOperationInsideConstructorIssue - src/app/models/Model.php:26:13 - 'PDO::query' not allowed inside __construct()
$this->pdo->query($query);
------------------------------
2 errors found
------------------------------
特性
- 检查操作 资源
- 资源操作函数列表由 struggle-for-php/resource-operations 提供
- 基于 sebastianbergmann/resource-operations 的分支
待办事项
- 支持灵活设置 XML 以标记供应商库
免责声明
此插件处于非常实验性的状态。
安装
$ composer require --dev struggle-for-php/sfp-psalm-dont-operation-inside-constructor-plugin:dev-master
$ vendor/bin/psalm-plugin enable struggle-for-php/sfp-psalm-dont-operation-inside-constructor-plugin