1 | <?php |
||
37 | final class EngineAsArgumentInKernelControllerTest extends TestCase |
||
38 | { |
||
39 | public function testCanBeCreated() |
||
47 | |||
48 | public function testKernelInterface() |
||
56 | |||
57 | public function testFrameworkReturnsResponse() |
||
65 | |||
66 | public function testContainerCanBeCreated() |
||
67 | { |
||
68 | $this->assertInstanceOf( |
||
69 | // ...::class, // 5.4 < php |
||
70 | 'Symfony\Component\DependencyInjection\ContainerBuilder', |
||
71 | $this->container() |
||
72 | ); |
||
73 | } |
||
74 | |||
75 | public function testContainerInterface() |
||
76 | { |
||
77 | $this->assertInstanceOf( |
||
78 | // ...::class, // 5.4 < php |
||
79 | 'psr\Container\ContainerInterface', |
||
80 | $this->container() |
||
81 | ); |
||
82 | } |
||
83 | |||
84 | /* |
||
85 | public function testComponentReturnsResponse() |
||
86 | { |
||
87 | $requestStack = new RequestStack(); |
||
88 | $routes = new RouteCollectionBuilder(); // Because I know how to use it. |
||
89 | $routes->add('/', EngineAsArgumentController::class, 'index'); // .'::__invoke' |
||
90 | //^ It should be tested if the actually used controller resolver can resolve this! |
||
91 | //^ Returns Symfony/Component/Routing/Route . |
||
92 | $dispatcher = new EventDispatcher(); |
||
93 | $dispatcher->addSubscriber(new RouterListener( |
||
94 | new UrlMatcher( |
||
95 | $routes->build(), |
||
96 | new RequestContext() |
||
97 | ), |
||
98 | $requestStack |
||
99 | )); |
||
100 | $dispatcher->addSubscriber(new ResponseListener('UTF-8')); |
||
101 | |||
102 | |||
103 | $this->assertInstanceOf( |
||
104 | // Response::class, // 5.4 < php |
||
105 | 'Symfony\Component\HttpFoundation\Response', |
||
106 | (new HttpKernel( |
||
107 | $dispatcher, |
||
108 | new ContainerControllerResolver($c), |
||
109 | $requestStack, |
||
110 | new ArgumentResolver() |
||
111 | ))->handle(Request::create('/', 'GET')) |
||
112 | ); |
||
113 | } |
||
114 | */ |
||
115 | |||
116 | private function container() |
||
154 | } |
||
155 | |||
156 | // http://api.symfony.com/3.3/Symfony/Bridge/Twig/TwigEngine.html |
||
158 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: