Passed
Push — master ( cbe288...130872 )
by Peter
02:31
created
Labels
Severity
1
<?php
2
3
use AbterPhp\Framework\Constant\Event;
0 ignored issues
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...
4
use AbterPhp\Framework\Constant\Module;
5
use AbterPhp\Framework\Constant\Priorities;
6
use AbterPhp\Website\Bootstrappers;
7
use AbterPhp\Website\Events;
8
9
return [
10
    Module::IDENTIFIER         => 'AbterPhp\Website',
11
    Module::DEPENDENCIES       => ['AbterPhp\Admin'],
12
    Module::ENABLED            => true,
13
    Module::BOOTSTRAPPERS      => [
14
        Bootstrappers\Orm\OrmBootstrapper::class,
15
        Bootstrappers\Validation\ValidatorBootstrapper::class,
16
    ],
17
    Module::CLI_BOOTSTRAPPERS  => [
18
        Bootstrappers\Database\MigrationsBootstrapper::class,
19
    ],
20
    Module::HTTP_BOOTSTRAPPERS => [
21
        Bootstrappers\Http\Controllers\Website\IndexBootstrapper::class,
22
        Bootstrappers\Http\Views\BuildersBootstrapper::class,
23
    ],
24
    Module::EVENTS             => [
25
        Event::TEMPLATE_ENGINE_READY => [
26
            /** @see \AbterPhp\Website\Events\Listeners\TemplateInitializer::handle */
27
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\TemplateInitializer::class)],
28
        ],
29
        Event::NAVIGATION_READY      => [
30
            /** @see \AbterPhp\Website\Events\Listeners\NavigationBuilder::handle */
31
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\NavigationBuilder::class)],
32
        ],
33
        Event::ENTITY_POST_CHANGE    => [
34
            /** @see \AbterPhp\Website\Events\Listeners\PageInvalidator::handle */
35
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\PageInvalidator::class)],
36
        ],
37
        Event::DASHBOARD_READY       => [
38
            /** @see \AbterPhp\Website\Events\Listeners\DashboardBuilder::handle */
39
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\DashboardBuilder::class)],
40
        ],
41
    ],
42
    Module::ROUTE_PATHS        => [
43
        Priorities::NORMAL       => [
44
            __DIR__ . '/admin-routes.php',
45
        ],
46
        Priorities::BELOW_NORMAL => [
47
            __DIR__ . '/website-routes.php',
48
        ],
49
    ],
50
    Module::MIGRATION_PATHS    => [
51
        Priorities::NORMAL => [
52
            realpath(__DIR__ . '/src/Databases/Migrations'),
53
        ],
54
    ],
55
    Module::RESOURCE_PATH      => realpath(__DIR__ . '/resources'),
56
    Module::ASSETS_PATHS       => [
57
        'root'    => realpath(__DIR__ . '/resources/rawassets'),
58
        'website' => realpath(__DIR__ . '/resources/rawassets'),
59
    ],
60
];
61