1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Port\Loader; |
4
|
|
|
|
5
|
|
|
use App\Port\Loader\Helpers\Facade\LoaderHelper; |
6
|
|
|
use App\Port\Loader\Loaders\AliasesLoaderTrait; |
7
|
|
|
use App\Port\Loader\Loaders\ConfigsLoaderTrait; |
8
|
|
|
use App\Port\Loader\Loaders\ConsolesLoaderTrait; |
9
|
|
|
use App\Port\Loader\Loaders\MigrationsLoaderTrait; |
10
|
|
|
use App\Port\Loader\Loaders\ProvidersLoaderTrait; |
11
|
|
|
use App\Port\Loader\Loaders\ViewsLoaderTrait; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class AutoLoaderTrait. |
15
|
|
|
* |
16
|
|
|
* @author Mahmoud Zalt <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
trait AutoLoaderTrait |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
// using each component loader trait |
22
|
|
|
use ConfigsLoaderTrait; |
23
|
|
|
use MigrationsLoaderTrait; |
24
|
|
|
use ViewsLoaderTrait; |
25
|
|
|
use ProvidersLoaderTrait; |
26
|
|
|
use ConsolesLoaderTrait; |
27
|
|
|
use AliasesLoaderTrait; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* * to be used from the `boot` function of the main service provider |
31
|
|
|
*/ |
32
|
|
|
public function bootLoaders() |
33
|
|
|
{ |
34
|
|
|
// the config files should be loaded first from all the directories in their own loop |
35
|
|
|
foreach (LoaderHelper::getPortFoldersNames() as $portFolderName) { |
36
|
|
|
$this->loadConfigsFromPort($portFolderName); // TODO: move this to the loop below at the top |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
// > iterate over all the port folders and autoload most of the components |
40
|
|
|
foreach (LoaderHelper::getPortFoldersNames() as $portFolderName) { |
41
|
|
|
$this->loadProvidersFromPort($portFolderName); |
|
|
|
|
42
|
|
|
$this->loadMigrationsFromPort($portFolderName); |
43
|
|
|
$this->loadViewsFromPort($portFolderName); |
44
|
|
|
$this->loadConsolesFromPort($portFolderName); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
// > iterate over all the containers folders and autoload most of the components |
48
|
|
|
foreach (LoaderHelper::getContainersNames() as $containerName) { |
49
|
|
|
$this->loadConfigsFromContainers($containerName); |
50
|
|
|
$this->loadProvidersFromContainers($containerName); |
51
|
|
|
$this->loadMigrationsFromContainers($containerName); |
52
|
|
|
$this->loadViewsFromContainers($containerName); |
53
|
|
|
$this->loadViewsFromContainers($containerName); |
54
|
|
|
$this->loadConsolesFromContainers($containerName); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* to be used from the `register` function of the main service provider |
60
|
|
|
*/ |
61
|
|
|
public function registerLoaders() |
62
|
|
|
{ |
63
|
|
|
$this->loadContainerFactories(); |
|
|
|
|
64
|
|
|
$this->loadPortInternalAliases(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.