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

Dynamic variable does not understand ? #38

Closed
roukmoute opened this issue Dec 16, 2016 · 3 comments
Closed

Dynamic variable does not understand ? #38

roukmoute opened this issue Dec 16, 2016 · 3 comments

Comments

@roukmoute
Copy link

This is my example code:

/**
 * @param array $data
 *
 * @return static
 */
public static function fromArray(array $data)
{
    foreach ($data as $key => $value) {
        if (property_exists(self::class, $key)) {
            ${$key} = $value;
        }
    }

    /** @var $location */
    return new static($location);
}

I've got this error:

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   src/Example/Position.php                                                                                                                                                          
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
         Internal error: Argument 1 passed to PHPStan\Analyser\Scope::assignVariable() must be of the type string, object given, called in /www-data/vendor/phpstan/phpstan/src/Analyser/NodeScopeResolver.php on  
         line 658                                                                                                                                                                                                  
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
@ondrejmirtes
Copy link
Member

Please check out if it does not work with the latest master. This was possible fixed here: 7b37f03

Thanks for the report.

@roukmoute
Copy link
Author

roukmoute commented Dec 16, 2016

Yep it works on dev-master :)

Good job!

But I work only with released version, I wait you next version ;)

@ondrejmirtes
Copy link
Member

Yep, of course, I just wanted to make sure that this is resolved :)

@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