struggle-for-php / angry-regex
PHPStan 规则用于检测不利的正则表达式
0.0.2
2019-06-10 11:54 UTC
Requires
- php: >=7.2.0
- phpstan/phpstan: ^0.11
Requires (Dev)
- phpstan/phpstan-phpunit: ^0.11.2
- phpunit/phpunit: ^8.1
- zendframework/zend-coding-standard: 2.0.0-alpha3
This package is auto-updated.
Last update: 2024-09-15 20:51:07 UTC
README
PHPStan 规则用于检测不利的正则表达式。
并且比 PHPStan 的正则表达式检查添加更多的检查。
基于 Tokumaru 的声明
在正则表达式验证中,请使用 \A 和 \z 而不是 ^ 和 $
示例
$ ../vendor/bin/phpstan analyse --level=1 src/ Note: Using configuration file /tmp/angry-regex/demo/phpstan.neon. 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% ------ ------------------------------------------------------------- Line Demo.php ------ ------------------------------------------------------------- 17 Regex pattern is invalid: Unfavorable `^` or `$` /^[0-9]+$/ ------ ------------------------------------------------------------- [ERROR] Found 1 error
安装
composer require --dev struggle-for-php/angry-regex
配置
在你的 phpstan.neon
配置文件中,添加以下部分
includes: - vendor/struggle-for-php/angry-regex/rules.neon
另请参阅。
- Validator\Ip 在任何情况下都不应允许换行符。 - zendframework/zendframework#6104