PHPStan Rule to detect Unfavorable Regex.
and add more checking than PHPStan's Regex check.
正規表現によるバリデーションでは ^ と $ ではなく \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
In your phpstan.neon
configuration, add following section:
includes:
- vendor/struggle-for-php/angry-regex/rules.neon
- Validator\Ip should not allow newlines in any case. - zendframework/zendframework#6104