Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Replacement data still remain' logic error cause #340

Closed
pgee70 opened this issue Jul 27, 2020 · 6 comments
Closed

'Replacement data still remain' logic error cause #340

pgee70 opened this issue Jul 27, 2020 · 6 comments
Labels

Comments

@pgee70
Copy link

pgee70 commented Jul 27, 2020

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!

@kenjis kenjis added the bug label Jul 28, 2020
@kenjis
Copy link
Owner

kenjis commented Jul 28, 2020

@pgee70 Thank you for reporting!

I didn't know why Travis tests fail recently.

@kenjis
Copy link
Owner

kenjis commented Aug 31, 2020

I fixed the version for now. #347

@kenjis
Copy link
Owner

kenjis commented Dec 25, 2020

Because of #347, we can't install PHPUnit 9.3.

@kenjis
Copy link
Owner

kenjis commented Feb 27, 2021

I'm trying to fix this problem, but it is still in the way.
See #364
See #365

@kenjis
Copy link
Owner

kenjis commented Mar 2, 2021

Fixed #366

@kenjis
Copy link
Owner

kenjis commented Mar 2, 2021

Fixed in v0.19.0.

@kenjis kenjis closed this as completed Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants