1 | <?php |
||
11 | class EloquentAdapter implements Adapter |
||
12 | { |
||
13 | /** @var \Illuminate\Database\Capsule\Manager */ |
||
14 | protected $manager; |
||
15 | |||
16 | /** @var \Psr\Container\ContainerInterface */ |
||
17 | protected $container; |
||
18 | |||
19 | /** @var \Wandu\Migrator\Configuration */ |
||
20 | protected $config; |
||
21 | |||
22 | public function __construct(Manager $manager, ContainerInterface $container, Configuration $config) |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | public function initialize() |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function getAppliedIds(): array |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function isApplied($id): bool |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function getMigrationInstance(string $id, string $name): Migration |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function addToMigrationTable($id) |
||
86 | |||
87 | public function removeFromMigrationTable($id) |
||
93 | |||
94 | /** |
||
95 | * @return bool |
||
96 | */ |
||
97 | protected function hasMigrateTable() |
||
106 | |||
107 | /** |
||
108 | * @return \Illuminate\Database\Query\Builder |
||
109 | */ |
||
110 | protected function createMigrationQuery() |
||
114 | |||
115 | /** |
||
116 | * @return \Illuminate\Database\Connection |
||
117 | */ |
||
118 | protected function getConnection() |
||
122 | } |
||
123 |
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: