-
-
Notifications
You must be signed in to change notification settings - Fork 143
mago could warn about the use of preg_replace with explode would suffice #1554
Copy link
Copy link
Open
Labels
c-linterPHP linting for errors, style, and bugsPHP linting for errors, style, and bugst-enhancementNew feature or requestNew feature or request
Description
Feature
I'd like mago to warn about the use of preg_split when explode would suffice: When flags is 0, and the string content doesn't contain any of the special chars preg_quote escapes: \ + * ? [ ^ ] $ ( ) { } = ! < > | : - #
Ideally it could also offer a fixer for that, but a warning alone would be very useful for me. I've got 20 years of regex abuse to clean up :-)
Example
<?php
# Example where it should warn.
$csvline="1, 2, 3, 4, 99";
foreach (preg_split("/, /",$csvline) as $k=>$v) {
print "#$k = $v\n";
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c-linterPHP linting for errors, style, and bugsPHP linting for errors, style, and bugst-enhancementNew feature or requestNew feature or request