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

bump psalm, fix errors, add usePhpDocPropertiesWithoutMagicCall #544

Merged
merged 1 commit into from
Feb 18, 2020

Conversation

orklah
Copy link
Contributor

@orklah orklah commented Feb 18, 2020

Bumping psalm on last version to use usePhpDocPropertiesWithoutMagicCall.

This allows to drop some ignored errors and gain some type coverage.

Also fixed some errors

@orklah
Copy link
Contributor Author

orklah commented Feb 18, 2020

This PR doesn't fix all current Psalm issues, but after seeing #543 (comment), I prefer creating it now to avoid doing this work twice

src/Reflection/ReflectionProperty.php Outdated Show resolved Hide resolved
@Ocramius Ocramius added this to the 4.0.0 milestone Feb 18, 2020
@Ocramius Ocramius self-assigned this Feb 18, 2020
@Ocramius Ocramius added dependencies Pull requests that update a dependency file enhancement labels Feb 18, 2020
@Ocramius Ocramius assigned orklah and unassigned Ocramius Feb 18, 2020
@orklah
Copy link
Contributor Author

orklah commented Feb 18, 2020

This is now error free on Psalm 3.9.2

FYI, I added those errors in baseline:

ERROR: InvalidReturnType - src\Reflection\Adapter\ReflectionClass.php:228:21 - The declared return type 'list<ReflectionProperty>' for Roave\BetterReflection\Reflection\Adapter\ReflectionClass::getProperties is incorrect, got 'array
<string, Roave\BetterReflection\Reflection\Adapter\ReflectionProperty>'
    public function getProperties($filter = null)


ERROR: InvalidReturnType - src\Reflection\Adapter\ReflectionObject.php:202:21 - The declared return type 'list<ReflectionProperty>' for Roave\BetterReflection\Reflection\Adapter\ReflectionObject::getProperties is incorrect, got 'arr
ay<string, Roave\BetterReflection\Reflection\Adapter\ReflectionProperty>'
    public function getProperties($filter = null)


ERROR: PossiblyNullPropertyAssignmentValue - src\Reflection\ReflectionFunctionAbstract.php:512:35 -  with non-nullable declared type 'array<array-key, PhpParser\Node\Stmt>' cannot be assigned nullable type 'array<array-key, PhpParse
r\Node\Stmt>|null'
        $this->getNode()->stmts = $functionNode->getStmts();


ERROR: PossiblyNullPropertyAssignmentValue - src\Reflection\ReflectionFunctionAbstract.php:524:35 -  with non-nullable declared type 'array<array-key, PhpParser\Node\Stmt>' cannot be assigned nullable type 'array<array-key, PhpParse
r\Node\Stmt>|null'
        $this->getNode()->stmts = $this->loadStaticParser()->parse('<?php ' . $newBody);

First and second one are due to a more precise definition of Reflection library by Psalm. Types are not compatible between native library and BR (cf #530)

Third and fourth are due to an assignment in Php-Parser from Php-Parser and one side of the assignment could contain null. This is probably due to an error in phpdoc on Php-Parser side.

@Ocramius Ocramius merged commit 8c6538a into Roave:master Feb 18, 2020
@Ocramius
Copy link
Member

Thanks @orklah!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants