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

Psalm & PHPStan strict rules #217

Merged
merged 3 commits into from
Oct 14, 2024
Merged

Conversation

spaze
Copy link
Contributor

@spaze spaze commented Oct 13, 2024

Added Psalm and PHPStan strict rules.

Psalm: No errors on level 1 (the highest level for Psalm) and "Psalm was able to infer types for 100% of the codebase", not bad!

@spaze spaze changed the title Analyze code with Psalm as well Psalm & PHPStan strict rules Oct 13, 2024
spaze added 3 commits October 13, 2024 23:51
No errors on level 1 (the highest level for Psalm) and "Psalm was able to infer types for 100% of the codebase", not bad!
@spaze
Copy link
Contributor Author

spaze commented Oct 13, 2024

Psalm doesn't support PHP 8.4 yet (vimeo/psalm#11107) I'll take care of this PR once it does.

@antonioribeiro
Copy link
Owner

antonioribeiro commented Oct 14, 2024

I have this error on PHP 8.2 on an M1: vimeo/psalm#11067

Screenshot 2024-10-14 at 09 18 27

@antonioribeiro
Copy link
Owner

Added Psalm and PHPStan strict rules.

Psalm: No errors on level 1 (the highest level for Psalm) and "Psalm was able to infer types for 100% of the codebase", not bad!

Amazing! ❤️

@antonioribeiro
Copy link
Owner

Merging as the fatal error I got is not really fatal and it's passing on Github actions

@antonioribeiro antonioribeiro merged commit a46da2d into antonioribeiro:9.x Oct 14, 2024
2 of 5 checks passed
@spaze spaze deleted the spaze/psalm branch October 14, 2024 13:03
@antonioribeiro
Copy link
Owner

Hey @spaze, didn't you run Psalm on tests on purpose? I just added them to Psalm but also had to ignore some stuff:

<?xml version="1.0"?>
<psalm
    errorLevel="1"
    resolveFromConfigFile="true"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="https://getpsalm.org/schema/config"
    xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
    findUnusedBaselineEntry="true"
    findUnusedCode="false"
>
    <projectFiles>
        <directory name="src" />
        <directory name="tests" />
        <ignoreFiles>
            <directory name="vendor" />
        </ignoreFiles>
    </projectFiles>

    <issueHandlers>
        <PropertyNotSetInConstructor>
            <errorLevel type="suppress">
                <file name="tests/Google2FATest.php" />
            </errorLevel>
            <errorLevel type="suppress">
                <file name="tests/QRCodeTest.php" />
            </errorLevel>
        </PropertyNotSetInConstructor>
        <MixedAssignment>
            <errorLevel type="suppress">
                <file name="tests/helpers.php" />
            </errorLevel>
        </MixedAssignment>
        <ForbiddenCode>
            <errorLevel type="suppress">
                <file name="tests/helpers.php" />
            </errorLevel>
        </ForbiddenCode>
    </issueHandlers>
</psalm>

And then opened a ticket on Psalm too: vimeo/psalm#11132

@spaze
Copy link
Contributor Author

spaze commented Oct 20, 2024

Unfortunately I haven't run Psalm on tests, for no particular reason other than I just forgot to use the same dirs that PHPStan runs on 😇

@antonioribeiro
Copy link
Owner

Great! I was just afraid you bumped into any other problems, so all good, thanks!

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