Hello guys
I just started to get this exception while running Phinx :
PHP Fatal error: Uncaught SymfonyComponentConsoleExceptionLogicException: The command defined in "PhinxConsoleCommandInit" cannot have an empty name. in /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/symfony/console/Command/Command.php:453
Stack trace:
thrown in /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/symfony/console/Command/Command.php on line 453
I was using version 0.10.6 when I got the error. I tried upgrading to 0.10.8 , but still the same problem.
My php version is PHP 7.3.7
It was running okay 3 hours ago...
Can anyone help me?
Here broke SymfonyComponentConsoleCommandCommand::getName
https://github.com/symfony/console/commit/4510f04e70344d70952566e4262a0b11df39cb10#diff-25a75e093c4a0d5564a36cebbb1384b3R461
I got crazy trying to figure out what is the problem. It's a relief to see that it's not just in my head.
What should we do then? downgrade phinx?
Thanks
Force the version of symphony/console in your composer.json untill they fix it with
"symfony/console": "v3.4.27"
I did that here...
Is there a reasonable fix on cake's side?
Can the method be made to return a name?
You have to set ne name of the command in PhinxApplication.php:59
$this->addCommands([
new CommandInit('init'),
new CommandCreate('create'),
new CommandMigrate('migrate'),
new CommandRollback('rollback'),
new CommandStatus('status'),
new CommandBreakpoint('breakpoint'),
new CommandTest('test'),
new CommandSeedCreate('seedcreate'),
new CommandSeedRun('seedrun'),
]);
Or fix the console version : "symfony/console": "v3.4.27"
@Xakki Based on https://github.com/symfony/console/commit/4510f04e70344d70952566e4262a0b11df39cb10 you can make a fix on symfony/console to revert the bad change and allow nullable (including documented |null).
Looks like Symfony's Command::getName() was never intended to return null, but it worked in Phinx because types were not enforced (they were only declared using PHPdocs). It is my understanding that for its version 5 Symfony intends to enforce its type returns.
So preparing a fix for Phinx seems to me to be the best approach, as it immediately solves the issue and prepares for the future. I've created a PR for it, please have a look a leave a comment if you see it fit.
Your PR https://github.com/cakephp/phinx/pull/1588 indeed seems quite future proof
Nice one!
Force the version of symphony/console in your composer.json untill they fix it with
"symfony/console": "v3.4.27"
I did that here...
good idea
Most helpful comment
Looks like Symfony's Command::getName() was never intended to return
null, but it worked in Phinx because types were not enforced (they were only declared using PHPdocs). It is my understanding that for its version 5 Symfony intends to enforce its type returns.So preparing a fix for Phinx seems to me to be the best approach, as it immediately solves the issue and prepares for the future. I've created a PR for it, please have a look a leave a comment if you see it fit.