1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/nnx-framework/doctrine-fixture-module |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace Nnx\DoctrineFixtureModule\Executor; |
7
|
|
|
|
8
|
|
|
use Nnx\DoctrineFixtureModule\FixtureInitializer\FixtureInitializerManagerInterface; |
9
|
|
|
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface; |
10
|
|
|
use Zend\ServiceManager\AbstractPluginManager; |
11
|
|
|
use Zend\ServiceManager\FactoryInterface; |
12
|
|
|
use Zend\ServiceManager\MutableCreationOptionsInterface; |
13
|
|
|
use Zend\ServiceManager\MutableCreationOptionsTrait; |
14
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
15
|
|
|
use Nnx\DoctrineFixtureModule\Loader\FixtureLoaderManagerInterface; |
16
|
|
|
use Nnx\DoctrineFixtureModule\Options\ModuleOptions; |
17
|
|
|
use Doctrine\Fixture\Loader\ClassLoader; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class ClassListFixtureExecutorFactory |
23
|
|
|
* |
24
|
|
|
* @package Nnx\DoctrineFixtureModule\Executor |
25
|
|
|
*/ |
26
|
|
|
class ClassListFixtureExecutorFactory implements FactoryInterface, MutableCreationOptionsInterface |
27
|
|
|
{ |
28
|
|
|
use MutableCreationOptionsTrait; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @inheritDoc |
32
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
33
|
|
|
*/ |
34
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
35
|
|
|
{ |
36
|
|
|
$appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() :$serviceLocator; |
37
|
|
|
|
38
|
|
|
$creationOptions = $this->getCreationOptions(); |
39
|
|
|
|
40
|
|
|
/** @var DefaultExecutorConfiguration $configuration */ |
41
|
|
|
$configuration = $appServiceLocator->get(DefaultExecutorConfiguration::class); |
42
|
|
|
/** @var FixtureExecutorBuilderInterface $builder */ |
43
|
|
|
$builder = $appServiceLocator->get(FixtureExecutorBuilderInterface::class); |
44
|
|
|
|
45
|
|
|
/** @var FixtureInitializerManagerInterface $fixtureInitializerManager */ |
46
|
|
|
$fixtureInitializerManager = $appServiceLocator->get(FixtureInitializerManagerInterface::class); |
47
|
|
|
|
48
|
|
|
$executor = new ClassListFixtureExecutor($configuration, $builder, $fixtureInitializerManager); |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** @var FixtureLoaderManagerInterface $fixtureLoaderManager */ |
52
|
|
|
$fixtureLoaderManager = $appServiceLocator->get(FixtureLoaderManagerInterface::class); |
53
|
|
|
|
54
|
|
|
$classList = array_key_exists('classList', $creationOptions) ? $creationOptions['classList'] : []; |
55
|
|
|
|
56
|
|
|
$classLoaderCreationOptions = [ |
57
|
|
|
'classList' => $classList |
58
|
|
|
]; |
59
|
|
|
$loader = $fixtureLoaderManager->get(ClassLoader::class, $classLoaderCreationOptions); |
|
|
|
|
60
|
|
|
$executor->setLoader($loader); |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */ |
65
|
|
|
$moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class); |
66
|
|
|
|
67
|
|
|
/** @var ModuleOptions $moduleOptions */ |
68
|
|
|
$moduleOptions = $moduleOptionsPluginManager->get(ModuleOptions::class); |
69
|
|
|
|
70
|
|
|
$executor->setContextInitializer($moduleOptions->getContextInitializer()); |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
return $executor; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.