@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use \neon\core\Env; |
17 | 17 | use \Carbon\Carbon; |
18 | 18 | |
19 | -if (! function_exists('dp')) { |
|
19 | +if (!function_exists('dp')) { |
|
20 | 20 | /** |
21 | 21 | * Debug function. Prints all passed in arguments to the screen. |
22 | 22 | * arguments containing objects or arrays are output using print_r |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | -if (! function_exists('backtrace_line_by_function')) { |
|
41 | +if (!function_exists('backtrace_line_by_function')) { |
|
42 | 42 | /** |
43 | 43 | * Tries to get the line and file that called the specified functions |
44 | 44 | * - will return the earliest match in execution order that it found. |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | { |
51 | 51 | $bt = debug_backtrace(); |
52 | 52 | $lineInfo = ''; |
53 | - foreach($bt as $trace) { |
|
53 | + foreach ($bt as $trace) { |
|
54 | 54 | if (isset($trace['function']) && $trace['function'] === $functionToShow) { |
55 | - $lineInfo = '==> [' . (isset($trace['file']) ? $trace['file'] : ' unknown file '). ':' . (isset($trace['line']) ? $trace['line'] : ' unknown line ' ) . ']'; |
|
55 | + $lineInfo = '==> ['.(isset($trace['file']) ? $trace['file'] : ' unknown file ').':'.(isset($trace['line']) ? $trace['line'] : ' unknown line ').']'; |
|
56 | 56 | break; |
57 | 57 | } |
58 | 58 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -if (! function_exists('dp_string')) { |
|
63 | +if (!function_exists('dp_string')) { |
|
64 | 64 | /** |
65 | 65 | * This generates a nice debug string and returns it. It will only |
66 | 66 | * print to the screen if you are in debug mode. Otherwise it prints |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | -if (! function_exists('dd')) { |
|
95 | +if (!function_exists('dd')) { |
|
96 | 96 | /** |
97 | 97 | * This is the same as the dp (debug print) function but exits after |
98 | 98 | * **Note:** If not in debug will print to log error and not exit |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | -if (! function_exists('debug_message')) { |
|
115 | +if (!function_exists('debug_message')) { |
|
116 | 116 | /** |
117 | 117 | * This is the same as the dp_string (debug print) function however it returns the string |
118 | 118 | * The main difference is that it will only output a message if neon is in debug mode |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | -if (! function_exists('neon')) { |
|
134 | +if (!function_exists('neon')) { |
|
135 | 135 | /** |
136 | 136 | * Shortcut method to ```\Neon::$app``` |
137 | 137 | * @param string $name |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | -if (! function_exists('setting')) { |
|
146 | +if (!function_exists('setting')) { |
|
147 | 147 | /** |
148 | 148 | * @param string $app the app responsible for this setting |
149 | 149 | * @param string $name the setting name |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * the setting has been set in the current session |
153 | 153 | * @return string |
154 | 154 | */ |
155 | - function setting($app, $name, $default=null, $refresh=false) |
|
155 | + function setting($app, $name, $default = null, $refresh = false) |
|
156 | 156 | { |
157 | 157 | return neon()->getSettingsManager()->get($app, $name, $default, $refresh); |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | -if (! function_exists('set_setting')) { |
|
161 | +if (!function_exists('set_setting')) { |
|
162 | 162 | /** |
163 | 163 | * @param string $app the app responsible for this setting |
164 | 164 | * @param string $name the setting name |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | -if (! function_exists('url')) { |
|
174 | +if (!function_exists('url')) { |
|
175 | 175 | /** |
176 | 176 | * Alias of \neon\core\helpers\Url::to |
177 | 177 | * @see \neon\core\helpers\Url::to() |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | -if (! function_exists('url_base')) { |
|
194 | +if (!function_exists('url_base')) { |
|
195 | 195 | /** |
196 | 196 | * Returns the base URL of the current request. |
197 | 197 | * @param boolean|string $scheme the URI scheme to use in the returned base URL: |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | -if (! function_exists('to_bytes')) { |
|
210 | +if (!function_exists('to_bytes')) { |
|
211 | 211 | /** |
212 | 212 | * Returns the number of bytes as integer from a strings like `128K` | `128M` | `2G` | `1T` | `1P` |
213 | 213 | * |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | -if (! function_exists('format_bytes')) { |
|
222 | +if (!function_exists('format_bytes')) { |
|
223 | 223 | /** |
224 | 224 | * Output a formatted size like '128M' from bytes. |
225 | 225 | * |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | -if (! function_exists('truthy')) { |
|
235 | +if (!function_exists('truthy')) { |
|
236 | 236 | /** |
237 | 237 | * Php if statement handles truthy and falsey string conversions by default e.g. evaluating a '0' string to false |
238 | 238 | * however a string of 'false' is evaluated as true. This function resolves that difference. This should be used |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | -if (! function_exists('env')) { |
|
251 | +if (!function_exists('env')) { |
|
252 | 252 | /** |
253 | 253 | * Gets the value of an environment variable. |
254 | 254 | * Interprets 'true', 'false', 'empty' and 'null' strings appropriately |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | -if (! function_exists('neon_secret')) { |
|
286 | +if (!function_exists('neon_secret')) { |
|
287 | 287 | /** |
288 | 288 | * Gets the value of NEON_SECRET creating it if missing |
289 | 289 | * @return string |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
296 | -if (! function_exists('neon_encryption_key')) { |
|
296 | +if (!function_exists('neon_encryption_key')) { |
|
297 | 297 | /** |
298 | 298 | * Gets the value of NEON_SECRET creating it if missing |
299 | 299 | * @return string |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | -if (! function_exists('value')) { |
|
306 | +if (!function_exists('value')) { |
|
307 | 307 | /** |
308 | 308 | * Return the value of the given value. |
309 | 309 | * If the $value is a Closure, it will first be executed then its result returned |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | -if (! function_exists('collect')) { |
|
320 | +if (!function_exists('collect')) { |
|
321 | 321 | /** |
322 | 322 | * Create a collection from the given value. |
323 | 323 | * |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | -if (! function_exists('now')) { |
|
333 | +if (!function_exists('now')) { |
|
334 | 334 | /** |
335 | 335 | * Create a new Carbon instance for the current time. |
336 | 336 | * |
@@ -343,27 +343,27 @@ discard block |
||
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | -if (! function_exists('profile_begin')) { |
|
346 | +if (!function_exists('profile_begin')) { |
|
347 | 347 | /** |
348 | 348 | * @param string $name |
349 | 349 | */ |
350 | - function profile_begin($name, $category='neon') |
|
350 | + function profile_begin($name, $category = 'neon') |
|
351 | 351 | { |
352 | 352 | \Neon::beginProfile($name, $category); |
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | -if (! function_exists('profile_end')) { |
|
356 | +if (!function_exists('profile_end')) { |
|
357 | 357 | /** |
358 | 358 | * @param string $name |
359 | 359 | */ |
360 | - function profile_end($name=null, $category='neon') |
|
360 | + function profile_end($name = null, $category = 'neon') |
|
361 | 361 | { |
362 | 362 | \Neon::endProfile($name, $category); |
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
366 | -if (! function_exists('encrypt')) { |
|
366 | +if (!function_exists('encrypt')) { |
|
367 | 367 | /** |
368 | 368 | * @param string $data |
369 | 369 | * @return string - encrypted data |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | -if (! function_exists('decrypt')) { |
|
377 | +if (!function_exists('decrypt')) { |
|
378 | 378 | /** |
379 | 379 | * @param string $data |
380 | 380 | * @return string - encrypted data |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if (! function_exists('get_alias')) { |
|
388 | +if (!function_exists('get_alias')) { |
|
389 | 389 | /** |
390 | 390 | * @param string $path |
391 | 391 | * @return string - resolved path |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | } |
398 | 398 | |
399 | -if (! function_exists('on_url')) { |
|
399 | +if (!function_exists('on_url')) { |
|
400 | 400 | /** |
401 | 401 | * This function is useful for checking if links should be active, |
402 | 402 | * |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
420 | -if (! function_exists('_t')) { |
|
420 | +if (!function_exists('_t')) { |
|
421 | 421 | /** |
422 | 422 | * Translates a message to the target language |
423 | 423 | * This function is a wrapper to the \Neon::t method |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | * @param string $category if provided will save the text to that category. Defaults to 'neon' |
438 | 438 | * @return string the translated message. |
439 | 439 | */ |
440 | - function _t($text, $params=[], $category='neon') |
|
440 | + function _t($text, $params = [], $category = 'neon') |
|
441 | 441 | { |
442 | 442 | return \Neon::t($category, $text, $params); |
443 | 443 | } |
444 | 444 | } |
445 | -if (! function_exists('faker')) { |
|
445 | +if (!function_exists('faker')) { |
|
446 | 446 | /** |
447 | 447 | * Generate a faker object |
448 | 448 | * @return \Faker\Generator; |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | return $faker; |
456 | 456 | } |
457 | 457 | } |
458 | -if (! function_exists('user_is')) { |
|
458 | +if (!function_exists('user_is')) { |
|
459 | 459 | /** |
460 | 460 | * @return boolean whether the user is/has a particular role |
461 | 461 | */ |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | -if (! function_exists('user_can')) { |
|
468 | +if (!function_exists('user_can')) { |
|
469 | 469 | /** |
470 | 470 | * Whether the user can perform a permission |
471 | 471 | * @param $permission |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | -if (! function_exists('is_route')) { |
|
480 | +if (!function_exists('is_route')) { |
|
481 | 481 | /** |
482 | 482 | * Test whether the current application is on a particular route |
483 | 483 | * This is url rewrite safe! However you must reference the module/controller/action and not the url directly |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * @param string $pattern |
487 | 487 | * @param array $params |
488 | 488 | */ |
489 | - function is_route($pattern, $params=[]) |
|
489 | + function is_route($pattern, $params = []) |
|
490 | 490 | { |
491 | 491 | return neon()->request->isRoute($pattern, $params); |
492 | 492 | } |
@@ -31,10 +31,11 @@ discard block |
||
31 | 31 | { |
32 | 32 | echo dp_string(...$dump); |
33 | 33 | $backtrace = backtrace_line_by_function('dp'); |
34 | - if (neon()->debug) |
|
35 | - echo $backtrace; |
|
36 | - else |
|
37 | - \Neon::error($backtrace); |
|
34 | + if (neon()->debug) { |
|
35 | + echo $backtrace; |
|
36 | + } else { |
|
37 | + \Neon::error($backtrace); |
|
38 | + } |
|
38 | 39 | } |
39 | 40 | } |
40 | 41 | |
@@ -85,8 +86,9 @@ discard block |
||
85 | 86 | $str .= "<pre>$debug</pre>"; |
86 | 87 | } |
87 | 88 | |
88 | - if (neon()->debug) |
|
89 | - return $str; |
|
89 | + if (neon()->debug) { |
|
90 | + return $str; |
|
91 | + } |
|
90 | 92 | \Neon::error($str); |
91 | 93 | return ''; |
92 | 94 | } |
@@ -124,8 +126,9 @@ discard block |
||
124 | 126 | function debug_message(...$dump) |
125 | 127 | { |
126 | 128 | // security feature to ensure debug is not displayed unless in debug mode |
127 | - if (!neon()->debug) |
|
128 | - return ''; |
|
129 | + if (!neon()->debug) { |
|
130 | + return ''; |
|
131 | + } |
|
129 | 132 | return dp_string(...$dump); |
130 | 133 | } |
131 | 134 | } |
@@ -242,8 +245,9 @@ discard block |
||
242 | 245 | */ |
243 | 246 | function truthy($value) |
244 | 247 | { |
245 | - if ($value && strtolower($value) !== "false") |
|
246 | - return true; |
|
248 | + if ($value && strtolower($value) !== "false") { |
|
249 | + return true; |
|
250 | + } |
|
247 | 251 | return false; |
248 | 252 | } |
249 | 253 | } |
@@ -450,8 +454,9 @@ discard block |
||
450 | 454 | function faker() |
451 | 455 | { |
452 | 456 | static $faker = null; |
453 | - if ($faker === null) |
|
454 | - $faker = \Faker\Factory::create(); |
|
457 | + if ($faker === null) { |
|
458 | + $faker = \Faker\Factory::create(); |
|
459 | + } |
|
455 | 460 | return $faker; |
456 | 461 | } |
457 | 462 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | parent::__construct($config, $options); |
33 | 33 | // Set default path for ChromeDriver |
34 | 34 | if (!isset($this->config['path'])) { |
35 | - $this->config['path'] = __DIR__ . '/bin/72/chromedriver-' . $this->getDriverSuffix(); |
|
35 | + $this->config['path'] = __DIR__.'/bin/72/chromedriver-'.$this->getDriverSuffix(); |
|
36 | 36 | } |
37 | 37 | // Set default WebDriver port |
38 | 38 | if (!isset($this->config['port'])) { |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | } |
79 | 79 | $descriptorSpec = array( |
80 | 80 | array('pipe', 'r'), |
81 | - array('file', $this->getLogDir() . 'ChromeDriver.output.txt', 'w'), |
|
82 | - array('file', $this->getLogDir() . 'ChromeDriver.errors.txt', 'a') |
|
81 | + array('file', $this->getLogDir().'ChromeDriver.output.txt', 'w'), |
|
82 | + array('file', $this->getLogDir().'ChromeDriver.errors.txt', 'a') |
|
83 | 83 | ); |
84 | 84 | $this->resource = proc_open($command, $descriptorSpec, $this->pipes, null, null, array('bypass_shell' => true)); |
85 | 85 | if (!is_resource($this->resource) || !proc_get_status($this->resource)['running']) { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // Make sure the value is true/false and not 1/0 |
168 | 168 | $configValue = ($configValue) ? 'true' : 'false'; |
169 | 169 | } |
170 | - $params[] = $mapping[$configKey] . '=' . $configValue; |
|
170 | + $params[] = $mapping[$configKey].'='.$configValue; |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | return implode(' ', $params); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // Prefix command with exec on non Windows systems to ensure that we receive the correct pid. |
181 | 181 | // See http://php.net/manual/en/function.proc-get-status.php#93382 |
182 | 182 | $commandPrefix = $this->isWindows() ? '' : 'exec '; |
183 | - return $commandPrefix . escapeshellarg(realpath($this->config['path'])) . ' ' . $this->getCommandParameters() . ' --url-base=/wd/hub'; |
|
183 | + return $commandPrefix.escapeshellarg(realpath($this->config['path'])).' '.$this->getCommandParameters().' --url-base=/wd/hub'; |
|
184 | 184 | } |
185 | 185 | /** |
186 | 186 | * Checks if the current machine is Windows. |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | * @param integer $size size of the string required |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - protected static function randomString($size=20) |
|
36 | + protected static function randomString($size = 20) |
|
37 | 37 | { |
38 | 38 | $source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
39 | 39 | $sourceLen = strlen($source); |
40 | 40 | $string = ''; |
41 | - for ($i=0; $i<$size; $i++) |
|
42 | - $string .= substr($source, rand(0, $sourceLen-1), 1); |
|
41 | + for ($i = 0; $i < $size; $i++) |
|
42 | + $string .= substr($source, rand(0, $sourceLen - 1), 1); |
|
43 | 43 | return $string; |
44 | 44 | } |
45 | 45 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @param int $time the time if not now |
85 | 85 | * @return datetime in form yyyy-mm-dd hh-mm-ss |
86 | 86 | */ |
87 | - protected function datetime($time=null, $format='Y-m-d H:i:s') |
|
87 | + protected function datetime($time = null, $format = 'Y-m-d H:i:s') |
|
88 | 88 | { |
89 | - return date($format, ($time===null ? time() : $time)); |
|
89 | + return date($format, ($time === null ? time() : $time)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -38,8 +38,9 @@ |
||
38 | 38 | $source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
39 | 39 | $sourceLen = strlen($source); |
40 | 40 | $string = ''; |
41 | - for ($i=0; $i<$size; $i++) |
|
42 | - $string .= substr($source, rand(0, $sourceLen-1), 1); |
|
41 | + for ($i=0; $i<$size; $i++) { |
|
42 | + $string .= substr($source, rand(0, $sourceLen-1), 1); |
|
43 | + } |
|
43 | 44 | return $string; |
44 | 45 | } |
45 | 46 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('neon_test_database_create')) { |
|
3 | +if (!function_exists('neon_test_database_create')) { |
|
4 | 4 | /** |
5 | 5 | * Creates the test database and user |
6 | 6 | * Note this does not run the neon installation and create the |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function neon_test_database_create() |
11 | 11 | { |
12 | - $installDb = env('INSTALL_TEST_DB', true); |
|
12 | + $installDb = env('INSTALL_TEST_DB', true); |
|
13 | 13 | if ($installDb) { |
14 | 14 | $db = env('DB_NAME'); |
15 | 15 | $host = env('DB_HOST', 'localhost'); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if (! function_exists('neon_test_db_cmd')) { |
|
53 | +if (!function_exists('neon_test_db_cmd')) { |
|
54 | 54 | function neon_test_db_cmd($cmd) |
55 | 55 | { |
56 | 56 | // A security risk here? Mind you if you can run PHP your system is compromised anyway. |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | # use the following line to see any warnings and errors |
63 | 63 | #exec($c); |
64 | 64 | # or use this one to suppress them (inc the one about the password) |
65 | - exec($c . " 2>/dev/null"); |
|
65 | + exec($c." 2>/dev/null"); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if (! function_exists('neon_test_server_restart')) { |
|
69 | +if (!function_exists('neon_test_server_restart')) { |
|
70 | 70 | /** |
71 | 71 | * Restart a test server |
72 | 72 | * @param $name |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param int $port |
75 | 75 | * @throws Exception |
76 | 76 | */ |
77 | - function neon_test_server_restart($name, $docRoot=DIR_TEST.'/_root/public', $port=6969) |
|
77 | + function neon_test_server_restart($name, $docRoot = DIR_TEST.'/_root/public', $port = 6969) |
|
78 | 78 | { |
79 | 79 | echo "\nRestarting test server...\n"; |
80 | 80 | neon_test_server_stop($name); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -if (! function_exists('neon_test_server_start')) { |
|
85 | +if (!function_exists('neon_test_server_start')) { |
|
86 | 86 | /** |
87 | 87 | * Spin up the test server to run the acceptance tests against |
88 | 88 | * @param string $name |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return \Symfony\Component\Process\Process |
92 | 92 | * @throws Exception |
93 | 93 | */ |
94 | - function neon_test_server_start($name, $docRoot=DIR_TEST.'/_root/public', $port=6969, $silent=false) |
|
94 | + function neon_test_server_start($name, $docRoot = DIR_TEST.'/_root/public', $port = 6969, $silent = false) |
|
95 | 95 | { |
96 | 96 | if (preg_match("/[^a-z0-9_]/", $name) !== 0) { |
97 | 97 | throw new \Exception('The name must contain only [a-z0-9_] characters'); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * Tests are run against this server |
102 | 102 | */ |
103 | 103 | $address = "localhost:$port"; |
104 | - $command = PHP_BINARY . " -S {$address} -t {$docRoot}"; |
|
104 | + $command = PHP_BINARY." -S {$address} -t {$docRoot}"; |
|
105 | 105 | if (!$silent) { |
106 | 106 | echo "\n|======================================================"; |
107 | 107 | echo "\n| Creating Test Server"; |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | } |
119 | 119 | $process = \neon\core\test\ProcessForker::run($name, $command); |
120 | 120 | try { |
121 | - retry(10, function () use ($address) { |
|
121 | + retry(10, function() use ($address) { |
|
122 | 122 | $client = new GuzzleHttp\Client(); |
123 | 123 | $res = $client->request('GET', $address); |
124 | - echo ' - Server running with code: ' . $res->getStatusCode() . "\n"; |
|
124 | + echo ' - Server running with code: '.$res->getStatusCode()."\n"; |
|
125 | 125 | }, 1000); |
126 | - } catch(GuzzleHttp\Exception\ConnectException $e) { |
|
126 | + } catch (GuzzleHttp\Exception\ConnectException $e) { |
|
127 | 127 | throw new \Exception('Unable to connect to the local test server'); |
128 | 128 | } |
129 | 129 | return $process; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | -if (! function_exists('retry')) { |
|
133 | +if (!function_exists('retry')) { |
|
134 | 134 | /** |
135 | 135 | * Retry an operation a given number of times. |
136 | 136 | * |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | try { |
149 | 149 | return $callback(); |
150 | 150 | } catch (\Exception $e) { |
151 | - if (! $times) { |
|
151 | + if (!$times) { |
|
152 | 152 | throw $e; |
153 | 153 | } |
154 | 154 | $times--; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | -if (! function_exists('neon_test_server_stop')) { |
|
163 | +if (!function_exists('neon_test_server_stop')) { |
|
164 | 164 | /** |
165 | 165 | * Spin up the test server to run the acceptance tests against |
166 | 166 | * @param string $name |
@@ -24,5 +24,5 @@ |
||
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(); |
29 | 29 | \ No newline at end of file |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $class = \get_class($this); |
66 | 66 | if (($pos = strrpos($class, '\\')) !== false) { |
67 | 67 | $controllers = neon()->isConsoleApp() ? 'console' : 'controllers'; |
68 | - $this->controllerNamespace = substr($class, 0, $pos) . '\\' . $controllers; |
|
68 | + $this->controllerNamespace = substr($class, 0, $pos).'\\'.$controllers; |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | parent::init(); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param boolean $refresh - default false |
146 | 146 | * @return type |
147 | 147 | */ |
148 | - public function getSetting($name, $default=null, $refresh=false) |
|
148 | + public function getSetting($name, $default = null, $refresh = false) |
|
149 | 149 | { |
150 | 150 | $settingManager = neon()->settingsManager; |
151 | 151 | return $settingManager->get($this->id, $name, $default, $refresh); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | /** |
186 | 186 | * @inheritdoc |
187 | 187 | */ |
188 | - public function uninstall(){} |
|
188 | + public function uninstall() {} |
|
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Get the alias key to this module (App) |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function getClassAlias() |
197 | 197 | { |
198 | - return '@' . rtrim(str_replace(['\\', 'App'], ['/', ''], get_called_class()), "/"); |
|
198 | + return '@'.rtrim(str_replace(['\\', 'App'], ['/', ''], get_called_class()), "/"); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function getAssetsPath() |
234 | 234 | { |
235 | - return $this->getPath() . '/assets'; |
|
235 | + return $this->getPath().'/assets'; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function getDocsPath() |
242 | 242 | { |
243 | - return $this->getPath() . '/docs'; |
|
243 | + return $this->getPath().'/docs'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @see $this->getAssetsPath() |
251 | 251 | * @return string |
252 | 252 | */ |
253 | - public function publishAssets(&$url='', &$path='') |
|
253 | + public function publishAssets(&$url = '', &$path = '') |
|
254 | 254 | { |
255 | 255 | $assets = neon()->assetManager->publish($this->getAssetsPath()); |
256 | 256 | list($path, $url) = $assets; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | public function getDataMapProviders() |
267 | 267 | { |
268 | 268 | $availableMaps = []; |
269 | - foreach(neon()->getAllApps() as $name => $config) { |
|
269 | + foreach (neon()->getAllApps() as $name => $config) { |
|
270 | 270 | $app = neon($name); |
271 | 271 | if ($app instanceof IDataMapProvider) { |
272 | 272 | $maps = $app->getDataMapTypes(); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | if ($provider === null) { |
293 | 293 | throw new \Exception("The map provider '$name' specified can not be found."); |
294 | 294 | } |
295 | - if (! $provider instanceof IDataMapProvider) { |
|
295 | + if (!$provider instanceof IDataMapProvider) { |
|
296 | 296 | throw new \Exception("The Provider '$name' must implement the 'neon\\core\\interfaces\\IDataMapProvider' interface."); |
297 | 297 | } |
298 | 298 | return $provider; |
@@ -106,8 +106,9 @@ |
||
106 | 106 | public function getMenu() |
107 | 107 | { |
108 | 108 | // if the menu has been overridden |
109 | - if ($this->_menu !== null) |
|
110 | - return $this->_menu; |
|
109 | + if ($this->_menu !== null) { |
|
110 | + return $this->_menu; |
|
111 | + } |
|
111 | 112 | return $this->getDefaultMenu(); |
112 | 113 | } |
113 | 114 |
@@ -105,7 +105,7 @@ |
||
105 | 105 | * ], |
106 | 106 | * ] |
107 | 107 | */ |
108 | - public function addFile($id, $path='/'); |
|
108 | + public function addFile($id, $path = '/'); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Get the information about the root node. |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param boolean $withDeleted |
52 | 52 | * @return Media|null|\yii\db\ActiveRecord |
53 | 53 | */ |
54 | - public static function findDirectoryByPath($path, $withDeleted=false) |
|
54 | + public static function findDirectoryByPath($path, $withDeleted = false) |
|
55 | 55 | { |
56 | 56 | $path = static::getPath($path); |
57 | 57 | return static::query($withDeleted) |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param string $parentPath - the parent path used to find the parent node |
85 | 85 | * @return Media|null|\yii\db\ActiveRecord |
86 | 86 | */ |
87 | - public static function findParentByPath($path, &$parentPath='') |
|
87 | + public static function findParentByPath($path, &$parentPath = '') |
|
88 | 88 | { |
89 | 89 | $info = pathinfo($path); |
90 | 90 | $parentPath = $info['dirname']; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $node = new static(['path' => $path, 'type' => 'dir', 'parent_id' => $parent->id]); |
110 | 110 | $node->save(); |
111 | 111 | if ($node->hasErrors()) { |
112 | - throw new \Exception('Model validation errors: ' . print_r($node->getErrors(), true)); |
|
112 | + throw new \Exception('Model validation errors: '.print_r($node->getErrors(), true)); |
|
113 | 113 | } |
114 | 114 | return $node->toArray(); |
115 | 115 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | // update directories - and their child paths |
227 | 227 | if ($this->isDir()) { |
228 | 228 | $originalPath = $this->path; |
229 | - $newPath = $intoNode->path . $this->path; |
|
229 | + $newPath = $intoNode->path.$this->path; |
|
230 | 230 | $this->path = $newPath; |
231 | 231 | $success = $this->save(); |
232 | 232 | if ($success) { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public static function replacePaths($findPath, $replacePath, $wherePath) |
251 | 251 | { |
252 | 252 | $tableName = static::tableName(); |
253 | - $sql = 'UPDATE ' . $tableName . ' SET path = REPLACE(path, :findPath, :replacePath) WHERE path LIKE :wherePath'; |
|
253 | + $sql = 'UPDATE '.$tableName.' SET path = REPLACE(path, :findPath, :replacePath) WHERE path LIKE :wherePath'; |
|
254 | 254 | return Media::getDb()->createCommand($sql) |
255 | 255 | ->bindValues([ |
256 | 256 | ':findPath' => $findPath, |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return \neon\core\db\ActiveQuery |
267 | 267 | */ |
268 | - public function getChildrenQuery($withDeleted=false) |
|
268 | + public function getChildrenQuery($withDeleted = false) |
|
269 | 269 | { |
270 | 270 | return static::query($withDeleted)->alias('media') |
271 | 271 | ->where(['parent_id' => $this->id]); |
@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | public static function createDirectory($path) |
105 | 105 | { |
106 | 106 | $parent = static::findParentByPath($path, $parentPath); |
107 | - if ($parent === null) |
|
108 | - throw new \Exception("Directory does not exist with path '$parentPath'"); |
|
107 | + if ($parent === null) { |
|
108 | + throw new \Exception("Directory does not exist with path '$parentPath'"); |
|
109 | + } |
|
109 | 110 | $node = new static(['path' => $path, 'type' => 'dir', 'parent_id' => $parent->id]); |
110 | 111 | $node->save(); |
111 | 112 | if ($node->hasErrors()) { |
@@ -155,11 +156,13 @@ discard block |
||
155 | 156 | { |
156 | 157 | $path = $this->$attribute; |
157 | 158 | // must be absolute and start with / |
158 | - if ($path[0] !== '/') |
|
159 | - $this->addError('path', "Must be absolute path and start with a '/' provided: '$path'"); |
|
159 | + if ($path[0] !== '/') { |
|
160 | + $this->addError('path', "Must be absolute path and start with a '/' provided: '$path'"); |
|
161 | + } |
|
160 | 162 | // prevent folders with no names being created |
161 | - if (strpos($path, '//') !== false) |
|
162 | - $this->addError('path', "Path can not contain a double forward slash"); |
|
163 | + if (strpos($path, '//') !== false) { |
|
164 | + $this->addError('path', "Path can not contain a double forward slash"); |
|
165 | + } |
|
163 | 166 | } |
164 | 167 | |
165 | 168 | /** |
@@ -303,8 +306,9 @@ discard block |
||
303 | 306 | */ |
304 | 307 | public static function getPath($path) |
305 | 308 | { |
306 | - if ($path === '/' && neon()->firefly->mediaManager->getRootPath() !== '/') |
|
307 | - $path = neon()->firefly->mediaManager->getRootPath(); |
|
309 | + if ($path === '/' && neon()->firefly->mediaManager->getRootPath() !== '/') { |
|
310 | + $path = neon()->firefly->mediaManager->getRootPath(); |
|
311 | + } |
|
308 | 312 | return $path; |
309 | 313 | } |
310 | 314 | } |
311 | 315 | \ No newline at end of file |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @throws \InvalidArgumentException if the $contents is an object and it does not have a getRealPath function |
166 | 166 | * @return bool True on success, false on failure. |
167 | 167 | */ |
168 | - public function put($path, $contents, $visibility=null); |
|
168 | + public function put($path, $contents, $visibility = null); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Get meta data for this file |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param string $algorithm - Any algorithm supported by hash() |
236 | 236 | * @return bool|string return false on failure the hash output string on success |
237 | 237 | */ |
238 | - public function hash($path, $algorithm='md5'); |
|
238 | + public function hash($path, $algorithm = 'md5'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Get the underlying Flysystem driver |