-
Notifications
You must be signed in to change notification settings - Fork 72
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
Merge php8
back into master
#809
Conversation
…rator add php8 nullsafe operator
feat(php8): union types with new AST node
…tch-statement # Conflicts: # src/ast/matcharm.js
feat(php8): match expression
feat(php8): named arguments
…d-props Fixed parsing of optional promoted properties when type is nullable
PHP8 Attrributes repeating
… parsing classes and interfaces
…n-src-location Fix method flags in src location
…for-static-type-return Add support for static type return
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.
That's the first quick review of the code, I would need to run it on my computer and read it again, complementary with coments made on #807
src/lexer/scripting.js
Outdated
@@ -16,6 +16,11 @@ module.exports = { | |||
case "\r\n": | |||
return this.T_WHITESPACE(); | |||
case "#": | |||
if (this._input[this.offset] === "[") { |
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.
should check the php version before parsing as PHP8
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.
fixed
).toMatchSnapshot(); | ||
}); | ||
it("can parse anon-class attributes", () => { | ||
expect(parser.parseEval(`$a = new #[T] class {};`)).toMatchSnapshot(); |
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.
could be cool to add tests over previous PHP versions in order to test non regressions
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.
added a test for anonymous classes and functions
} | ||
`) | ||
).toMatchSnapshot(); | ||
}); |
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.
missing tests over bad syntax on php 8 like :
#[Foo]
$a = 1;
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.
Good call - turns out we're currently dropping the first line instead of parsing it as a comment. I'm not sure about how to fix this correctly, shall we create a separate issue for it? cc @cseufert
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.
Yes, I guess we need to check if the attribute was consumed, and if not, throw an error. Sorry been absolutely flat out, but will have a look when I get some time.
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.
@cseufert no worries, thanks for the feedback!
it("knows where a function definiton starts", function () { | ||
const phpCode = ` | ||
class b { | ||
// prettier-ignore |
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.
should also test with an attribute (as I think they are also included)
class... {
#[Foo]
// comment
public function ...
}
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.
This case is already covered here: https://github.com/glayzzle/php-parser/pull/809/files#diff-afaacbd57a577ff9abf9ab4d44fc4ca9a4a814f5ed5fb7a6b381494d268bb5c0R32 (attributes.test.js, can parse params with comments
)
Hi @ichiriac 🙂 Do you think we can move forward with this? The only open issue is #809 (comment), which we can address in a separate PR i think. |
@ichiriac friendly bump 🙃 |
Hi @ichiriac, happy holidays 🙂 Is there anything I can do to help move this forward? |
Maybe @b4dnewz can help since he is the second member of glayzzle? |
@jebarjonet Yeah, it would be great if someone else could take a look. I'm not sure if anyone else next to @ichiriac knows the codebase well enough, but I guess slowly the benefits of moving this forward outweigh the risk of introducing issues (which can then be fixed). I also have merge permissions on the repo, but I'd prefer not to use them without anyone else's approval 😉 |
@ichiriac Friendly ping |
Updated version of #807 with resolved conflicts