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

Method call on class-name variable on __construct #92

Closed
Slamdunk opened this issue Jan 19, 2017 · 5 comments
Closed

Method call on class-name variable on __construct #92

Slamdunk opened this issue Jan 19, 2017 · 5 comments

Comments

@Slamdunk
Copy link
Contributor

namespace MyNamespace;

class MyClass
{
    public function __construct()
    {
        $thisClass = __CLASS__;
        $thisClass::myMethod();
    }

    public static function myMethod()
    {
    }
}

Output:

Catchable fatal error: Object of class PhpParser\Node\Expr\Variable could not be converted
to string in ./vendor/phpstan/phpstan/src/Rules/Classes/RequireParentConstructCallRule.php
on line 92
@ondrejmirtes
Copy link
Member

Good catch, I'll fix it.

@Slamdunk
Copy link
Contributor Author

Slamdunk commented Jan 19, 2017

I wanted to create a PR with solely a failing test, but didn't figure out the eligible path/configuration: any suggestion for the future?

@ondrejmirtes
Copy link
Member

This is how I fixed it, including a test: 4c075f7

I don't know what you mean by path/configuration. To run tests, you just run vendor/bin/phing in the root dir.

@Slamdunk
Copy link
Contributor Author

I know how to run tests, I was looking for the right place to put it, and tests/PHPStan/Rules/Classes/data/call-to-parent-constructor.php is the answer.
Thanks for the bugfix 👍

@ondrejmirtes
Copy link
Member

You can discover the file (or even create a new test with a new file) by looking for a test for the rule that has the bug :)

@lock lock bot locked as resolved and limited conversation to collaborators Dec 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants