Completed
Push — master ( c4223d...e3af10 )
by Nikita
03:25
created

DefaultCommandSubscriber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 6 1
A defaultCommandCallback() 0 22 1
1
<?php
2
3
namespace Taisiya\CoreBundle\Composer\Event;
4
5
use Composer\EventDispatcher\Event;
6
use Composer\EventDispatcher\EventDispatcher;
7
use Taisiya\CoreBundle\App;
8
use Taisiya\CoreBundle\Composer\ScriptHandler;
9
use Taisiya\CoreBundle\Event\Config\RebuildSettingsEvent;
10
11
final class DefaultCommandSubscriber implements DefaultCommandSubscriberInterface
12
{
13
    const EVENT_CONFIG_REBUILD_SETTINGS = 'config.rebuild_settings';
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public static function getSubscribedEvents()
19
    {
20
        return [
21
            ScriptHandler::EVENT_DEFAULT_COMMAND => 'defaultCommandCallback',
22
        ];
23
    }
24
25
    /**
26
     * @param Event $event
27
     */
28
    public static function defaultCommandCallback(Event $event): void
29
    {
30
//        /** @var App $app */
0 ignored issues
show
Unused Code Comprehensibility introduced by
51% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
31
//        $app = $event->getArguments()['app'];
32
//
33
//        /** @var EventDispatcher $dispatcher */
34
//        $dispatcher = $event->getComposer()->getEventDispatcher();
35
//
36
//        $rebuildSettingsEvent = new Event(self::EVENT_CONFIG_REBUILD_SETTINGS, ['app' => $app]);
37
//
38
//        $dispatcher->dispatch(self::EVENT_CONFIG_REBUILD_SETTINGS, $rebuildSettingsEvent);
39
40
        /** @var App $app */
41
        $app = $event->getArguments()['app'];
42
43
        /** @var EventDispatcher $dispatcher */
44
        $dispatcher = $app->getContainer()['event_dispatcher'];
45
46
        $rebuildSettingsEvent = new RebuildSettingsEvent();
47
48
        $dispatcher->dispatch(RebuildSettingsEvent::NAME, $rebuildSettingsEvent);
0 ignored issues
show
Documentation introduced by
$rebuildSettingsEvent is of type object<Taisiya\CoreBundl...g\RebuildSettingsEvent>, but the function expects a null|object<Composer\EventDispatcher\Event>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
    }
50
}
51