Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

engine/classes/Elgg/Cli.php (1 issue)

calls to non-existent methods.

Bug Major
1
<?php
2
3
namespace Elgg;
4
5
use Elgg\Cli\Command;
6
use Symfony\Component\Console\Application as ConsoleApplication;
7
8
/**
9
 * CLI bootstrap
10
 */
11
class Cli {
12
13
	/**
14
	 * @var ConsoleApplication
15
	 */
16
	protected $console;
17
18
	/**
19
	 * @var HooksRegistrationService
20
	 */
21
	protected $hooks;
22
23
	/**
24
	 * Constructor
25
	 *
26
	 * @param ConsoleApplication       $console Console application instance
27
	 * @param HooksRegistrationService $hooks   Hooks registration service
28
	 */
29 1
	public function __construct(ConsoleApplication $console, HooksRegistrationService $hooks) {
30 1
		$this->console = $console;
31 1
		$this->hooks = $hooks;
32 1
	}
33
34
	/**
35
	 * Add CLI tools to the console application
36
	 * @return void
37
	 */
38
	protected function bootstrap() {
39
		$commands = $this->hooks->trigger('commands', 'cli', null, []);
0 ignored issues
show
The method trigger() does not exist on Elgg\HooksRegistrationService. Since it exists in all sub-types, consider adding an abstract or default implementation to Elgg\HooksRegistrationService. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
		/** @scrutinizer ignore-call */ 
40
  $commands = $this->hooks->trigger('commands', 'cli', null, []);
Loading history...
40
		foreach ($commands as $command) {
41
			if (class_exists($command) && is_subclass_of($command, Command::class)) {
42
				$this->console->add(new $command());
43
			}
44
		}
45
	}
46
47
	/**
48
	 * Bootstrap and run console application
49
	 * @return void
50
	 */
51
	public function run() {
52
		$this->bootstrap();
53
		$this->console->run();
54
	}
55
56
}
57