[php-src] PR #20750: feat: add PREG_REPLACE_COUNT_CHANGES flag for counting actual replace
| From: | jordikroon | Date: | Sun, 21 Dec 2025 12:32:34 +0000 |
| Subject: | [php-src] PR #20750: feat: add PREG_REPLACE_COUNT_CHANGES flag for counting actual replace | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34338@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20750
Author: jordikroon
Add a new flag
PREG_REPLACE_COUNT_CHANGES to preg_replace() and preg_replace_callback()
that counts only effective changes rather than all matched replacements. When this flag is set, the
replacement count is incremented only when the replacement differs from the original matched text,
allowing callers to distinguish between identity replacements and actual content changes.
- Add PREG_REPLACE_COUNT_CHANGES constant definition
- Extend php_pcre_replace() and php_pcre_replace_impl() signatures with
flags parameter
- Implement change detection logic comparing replacement with original match
- Update function signatures throughout the codebase (php_pcre_replace_array,
php_replace_in_subject, _preg_replace_common)
- Add test coverage for identity replacements, backreferences, and callbacks
- Update stub definitions and internal function signatures