Completed
Push — master ( 4eb4a8...a52438 )
by Henry
07:48
created

includes/Console/ConsoleAbstract.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Console;
3
4
use Redaxscript\Config;
5
use Redaxscript\Language;
6
use Redaxscript\Registry;
7
use Redaxscript\Request;
8
use Redaxscript\Validator;
9
use function php_sapi_name;
10
11
/**
12
 * abstract class to handle the command line interface
13
 *
14
 * @since 3.0.0
15
 *
16
 * @package Redaxscript
17
 * @category Console
18
 * @author Henry Ruhs
19
 */
20
21
abstract class ConsoleAbstract
22
{
23
	/**
24
	 * instance of the registry class
25
	 *
26
	 * @var Registry
27
	 */
28
29
	protected $_registry;
30
31
	/**
32
	 * instance of the request class
33
	 *
34
	 * @var Request
35
	 */
36
37
	protected $_request;
38
39
	/**
40
	 * instance of the language class
41
	 *
42
	 * @var Language
43
	 */
44
45
	protected $_language;
46
47
	/**
48
	 * instance of the config class
49
	 *
50
	 * @var Config
51
	 */
52
53
	protected $_config;
54
55
	/**
56
	 * array of command namespaces
57
	 *
58
	 * @var string
59
	 */
60
61
	protected $_namespaceArray;
62
63
	/**
64
	 * constructor of the class
65
	 *
66
	 * @since 4.5.0
67
	 *
68
	 * @param Registry $registry instance of the registry class
69
	 * @param Request $request instance of the request class
70
	 * @param Language $language instance of the language class
71
	 * @param Config $config instance of the config class
72
	 */
73
74 3
	public function __construct(Registry $registry, Request $request, Language $language, Config $config)
75
	{
76 3
		$this->_registry = $registry;
77 3
		$this->_request = $request;
78 3
		$this->_language = $language;
79 3
		$this->_config = $config;
80 3
		$accessValidator = new Validator\Access();
81
82 3
		if (php_sapi_name() === 'cli')
83
		{
84 3
			$this->_namespaceArray =
85
			[
0 ignored issues
show
Documentation Bug introduced by
It seems like array('backup' => 'Redax...e\\Command\\Uninstall') of type array<string,string,{"ba...,"uninstall":"string"}> is incompatible with the declared type string of property $_namespaceArray.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
86 3
				'backup' => 'Redaxscript\Console\Command\Backup',
87
				'cache' => 'Redaxscript\Console\Command\Cache',
88
				'config' => 'Redaxscript\Console\Command\Config',
89
				'help' => 'Redaxscript\Console\Command\Help',
90
				'install' => 'Redaxscript\Console\Command\Install',
91
				'migrate' => 'Redaxscript\Console\Command\Migrate',
92
				'restore' => 'Redaxscript\Console\Command\Restore',
93
				'setting' => 'Redaxscript\Console\Command\Setting',
94
				'status' => 'Redaxscript\Console\Command\Status',
95
				'uninstall' => 'Redaxscript\Console\Command\Uninstall'
96
			];
97
		}
98
		else if($this->_request->getServer('REMOTE_ADDR') === '127.0.0.1' || $accessValidator->validate('1', $registry->get('myGroups')))
99
		{
100
			$this->_namespaceArray =
101
			[
0 ignored issues
show
Documentation Bug introduced by
It seems like array('auth' => 'Redaxsc...e\\Command\\Uninstall') of type array<string,string,{"au...,"uninstall":"string"}> is incompatible with the declared type string of property $_namespaceArray.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
102
				'auth' => 'Redaxscript\Console\Command\Auth',
103
				'backup' => 'Redaxscript\Console\Command\Backup',
104
				'cache' => 'Redaxscript\Console\Command\Cache',
105
				'config' => 'Redaxscript\Console\Command\Config',
106
				'help' => 'Redaxscript\Console\Command\Help',
107
				'install' => 'Redaxscript\Console\Command\Install',
108
				'migrate' => 'Redaxscript\Console\Command\Migrate',
109
				'restore' => 'Redaxscript\Console\Command\Restore',
110
				'setting' => 'Redaxscript\Console\Command\Setting',
111
				'status' => 'Redaxscript\Console\Command\Status',
112
				'uninstall' => 'Redaxscript\Console\Command\Uninstall'
113
			];
114
		}
115
		else
116
		{
117
			$this->_namespaceArray =
118
			[
0 ignored issues
show
Documentation Bug introduced by
It seems like array('auth' => 'Redaxsc...sole\\Command\\Status') of type array<string,string,{"au...ng","status":"string"}> is incompatible with the declared type string of property $_namespaceArray.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
119
				'auth' => 'Redaxscript\Console\Command\Auth',
120
				'help' => 'Redaxscript\Console\Command\Help',
121
				'status' => 'Redaxscript\Console\Command\Status'
122
			];
123
		}
124 3
	}
125
}
126