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

Stub ClassMetadata::getAssociationTargetClass() #14

Merged
merged 1 commit into from
May 1, 2019

Conversation

jaikdean
Copy link
Contributor

This just stubs the ClassMetadata::getAssociationTargetClass() method to hint the return type as class-string.

Example code

$associationClassMetadata = $entityManager->getClassMetadata(
    $classMetadata->getAssociationTargetClass($associationName)
);

Without this stub

$ vendor/bin/psalm src/file.php
Scanning files...
Analyzing files...

ERROR: ArgumentTypeCoercion - src/file.php:79:17 - Argument 1 of Doctrine\ORM\EntityManagerInterface::getclassmetadata expects class-string, parent type string provided
                $classMetadata->getAssociationTargetClass($associationName)


------------------------------
1 errors found
------------------------------

Checks took 2.85 seconds and used 244.993MB of memory
Psalm was able to infer types for 92.9400% of the codebase

With this stub

$ vendor/bin/psalm src/file.php 
Scanning files...
Analyzing files...

------------------------------
No errors found!
------------------------------

Checks took 3.99 seconds and used 246.643MB of memory
Psalm was able to infer types for 92.9398% of the codebase

@weirdan
Copy link
Member

weirdan commented May 1, 2019

Thanks. I've got to fix failing tests before merging this though.

@weirdan weirdan force-pushed the stub-classmetadata branch from 12b00c3 to fb78583 Compare May 1, 2019 01:28
@weirdan weirdan merged commit bb624d3 into psalm:master May 1, 2019
@weirdan
Copy link
Member

weirdan commented May 1, 2019

Released in 0.4.2

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

Successfully merging this pull request may close these issues.

2 participants