1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* |
5
|
|
|
* (c) Yaroslav Honcharuk <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Yarhon\RouteGuardBundle\Tests\Functional\app; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
14
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Yaroslav Honcharuk <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class Kernel extends BaseKernel |
21
|
|
|
{ |
22
|
|
|
const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
23
|
|
|
|
24
|
|
|
private $testVarDir; |
25
|
|
|
private $testBundles; |
26
|
|
|
private $testConfigs; |
27
|
|
|
|
28
|
|
|
public function __construct($varDir, $bundles, $configs, $environment, $debug) |
29
|
|
|
{ |
30
|
|
|
$this->testVarDir = $varDir; |
31
|
|
|
$this->testBundles = $bundles; |
32
|
|
|
$this->testConfigs = $configs; |
33
|
|
|
|
34
|
|
|
parent::__construct($environment, $debug); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function registerBundles() |
38
|
|
|
{ |
39
|
|
|
$bundles = []; |
40
|
|
|
|
41
|
|
|
foreach ($this->testBundles as $class) { |
42
|
|
|
$bundles[] = new $class(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return $bundles; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getCacheDir() |
49
|
|
|
{ |
50
|
|
|
return $this->testVarDir.'/cache/'.$this->environment; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getLogDir() |
54
|
|
|
{ |
55
|
|
|
return $this->testVarDir.'/logs'; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getProjectDir() |
59
|
|
|
{ |
60
|
|
|
return __DIR__; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
64
|
|
|
{ |
65
|
|
|
$confDir = $this->getProjectDir().'/config'; |
66
|
|
|
|
67
|
|
|
$loader->load($confDir.'/*'.self::CONFIG_EXTS, 'glob'); |
68
|
|
|
|
69
|
|
|
$loader->load(function (ContainerBuilder $container) { |
70
|
|
|
foreach ($this->testConfigs as $extension => $config) { |
71
|
|
|
$container->loadFromExtension($extension, $config); |
72
|
|
|
} |
73
|
|
|
}); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
// Note: serialize/unserialize are needed for Client insulation. |
77
|
|
|
public function serialize() |
78
|
|
|
{ |
79
|
|
|
return serialize([$this->testVarDir, $this->testBundles, $this->testConfigs, $this->getEnvironment(), $this->isDebug()]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function unserialize($string) |
83
|
|
|
{ |
84
|
|
|
$this->__construct(...unserialize($string)); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/* |
88
|
|
|
protected function build(ContainerBuilder $container) |
89
|
|
|
{ |
90
|
|
|
$container->register('logger', \Psr\Log\NullLogger::class); |
91
|
|
|
} |
92
|
|
|
*/ |
93
|
|
|
} |
94
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less 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. Please note the @ignore annotation hint above.