1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of Cycle Database package. |
||
5 | * |
||
6 | * For the full copyright and license information, please view the LICENSE |
||
7 | * file that was distributed with this source code. |
||
8 | */ |
||
9 | |||
10 | declare(strict_types=1); |
||
11 | |||
12 | namespace Cycle\Database\Config; |
||
13 | |||
14 | use Cycle\Database\Config\MySQL\ConnectionConfig; |
||
0 ignored issues
–
show
|
|||
15 | use Cycle\Database\Driver\MySQL\MySQLDriver; |
||
16 | |||
17 | /** |
||
18 | * @template-extends DriverConfig<ConnectionConfig> |
||
19 | */ |
||
20 | class MySQLDriverConfig extends DriverConfig |
||
21 | { |
||
22 | public function __construct( |
||
23 | ConnectionConfig $connection, |
||
24 | string $driver = MySQLDriver::class, |
||
25 | bool $reconnect = true, |
||
26 | string $timezone = 'UTC', |
||
27 | 4 | bool $queryCache = true, |
|
28 | bool $readonlySchema = false, |
||
29 | bool $readonly = false, |
||
30 | array $options = [], |
||
31 | ) { |
||
32 | /** @psalm-suppress ArgumentTypeCoercion */ |
||
33 | parent::__construct( |
||
34 | connection: $connection, |
||
35 | driver: $driver, |
||
36 | reconnect: $reconnect, |
||
37 | 4 | timezone: $timezone, |
|
38 | 4 | queryCache: $queryCache, |
|
39 | readonlySchema: $readonlySchema, |
||
40 | readonly: $readonly, |
||
41 | options: $options, |
||
42 | ); |
||
43 | } |
||
44 | } |
||
45 |
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: