1 | <?php |
||
23 | class ProfilerTest extends BaseTestCase |
||
24 | { |
||
25 | /** @var DebugStack */ |
||
26 | private $logger; |
||
27 | /** @var \Twig_Environment */ |
||
28 | private $twig; |
||
29 | /** @var DoctrineDataCollector */ |
||
30 | private $collector; |
||
31 | |||
32 | public function setUp() |
||
33 | { |
||
34 | $this->logger = new DebugStack(); |
||
35 | $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); |
||
36 | $registry->expects($this->once())->method('getManagers')->willReturn([]); |
||
37 | $this->collector = new DoctrineDataCollector($registry); |
||
38 | $this->collector->addLogger('foo', $this->logger); |
||
39 | |||
40 | $twigLoaderFilesystem = new \Twig_Loader_Filesystem(__DIR__.'/../Resources/views/Collector'); |
||
41 | $twigLoaderFilesystem->addPath(__DIR__.'/../vendor/symfony/web-profiler-bundle/Resources/views', 'WebProfiler'); |
||
42 | $this->twig = new \Twig_Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]); |
||
43 | |||
44 | $this->twig->addExtension(new CodeExtension('', '', '')); |
||
45 | $this->twig->addExtension(new RoutingExtension($this->getMockBuilder(UrlGeneratorInterface::class)->getMock())); |
||
46 | $this->twig->addExtension(new HttpKernelExtension($this->getMockBuilder(FragmentHandler::class)->disableOriginalConstructor()->getMock())); |
||
|
|||
47 | $this->twig->addExtension(new WebProfilerExtension()); |
||
48 | $this->twig->addExtension(new DoctrineExtension()); |
||
49 | |||
50 | $loader = $this->getMockBuilder(\Twig_RuntimeLoaderInterface::class)->getMock(); |
||
51 | $loader->method('load')->willReturn($this->getMockBuilder(HttpKernelRuntime::class)->disableOriginalConstructor()->getMock()); |
||
52 | $this->twig->addRuntimeLoader($loader); |
||
53 | } |
||
54 | |||
55 | public function testRender() |
||
86 | } |
||
87 |
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.