Passed
Push — develop ( 319bd8...330c7a )
by Neill
16:41 queued 15s
created
neon/core/Yii.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,5 +24,5 @@
 block discarded – undo
24 24
 
25 25
 spl_autoload_register(['Yii', 'autoload'], true, true);
26 26
 // Ability to replace any yii core class with an alternative
27
-Yii::$classMap = require YII2_PATH . '/classes.php';
27
+Yii::$classMap = require YII2_PATH.'/classes.php';
28 28
 Yii::$container = new yii\di\Container();
Please login to merge, or discard this patch.
neon/core/web/Request.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @throws \yii\base\InvalidConfigException
205 205
 	 * @throws HttpException - if validation fails
206 206
 	 */
207
-	public function validate($data, $rules, $errorCode=400)
207
+	public function validate($data, $rules, $errorCode = 400)
208 208
 	{
209 209
 		$model = $this->validateData($data, $rules);
210 210
 		if ($model->hasErrors()) {
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 	 * // $req->hasErrors();
237 237
 	 * ```
238 238
 	 */
239
-	public function validateData($data, $rules, $type="get")
239
+	public function validateData($data, $rules, $type = "get")
240 240
 	{
241 241
 		$validate = [];
242
-		foreach($data as $key => $default)
242
+		foreach ($data as $key => $default)
243 243
 			$validate[$key] = $this->$type($key, $default);
244 244
 		return \yii\base\DynamicModel::validateData($validate, $rules);
245 245
 	}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * used is the $pattern matches the current route
386 386
 	 * @return bool
387 387
 	 */
388
-	public function isRoute($pattern, $params=[])
388
+	public function isRoute($pattern, $params = [])
389 389
 	{
390 390
 		$route = neon()->controller->getRoute();
391 391
 		$match = Str::is(ltrim($pattern, '/'), $route);
Please login to merge, or discard this patch.
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -152,10 +152,12 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function get($name = null, $defaultValue = null)
154 154
 	{
155
-		if ($this->_sanitisedQueryParams == null)
156
-			$this->sanitiseBodyQueryParams();
157
-		if ($name == null)
158
-			return $this->_sanitisedQueryParams;
155
+		if ($this->_sanitisedQueryParams == null) {
156
+					$this->sanitiseBodyQueryParams();
157
+		}
158
+		if ($name == null) {
159
+					return $this->_sanitisedQueryParams;
160
+		}
159 161
 		return isset($this->_sanitisedQueryParams[$name]) ? $this->_sanitisedQueryParams[$name] : $defaultValue;
160 162
 	}
161 163
 
@@ -239,8 +241,9 @@  discard block
 block discarded – undo
239 241
 	public function validateData($data, $rules, $type="get")
240 242
 	{
241 243
 		$validate = [];
242
-		foreach($data as $key => $default)
243
-			$validate[$key] = $this->$type($key, $default);
244
+		foreach($data as $key => $default) {
245
+					$validate[$key] = $this->$type($key, $default);
246
+		}
244 247
 		return \yii\base\DynamicModel::validateData($validate, $rules);
245 248
 	}
246 249
 
@@ -253,10 +256,12 @@  discard block
 block discarded – undo
253 256
 	 */
254 257
 	public function post($name = null, $defaultValue = null)
255 258
 	{
256
-		if ($this->_sanitisedBodyParams == null)
257
-			$this->sanitiseBodyQueryParams();
258
-		if ($name == null)
259
-			return $this->_sanitisedBodyParams;
259
+		if ($this->_sanitisedBodyParams == null) {
260
+					$this->sanitiseBodyQueryParams();
261
+		}
262
+		if ($name == null) {
263
+					return $this->_sanitisedBodyParams;
264
+		}
260 265
 		return isset($this->_sanitisedBodyParams[$name]) ? $this->_sanitisedBodyParams[$name] : $defaultValue;
261 266
 	}
262 267
 
@@ -390,10 +395,14 @@  discard block
 block discarded – undo
390 395
 		$route = neon()->controller->getRoute();
391 396
 		$match = Str::is(ltrim($pattern, '/'), $route);
392 397
 		// we can return imidiately if the route does not match the pattern
393
-		if (!$match) return false;
398
+		if (!$match) {
399
+			return false;
400
+		}
394 401
 
395 402
 		// if no param search specified then return the match
396
-		if (empty($params)) return $match;
403
+		if (empty($params)) {
404
+			return $match;
405
+		}
397 406
 
398 407
 		// Finally check if $params exist in request params
399 408
 		return Arr::isSubset($params, neon()->request->getQueryParams());
Please login to merge, or discard this patch.
neon/core/test/helpers.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use neon\core\helpers\File;
4 4
 
5
-if (! function_exists('neon_test_database_create')) {
5
+if (!function_exists('neon_test_database_create')) {
6 6
 	/**
7 7
 	 * Creates the test database and user
8 8
 	 * Note this does not run the neon installation and create the
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	function neon_test_database_create()
13 13
 	{
14
-		$installDb  = env('INSTALL_TEST_DB', true);
14
+		$installDb = env('INSTALL_TEST_DB', true);
15 15
 		if ($installDb) {
16 16
 			$db = env('DB_NAME');
17 17
 			$host = env('DB_HOST', 'localhost');
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 }
54 54
 
55
-if (! function_exists('neon_test_db_cmd')) {
55
+if (!function_exists('neon_test_db_cmd')) {
56 56
 	function neon_test_db_cmd($cmd)
57 57
 	{
58 58
 		// A security risk here?  Mind you if you can run PHP your system is compromised anyway.
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		# use the following line to see any warnings and errors
65 65
 		#exec($c);
66 66
 		# or use this one to suppress them (inc the one about the password)
67
-		exec($c . " 2>/dev/null");
67
+		exec($c." 2>/dev/null");
68 68
 	}
69 69
 }
70 70
 
71
-if (! function_exists('neon_test_server_restart')) {
71
+if (!function_exists('neon_test_server_restart')) {
72 72
 	/**
73 73
 	 * Restart a test server
74 74
 	 * @param $name
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 	 * @param int $port
77 77
 	 * @throws Exception
78 78
 	 */
79
-	function neon_test_server_restart($name='test_server', $docRoot=DIR_TEST.'/_root/public', $port=8888)
79
+	function neon_test_server_restart($name = 'test_server', $docRoot = DIR_TEST.'/_root/public', $port = 8888)
80 80
 	{
81 81
 		neon_test_server_stop($name);
82 82
 		echo "\nRestarting test server...\n";
83 83
 		// clear the cache
84
-		File::removeDirectory(DIR_TEST . '/_root/var');
85
-		File::removeDirectory(DIR_TEST . '/_root/system');
84
+		File::removeDirectory(DIR_TEST.'/_root/var');
85
+		File::removeDirectory(DIR_TEST.'/_root/system');
86 86
 		neon_test_server_start($name, $docRoot, $port, true);
87 87
 	}
88 88
 }
89 89
 
90
-if (! function_exists('neon_test_server_start')) {
90
+if (!function_exists('neon_test_server_start')) {
91 91
 	/**
92 92
 	 * Spin up the test server to run the acceptance tests against
93 93
 	 * @param string $name
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @return \Symfony\Component\Process\Process
97 97
 	 * @throws Exception
98 98
 	 */
99
-	function neon_test_server_start($name='test_server', $docRoot=DIR_TEST.'/_root/public', $port=8888, $silent=false)
99
+	function neon_test_server_start($name = 'test_server', $docRoot = DIR_TEST.'/_root/public', $port = 8888, $silent = false)
100 100
 	{
101 101
 		if (preg_match("/[^a-z0-9_]/", $name) !== 0) {
102 102
 			throw new \Exception('The name must contain only [a-z0-9_] characters');
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		 * Tests are run against this server
107 107
 		 */
108 108
 		$address = "localhost:$port";
109
-		$command = PHP_BINARY . " -S {$address} -t {$docRoot}";
109
+		$command = PHP_BINARY." -S {$address} -t {$docRoot}";
110 110
 		if (!$silent) {
111 111
 			echo "\n|======================================================";
112 112
 			echo "\n| Creating Test Server";
@@ -123,19 +123,19 @@  discard block
 block discarded – undo
123 123
 		}
124 124
 		$process = \neon\core\test\ProcessForker::run($name, $command);
125 125
 		try {
126
-			retry(10, function () use ($address) {
126
+			retry(10, function() use ($address) {
127 127
 				$client = new GuzzleHttp\Client();
128 128
 				$res = $client->request('GET', $address);
129
-				echo ' - Server running with code: ' . $res->getStatusCode() . "\n";
129
+				echo ' - Server running with code: '.$res->getStatusCode()."\n";
130 130
 			}, 1000);
131
-		} catch(GuzzleHttp\Exception\ConnectException $e) {
131
+		} catch (GuzzleHttp\Exception\ConnectException $e) {
132 132
 			throw new \Exception('Unable to connect to the local test server');
133 133
 		}
134 134
 		return $process;
135 135
 	}
136 136
 }
137 137
 
138
-if (! function_exists('retry')) {
138
+if (!function_exists('retry')) {
139 139
 	/**
140 140
 	 * Retry an operation a given number of times.
141 141
 	 *
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		try {
154 154
 			return $callback();
155 155
 		} catch (\Exception $e) {
156
-			if (! $times) {
156
+			if (!$times) {
157 157
 				throw $e;
158 158
 			}
159 159
 			$times--;
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
 	}
166 166
 }
167 167
 
168
-if (! function_exists('neon_test_server_stop')) {
168
+if (!function_exists('neon_test_server_stop')) {
169 169
 	/**
170 170
 	 * Spin up the test server to run the acceptance tests against
171 171
 	 * @param string $name
172 172
 	 * @throws \Exception if name is not formatted correctly
173 173
 	 */
174
-	function neon_test_server_stop($name='test_server')
174
+	function neon_test_server_stop($name = 'test_server')
175 175
 	{
176 176
 		if (preg_match("/[^a-z0-9_]/", $name) !== 0) {
177 177
 			throw new \Exception('The name must contain only [a-z0-9_] characters');
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	}
182 182
 }
183 183
 
184
-if (! function_exists('test_url')) {
184
+if (!function_exists('test_url')) {
185 185
 	/**
186 186
 	 * Return the test url
187 187
 	 */
Please login to merge, or discard this patch.
neon/core/test/WebBrowserDriver.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		parent::__construct($config, $options);
36 36
 		// Set default path for ChromeDriver
37 37
 		if (!isset($this->config['path'])) {
38
-			$this->config['path'] = __DIR__ . '/bin/'.$this->chromeVersion.'/chromedriver-' . $this->getDriverSuffix();
38
+			$this->config['path'] = __DIR__.'/bin/'.$this->chromeVersion.'/chromedriver-'.$this->getDriverSuffix();
39 39
 		}
40 40
 		// Set default WebDriver port
41 41
 		if (!isset($this->config['port'])) {
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 		}
82 82
 		$descriptorSpec = array(
83 83
 			array('pipe', 'r'),
84
-			array('file', $this->getLogDir() . 'ChromeDriver.output.txt', 'w'),
85
-			array('file', $this->getLogDir() . 'ChromeDriver.errors.txt', 'a')
84
+			array('file', $this->getLogDir().'ChromeDriver.output.txt', 'w'),
85
+			array('file', $this->getLogDir().'ChromeDriver.errors.txt', 'a')
86 86
 		);
87 87
 		$this->resource = proc_open($command, $descriptorSpec, $this->pipes, null, null, array('bypass_shell' => true));
88 88
 		if (!is_resource($this->resource) || !proc_get_status($this->resource)['running']) {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 					// Make sure the value is true/false and not 1/0
171 171
 					$configValue = ($configValue) ? 'true' : 'false';
172 172
 				}
173
-				$params[] = $mapping[$configKey] . '=' . $configValue;
173
+				$params[] = $mapping[$configKey].'='.$configValue;
174 174
 			}
175 175
 		}
176 176
 		return implode(' ', $params);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		// Prefix command with exec on non Windows systems to ensure that we receive the correct pid.
184 184
 		// See http://php.net/manual/en/function.proc-get-status.php#93382
185 185
 		$commandPrefix = $this->isWindows() ? '' : 'exec ';
186
-		return $commandPrefix . escapeshellarg(realpath($this->config['path'])) . ' ' . $this->getCommandParameters() . ' --url-base=/wd/hub';
186
+		return $commandPrefix.escapeshellarg(realpath($this->config['path'])).' '.$this->getCommandParameters().' --url-base=/wd/hub';
187 187
 	}
188 188
 	/**
189 189
 	 * Checks if the current machine is Windows.
Please login to merge, or discard this patch.
neon/core/db/Connection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	{
87 87
 		$currentVersion = neon()->getVersion();
88 88
 		$dbName = env('DB_NAME');
89
-		$filename = gmdate('ymd_His') . '_' . $dbName . '_' . $currentVersion . '.sql';
89
+		$filename = gmdate('ymd_His').'_'.$dbName.'_'.$currentVersion.'.sql';
90 90
 		return $this->getBackupDirectory()."/$filename";
91 91
 	}
92 92
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			'--dump-date',
110 110
 			'--no-autocommit',
111 111
 			'--routines',
112
-			'--default-character-set=' . $this->charset,
112
+			'--default-character-set='.$this->charset,
113 113
 			'--set-charset',
114 114
 			'--triggers',
115 115
 			'--host='.env('DB_HOST'),
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public function restore($path)
137 137
 	{
138
-		$process = new Process('mysql ' . env('DB_NAME') . ' < "' . $path . '"');
138
+		$process = new Process('mysql '.env('DB_NAME').' < "'.$path.'"');
139 139
 		$result = $process->run();
140 140
 		if (!$process->isSuccessful()) {
141 141
 			throw new ProcessFailedException($process);
Please login to merge, or discard this patch.
neon/core/db/TreeRecord.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param int $depth
78 78
 	 * @return int
79 79
 	 */
80
-	public function rebuildTree($parent, $left, $depth=0)
80
+	public function rebuildTree($parent, $left, $depth = 0)
81 81
 	{
82 82
 		// the right value of this node is the left value + 1
83 83
 		$right = $left + 1;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @throws \Exception|\Throwable
118 118
 	 * @return TreeRecord the child added
119 119
 	 */
120
-	public function addChild(TreeRecord $node, callable $callable=null) : TreeRecord
120
+	public function addChild(TreeRecord $node, callable $callable = null) : TreeRecord
121 121
 	{
122 122
 		$result = static::addAsLastChildOf($this, $node);
123 123
 		if ($callable) $callable($node);
Please login to merge, or discard this patch.
Braces   +18 added lines, -11 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function makeRoot()
62 62
 	{
63
-		if (static::find()->root()->exists())
64
-			throw new \Exception('You can only create one root node');
63
+		if (static::find()->root()->exists()) {
64
+					throw new \Exception('You can only create one root node');
65
+		}
65 66
 		$this->tree_left = 1;
66 67
 		$this->tree_right = 2;
67 68
 		$this->tree_depth = 0;
@@ -120,7 +121,9 @@  discard block
 block discarded – undo
120 121
 	public function addChild(TreeRecord $node, callable $callable=null) : TreeRecord
121 122
 	{
122 123
 		$result = static::addAsLastChildOf($this, $node);
123
-		if ($callable) $callable($node);
124
+		if ($callable) {
125
+			$callable($node);
126
+		}
124 127
 		return $node;
125 128
 	}
126 129
 
@@ -155,8 +158,9 @@  discard block
 block discarded – undo
155 158
 	 */
156 159
 	public function moveAsFirstChildOf(TreeRecord $parent)
157 160
 	{
158
-		if ($parent === $this || $this->isAncestorOf($parent))
159
-			throw new \Excepton("Cannot move node as first child of itself or into a descendant");
161
+		if ($parent === $this || $this->isAncestorOf($parent)) {
162
+					throw new \Excepton("Cannot move node as first child of itself or into a descendant");
163
+		}
160 164
 		$oldDepth = $this->tree_depth;
161 165
 		$this->tree_left = $parent->tree_depth + 1;
162 166
 		$this->tree_parent = $parent->getPrimaryKey();
@@ -230,12 +234,15 @@  discard block
 block discarded – undo
230 234
 	public static function validateAdd(TreeRecord $parent, TreeRecord $node)
231 235
 	{
232 236
 		// cannot insert as child of itself
233
-		if ($parent === $node)
234
-			throw new \Exception("Cannot insert node as last child of itself");
235
-		if ($parent->getIsNewRecord())
236
-			throw new \Exception('The parent node must exist.');
237
-		if ($node->tree_depth === 0 && $parent->isRoot())
238
-			throw new \Exception('Can not put a root node inside another root node');
237
+		if ($parent === $node) {
238
+					throw new \Exception("Cannot insert node as last child of itself");
239
+		}
240
+		if ($parent->getIsNewRecord()) {
241
+					throw new \Exception('The parent node must exist.');
242
+		}
243
+		if ($node->tree_depth === 0 && $parent->isRoot()) {
244
+					throw new \Exception('Can not put a root node inside another root node');
245
+		}
239 246
 	}
240 247
 
241 248
 	/**
Please login to merge, or discard this patch.
neon/core/db/TreeQuery.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			$columns = ['tree_root' => SORT_ASC] + $columns;
40 40
 		}
41 41
 
42
-		$this->andWhere(['tree_right' => new Expression($db->quoteColumnName('tree_left') . ' + 1')])
42
+		$this->andWhere(['tree_right' => new Expression($db->quoteColumnName('tree_left').' + 1')])
43 43
 			->addOrderBy($columns);
44 44
 
45 45
 		return $this;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @param null $parent
70 70
 	 * @param null $root
71 71
 	 */
72
-	public function getProperties(&$left=null, &$right=null, &$parent=null, &$root=null)
72
+	public function getProperties(&$left = null, &$right = null, &$parent = null, &$root = null)
73 73
 	{
74 74
 		$model = new $this->modelClass();
75 75
 		$model->getPropertes($left, $right, $parent, $root);
Please login to merge, or discard this patch.
neon/core/console/CacheController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 		$r = new Renderer();
46 46
 		$r->smarty->clearCompiledTemplate();
47 47
 		$r->smarty->clearAllCache();
48
-		foreach(neon()->view->renderers as $ext => $config) {
48
+		foreach (neon()->view->renderers as $ext => $config) {
49 49
 			$renderer = neon()->view->getRendererByExtension($ext);
50 50
 			if ($renderer instanceof ICanFlushTemplates) {
51 51
 				$renderer->flushTemplates();
Please login to merge, or discard this patch.
neon/daedalus/migrations/m170121_171048_dds_dds_changes_for_choices.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 //		$connection->createCommand($sql)->execute();
26 26
 
27 27
 		// 1. add the choices datatype
28
-$sql =<<<EOQ
28
+$sql = <<<EOQ
29 29
 SET foreign_key_checks = 0;
30 30
 REPLACE INTO `dds_data_type` (`data_type_ref`, `label`, `description`, `definition`, `storage_ref`, `deleted`)
31 31
 VALUES
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	{
47 47
 		$connection = neon()->db;
48 48
 
49
-$sql =<<<EOQ
49
+$sql = <<<EOQ
50 50
 SET foreign_key_checks = 0;
51 51
 DELETE FROM {{%dds_data_type}} WHERE `data_type_ref`='choice' LIMIT 1;
52 52
 SET foreign_key_checks = 1;
Please login to merge, or discard this patch.