'Replacement data still remain' logic error cause
pgee70 opened this issue · 6 comments
This isn't really a bug report, just an error report, more to help others.
when installing via composer your library kenjis/ci-phpunit-test:2.x-dev
this installed the most recent version of nikic/php-parser V4.7.0
when php-parser v4.7 tokenises a file, this version has a post-processing step. This step changes the offsets of the nodes, so that functions that have to be substituted out (from the white-list + overloads) are out of sync with the nodes from token_get_all().
so when your code gets around to using static::$replacement in abstract class AbstractPatcher, the nodes have the wrong index.
This in turn causes the function to not be found in FunctionPatcher::generateNewSource, generating a throw new LogicException('Replacement data still remain');
While the cause took me many hours to locate, the fix is simple, explicitly use the recommended version of php-parser, so my composer.json becomes:
"require-dev": {
"phpunit/phpunit": "8.4.3",
"kenjis/ci-phpunit-test": "2.x-dev",
"nikic/php-parser": "4.2.5"
}
then just update composer and the problem was fixed!
Fixed in v0.19.0.