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

@var for public promoted properties leading to property not found #6860

Closed
iquito opened this issue Nov 8, 2021 · 3 comments
Closed

@var for public promoted properties leading to property not found #6860

iquito opened this issue Nov 8, 2021 · 3 comments

Comments

@iquito
Copy link

iquito commented Nov 8, 2021

In version 4.12.0 of Psalm there are increased levels of problems with constructor property promotion - any @var annotations within constructor property promotion for public properties leads to those properties not even existing to Psalm:

https://psalm.dev/r/db3ba03f68

Gives the errors:

ERROR: InvalidDocblock - 9:9 - Param string of A::__construct should be documented as a param or a property, not both

ERROR: UndefinedPropertyAssignment - 15:1 - Instance property A::$string is not defined
@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/db3ba03f68
<?php

final class A
{
	public function __construct(
        /**
         * @var string Some documentation for what the values of this string could be
         */
        public string $string,
    ) {
    }
}

$a = new A('dada');
$a->string = 'da';
Psalm output (using commit 9491ea4):

ERROR: InvalidDocblock - 9:9 - Param string of A::__construct should be documented as a param or a property, not both

ERROR: UndefinedPropertyAssignment - 15:1 - Instance property A::$string is not defined

@orklah
Copy link
Collaborator

orklah commented Nov 8, 2021

Yeah, this is the same issue as #6857

I'll fix that

@orklah orklah closed this as completed Nov 8, 2021
@iquito
Copy link
Author

iquito commented Nov 8, 2021

Great, thanks!

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

No branches or pull requests

2 participants