struggle-for-php / angry-regex
PHPStan Rule to detect Unfavorable Regex
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 3
Open Issues: 1
Type:phpstan-extension
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-10-15 20:56:43 UTC
README
PHPStan Rule to detect Unfavorable Regex.
and add more checking than PHPStan's Regex check.
Based on Tokumaru's statement
正規表現によるバリデーションでは ^ と $ ではなく \A と \z を使おう
Example
$ ../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
Installation
composer require --dev struggle-for-php/angry-regex
Configuration
In your phpstan.neon
configuration, add following section:
includes: - vendor/struggle-for-php/angry-regex/rules.neon
Also see.
- Validator\Ip should not allow newlines in any case. - zendframework/zendframework#6104