GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — dev ( 40bda2...5b7120 )
by Андрей
04:01
created

Module::init()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 2
eloc 11
nc 2
nop 1
1
<?php
2
/**
3
 * @link https://github.com/old-town/workflow-zf2-dispatch
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\ZF2\Dispatch;
7
8
9
use Zend\ModuleManager\Listener\ServiceListenerInterface;
10
use Zend\ModuleManager\ModuleManager;
11
use Zend\ModuleManager\ModuleManagerInterface;
12
use Zend\Mvc\ModuleRouteListener;
13
use Zend\Mvc\MvcEvent;
14
use Zend\EventManager\EventInterface;
15
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
16
use Zend\ModuleManager\Feature\ConfigProviderInterface;
17
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
18
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
19
use OldTown\Workflow\ZF2\Dispatch\Listener\WorkflowDispatchListener;
20
use Zend\ServiceManager\ServiceLocatorAwareTrait;
21
use Zend\ModuleManager\Feature\InitProviderInterface;
22
use Zend\ServiceManager\ServiceLocatorInterface;
23
use OldTown\Workflow\ZF2\Dispatch\Metadata\MetadataReaderManager;
24
use OldTown\Workflow\ZF2\Dispatch\Metadata\MetadataReaderProviderInterface;
25
use OldTown\Workflow\ZF2\Dispatch\RunParamsHandler\RouteHandler;
26
27
/**
28
 * Class Module
29
 *
30
 * @package OldTown\Workflow\ZF2\Dispatch
31
 */
32
class Module implements
33
    BootstrapListenerInterface,
34
    ConfigProviderInterface,
35
    AutoloaderProviderInterface,
36
    DependencyIndicatorInterface,
37
    InitProviderInterface
38
{
39
    use ServiceLocatorAwareTrait;
40
41
    /**
42
     * Имя секции в конфиги приложения
43
     *
44
     * @var string
45
     */
46
    const CONFIG_KEY = 'workflow_zf2_dispatch';
47
48
    /**
49
     * @return array
50
     */
51
    public function getModuleDependencies()
52
    {
53
        return [
54
            'OldTown\\Workflow\\ZF2'
55
        ];
56
    }
57
58
    /**
59
     * @param EventInterface $e
60
     *
61
     * @return array|void
62
     *
63
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
64
     */
65
    public function onBootstrap(EventInterface $e)
66
    {
67
        /** @var MvcEvent $e */
68
        $eventManager        = $e->getApplication()->getEventManager();
69
        $moduleRouteListener = new ModuleRouteListener();
70
        $moduleRouteListener->attach($eventManager);
71
72
        $sm = $e->getApplication()->getServiceManager();
73
74
        /** @var WorkflowDispatchListener $injectWorkflowListener */
75
        $injectWorkflowListener = $sm->get(WorkflowDispatchListener::class);
76
        $eventManager->attach($injectWorkflowListener);
0 ignored issues
show
Documentation introduced by
$injectWorkflowListener is of type object<OldTown\Workflow\...rkflowDispatchListener>, but the function expects a string.

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...
77
78
        /** @var RouteHandler $routeHandler */
79
        $routeHandler = $sm->get(RouteHandler::class);
80
        $eventManager->attach($routeHandler);
0 ignored issues
show
Documentation introduced by
$routeHandler is of type object<OldTown\Workflow\...msHandler\RouteHandler>, but the function expects a string.

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...
81
    }
82
83
84
    /**
85
     * @return mixed
86
     */
87
    public function getConfig()
88
    {
89
        return include __DIR__ . '/config/module.config.php';
90
    }
91
92
    /**
93
     * @return array
94
     */
95
    public function getAutoloaderConfig()
96
    {
97
        return array(
98
            'Zend\Loader\StandardAutoloader' => array(
99
                'namespaces' => array(
100
                    __NAMESPACE__ => __DIR__ . '/src/',
101
                ),
102
            ),
103
        );
104
    }
105
106
107
    /**
108
     *
109
     * @param ModuleManagerInterface $manager
110
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
111
     * @throws Exception\ErrorInitModuleException
112
     */
113
    public function init(ModuleManagerInterface $manager)
114
    {
115
116
        if (!$manager instanceof ModuleManager) {
117
            $errMsg =sprintf('Module manager not implement %s', ModuleManager::class);
118
            throw new Exception\ErrorInitModuleException($errMsg);
119
        }
120
        /** @var ModuleManager $manager */
121
122
        /** @var ServiceLocatorInterface $sm */
123
        $sm = $manager->getEvent()->getParam('ServiceManager');
124
125
        /** @var ServiceListenerInterface $serviceListener */
126
        $serviceListener = $sm->get('ServiceListener');
127
        $serviceListener->addServiceManager(
128
            MetadataReaderManager::class,
129
            'workflow_zf2_dispatch_metadata_reader',
130
            MetadataReaderProviderInterface::class,
131
            'getWorkflowDispatchMetadataReaderConfig'
132
        );
133
    }
134
}