For instance, Patchwork's preprocessor botches Symfony's MicroKernelTrait. The folowing line (:187 of v7.0) is the first to reveal the issue:
$configureContainer->getClosure($this)(new ContainerConfigurator($container, $kernelLoader, $instanceof, $file, $file, $this->getEnvironment()), $loader, $container);
This ends up causing bug #146; specifically, it is the part mentioned in this comment.
Two observations are of interest here:
-
Expressions of the shape foo($x)($y) were not permitted in PHP ≤5.
-
Another peculiarity of PHP ≤5's parser was the different treatment of the following expressions:
// Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)
(foo())->bar
Starting with version 2.1.0, Patchwork supports the interception of new expressions. To maintain compatibility with PHP 5, an effort was made to prevent the Patchwork's preprocessor from introducing the the error illustrated by Observation 2 above. This means unparenthesizing some expressions, but not others. To this end, a list of token types is being kept in Patchwork\CodeManipulation\Actions\RedefinitionOfNew\hasExtraParentheses(). It is precisely after those tokens that parentheses are left intact.
To accommodate the more reasonable grammars of PHP 7+'s parsers that now allow expressions like the one in Observation 1, let us expand the aforementioned "do not unparenthesize after" list with the following tokens:
For instance, Patchwork's preprocessor botches Symfony's MicroKernelTrait. The folowing line (:187 of v7.0) is the first to reveal the issue:
This ends up causing bug #146; specifically, it is the part mentioned in this comment.
Two observations are of interest here:
Expressions of the shape
foo($x)($y)were not permitted in PHP ≤5.Another peculiarity of PHP ≤5's parser was the different treatment of the following expressions:
Starting with version 2.1.0, Patchwork supports the interception of
newexpressions. To maintain compatibility with PHP 5, an effort was made to prevent the Patchwork's preprocessor from introducing the the error illustrated by Observation 2 above. This means unparenthesizing some expressions, but not others. To this end, a list of token types is being kept in Patchwork\CodeManipulation\Actions\RedefinitionOfNew\hasExtraParentheses(). It is precisely after those tokens that parentheses are left intact.To accommodate the more reasonable grammars of PHP 7+'s parsers that now allow expressions like the one in Observation 1, let us expand the aforementioned "do not unparenthesize after" list with the following tokens:
)]