Passed
Push — master ( 0bc77e...3cb892 )
by Peter
02:32
created
Labels
Severity
1
<?php
2
3
use AbterPhp\Admin\Bootstrappers;
4
use AbterPhp\Admin\Console;
5
use AbterPhp\Admin\Events;
6
use AbterPhp\Admin\Http;
7
use AbterPhp\Framework\Constant\Event;
1 ignored issue
show
This use statement conflicts with another class in this namespace, Event. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/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 before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
8
use AbterPhp\Framework\Constant\Module;
9
use AbterPhp\Framework\Constant\Priorities;
10
11
return [
12
    Module::IDENTIFIER         => 'AbterPhp\Admin',
13
    Module::DEPENDENCIES       => ['AbterPhp\Framework'],
14
    Module::ENABLED            => true,
15
    Module::BOOTSTRAPPERS      => [
16
        Bootstrappers\Orm\OrmBootstrapper::class,
17
        Bootstrappers\Validation\ValidatorBootstrapper::class,
18
    ],
19
    Module::CLI_BOOTSTRAPPERS  => [
20
        Bootstrappers\Console\Commands\CommandsBootstrapper::class,
21
    ],
22
    Module::HTTP_BOOTSTRAPPERS => [
23
        Bootstrappers\Http\Controllers\Execute\LoginBootstrapper::class,
24
        Bootstrappers\Http\Controllers\Form\LoginBootstrapper::class,
25
        Bootstrappers\Http\Controllers\Form\UserBootstrapper::class,
26
        Bootstrappers\Http\Views\BuildersBootstrapper::class,
27
        Bootstrappers\Vendor\SlugifyBootstrapper::class,
28
    ],
29
    Module::COMMANDS           => [
30
        Console\Commands\User\Create::class,
31
        Console\Commands\User\Delete::class,
32
        Console\Commands\User\UpdatePassword::class,
33
        Console\Commands\UserGroup\Display::class,
34
    ],
35
    Module::EVENTS             => [
36
        Event::AUTH_READY         => [
37
            /** @see Events\Listeners\AuthInitializer::handle */
38
            sprintf('%s@handle', Events\Listeners\AuthInitializer::class),
39
        ],
40
        Event::NAVIGATION_READY   => [
41
            /** @see Events\Listeners\NavigationBuilder::handle */
42
            sprintf('%s@handle', Events\Listeners\NavigationBuilder::class),
43
        ],
44
        Event::ENTITY_POST_CHANGE => [
45
            /** @see Events\Listeners\AuthInvalidator::handle */
46
            sprintf('%s@handle', Events\Listeners\AuthInvalidator::class),
47
        ],
48
        Event::DASHBOARD_READY    => [
49
            /** @see Events\Listeners\DashboardRegistrar::build */
50
            sprintf('%s@handle', Events\Listeners\DashboardBuilder::class),
51
        ],
52
    ],
53
    Module::MIDDLEWARE         => [
54
        Priorities::NORMAL => [
55
            Http\Middleware\CheckCsrfToken::class,
56
            Http\Middleware\Security::class,
57
        ],
58
    ],
59
    Module::ROUTE_PATHS        => [
60
        Priorities::NORMAL => [
61
            __DIR__ . '/admin-routes.php',
62
            __DIR__ . '/login-routes.php',
63
        ],
64
    ],
65
    Module::MIGRATION_PATHS    => [
66
        Priorities::NORMAL => [
67
            realpath(__DIR__ . '/Databases/Migrations'),
68
        ],
69
    ],
70
];
71