Passed
Push — master ( aa1d71...aaf84d )
by Sergey
02:39
created
src/PhpConsole/EvalProvider.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 		try {
42 42
 			$result->return = static::executeCode($code, $this->sharedVars);
43 43
 		}
44
-		catch(\Throwable $exception) {
44
+		catch (\Throwable $exception) {
45 45
 			$result->exception = $exception;
46 46
 		}
47
-		catch(\Exception $exception) {
47
+		catch (\Exception $exception) {
48 48
 			$result->exception = $exception;
49 49
 		}
50 50
 		$result->time = abs(microtime(true) - $startTime - $selfTime);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @throws \Exception
62 62
 	 */
63 63
 	public function addCodeHandler($callback) {
64
-		if(!is_callable($callback)) {
64
+		if (!is_callable($callback)) {
65 65
 			throw new \Exception('Argument is not callable');
66 66
 		}
67 67
 		$this->codeCallbackHandlers[] = $callback;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return mixed
74 74
 	 */
75 75
 	protected function applyHandlersToCode($code) {
76
-		foreach($this->codeCallbackHandlers as $callback) {
76
+		foreach ($this->codeCallbackHandlers as $callback) {
77 77
 			call_user_func_array($callback, array(&$code));
78 78
 		}
79 79
 		return $code;
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	protected function backupGlobals() {
86 86
 		$this->globalsBackup = array();
87
-		foreach($GLOBALS as $key => $value) {
88
-			if($key != 'GLOBALS') {
87
+		foreach ($GLOBALS as $key => $value) {
88
+			if ($key != 'GLOBALS') {
89 89
 				$this->globalsBackup[$key] = $value;
90 90
 			}
91 91
 		}
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * Restore global vars data from backup var
96 96
 	 */
97 97
 	protected function restoreGlobals() {
98
-		foreach($this->globalsBackup as $key => $value) {
98
+		foreach ($this->globalsBackup as $key => $value) {
99 99
 			$GLOBALS[$key] = $value;
100 100
 		}
101
-		foreach(array_diff(array_keys($GLOBALS), array_keys($this->globalsBackup)) as $newKey) {
102
-			if($newKey != 'GLOBALS') {
101
+		foreach (array_diff(array_keys($GLOBALS), array_keys($this->globalsBackup)) as $newKey) {
102
+			if ($newKey != 'GLOBALS') {
103 103
 				unset($GLOBALS[$newKey]);
104 104
 			}
105 105
 		}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @return mixed
113 113
 	 */
114 114
 	protected static function executeCode($_code, array $_sharedVars) {
115
-		foreach($_sharedVars as $var => $value) {
116
-			if(isset($GLOBALS[$var]) && $var[0] == '_') { // extract($this->sharedVars, EXTR_OVERWRITE) and $$var = $value do not overwrites global vars
115
+		foreach ($_sharedVars as $var => $value) {
116
+			if (isset($GLOBALS[$var]) && $var[0] == '_') { // extract($this->sharedVars, EXTR_OVERWRITE) and $$var = $value do not overwrites global vars
117 117
 				$GLOBALS[$var] = $value;
118 118
 			}
119
-			elseif(!isset($$var)) {
119
+			elseif (!isset($$var)) {
120 120
 				$$var = $value;
121 121
 			}
122 122
 		}
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 	 * @codeCoverageIgnore
176 176
 	 */
177 177
 	protected function forcePhpConsoleClassesAutoLoad() {
178
-		foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__), \RecursiveIteratorIterator::LEAVES_ONLY) as $path) {
178
+		foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__), \RecursiveIteratorIterator::LEAVES_ONLY) as $path) {
179 179
 			/** @var $path \SplFileInfo */
180
-			if($path->isFile() && $path->getExtension() == 'php' && $path->getFilename() !== 'PsrLogger.php') {
180
+			if ($path->isFile() && $path->getExtension() == 'php' && $path->getFilename() !== 'PsrLogger.php') {
181 181
 				require_once($path->getPathname());
182 182
 			}
183 183
 		}
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 	 * @codeCoverageIgnore
190 190
 	 */
191 191
 	protected function applyOpenBaseDirSetting() {
192
-		if($this->openBaseDirs) {
192
+		if ($this->openBaseDirs) {
193 193
 			$value = implode(PATH_SEPARATOR, $this->openBaseDirs);
194
-			if(ini_get('open_basedir') != $value) {
194
+			if (ini_get('open_basedir') != $value) {
195 195
 				$this->forcePhpConsoleClassesAutoLoad();
196
-				if(ini_set('open_basedir', $value) === false) {
196
+				if (ini_set('open_basedir', $value) === false) {
197 197
 					throw new \Exception('Unable to set "open_basedir" php.ini setting');
198 198
 				}
199 199
 			}
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	 * @throws \Exception
228 228
 	 */
229 229
 	public function addSharedVarReference($name, &$var) {
230
-		if(isset($this->sharedVars[$name])) {
230
+		if (isset($this->sharedVars[$name])) {
231 231
 			throw new \Exception('Var with name "' . $name . '" already added');
232 232
 		}
233
-		$this->sharedVars[$name] =& $var;
233
+		$this->sharedVars[$name] = & $var;
234 234
 	}
235 235
 }
236 236
 
Please login to merge, or discard this patch.
src/PhpConsole/Helper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 		 * @return Connector
39 39
 		 */
40 40
 		public static function register(Connector $connector = null, Handler $handler = null) {
41
-			if(static::$connector) {
41
+			if (static::$connector) {
42 42
 				throw new \Exception('Helper already registered');
43 43
 			}
44 44
 			self::$handler = $handler;
45
-			self::$connector = $connector ? : Connector::getInstance();
45
+			self::$connector = $connector ?: Connector::getInstance();
46 46
 			self::$isActive = self::$connector->isActiveClient();
47 47
 			return self::$connector;
48 48
 		}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		 * @throws \Exception
62 62
 		 */
63 63
 		public static function getConnector() {
64
-			if(!self::$connector) {
64
+			if (!self::$connector) {
65 65
 				throw new \Exception('Helper is not registered. Call ' . get_called_class() . '::register()');
66 66
 			}
67 67
 			return self::$connector;
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 		 * @throws \Exception
74 74
 		 */
75 75
 		public static function getHandler() {
76
-			if(!self::$connector) {
76
+			if (!self::$connector) {
77 77
 				throw new \Exception('Helper is not registered. Call ' . get_called_class() . '::register()');
78 78
 			}
79
-			if(!self::$handler) {
79
+			if (!self::$handler) {
80 80
 				self::$handler = Handler::getInstance();
81 81
 			}
82 82
 			return self::$handler;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		 * @param int|array $ignoreTraceCalls Ignore tracing classes by name prefix `array('PhpConsole')` or fixed number of calls to ignore
90 90
 		 */
91 91
 		public static function debug($data, $tags = null, $ignoreTraceCalls = 0) {
92
-			if(self::$isActive) {
92
+			if (self::$isActive) {
93 93
 				self::$connector->getDebugDispatcher()->dispatchDebug($data, $tags, is_numeric($ignoreTraceCalls) ? $ignoreTraceCalls + 1 : $ignoreTraceCalls);
94 94
 			}
95 95
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		 * @param $args
102 102
 		 */
103 103
 		public static function __callStatic($tags, $args) {
104
-			if(isset($args[1])) {
104
+			if (isset($args[1])) {
105 105
 				$tags .= '.' . $args[1];
106 106
 			}
107 107
 			static::debug(isset($args[0]) ? $args[0] : null, $tags, 1);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 	use PhpConsole\Helper;
115 115
 
116
-	if(!class_exists('PC', false)) {
116
+	if (!class_exists('PC', false)) {
117 117
 		/**
118 118
 		 * Helper short class name in global namespace
119 119
 		 */
Please login to merge, or discard this patch.
src/PhpConsole/Auth.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,11 +71,11 @@
 block discarded – undo
71 71
 	 */
72 72
 	protected function getClientUid() {
73 73
 		$clientUid = '';
74
-		if($this->publicKeyByIp) {
75
-			if(isset($_SERVER['REMOTE_ADDR'])) {
74
+		if ($this->publicKeyByIp) {
75
+			if (isset($_SERVER['REMOTE_ADDR'])) {
76 76
 				$clientUid .= $_SERVER['REMOTE_ADDR'];
77 77
 			}
78
-			if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
78
+			if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
79 79
 				$clientUid .= $_SERVER['HTTP_X_FORWARDED_FOR'];
80 80
 			}
81 81
 		}
Please login to merge, or discard this patch.
src/PhpConsole/PsrLogger.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 */
57 57
 	public function log($level, $message, array $context = array()) {
58
-		if(is_object($message) && is_callable($message, '__toString')) {
58
+		if (is_object($message) && is_callable($message, '__toString')) {
59 59
 			$message = (string)$message;
60 60
 		}
61 61
 		$message = $this->fetchMessageContext($message, $context);
62 62
 
63
-		if(isset(static::$debugLevels[$level])) {
63
+		if (isset(static::$debugLevels[$level])) {
64 64
 			$this->connector->getDebugDispatcher()->dispatchDebug($message, static::$debugLevels[$level], $this->ignoreTraceCalls);
65 65
 		}
66
-		elseif(isset(static::$errorsLevels[$level])) {
67
-			if(isset($context['exception']) && ($context['exception'] instanceof \Exception || $context['exception'] instanceof \Throwable)) {
66
+		elseif (isset(static::$errorsLevels[$level])) {
67
+			if (isset($context['exception']) && ($context['exception'] instanceof \Exception || $context['exception'] instanceof \Throwable)) {
68 68
 				$this->connector->getErrorsDispatcher()->dispatchException($context['exception']);
69 69
 			}
70 70
 			else {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 	protected function fetchMessageContext($message, array $context) {
80 80
 		$replace = array();
81
-		foreach($context as $key => $value) {
81
+		foreach ($context as $key => $value) {
82 82
 			$replace['{' . $key . '}'] = $this->contextDumper->dump($value);
83 83
 		}
84 84
 		return strtr($message, $replace);
Please login to merge, or discard this patch.
src/PhpConsole/Dispatcher/Errors.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 	 * @param int|array $ignoreTraceCalls Ignore tracing classes by name prefix `array('PhpConsole')` or fixed number of calls to ignore
56 56
 	 */
57 57
 	public function dispatchError($code = null, $text = null, $file = null, $line = null, $ignoreTraceCalls = 0) {
58
-		if($this->isActive()) {
58
+		if ($this->isActive()) {
59 59
 			$message = new ErrorMessage();
60 60
 			$message->code = $code;
61 61
 			$message->class = $this->getErrorTypeByCode($code);
62 62
 			$message->data = $this->dumper->dump($text);
63 63
 			$message->file = $file;
64 64
 			$message->line = $line;
65
-			if($ignoreTraceCalls !== null) {
65
+			if ($ignoreTraceCalls !== null) {
66 66
 				$message->trace = $this->fetchTrace(debug_backtrace(), $file, $line, is_array($ignoreTraceCalls) ? $ignoreTraceCalls : $ignoreTraceCalls + 1);
67 67
 			}
68 68
 			$this->sendMessage($message);
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @param \Exception|\Throwable $exception
75 75
 	 */
76 76
 	public function dispatchException($exception) {
77
-		if($this->isActive()) {
78
-			if($this->dispatchPreviousExceptions && $exception->getPrevious()) {
77
+		if ($this->isActive()) {
78
+			if ($this->dispatchPreviousExceptions && $exception->getPrevious()) {
79 79
 				$this->dispatchException($exception->getPrevious());
80 80
 			}
81 81
 			$message = new ErrorMessage();
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @param Message $message
95 95
 	 */
96 96
 	protected function sendMessage(Message $message) {
97
-		if(!$this->isIgnored($message)) {
97
+		if (!$this->isIgnored($message)) {
98 98
 			parent::sendMessage($message);
99 99
 			$this->sentMessages[] = $message;
100 100
 		}
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 * @return string
107 107
 	 */
108 108
 	protected function getErrorTypeByCode($code) {
109
-		if(!static::$errorsConstantsValues) {
110
-			foreach(static::$errorsConstantsNames as $constantName) {
111
-				if(defined($constantName)) {
109
+		if (!static::$errorsConstantsValues) {
110
+			foreach (static::$errorsConstantsNames as $constantName) {
111
+				if (defined($constantName)) {
112 112
 					static::$errorsConstantsValues[constant($constantName)] = $constantName;
113 113
 				}
114 114
 			}
115 115
 		}
116
-		if(isset(static::$errorsConstantsValues[$code])) {
116
+		if (isset(static::$errorsConstantsValues[$code])) {
117 117
 			return static::$errorsConstantsValues[$code];
118 118
 		}
119 119
 		return (string)$code;
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	 * @return bool
126 126
 	 */
127 127
 	protected function isIgnored(ErrorMessage $message) {
128
-		if($this->ignoreRepeatedSource && $message->file) {
129
-			foreach($this->sentMessages as $sentMessage) {
130
-				if($message->file == $sentMessage->file && $message->line == $sentMessage->line && $message->class == $sentMessage->class) {
128
+		if ($this->ignoreRepeatedSource && $message->file) {
129
+			foreach ($this->sentMessages as $sentMessage) {
130
+				if ($message->file == $sentMessage->file && $message->line == $sentMessage->line && $message->class == $sentMessage->class) {
131 131
 					return true;
132 132
 				}
133 133
 			}
Please login to merge, or discard this patch.
src/PhpConsole/Dispatcher/Evaluate.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @param $code
54 54
 	 */
55 55
 	public function dispatchCode($code) {
56
-		if($this->isActive()) {
56
+		if ($this->isActive()) {
57 57
 			$previousLastError = error_get_last();
58 58
 			$oldDisplayErrors = ini_set('display_errors', false);
59 59
 			$result = $this->evalProvider->evaluate($code);
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 			$message->time = round($result->time, 6);
66 66
 
67 67
 			$newLastError = error_get_last();
68
-			if($newLastError && $newLastError != $previousLastError) {
68
+			if ($newLastError && $newLastError != $previousLastError) {
69 69
 				$this->connector->getErrorsDispatcher()->dispatchError($newLastError ['type'], $newLastError ['message'], $newLastError ['file'], $newLastError ['line'], 999);
70 70
 			}
71
-			if($result->exception) {
71
+			if ($result->exception) {
72 72
 				$this->connector->getErrorsDispatcher()->dispatchException($result->exception);
73 73
 			}
74 74
 			$this->sendMessage($message);
Please login to merge, or discard this patch.
src/PhpConsole/Dispatcher/Debug.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
 	 * @param int|array $ignoreTraceCalls Ignore tracing classes by name prefix `array('PhpConsole')` or fixed number of calls to ignore
27 27
 	 */
28 28
 	public function dispatchDebug($data, $tags = null, $ignoreTraceCalls = 0) {
29
-		if($this->isActive()) {
29
+		if ($this->isActive()) {
30 30
 			$message = new DebugMessage();
31 31
 			$message->data = $this->dumper->dump($data);
32
-			if($tags) {
32
+			if ($tags) {
33 33
 				$message->tags = explode('.', $tags);
34 34
 			}
35
-			if($this->detectTraceAndSource && $ignoreTraceCalls !== null) {
35
+			if ($this->detectTraceAndSource && $ignoreTraceCalls !== null) {
36 36
 				$message->trace = $this->fetchTrace(debug_backtrace(), $message->file, $message->line, $ignoreTraceCalls);
37 37
 			}
38 38
 			$this->sendMessage($message);
Please login to merge, or discard this patch.
examples/features/eval_terminal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 require_once(__DIR__ . '/../../src/PhpConsole/__autoload.php');
4 4
 
5 5
 $password = null;
6
-if(!$password) {
6
+if (!$password) {
7 7
 	die('Please set $password variable value in ' . __FILE__);
8 8
 }
9 9
 
Please login to merge, or discard this patch.
examples/features/highload_optimization.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 require_once(__DIR__ . '/../../src/PhpConsole/__autoload.php');
4 4
 
5
-if(PhpConsole\Connector::getInstance()->isActiveClient()) {
5
+if (PhpConsole\Connector::getInstance()->isActiveClient()) {
6 6
 	// ... any PHP Console initialization & configuration code
7 7
 }
8 8
 
Please login to merge, or discard this patch.