#97522Word "new" in command "description" breaks DI
Description
Given a command definition like this …
services:
_defaults:
autowire: true
autoconfigure: true
public: false
Acme\Foo\:
resource: '../Classes/*'
Acme\Foo\Command\BarCommand:
tags:
- name: console.command
command: example:bar
description: Build a new bar
schedulable: false
Acme\Foo\Command\QuxCommand:
tags:
- name: console.command
command: example:qux
description: Do something
schedulable: false
… you get an error like this:
[ ParseError ]
syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM), expecting '('
Exception trace:
#0 ()
var/cache/code/di/DependencyInjectionContainer_<hash>.php:<line>
...
The generated service in the DI cache file:
/**
* Gets the public 'Acme\Foo\Command\BarCommand' shared autowired service.
*
* @return \Acme\Foo\Command\BarCommand
*/
protected function getBarCommandService()
{
$this->services['Acme\\Foo\\Command\\BarCommand'] = $instance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceForDi(\Acme\Foo\Command\BarCommand::class, \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceForDi(\Acme\Foo\Security\BarDependency::class));
$instance->setName('example:bar');
$instance->setDescription('Build a \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceForDi(bar');
return $instance;
}
/**
* Gets the public 'Acme\Foo\Command\QuxCommand' shared autowired service.
*
* @return \Acme\Foo\Command\QuxCommand
*/
protected function getQuxCommandService::class)
{
# ...
}
This is very likely caused by the rather simple replacement here:
$code = preg_replace('/new ([^\(\s]+)\(/', '\\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::makeInstanceForDi(\\1::class, ', $code);Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.