@@ -2,7 +2,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | */ |
@@ -35,7 +35,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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. |
@@ -86,7 +86,7 @@ discard block |
||
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 |
||
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 |
||
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); |
@@ -77,7 +77,7 @@ discard block |
||
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 |
||
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); |
@@ -60,8 +60,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -39,7 +39,7 @@ discard block |
||
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 |
||
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); |
@@ -45,7 +45,7 @@ |
||
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(); |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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; |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | |
5 | 5 | class m160913_121403__neon_dds_changes extends Migration |
6 | 6 | { |
7 | - // Use safeUp/safeDown to run migration code within a transaction |
|
8 | - public function safeUp() |
|
9 | - { |
|
7 | + // Use safeUp/safeDown to run migration code within a transaction |
|
8 | + public function safeUp() |
|
9 | + { |
|
10 | 10 | // add a series of default types to the datatypes |
11 | 11 | $sql =<<<EOQ |
12 | 12 | INSERT INTO `dds_data_type` (`data_type_ref`, `label`, `description`, `definition`, `storage_ref`, `deleted`) |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | $command = $connection->createCommand($sql); |
41 | 41 | $command->execute(); |
42 | 42 | |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public function safeDown() |
|
46 | - { |
|
45 | + public function safeDown() |
|
46 | + { |
|
47 | 47 | // delete the additional rows in the datatypes |
48 | 48 | $sql =<<<EOQ |
49 | 49 | DELETE FROM `dds_data_type` WHERE `data_type_ref` IN |
@@ -55,5 +55,5 @@ discard block |
||
55 | 55 | $command = $connection->createCommand($sql); |
56 | 56 | $command->execute(); |
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | public function safeUp() |
9 | 9 | { |
10 | 10 | // add a series of default types to the datatypes |
11 | - $sql =<<<EOQ |
|
11 | + $sql = <<<EOQ |
|
12 | 12 | INSERT INTO `dds_data_type` (`data_type_ref`, `label`, `description`, `definition`, `storage_ref`, `deleted`) |
13 | 13 | VALUES |
14 | 14 | ('binary','Normal Binary','For normal binaries such as images up to 16MB in size','','binary',0), |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function safeDown() |
46 | 46 | { |
47 | 47 | // delete the additional rows in the datatypes |
48 | - $sql =<<<EOQ |
|
48 | + $sql = <<<EOQ |
|
49 | 49 | DELETE FROM `dds_data_type` WHERE `data_type_ref` IN |
50 | 50 | ('binary', 'binarylong', 'binaryshort', 'date', 'datetime', 'float', 'floatdouble', |
51 | 51 | 'integer', 'integerlong', 'integershort', 'integertiny', 'text', 'textlong', 'textshort', |
@@ -4,26 +4,26 @@ |
||
4 | 4 | |
5 | 5 | class m170904_201142_dds_multichoice_creation extends Migration |
6 | 6 | { |
7 | - public function safeUp() |
|
8 | - { |
|
9 | - $sql =<<<EOQ |
|
7 | + public function safeUp() |
|
8 | + { |
|
9 | + $sql =<<<EOQ |
|
10 | 10 | SET foreign_key_checks = 0; |
11 | 11 | REPLACE INTO `dds_data_type` (`data_type_ref`, `label`, `description`, `definition`, `storage_ref`, `deleted`) |
12 | 12 | VALUES |
13 | 13 | ('choice_multiple','Multiple Choice','For storing multiple choice keys','{"size":10000}','text',0); |
14 | 14 | SET foreign_key_checks = 1; |
15 | 15 | EOQ; |
16 | - $this->execute($sql); |
|
16 | + $this->execute($sql); |
|
17 | 17 | |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - public function safeDown() |
|
21 | - { |
|
22 | - $sql =<<<EOQ |
|
20 | + public function safeDown() |
|
21 | + { |
|
22 | + $sql =<<<EOQ |
|
23 | 23 | SET foreign_key_checks=0; |
24 | 24 | DELETE FROM `dds_data_type` WHERE `data_type_ref`='choice_multiple'; |
25 | 25 | SET foreign_key_checks=1; |
26 | 26 | EOQ; |
27 | - $this->execute($sql); |
|
28 | - } |
|
27 | + $this->execute($sql); |
|
28 | + } |
|
29 | 29 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | { |
7 | 7 | public function safeUp() |
8 | 8 | { |
9 | - $sql =<<<EOQ |
|
9 | + $sql = <<<EOQ |
|
10 | 10 | SET foreign_key_checks = 0; |
11 | 11 | REPLACE INTO `dds_data_type` (`data_type_ref`, `label`, `description`, `definition`, `storage_ref`, `deleted`) |
12 | 12 | VALUES |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | public function safeDown() |
21 | 21 | { |
22 | - $sql =<<<EOQ |
|
22 | + $sql = <<<EOQ |
|
23 | 23 | SET foreign_key_checks=0; |
24 | 24 | DELETE FROM `dds_data_type` WHERE `data_type_ref`='choice_multiple'; |
25 | 25 | SET foreign_key_checks=1; |