Skip to content

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

Merged
merged 1 commit into from
Dec 15, 2022
Merged

Conversation

jrmajor
Copy link
Contributor

@jrmajor jrmajor commented Nov 30, 2022

This PR adds support for array{foo: int, ...} syntax (phpstan/phpstan#8438).

@ondrejmirtes
Copy link
Member

Thank you. This is useful so that unsealed array shapes in @psalm-var are not a parse error for PHPStan anymore, but I don't want to take any further action for this. To fully support all possible use-cases, PHPStan would need 3-4 different ConstantArrayType implementations, but right now we only have one.

@ondrejmirtes ondrejmirtes merged commit 950bddf into phpstan:1.9.x Dec 15, 2022
/** @var bool */
public $sealed;

public function __construct(array $items, bool $sealed = true)

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, see

https://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

Copy link
Contributor Author

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.

$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
$items = [$this->parseArrayShapeItem($tokens)];
$items = [];
$sealed = true;

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, if this goes to false for default value, it may reduce the possible error.

that's sealed true make all changes to add ... which actually not, see

https://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

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.

3 participants