phpstan-magento icon indicating copy to clipboard operation
phpstan-magento copied to clipboard

Issue with ::class and Missing Return Statement in CI

Open Morgy93 opened this issue 11 months ago • 9 comments

Hello,

I’m encountering an issue where referencing a class with ::class causes the referenced class to throw the following error in CI (but not locally):

Method Two::getDependencies() should return array but return statement is missing.

As an example, this happens when working with data patches that have dependencies:

<?php

declare(strict_types=1);

use Magento\Framework\Setup\Patch\DataPatchInterface;

class One implements DataPatchInterface
{
    public static function getDependencies(): array
    {
        return [
            Two::class, // <--------------------------------------------------------------
        ];
    }
}
<?php

declare(strict_types=1);

use Magento\Framework\Setup\Patch\DataPatchInterface;

class Two implements DataPatchInterface
{
    public static function getDependencies(): array
    {
        return [];
    }
}

In this setup, the error is thrown in CI, even though everything runs fine locally.

Has anyone experienced this behavior? Could it be related to a specific configuration? Any guidance on resolving this discrepancy would be greatly appreciated.

Morgy93 avatar Jan 16 '25 10:01 Morgy93