Removing usage of preg_quote broke PHP 7.2
Closed this issue · 1 comments
nico-incubiq commented
This commit causes php 7.2.* to choke (tested on 7.2.19 and 7.2.23). Here's a simple bit of code i put together to reproduce:
use PhpCsFixerCustomFixers\Fixer\PhpdocSelfAccessorFixer;
include_once('./vendor/autoload.php');
$reflection = new ReflectionClass(PhpdocSelfAccessorFixer::class);
$method = $reflection->getMethod('getNewContent');
$method->setAccessible(true);
$fixer = new PhpdocSelfAccessorFixer();
$method->invoke($fixer, '/**
* @param string $message Error message.
*/', 'Nicolas\ErrorCatalogue', 'PublicException');
The error is: PHP Warning: preg_replace(): Compilation failed: unknown property name after \P or \p at offset 72
. Seems to come from the fact the quoting doesn't work properly, as the \E
in \ErrorCatalogue
is wrongly interpreted as the end of the quoting. This is fixed in PHP 7.3, but it might be easier to bring back preg_quote
rather than releasing a new bugfix version of PHP 7.2.
kubawerlos commented
Thanks @nico-incubiq for the report, I've found a case that brakes each PHP version.