Skip to content

PHPstan does not find container helper functions used on packages php configs #381

Closed
@thePanz

Description

@thePanz

Similar (but solved) issue: #269 , where the helper functions are used in the services.php file.

In this issue, the error is triggered when helper functions are used in a package configuration file (the ones under config/packages/**.php).

Example:

# config/packages/messenger.php
<?php

declare(strict_types=1);

use App\Infrastructure\Symfony\Messenger\AsyncMessage;
use Symfony\Config\FrameworkConfig;

use function Symfony\Component\DependencyInjection\Loader\Configurator\env;

return static function (FrameworkConfig $framework): void {
    $messenger = $framework->messenger()->failureTransport('failed');
    $messenger->transport('async')->dsn(env('MESSENGER_TRANSPORT_DSN'));
}:

Phpstan error:

Used function Symfony\Component\DependencyInjection\Loader\Configurator\env not found

The solution is to re-add the scanFile configuration to phpstan.neon, as initially documented in #271

Note: that the documentation was added in b1c5152, but then removed in 94e6c34

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions