You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
<?phpdeclare(strict_types=1);
useMagento\Framework\Setup\Patch\DataPatchInterface;
class One implements DataPatchInterface
{
publicstaticfunctiongetDependencies(): array
{
return [
Two::class, // <--------------------------------------------------------------
];
}
}
<?phpdeclare(strict_types=1);
useMagento\Framework\Setup\Patch\DataPatchInterface;
class Two implements DataPatchInterface
{
publicstaticfunctiongetDependencies(): 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.
The text was updated successfully, but these errors were encountered:
Interesting. No one reported this so far, and I don't have a clue right now why I would fail.
Is this a Magento project or a Magento module? In the latter case, the only difference would be the way the generated files get created. Locally it's Magento logic, in CI it would be our module.
What happens if you replace the :class notation with a string with the fully qualified class name? Does the error appear in CI also?
I can currently reproduce this issue in two different custom modules: one using a data patch and another using a ViewModel.
For example, in the phtml file: $viewModel = $viewModels->require(\Some\Example\Class::class);
This triggers the same "missing return type" error for the methods in Some\Example\Class.
Using the alternative: $viewModel = $viewModels->require('Some\Example\Class');
doesn’t resolve the issue either; the error persists.
Additionally, phpcs complains with: Use ::class notation instead. (Magento2.PHP.LiteralNamespaces.LiteralClassUsage) 😅
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):As an example, this happens when working with data patches that have dependencies:
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.
The text was updated successfully, but these errors were encountered: