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

InvalidDocblock in ignored directory #4265

Closed
binarious opened this issue Oct 1, 2020 · 6 comments
Closed

InvalidDocblock in ignored directory #4265

binarious opened this issue Oct 1, 2020 · 6 comments

Comments

@binarious
Copy link
Contributor

I have ignored the vendor folder in ignoreFiles, but it still shows one InvalidDocblock error (while silencing other issues in that folder) in Psalm (v3.13 - v3.16):

ERROR: InvalidDocblock - vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php:26:5 - Badly-formatted @param in docblock for Swift_Events_EventDispatcher::createSendEvent (see https://psalm.dev/008)
    /**
     * Create a new SendEvent for $source and $message.
     *
     * @param Swift_Transport $source
     * @param Swift_Mime_SimpleMessage
     *
     * @return Swift_Events_SendEvent
     */
    public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message);

psalm.xml

<?xml version="1.0"?>
<psalm
    errorLevel="2"
    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"
>
    <projectFiles>
        <directory name="src"/>
        <ignoreFiles>
            <directory name="vendor"/>
            <directory name="var"/>
        </ignoreFiles>
    </projectFiles>
    <stubs>
        <file name="etc/stubs/ParameterBag.php" />
        <file name="etc/stubs/FormBuilderInterface.php" />
        <file name="etc/stubs/ConstraintViolationListInterface.php" />
    </stubs>
    <plugins>
        <pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
        <pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin"/>
    </plugins>
    <issueHandlers>
        <PropertyNotSetInConstructor>
            <errorLevel type="suppress">
                <referencedProperty name="Doctrine\Common\DataFixtures\AbstractFixture::$referenceRepository" />
                <referencedProperty name="Symfony\Component\HttpFoundation\Response::$content" />
                <referencedProperty name="Symfony\Component\HttpFoundation\Response::$headers" />
                <referencedProperty name="Symfony\Component\HttpFoundation\Response::$version" />
                <referencedProperty name="Symfony\Component\HttpFoundation\Response::$statusCode" />
                <referencedProperty name="Symfony\Component\HttpFoundation\Response::$statusText" />
                <referencedProperty name="Symfony\Component\HttpFoundation\Response::$charset" />
                <referencedProperty name="Doctrine\Migrations\AbstractMigration::$version" />
                <referencedProperty name="Doctrine\Migrations\AbstractMigration::$connection" />
                <referencedProperty name="Doctrine\Migrations\AbstractMigration::$sm" />
                <referencedProperty name="Doctrine\Migrations\AbstractMigration::$platform" />
                <referencedProperty name="Application\Migrations\Version20180706093739::$container" />
            </errorLevel>
        </PropertyNotSetInConstructor>
        <MissingConstructor>
            <errorLevel type="suppress">
                <directory name="src/DataFixtures/ORM" />
            </errorLevel>
        </MissingConstructor>
    </issueHandlers>
</psalm>
@psalm-github-bot
Copy link

Hey @binarious, can you reproduce the issue on https://psalm.dev ?

@rupa4ok
Copy link

rupa4ok commented Oct 5, 2020

Hi. The error is reproducible in symfony 5.1.6 and above, add the line

<ignoreFiles>
            <file name="src/.preload.php"/>
</ignoreFiles>

@YellowPhoenix18
Copy link

The error appears also on symfony 4, but is fixable in that way :)

@binarious
Copy link
Contributor Author

@rupa4ok Good catch. Symfony 5.1.6 and 4.4.14 added symfony/symfony#38063 and symfony/symfony#38142 which produce a new src/.preload.php which includes the srcApp_KernelDevDebugContainer.php.

@ghost
Copy link

ghost commented Jan 1, 2021

Same error on Psalm 4.3.2 and Symfony 5.2.1

[0;31mERROR�[0m: InvalidDocblock - vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:74:5 - Badly-formatted @param in docblock for Doctrine\ORM\EntityRepository::__construct (see https://psalm.dev/008)
    /**
     * Initializes a new <tt>EntityRepository</tt>.
     *
     * @psalm-param Mapping\ClassMetadata<T>
     */
    �[97;41mpublic function __construct(EntityManagerInterface $em, Mapping\ClassMetadata $class)�[0m

psalm.xml

<?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"
>
    <projectFiles>
        <directory name="src"/>
        <ignoreFiles>
            <directory name="vendor"/>
            <file name="src/Kernel.php"/>
        </ignoreFiles>
    </projectFiles>
</psalm>

There is no .preload.php in my src directory that's why adding this file to ignoreFiles throws an error:

Problem parsing .../psalm.xml:
  Could not resolve config path to .../src/.preload.php
Script vendor/bin/psalm handling the psalm event returned with error code 1

@orklah
Copy link
Collaborator

orklah commented Oct 12, 2021

This is expected. ignoreFiles is made to tell Psalm not to analyse a file, but Psalm will still need to parse signature and phpdoc of functions/methods/classes called from the code you want to analyse. And if it comes across an error, it has to tell you that it won't be able to analyse properly the code

@orklah orklah closed this as completed Oct 12, 2021
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

No branches or pull requests

4 participants