@@ -20,18 +20,18 @@ |
||
20 | 20 | */ |
21 | 21 | class ServeController extends YiiServeController |
22 | 22 | { |
23 | - /** |
|
24 | - * @var int port to serve on. |
|
25 | - */ |
|
26 | - public $port = 8080; |
|
27 | - /** |
|
28 | - * @var string path or path alias to directory to serve |
|
29 | - */ |
|
30 | - public $docroot = '@root/public'; |
|
31 | - /** |
|
32 | - * @var string path to router script. |
|
33 | - * See https://secure.php.net/manual/en/features.commandline.webserver.php |
|
34 | - */ |
|
35 | - public $router; |
|
23 | + /** |
|
24 | + * @var int port to serve on. |
|
25 | + */ |
|
26 | + public $port = 8080; |
|
27 | + /** |
|
28 | + * @var string path or path alias to directory to serve |
|
29 | + */ |
|
30 | + public $docroot = '@root/public'; |
|
31 | + /** |
|
32 | + * @var string path to router script. |
|
33 | + * See https://secure.php.net/manual/en/features.commandline.webserver.php |
|
34 | + */ |
|
35 | + public $router; |
|
36 | 36 | |
37 | 37 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | { |
28 | 28 | $branch = exec('git rev-parse --abbrev-ref HEAD'); |
29 | 29 | // find readme file |
30 | - $readme = $readmeFile; |
|
30 | + $readme = $readmeFile; |
|
31 | 31 | // read the entire readme |
32 | 32 | $str = file_get_contents($readme); |
33 | 33 | // replace the branch tags |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | // Check the version number conforms to semver format - 2.0.1 or 3.0.0[-beta][+build] |
62 | 62 | if (!preg_match('/^v[0-9]+\.[0-9]+\.[0-9]+([-+].*)?$/', $version, $match)) { |
63 | - $this->stderr("!! The version number is not a valid version it must be in the format 'v#.#.#' or 'v#.#.#[-description][+build]'.\n", Console::FG_RED); |
|
63 | + $this->stderr("!! The version number is not a valid version it must be in the format 'v#.#.#' or 'v#.#.#[-description][+build]'.\n", Console::FG_RED); |
|
64 | 64 | return ExitCode::UNSPECIFIED_ERROR; |
65 | 65 | } |
66 | 66 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | // Check to see if the javascript has been built since changing |
77 | 77 | if (!$this->confirm("=> Have you run the neon build process?\n")) { |
78 | - $this->stdout("-> Please run the build process before continuing! =>./neo core/build/neon\n", Console::FG_CYAN); |
|
78 | + $this->stdout("-> Please run the build process before continuing! =>./neo core/build/neon\n", Console::FG_CYAN); |
|
79 | 79 | return ExitCode::UNSPECIFIED_ERROR; |
80 | 80 | } |
81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // need to make sure that the version to update to is specified and checked in, in the composer.json file |
84 | 84 | // this ensures the tag will have the correct version listed |
85 | 85 | if (!$this->confirm("=> Are your tests passing?\n")) { |
86 | - $this->stdout("-> Please run all of the tests! =>./codecept run\n", Console::FG_CYAN); |
|
86 | + $this->stdout("-> Please run all of the tests! =>./codecept run\n", Console::FG_CYAN); |
|
87 | 87 | return ExitCode::UNSPECIFIED_ERROR; |
88 | 88 | } |
89 | 89 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | $process->wait(); |
101 | 101 | $gitVersions = explode("\n", $process->getOutput()); |
102 | 102 | $versions = []; |
103 | - foreach($gitVersions as $v) { |
|
104 | - $v = substr($v, strrpos($v, "/")+1); |
|
103 | + foreach ($gitVersions as $v) { |
|
104 | + $v = substr($v, strrpos($v, "/") + 1); |
|
105 | 105 | if ($v == '') continue; |
106 | - $versions[] = $v ; |
|
106 | + $versions[] = $v; |
|
107 | 107 | } |
108 | 108 | dp($versions); |
109 | 109 | if (in_array($version, $versions)) { |
@@ -102,7 +102,9 @@ |
||
102 | 102 | $versions = []; |
103 | 103 | foreach($gitVersions as $v) { |
104 | 104 | $v = substr($v, strrpos($v, "/")+1); |
105 | - if ($v == '') continue; |
|
105 | + if ($v == '') { |
|
106 | + continue; |
|
107 | + } |
|
106 | 108 | $versions[] = $v ; |
107 | 109 | } |
108 | 110 | dp($versions); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | if (isset($commands['core/help'])) { |
35 | 35 | unset($commands['core/help']); |
36 | 36 | } |
37 | - $this->stdout("\nThis is Neon version " . \Neon::getVersion() . ".\n"); |
|
37 | + $this->stdout("\nThis is Neon version ".\Neon::getVersion().".\n"); |
|
38 | 38 | if (!empty($commands)) { |
39 | 39 | $this->stdout("\nThe following commands are available:\n\n", Console::BOLD); |
40 | 40 | $len = 0; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (!empty($actions)) { |
48 | 48 | $prefix = $controller->getUniqueId(); |
49 | 49 | foreach ($actions as $action) { |
50 | - $string = $prefix . '/' . $action; |
|
50 | + $string = $prefix.'/'.$action; |
|
51 | 51 | if ($action === $controller->defaultAction) { |
52 | 52 | $string .= ' (default)'; |
53 | 53 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } elseif (($l = strlen($command)) > $len) { |
60 | 60 | $len = $l; |
61 | 61 | } |
62 | - $this->stdout('- ' . $this->ansiFormat($command, Console::FG_YELLOW)); |
|
62 | + $this->stdout('- '.$this->ansiFormat($command, Console::FG_YELLOW)); |
|
63 | 63 | $this->stdout(str_repeat(' ', $len + 4 - strlen($command))); |
64 | 64 | $this->stdout(Console::wrapText($description, $len + 4 + 2), Console::BOLD); |
65 | 65 | $this->stdout("\n"); |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | if (!empty($actions)) { |
72 | 72 | $prefix = $controller->getUniqueId(); |
73 | 73 | foreach ($actions as $action) { |
74 | - $string = ' ' . $prefix . '/' . $action; |
|
75 | - $this->stdout(' ' . $this->ansiFormat($string, Console::FG_GREEN)); |
|
74 | + $string = ' '.$prefix.'/'.$action; |
|
75 | + $this->stdout(' '.$this->ansiFormat($string, Console::FG_GREEN)); |
|
76 | 76 | if ($action === $controller->defaultAction) { |
77 | 77 | $string .= ' (default)'; |
78 | 78 | $this->stdout(' (default)', Console::FG_YELLOW); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | } |
91 | 91 | $scriptName = $this->getScriptName(); |
92 | 92 | $this->stdout("\nTo see the help of each command, enter:\n", Console::BOLD); |
93 | - $this->stdout("\n $scriptName " . $this->ansiFormat('help', Console::FG_YELLOW) . ' ' |
|
94 | - . $this->ansiFormat('<command-name>', Console::FG_CYAN) . "\n\n"); |
|
93 | + $this->stdout("\n $scriptName ".$this->ansiFormat('help', Console::FG_YELLOW).' ' |
|
94 | + . $this->ansiFormat('<command-name>', Console::FG_CYAN)."\n\n"); |
|
95 | 95 | } else { |
96 | 96 | $this->stdout("\nNo commands are found.\n\n", Console::BOLD); |
97 | 97 | } |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function getDefaultHelpHeader() |
106 | 106 | { |
107 | - return "\nThis is Yii version " . \Yii::getVersion() . ".\n" |
|
108 | - . "\nThis is Neon version " . \Neon::getVersion() . ".\n"; |
|
107 | + return "\nThis is Yii version ".\Yii::getVersion().".\n" |
|
108 | + . "\nThis is Neon version ".\Neon::getVersion().".\n"; |
|
109 | 109 | |
110 | 110 | } |
111 | 111 | |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function getModuleCommands($module) |
116 | 116 | { |
117 | - $prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/'; |
|
117 | + $prefix = $module instanceof Application ? '' : $module->getUniqueId().'/'; |
|
118 | 118 | |
119 | 119 | $commands = []; |
120 | 120 | |
121 | 121 | if ($module->id != 'core') { |
122 | 122 | foreach (array_keys($module->controllerMap) as $id) { |
123 | - $commands[] = $prefix . $id; |
|
123 | + $commands[] = $prefix.$id; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | $files = scandir($controllerPath); |
131 | 131 | foreach ($files as $file) { |
132 | 132 | if (!empty($file) && substr_compare($file, 'Controller.php', -14, 14) === 0) { |
133 | - $controllerClass = $module->controllerNamespace . '\\' . substr(basename($file), 0, -4); |
|
133 | + $controllerClass = $module->controllerNamespace.'\\'.substr(basename($file), 0, -4); |
|
134 | 134 | if ($this->validateControllerClass($controllerClass)) { |
135 | 135 | // if ($prefix == 'core' || $prefix == 'core/') |
136 | 136 | // continue; |
137 | - $commands[] = $prefix . Inflector::camel2id(substr(basename($file), 0, -14)); |
|
137 | + $commands[] = $prefix.Inflector::camel2id(substr(basename($file), 0, -14)); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | */ |
24 | 24 | class MigrateController extends \yii\console\controllers\MigrateController |
25 | 25 | { |
26 | - /** |
|
27 | - * @inheritdoc |
|
28 | - */ |
|
29 | - public $templateFile = '@neon/core/views/migration.php'; |
|
26 | + /** |
|
27 | + * @inheritdoc |
|
28 | + */ |
|
29 | + public $templateFile = '@neon/core/views/migration.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @var string Define the app that is responsible for this migration. |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | if ($app === null) { |
77 | 77 | throw new Exception('No app exists with id "'.$this->app.'"'); |
78 | 78 | } |
79 | - $this->getMigrator()->migrationPath = $app->getClassAlias() . '/migrations'; |
|
79 | + $this->getMigrator()->migrationPath = $app->getClassAlias().'/migrations'; |
|
80 | 80 | $this->migrationPath = $this->getMigrator()->migrationPath; |
81 | 81 | } |
82 | 82 | return true; |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | if (!preg_match('/^\w+$/', $name)) { |
121 | 121 | throw new Exception("The migration name should contain letters, digits and/or underscore characters only."); |
122 | 122 | } |
123 | - $name = 'm' . gmdate('Ymd_His') . '_' . $app . '_' . $name; |
|
124 | - $file = neon()->getAlias($this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php'); |
|
123 | + $name = 'm'.gmdate('Ymd_His').'_'.$app.'_'.$name; |
|
124 | + $file = neon()->getAlias($this->migrationPath.DIRECTORY_SEPARATOR.$name.'.php'); |
|
125 | 125 | if ($this->confirm("Create new migration '$file'?")) { |
126 | 126 | $content = Yii::$app->getView()->renderFile(Neon::getAlias($this->templateFile), ['className' => $name]); |
127 | 127 | FileHelper::createDirectory(dirname($file)); |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | $success = $this->migrator->migrateUp($class); |
152 | 152 | $time = microtime(true) - $start; |
153 | 153 | if ($success) { |
154 | - $this->stdout("*** applied $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_GREEN); |
|
154 | + $this->stdout("*** applied $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_GREEN); |
|
155 | 155 | return true; |
156 | 156 | } else { |
157 | - $this->stdout("*** failed to apply $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_RED); |
|
157 | + $this->stdout("*** failed to apply $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_RED); |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | } |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $success = $this->migrator->migrateDown($class); |
172 | 172 | if ($success) { |
173 | 173 | $time = microtime(true) - $start; |
174 | - $this->stdout("*** reverted $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_GREEN); |
|
174 | + $this->stdout("*** reverted $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_GREEN); |
|
175 | 175 | return true; |
176 | 176 | } else { |
177 | 177 | $time = microtime(true) - $start; |
178 | - $this->stdout("*** failed to revert $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_RED); |
|
178 | + $this->stdout("*** failed to revert $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_RED); |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | } |
@@ -54,8 +54,9 @@ |
||
54 | 54 | */ |
55 | 55 | public function getMigrator() |
56 | 56 | { |
57 | - if ($this->_migrator === null) |
|
58 | - $this->_migrator = new Migrator; |
|
57 | + if ($this->_migrator === null) { |
|
58 | + $this->_migrator = new Migrator; |
|
59 | + } |
|
59 | 60 | return $this->_migrator; |
60 | 61 | } |
61 | 62 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @var bool if true stop execution after first failed test |
21 | 21 | */ |
22 | - public $failFast=false; |
|
22 | + public $failFast = false; |
|
23 | 23 | /** |
24 | 24 | * @var string Comma separated list of tests to run for e.g. unit,acceptance,api |
25 | 25 | */ |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * run a codecept test |
41 | 41 | * @param string $tests |
42 | 42 | */ |
43 | - public function actionIndex($tests='unit,api,acceptance') |
|
43 | + public function actionIndex($tests = 'unit,api,acceptance') |
|
44 | 44 | { |
45 | 45 | $options = $this->failFast ? ' --fail-fast' : ''; |
46 | 46 | |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | |
50 | 50 | $options .= " $tests"; |
51 | 51 | |
52 | - $command = './codecept run ' . $options; |
|
52 | + $command = './codecept run '.$options; |
|
53 | 53 | $process = new Process($command, null, null, null, null); |
54 | 54 | |
55 | 55 | $this->stdout("-> Running command: $command\n", Console::FG_CYAN); |
56 | 56 | // enable real time output |
57 | - $process->run(function ($type, $buffer) { |
|
57 | + $process->run(function($type, $buffer) { |
|
58 | 58 | echo $buffer; |
59 | 59 | }); |
60 | 60 | } |
@@ -44,8 +44,9 @@ |
||
44 | 44 | { |
45 | 45 | $options = $this->failFast ? ' --fail-fast' : ''; |
46 | 46 | |
47 | - if ($this->run) |
|
48 | - $tests = $this->run; |
|
47 | + if ($this->run) { |
|
48 | + $tests = $this->run; |
|
49 | + } |
|
49 | 50 | |
50 | 51 | $options .= " $tests"; |
51 | 52 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $root = neon()->getAlias("@root").DIRECTORY_SEPARATOR; |
83 | 83 | |
84 | 84 | // 1. Check that Babel is installed and if not install it |
85 | - if (($result = $this->checkBabel())!=0) |
|
85 | + if (($result = $this->checkBabel()) != 0) |
|
86 | 86 | return $result; |
87 | 87 | |
88 | 88 | // 2. Create the babel config file |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return $result; |
91 | 91 | |
92 | 92 | // 3. Run babel over the project |
93 | - $sourceDirectory = $root.$path;; |
|
93 | + $sourceDirectory = $root.$path; ; |
|
94 | 94 | $outDirectory = $root.'babelOut'; |
95 | 95 | $command = "babel --root-mode=upward $sourceDirectory --out-dir=$outDirectory --out-file-extension=.build.js --ignore='$sourceDirectory/**/*.build.js','$sourceDirectory/**/vendor/*','$sourceDirectory/**/*.min.js'"; |
96 | 96 | $this->stdout("\n-> Running the babel command over $path\n"); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | // 5. Remove the babel directory |
112 | 112 | $this->stdout("\n-> Removing the temporary directory $outDirectory\n"); |
113 | - $deleteCommand="rm -rf $outDirectory"; |
|
113 | + $deleteCommand = "rm -rf $outDirectory"; |
|
114 | 114 | $this->stdout("-> $deleteCommand\n"); |
115 | 115 | $delete = new Process($deleteCommand); |
116 | 116 | $delete->start(); |
@@ -82,12 +82,14 @@ |
||
82 | 82 | $root = neon()->getAlias("@root").DIRECTORY_SEPARATOR; |
83 | 83 | |
84 | 84 | // 1. Check that Babel is installed and if not install it |
85 | - if (($result = $this->checkBabel())!=0) |
|
86 | - return $result; |
|
85 | + if (($result = $this->checkBabel())!=0) { |
|
86 | + return $result; |
|
87 | + } |
|
87 | 88 | |
88 | 89 | // 2. Create the babel config file |
89 | - if (($result = $this->checkBabelConfig($root)) != 0) |
|
90 | - return $result; |
|
90 | + if (($result = $this->checkBabelConfig($root)) != 0) { |
|
91 | + return $result; |
|
92 | + } |
|
91 | 93 | |
92 | 94 | // 3. Run babel over the project |
93 | 95 | $sourceDirectory = $root.$path;; |
@@ -68,7 +68,7 @@ |
||
68 | 68 | * 'order' => 1010, |
69 | 69 | * 'url' => ['/cms/index/index'], |
70 | 70 | * 'visible => neon()->user->is('neon-administrator') |
71 | - * ]; |
|
71 | + * ]; |
|
72 | 72 | * ``` |
73 | 73 | */ |
74 | 74 | public function getMenu(); |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | */ |
18 | 18 | trait PropertiesTrait |
19 | 19 | { |
20 | - public function toArray($except=[]) |
|
20 | + public function toArray($except = []) |
|
21 | 21 | { |
22 | - $array= []; |
|
22 | + $array = []; |
|
23 | 23 | $properties = $this->getProperties(); |
24 | - foreach($properties as $key => $value) { |
|
24 | + foreach ($properties as $key => $value) { |
|
25 | 25 | if (in_array($value, $except)) { continue; } |
26 | 26 | list($prop, $value) = $this->resolveProperty($key, $value); |
27 | 27 | $array[$prop] = $this->valueToArray($value); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function valueToArray($value) |
48 | 48 | { |
49 | 49 | if (is_array($value)) { |
50 | - foreach($value as $key => $val) { |
|
50 | + foreach ($value as $key => $val) { |
|
51 | 51 | $value[$key] = $this->valueToArray($val); |
52 | 52 | } |
53 | 53 | } else if (is_object($value) && $value instanceof IArrayable) { |
@@ -26,8 +26,9 @@ discard block |
||
26 | 26 | list($prop, $value) = $this->resolveProperty($key, $value); |
27 | 27 | $array[$prop] = $this->valueToArray($value); |
28 | 28 | } |
29 | - if (!isset($array['class'])) |
|
30 | - $array['class'] = get_called_class(); |
|
29 | + if (!isset($array['class'])) { |
|
30 | + $array['class'] = get_called_class(); |
|
31 | + } |
|
31 | 32 | return $array; |
32 | 33 | } |
33 | 34 | |
@@ -39,7 +40,9 @@ discard block |
||
39 | 40 | */ |
40 | 41 | public function resolveProperty($key, $value) |
41 | 42 | { |
42 | - if (is_int($key)) $key = $value; |
|
43 | + if (is_int($key)) { |
|
44 | + $key = $value; |
|
45 | + } |
|
43 | 46 | $value = is_string($value) ? $this->$value : call_user_func($value, $this, $key); |
44 | 47 | return [$key, $value]; |
45 | 48 | } |