1 | <?php |
||
20 | abstract class Transformer extends TransformerAbstract |
||
21 | { |
||
22 | use HasRelationships; |
||
23 | use MakesResources; |
||
24 | use OverridesFractal; |
||
25 | |||
26 | /** |
||
27 | * The container resolver callback. |
||
28 | * |
||
29 | * @var \Closure|null |
||
30 | */ |
||
31 | protected static $containerResolver; |
||
32 | |||
33 | /** |
||
34 | * Set a container using a resolver callback. |
||
35 | * |
||
36 | * @param \Closure $resolver |
||
37 | * @return void |
||
38 | */ |
||
39 | 192 | public static function containerResolver(Closure $resolver) |
|
43 | |||
44 | /** |
||
45 | * Resolve a container using the resolver callback. |
||
46 | * |
||
47 | * @return \Illuminate\Contracts\Container\Container |
||
48 | */ |
||
49 | 22 | protected function resolveContainer(): Container |
|
53 | |||
54 | /** |
||
55 | * Resolve a transformer from a class name string. |
||
56 | * |
||
57 | * @param string $transformer |
||
58 | * @return mixed |
||
59 | */ |
||
60 | 12 | protected function resolveTransformer(string $transformer) |
|
66 | } |
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: