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

MissingPropertyType not emitted #5974

Closed
thbley opened this issue Jun 22, 2021 · 4 comments · Fixed by #5980
Closed

MissingPropertyType not emitted #5974

thbley opened this issue Jun 22, 2021 · 4 comments · Fixed by #5980
Assignees
Labels
bug documentation easy problems Issues that can be fixed without background knowledge of Psalm

Comments

@thbley
Copy link
Contributor

thbley commented Jun 22, 2021

current: no error
expected: INFO: MissingPropertyType - Property test::$test does not have a declared type

https://psalm.dev/r/2971313991

@psalm-github-bot
Copy link

I found these snippets:

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

class test {
    public $test;
    
    public function __construct(DateTime $date) {
        $this->test = $date;
    }
}

$test = new test(new DateTime());
echo $test->test->format('c');
Psalm output (using commit 6d4d166):

No issues!

@weirdan weirdan added bug documentation easy problems Issues that can be fixed without background knowledge of Psalm labels Jun 22, 2021
@weirdan
Copy link
Collaborator

weirdan commented Jun 22, 2021

This is by design, in this case Psalm infers the type from the assignment in constructor. You should be able to turn it off with inferPropertyTypesFromConstructor flag in psalm.xml, but currently the flag is missing from the schema (and documentation).

@thbley
Copy link
Contributor Author

thbley commented Jun 22, 2021

Would be good to have it in the schema and the documentation!

Using: inferPropertyTypesFromConstructor="false"

I get:

Problem parsing psalm.xml:
  Error on line 22:
    Element '{https://getpsalm.org/schema/config}psalm', attribute 'inferPropertyTypesFromConstructor': The attribute 'inferPropertyTypesFromConstructor' is not allowed.

@thbley
Copy link
Contributor Author

thbley commented Jun 23, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation easy problems Issues that can be fixed without background knowledge of Psalm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants