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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix promoted readonly properties #6909

Merged
merged 2 commits into from
Nov 13, 2021

Conversation

trowski
Copy link
Contributor

@trowski trowski commented Nov 13, 2021

This fixes detection of readonly on promoted properties as well as the visibility of promoted readonly properties.

https://psalm.dev/r/0df6074053

https://psalm.dev/r/910eec3285

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/0df6074053
<?php

class Test {	
	public function __construct(public readonly int $foo) {

	}
}

$x = new Test(1234);
$x->foo = 123;
Psalm output (using commit c21aefa):

ERROR: ParseError - 4:46 - Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 4

ERROR: TooManyArguments - 9:6 - Too many arguments for Test::__construct - expecting 0 but saw 1

ERROR: UndefinedPropertyAssignment - 10:1 - Instance property Test::$foo is not defined

ERROR: InvalidDocblock - 4:30 - Param1 of Test::__construct has invalid syntax
https://psalm.dev/r/910eec3285
<?php

class Test {	
	public function __construct(private readonly int $foo) {

	}
}

$x = new Test(1234);
echo $x->foo;
Psalm output (using commit c21aefa):

ERROR: ParseError - 4:47 - Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 4

ERROR: TooManyArguments - 9:6 - Too many arguments for Test::__construct - expecting 0 but saw 1

ERROR: UndefinedPropertyFetch - 10:6 - Instance property Test::$foo is not defined

INFO: MixedArgument - 10:6 - Argument 1 of echo cannot be mixed, expecting string

ERROR: InvalidDocblock - 4:30 - Param1 of Test::__construct has invalid syntax

@orklah orklah added the release:feature The PR will be included in 'Features' section of the release notes label Nov 13, 2021
@orklah orklah merged commit 6d21288 into vimeo:master Nov 13, 2021
@orklah
Copy link
Collaborator

orklah commented Nov 13, 2021

Thanks! That's great!

@trowski trowski deleted the promoted-readonly-properties branch December 11, 2021 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature The PR will be included in 'Features' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants