These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | /** |
||
5 | * This file is part of phpDocumentor. |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | * |
||
10 | * @author Mike van Riel <[email protected]> |
||
11 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
12 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
13 | * @link http://phpdoc.org |
||
14 | */ |
||
15 | |||
16 | namespace phpDocumentor\Event; |
||
17 | |||
18 | use Symfony\Component\EventDispatcher\Event; |
||
19 | use Symfony\Component\EventDispatcher\EventDispatcher; |
||
20 | |||
21 | /** |
||
22 | * Event Dispatching class. |
||
23 | * |
||
24 | * This class provides a bridge to the Symfony2 EventDispatcher. |
||
25 | * At current this is provided by inheritance but future iterations should |
||
26 | * solve this by making it an adapter pattern. |
||
27 | * |
||
28 | * The class is implemented as (mockable) Singleton as this was the best |
||
29 | * solution to make the functionality available in every class of the project. |
||
30 | */ |
||
31 | class Dispatcher extends EventDispatcher |
||
32 | { |
||
33 | /** @var Dispatcher[] Keep track of an array of instances. */ |
||
34 | protected static $instances = []; |
||
35 | |||
36 | /** |
||
37 | * Override constructor to make this singleton. |
||
38 | * @codeCoverageIgnore For some reason |
||
39 | */ |
||
40 | protected function __construct() |
||
41 | { |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Returns a named instance of the Event Dispatcher. |
||
46 | */ |
||
47 | 5 | public static function getInstance(string $name = 'default'): self |
|
48 | { |
||
49 | 5 | if (!isset(self::$instances[$name])) { |
|
50 | 2 | self::setInstance($name, new self()); |
|
0 ignored issues
–
show
|
|||
51 | } |
||
52 | |||
53 | 5 | return self::$instances[$name]; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Sets a names instance of the Event Dispatcher. |
||
58 | */ |
||
59 | 1 | public static function setInstance(string $name, self $instance): void |
|
60 | { |
||
61 | 1 | self::$instances[$name] = $instance; |
|
62 | 1 | } |
|
63 | } |
||
64 |
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: