Search code examples
phppsalm-php

How to make Psalm infer 100% of the codebase in PHP


Currently running Psalm gives me:

Psalm was able to infer types for 94.8665% of the codebase

How to debug where it couldn't infer the type? I'd like to have 100% type coverage.

Here's my psalm.xml.dist config:

<?xml version="1.0"?>
<psalm
    errorLevel="4"
    resolveFromConfigFile="true"
    totallyTyped="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"
>
    <projectFiles>
        <directory name="src" />
        <ignoreFiles>
            <file name="src/Kernel.php"/>
            <directory name="vendor" />
        </ignoreFiles>
    </projectFiles>
</psalm>

Thank you for your support.


Solution

  • Looks like this was "easy". Just had to lower the errorLevel down to 1 and fix all the issues. More than 500 in total.

    As soon as I hit errorLevel=1 my code base was already 100% inferred.

    Badges achieved:

    • type maniac
    • totally typed