A preg_replace pattern uses the removed modifier that evaluates the replacement as code
What it finds
preg_replace('/(\w+)/e', ...): the e modifier evaluated the replacement as PHP code, with the matched text in it, which made every such call a way to run injected code. PHP 7 removed it, and the call now fails; preg_replace_callback does the job.
From the rule's source, regex_eval_modifier.rs.
<?phpfunction upper($s){ $a = preg_replace('/(\w+)/e', 'strtoupper("$1")', $s);tx0 reports: this pattern uses the e modifier $b = preg_replace('/(\w+)/i', '$1', $s); return $a . $b;} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/php:regex-eval-modifier" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:regex-eval-modifier] reason="..."tx0 explain tx0/php:regex-eval-modifier shows the same in the terminal. Found a false positive? Report it.