|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Handlers\OkFileHandlerFactory |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2020 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Handlers; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Loaders\LoaderFactoryInterface; |
|
24
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
25
|
|
|
use TechDivision\Import\Adapter\FilesystemAdapterFactoryInterface; |
|
26
|
|
|
use TechDivision\Import\Configuration\SubjectConfigurationInterface; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* A .OK file handler factory implementation. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Tim Wagner <[email protected]> |
|
32
|
|
|
* @copyright 2020 TechDivision GmbH <[email protected]> |
|
33
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
34
|
|
|
* @link https://github.com/techdivision/import |
|
35
|
|
|
* @link http://www.techdivision.com |
|
36
|
|
|
*/ |
|
37
|
|
|
class OkFileHandlerFactory implements HandlerFactoryInterface |
|
38
|
|
|
{ |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The DI container instance. |
|
42
|
|
|
* |
|
43
|
|
|
* @var \Symfony\Component\DependencyInjection\ContainerInterface |
|
44
|
|
|
*/ |
|
45
|
|
|
private $container; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* The loader factory instance used to create the loader for the proposed .OK filenames. |
|
49
|
|
|
* |
|
50
|
|
|
* @var \TechDivision\Import\Loaders\LoaderFactoryInterface |
|
51
|
|
|
*/ |
|
52
|
|
|
private $loaderFactory; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Initialize the factory with the DI container instance. |
|
56
|
|
|
* |
|
57
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container The DI container instance |
|
58
|
|
|
* @param \TechDivision\Import\Loaders\LoaderFactoryInterface $loaderFactory The loader factory instance used to create the loader for the proposed .OK filenames |
|
59
|
|
|
*/ |
|
60
|
|
|
public function __construct( |
|
61
|
|
|
ContainerInterface $container, |
|
62
|
|
|
LoaderFactoryInterface $loaderFactory |
|
63
|
|
|
) { |
|
64
|
|
|
$this->container = $container; |
|
65
|
|
|
$this->loaderFactory = $loaderFactory; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Return's the container instance. |
|
70
|
|
|
* |
|
71
|
|
|
* @return \Symfony\Component\DependencyInjection\ContainerInterface The container instance |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function getContainer() : ContainerInterface |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->container; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Return's the loader factory instance. |
|
80
|
|
|
* |
|
81
|
|
|
* @return \TechDivision\Import\Loaders\LoaderFactoryInterface The loader factory instance |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function getLoaderFactory() : LoaderFactoryInterface |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->loaderFactory; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Create's and return's a new handler instance. |
|
90
|
|
|
* |
|
91
|
|
|
* @return \TechDivision\Import\Handlers\HandlerInterface|null The new handler instance |
|
92
|
|
|
*/ |
|
93
|
|
|
public function createHandler(SubjectConfigurationInterface $subject = null) : HandlerInterface |
|
94
|
|
|
{ |
|
95
|
|
|
|
|
96
|
|
|
// load the proposed .OK file loader |
|
97
|
|
|
$proposedOkFileLoader = $this->getLoaderFactory()->createLoader($subject); |
|
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
// load the filesystem adapter instance |
|
100
|
|
|
$filesystemAdapter = $this->getContainer()->get($subject->getFilesystemAdapter()->getId()); |
|
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
// query whether or not we've a factory instance |
|
103
|
|
|
if ($filesystemAdapter instanceof FilesystemAdapterFactoryInterface) { |
|
104
|
|
|
$filesystemAdapter = $filesystemAdapter->createFilesystemAdapter($subject); |
|
|
|
|
|
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
// create a new .OK file handler instance |
|
108
|
|
|
$handler = new OkFileHandler(); |
|
109
|
|
|
$handler->setLoader($proposedOkFileLoader); |
|
|
|
|
|
|
110
|
|
|
$handler->setFilesystemAdapter($filesystemAdapter); |
|
|
|
|
|
|
111
|
|
|
$handler->setFileResolverConfiguration($subject->getFileResolver()); |
|
112
|
|
|
|
|
113
|
|
|
// return the new .OK file handler instance |
|
114
|
|
|
return $handler; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
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
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.