doctrine / DoctrineFixturesBundle

Symfony integration for the doctrine/data-fixtures library
MIT License
2.44k stars 201 forks source link

Impossible to profile LoadDataFixturesDoctrineCommand #442

Open garak opened 1 month ago

garak commented 1 month ago

Symfony 6.4.7 DoctrineBundle 2.12.0 FixturesBundle 3.6.0 ORM 3.1.3

When I try to run bin/console do:fi:lo --profile -v I get the following:

[Error]
Call to protected method Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand::execute() from scope Symfony\Component\Console\Command\TraceableCommand

trace:

at /myproject/vendor/symfony/console/Command/TraceableCommand.php:331
Symfony\Component\Console\Command\TraceableCommand->execute() at /myproject/vendor/symfony/console/Command/Command.php:326
Symfony\Component\Console\Command\Command->run() at /myproject/vendor/symfony/console/Command/TraceableCommand.php:286
Symfony\Component\Console\Command\TraceableCommand->run() at /myproject/vendor/symfony/console/Application.php:1096
Symfony\Component\Console\Application->doRunCommand() at /myproject/vendor/symfony/framework-bundle/Console/Application.php:126
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /myproject/vendor/symfony/console/Application.php:324
Symfony\Component\Console\Application->doRun() at /myproject/vendor/symfony/framework-bundle/Console/Application.php:80
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /myproject/vendor/symfony/console/Application.php:175

The command is working properly without the --profile flag.

garak commented 2 weeks ago

It seems that the problem is linked to using the CommandCompatibility trait. If I remove it, the profiling doesn't throw an exception anymore. I see that trait was introduced in PR #402 by @derrabus but I can't understand its purpose... the covariance allows us to add the return type, without the need for a check.

derrabus commented 2 weeks ago

I can't understand its purpose... the covariance allows us to add the return type, without the need for a check.

Adding a return type to a non-final class is a breaking change. On 4.0.x, the trait is gone already.