Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
created

Compiler/ConsoleCompilerPass.php (1 issue)

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\AdminBundle\DependencyInjection\Compiler;
4
5
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionListener;
6
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionSubscriber;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
10
/**
11
 * Class ConsoleCompilerPass.
12
 */
13
final class ConsoleCompilerPass implements CompilerPassInterface
14
{
15 3
    public function process(ContainerBuilder $container)
16
    {
17
        // if the old listener is no longer in use
18 3
        if (!$container->hasDefinition('kunstmaan_admin.consolelogger.listener')) {
19
            return;
20
        }
21
22 3
        $definition = $container->getDefinition('kunstmaan_admin.consolelogger.listener');
23
24
        // if the default setup is in use, the subscriber / listener take care of correctly handling the errors
25
        if (
26 3
            $container->hasParameter('kunstmaan_admin.consoleexception.class') &&
27 3
            ConsoleExceptionListener::class === $container->getParameter('kunstmaan_admin.consoleexception.class') &&
28 3
            '%kunstmaan_admin.consoleexception.class%' === $definition->getClass()
29
        ) {
30 3
            return;
31
        }
32
33
        // if the listener has been overwritten in any way, a deprecation warning is needed
34
        @trigger_error(
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...
35
            sprintf(
36
                'The "%s" is deprecated and replaced by "%s" since KunstmaanAdminBundle 5.1 and will be removed in KunstmaanAdminBundle 6.0.',
37
                ConsoleExceptionListener::class,
38
                ConsoleExceptionSubscriber::class
39
            ),
40
            E_USER_DEPRECATED
41
        );
42
    }
43
}
44