1 | <?php |
||
2 | namespace App\BxConsole; |
||
3 | |||
4 | use Bitrix\Main\Loader; |
||
0 ignored issues
–
show
|
|||
5 | use Bitrix\Main\ModuleManager; |
||
0 ignored issues
–
show
The type
Bitrix\Main\ModuleManager was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
6 | use Composer\Autoload\ClassLoader; |
||
7 | use Symfony\Component\Console\Command\Command; |
||
8 | use Symfony\Component\Console\Input\InputInterface; |
||
9 | use Symfony\Component\Console\Output\OutputInterface; |
||
10 | |||
11 | class Application extends \Symfony\Component\Console\Application { |
||
12 | |||
13 | const VERSION = '1.0.0'; |
||
14 | |||
15 | private $isBitrixLoaded; |
||
16 | |||
17 | private $bitrixCommands = []; |
||
0 ignored issues
–
show
|
|||
18 | |||
19 | public function __construct($name = 'BxConsole', $version = self::VERSION) |
||
20 | { |
||
21 | parent::__construct($name, $version); |
||
22 | |||
23 | EnvHelper::loadEnv(); |
||
24 | EnvHelper::getDocumentRoot(); |
||
25 | |||
26 | $loader = new \App\BxConsole\Bitrix\Loader(); |
||
27 | |||
28 | $this->isBitrixLoaded = $loader->initializeBitrix(); |
||
29 | |||
30 | if($this->isBitrixLoaded) { |
||
31 | foreach($loader->getModulesCommands() as $command) { |
||
32 | $this->add($command); |
||
33 | } |
||
34 | } |
||
35 | |||
36 | $pas4CliNamespace = EnvHelper::getPsr4CliNamespace(); |
||
37 | /** @scrutinizer ignore-call */ |
||
38 | $loaders = ClassLoader::getRegisteredLoaders(); |
||
39 | if(!empty($loaders)) { |
||
40 | $loader = current($loaders); |
||
41 | if($loader instanceof ClassLoader) { |
||
42 | $map = $loader->getClassMap(); |
||
43 | foreach($map as $class => $path) { |
||
44 | if(strpos($class, $pas4CliNamespace) === 0) { |
||
45 | try { |
||
46 | $obj = new $class(); |
||
47 | if($obj instanceof Command) { |
||
48 | $this->add($obj); |
||
49 | } |
||
50 | } catch (\Exception $e) { } |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
51 | } |
||
52 | } |
||
53 | } |
||
54 | } |
||
55 | |||
56 | $this->add(new Cron()); |
||
57 | } |
||
58 | |||
59 | public function doRun(InputInterface $input, OutputInterface $output) { |
||
60 | |||
61 | $exitCode = parent::doRun($input, $output); |
||
62 | |||
63 | if($this->isBitrixLoaded) { |
||
64 | if ($this->getCommandName($input) === null) { |
||
65 | $output->writeln(PHP_EOL . sprintf('Using Bitrix <info>kernel v%s</info>.</info>', SM_VERSION), |
||
0 ignored issues
–
show
|
|||
66 | OutputInterface::VERBOSITY_VERY_VERBOSE); |
||
67 | } |
||
68 | |||
69 | } else { |
||
70 | $output->writeln(PHP_EOL . sprintf('<error>No Bitrix kernel found in %s.</error> ' . |
||
71 | 'Please set DOCUMENT_ROOT value in composer.json <info>{"extra":{"document-root":DOCUMENT_ROOT}}</info>', $this->getDocumentRoot())); |
||
72 | } |
||
73 | |||
74 | return $exitCode; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function isBitrixLoaded(): bool |
||
81 | { |
||
82 | return $this->isBitrixLoaded; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getDocumentRoot() { |
||
89 | |||
90 | return (EnvHelper::getDocumentRoot() ?: ''); |
||
91 | } |
||
92 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths