1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace DoctrineORMModule; |
21
|
|
|
|
22
|
|
|
use DoctrineORMModule\Exception\InvalidConfigurationException; |
23
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
24
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @license MIT |
28
|
|
|
* @link www.doctrine-project.org |
29
|
|
|
* @author Thomas Dutrion <[email protected]> |
30
|
|
|
*/ |
31
|
|
|
final class EventDispatcherFactory |
32
|
|
|
{ |
33
|
|
|
public function __invoke(ServiceLocatorInterface $container) |
34
|
|
|
{ |
35
|
|
|
$eventDispatcher = new EventDispatcher(); |
36
|
|
|
|
37
|
|
|
$config = $container->get('config'); |
38
|
|
|
$eventListenerConfig = isset($config['doctrine']['cli']['event_dispatcher']['listeners']) ? |
39
|
|
|
$config['doctrine']['cli']['event_dispatcher']['listeners'] : |
40
|
|
|
[]; |
41
|
|
|
foreach ($eventListenerConfig as $event => $listener) { |
42
|
|
|
if (!$container->has($listener)) { |
43
|
|
|
throw new InvalidConfigurationException( |
44
|
|
|
"configuration for doctrine.cli.event_dispatcher.listeners is invalid: Unable to find $listener in container." |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
$eventDispatcher->addListener($event, $container->get($listener)); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $eventDispatcher; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
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: