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

Issues found by Psalm in DocBlock class #3861

Closed
sebastianbergmann opened this issue Sep 9, 2019 · 5 comments
Closed

Issues found by Psalm in DocBlock class #3861

sebastianbergmann opened this issue Sep 9, 2019 · 5 comments
Labels
type/bug Something is broken

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Sep 9, 2019

./tools/psalm --config=.psalm/config.xml --no-progress --show-info=false

ERROR: ImpureMethodCall - src/Util/Annotation/DocBlock.php:194:67 - Cannot call an possibly-mutating method PharIo\Version\VersionConstraintParser::parse from a mutation-free context
                        'constraint' => $versionConstraintParser->parse(\trim($matches['constraint'])),


ERROR: ImpurePropertyAssignment - src/Util/Annotation/DocBlock.php:229:16 - Cannot assign to a property from a mutation-free context
        return $this->parsedRequirements = \array_merge(


ERROR: InaccessibleProperty - src/Util/Annotation/DocBlock.php:229:16 - PHPUnit\Util\Annotation\DocBlock::$parsedRequirements is marked readonly
        return $this->parsedRequirements = \array_merge(


ERROR: ImpureFunctionCall - src/Util/Annotation/DocBlock.php:508:17 - Cannot call an impure function from a mutation-free context
            if (\json_last_error() !== \JSON_ERROR_NONE) {


ERROR: ImpureFunctionCall - src/Util/Annotation/DocBlock.php:510:86 - Cannot call an impure function from a mutation-free context
                    'The data set for the @testWith annotation cannot be parsed: ' . \json_last_error_msg()


ERROR: ImpureFunctionCall - src/Util/Annotation/DocBlock.php:560:20 - Cannot call an impure function from a mutation-free context
                ...\array_map(


------------------------------
6 errors found
------------------------------

Checks took 6.75 seconds and used 178.593MB of memory
Psalm was able to infer types for 91.0467% of the codebase
@sebastianbergmann sebastianbergmann added the type/bug Something is broken label Sep 9, 2019
@sebastianbergmann
Copy link
Owner Author

@Ocramius Can you have a look at this? If not, I'll try to find time for this ASAP.

@Ocramius
Copy link
Sponsor Contributor

Ocramius commented Sep 9, 2019


ERROR: ImpureMethodCall - src/Util/Annotation/DocBlock.php:194:67 - Cannot call an possibly-mutating method PharIo\Version\VersionConstraintParser::parse from a mutation-free context
                        'constraint' => $versionConstraintParser->parse(\trim($matches['constraint'])),

This is correct, because we don't know if VersionConstraintParser is pure

I'd say we should probably drop this one then, and re-introduce it only if we manage to make the object fully immutable. Note that immutability was achieved at some point, but I reverted that due to a performance regression.

* @psalm-mutation-free

@muglug
Copy link
Contributor

muglug commented Sep 9, 2019

Yeah, I agree it should be dropped for now!

I also I need to improve purity introspection into array_map callables.

@sebastianbergmann
Copy link
Owner Author

Thanks!, @Ocramius and @muglug.

@muglug
Copy link
Contributor

muglug commented Sep 9, 2019

array_map issue is already ticketed: vimeo/psalm#2112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants