Skip to content

Error: "Property has no typehint specified" although the type is specified in constructor #47

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

Open
karser opened this issue Jan 19, 2019 · 1 comment

Comments

@karser
Copy link

karser commented Jan 19, 2019

Hello,
Strict-rules require all class properties to have typehint, although the ones that are specified in the constructor are perfectly inferred by the IDE.
Maybe we could do the property typehint optional if type of the property is specified in the constructor?

The code:

<?php declare(strict_types = 1);

class Foo
{
    private $bar;

    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }
}

class Bar {}

Output:

+------------------------------------------------------+
| Line | test.php                                      |
+------------------------------------------------------+
| 5    | Property Foo::$bar has no typehint specified. |
+------------------------------------------------------+

 [ERROR] Found 1 error 

Expected output:
No errors

@karser
Copy link
Author

karser commented Jan 19, 2019

Sorry, I submitted this issue in a wrong repository. Please remove the issue

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

1 participant