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

Two models in MorphTo raises an error #1223

Closed
markuskooche opened this issue Apr 28, 2022 · 6 comments
Closed

Two models in MorphTo raises an error #1223

markuskooche opened this issue Apr 28, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@markuskooche
Copy link

markuskooche commented Apr 28, 2022

Larastan version: 2.1.4


It throws an error when using two Models in MorphTo.

/**
 * @return MorphTo<PrivatePost|PublicPost, Picture>
 */
public function post() : MorphTo
{
    return $this->morphTo();
}
Internal error: Internal error: Call to undefined method PHPStan\Type\UnionType::getClassName() ...
@szepeviktor szepeviktor added the bug Something isn't working label Apr 28, 2022
@szepeviktor
Copy link
Collaborator

szepeviktor commented Apr 28, 2022

Hello Markus! 👋

It may only need a 4 line long PR.

@canvural
Copy link
Collaborator

Which version are you using? This was fixed in the recent versions.

@szepeviktor
Copy link
Collaborator

This was fixed in the recent versions.

Was it #1187?

@markuskooche
Copy link
Author

I am using version 2.1.4

@falko100

This comment was marked as off-topic.

@canvural
Copy link
Collaborator

This is fixed in the recent versions. Test case: https://github.com/nunomaduro/larastan/blob/340d65ab78e52479c60de27c0851808b1802eaae/tests/Type/data/model-properties-relations.php#L72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants