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

new-keyword-redefinable causes Parse error: syntax error, unexpected token "->" #127

Closed
wvega opened this issue Feb 7, 2022 · 1 comment · Fixed by #128
Closed

new-keyword-redefinable causes Parse error: syntax error, unexpected token "->" #127

wvega opened this issue Feb 7, 2022 · 1 comment · Fixed by #128

Comments

@wvega
Copy link
Contributor

wvega commented Feb 7, 2022

Thank you again for quickly fixing #126! I ran into a different problem after I tried 2.1.20 on my project.

Patchwork rewrites the following:

$test = new class(new TestClass()) {
};

as something like:

$test = new class\Patchwork\CallRerouting\getInstantiator(...)->instantiate() {
}

The spliceAllInstantiations() removes the parenthesis around (new TestClass()) and produces an invalid anonymous class declaration:

if (hasExtraParentheses($s, $new)) {
removeExtraParentheses($s, $new);
}

I believe the fix for this problem is to add T_CLASS to the list of exceptions in hasExtraParentheses() so I'll try to pen a PR with tests and that oneliner.

@antecedent
Copy link
Owner

Thank you for fixing this! This is now part of version 2.1.21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants