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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamic propertylookup #183

Merged
merged 5 commits into from
Mar 9, 2018
Merged

Conversation

czosel
Copy link
Collaborator

@czosel czosel commented Mar 8, 2018

There are probably many cases where this still breaks, but it might be an improvement anyway 馃槃
#112

@mgrip
Copy link
Contributor

mgrip commented Mar 8, 2018

is it worth considering doing this from the parent level instead of the child?

ie when we print the property lookup, and node.offset.kind !== "constref", then wrap in curly's? Might be simpler than trying to go the other way and trying to catch every edge case

@czosel
Copy link
Collaborator Author

czosel commented Mar 9, 2018

@mgrip Of course, i can't believe i didn't notice that 馃槄

@@ -23,6 +23,6 @@ $encapsHereDoc2 = <<<STR
Hello foo $a bar
new line
STR;
$encapsedOffset = $a->bar$b;
$encapsedOffset = $a->{bar$b};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is $a->bar$b valid PHP?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, it seems to be a parse error in PHP7

php > $a = new stdClass;
php > $a->foobar = 1;
php > $b = 'bar';
php > echo $a->{"foo$b"};
1
php > echo $a->foo$b;

Parse error: syntax error, unexpected '$b' (T_VARIABLE), expecting ',' or ';' in php shell code on line 1
php > echo $a->{foo$b};

Parse error: syntax error, unexpected '$b' (T_VARIABLE) in php shell code on line 1

Copy link
Collaborator Author

@czosel czosel Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤 i'll remove it from the tests ... done!

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good solution 馃憤

@czosel czosel merged commit b8a8d79 into prettier:master Mar 9, 2018
@czosel czosel deleted the curly-propertylookup branch March 9, 2018 14:20
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 this pull request may close these issues.

None yet

4 participants