-
Notifications
You must be signed in to change notification settings - Fork 64
Support unsealed array shapes #169
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -503,29 +503,32 @@ private function tryParseArrayOrOffsetAccess(TokenIterator $tokens, Ast\Type\Typ | |
private function parseArrayShape(TokenIterator $tokens, Ast\Type\TypeNode $type): Ast\Type\ArrayShapeNode | ||
{ | ||
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET); | ||
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { | ||
return new Ast\Type\ArrayShapeNode([]); | ||
} | ||
|
||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); | ||
$items = [$this->parseArrayShapeItem($tokens)]; | ||
$items = []; | ||
$sealed = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jrmajor this cause error on Rector side, if this goes to that's sealed true make all changes to add https://github.com/rectorphp/rector-src/actions/runs/3706328433/jobs/6281403238 we forced pin to use 1.5.0 and the issue disappear |
||
|
||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); | ||
while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { | ||
do { | ||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); | ||
|
||
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { | ||
// trailing comma case | ||
return new Ast\Type\ArrayShapeNode($items); | ||
} | ||
|
||
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC)) { | ||
$sealed = false; | ||
$tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA); | ||
break; | ||
} | ||
|
||
$items[] = $this->parseArrayShapeItem($tokens); | ||
|
||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); | ||
} | ||
} while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)); | ||
|
||
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); | ||
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET); | ||
|
||
return new Ast\Type\ArrayShapeNode($items); | ||
return new Ast\Type\ArrayShapeNode($items, $sealed); | ||
} | ||
|
||
|
||
|
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.
@jrmajor this cause error on Rector side, that's sealed true make all changes to add
...
which actually not, seehttps://github.com/rectorphp/rector-src/actions/runs/3706328433/jobs/6281403238
we forced pin to use 1.5.0 and the issue disappear
/cc @TomasVotruba @ondrejmirtes
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.
Sorry, that's actually a bug in
__toString()
. I'll provide a fix later today.