Repository navigation
Blink: fix NoUnneededControlParentheses on clone, and ConstantCase on names - #289
Merged
Merged
Conversation
The expected output of the tables comes from the PHP engine. The fix follows.
…nstantCase clone was handled like return, so "clone ($a, [...])" became a parse error and "clone ($a ?: $b)" lost its meaning. Follow PHP-CS-Fixer's isWrappedCloneArgument. Different on purpose: after "?", the pair comes off only directly before ":", because PHP-CS-Fixer's output for "$f ? clone (new Foo)->bar : 1" is a parse error. ConstantCase changed every name that looks like true, false or null, so "const NULL" became "const null" and "self::NULL" failed at runtime. Follow PHP-CS-Fixer's checks.
Contributor
Author
|
CI here waits for a maintainer's approval, so I ran it on my fork. With the test commit alone, |
PHP-CS-Fixer removes these parentheses and the result is right, so blink should too. The expected output comes from the PHP engine. The fix follows.
"$f ? clone ($a)->b : 1" keeps its meaning without them, so follow PHP-CS-Fixer there. Other operands still keep them before anything but ":", where its output breaks.
Contributor
Author
|
I added two commits so a plain variable after |
Member
|
LGTM, Thank you 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Blink breaks this code. The PHP engine does not.
NoUnneededControlParentheses:clone ($a, ['x' => 1])andclone(...)became a parse error, andclone ($a ?: $b)lost its meaning.ConstantCase:const NULL = 1;becameconst null = 1;, soself::NULLfailed at runtime.Each fix commit follows a commit of failing tests, with expected output from the PHP engine.
One difference on purpose: after
?, the parentheses of anything but a plain variable only come off before:. PHP-CS-Fixer's output is a parse error for$f ? clone (new Foo)->bar : 1and has another meaning for$f ? clone ($o->b)() : 1. A few harmless shapes such as$f ? clone ($o->b)->c : 1keep them too.🤖 Generated with Claude Code