Aliance
(Lesnykh Ilia)
September 8, 2022, 1:58pm
1
Hello everyone.
Symfony has the following code:
if ($configuratorClass && !is_a(ContainerConfigurator::class, $configuratorClass, true)) {
$configureContainer->getClosure($this)($container, $loader);
return;
}
$file = (new \ReflectionObject($this))->getFileName();
/* @var ContainerPhpFileLoader $kernelLoader */
$kernelLoader = $loader->getResolver()->resolve($file);
$kernelLoader->setCurrentDir(\dirname($file));
$instanceof = &\Closure::bind(function &() { return $this->instanceof; }, $kernelLoader, $kernelLoader)();
$valuePreProcessor = AbstractConfigurator::$valuePreProcessor;
AbstractConfigurator::$valuePreProcessor = function ($value) {
return $this === $value ? new Reference('kernel') : $value;
};
try {
$configureContainer->getClosure($this)(new ContainerConfigurator($container, $kernelLoader, $instanceof, $file, $file, $this->getEnvironment()), $loader, $container);
} finally {
$instanceof = [];
And Sonar marks this line with an issue:
$instanceof = &\Closure::bind(function &() { return $this->instanceof; }, $kernelLoader, $kernelLoader)();
Put exactly one space between the “function” keyword and the opening parenthesis.
Do you guys have any advices how to fix it?
ganncamp
(G Ann Campbell)
September 9, 2022, 2:52pm
2
Hi,
To be clear, this isn’t code you’ve written; you’re analyzing library code? And if so, would you mind sharing why?
Assuming it is 3rd-party code, I would say there’s no need to fix it. The icon indicates it’s raised as a Code Smell, i.e. a readability issue, in this case. I would choose one of
ignore it
mark the issue false positive
edit your Quality Profile to disable the rule
HTH,
Ann