Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

Compiler/DeprecateClassParametersPass.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\RedirectBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * @internal
10
 */
11 View Code Duplication
final class DeprecateClassParametersPass implements CompilerPassInterface
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    public function process(ContainerBuilder $container)
14
    {
15
        $expectedValues = [
16
            'kunstmaan_redirect.menu.adaptor.class' => \Kunstmaan\RedirectBundle\Helper\Menu\RedirectMenuAdaptor::class,
17
            'kunstmaan_redirect.redirect_repository.class' => \Kunstmaan\RedirectBundle\Repository\RedirectRepository::class,
18
        ];
19
20
        foreach ($expectedValues as $parameter => $expectedValue) {
21
            if (false === $container->hasParameter($parameter)) {
22
                continue;
23
            }
24
25
            $currentValue = $container->getParameter($parameter);
26
            if ($currentValue !== $expectedValue) {
27
                @trigger_error(sprintf('Using the "%s" parameter to change the class of the service definition is deprecated in KunstmaanRedirectBundle 5.2 and will be removed in KunstmaanRedirectBundle 6.0. Use service decoration or a service alias instead.', $parameter), E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
28
            }
29
        }
30
    }
31
}
32