-
Notifications
You must be signed in to change notification settings - Fork 71
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
Use short form for type casts #102
Conversation
@@ -272,7 +272,7 @@ module.exports = { | |||
return this.node('cast')('int', this.next().read_expr()); | |||
|
|||
case this.tok.T_DOUBLE_CAST: | |||
return this.node('cast')('double', this.next().read_expr()); | |||
return this.node('cast')('float', this.next().read_expr()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure in PHP but in principle double and float have not the same precision, I'll check this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 got it from https://github.com/glayzzle/php-parser/blob/master/src/lexer.js#L111, actually there is only one token to these 3 casts types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly - they are just aliases in PHP 😉
@@ -142,28 +142,35 @@ describe('Test expressions', function() { | |||
}); | |||
|
|||
it('test cast', function() { | |||
var typesWithAlias = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything is good
hi @czosel, I'll release it under 2.2.0 soon, I need to fix another little regression elsewhere, almost done |
Awesome! Thanks to your support I'm positive we'll have a working prettier implementation for PHP soon! |
The
type
of types casts has been inconsistent: Sometimes, an alias/long form was used (e.g.boolean
), other times the short form (e.g.int
). This PR changes this by always using the short form.Please also see prettier/plugin-php#5 (comment) for some more context.
Thanks for your feedback in advance!