@@ -92,27 +92,27 @@ discard block |
||
92 | 92 | |
93 | 93 | //-------------------------------------------------------------------- |
94 | 94 | |
95 | - public function run($segments=[], $quiet=false) |
|
95 | + public function run($segments = [], $quiet = false) |
|
96 | 96 | { |
97 | - $name = array_shift( $segments ); |
|
97 | + $name = array_shift($segments); |
|
98 | 98 | |
99 | - if ( empty( $name ) ) |
|
99 | + if (empty($name)) |
|
100 | 100 | { |
101 | - $name = CLI::prompt( 'Migration name' ); |
|
101 | + $name = CLI::prompt('Migration name'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // Format to CI Standards |
105 | - $name = str_replace('.php', '', strtolower( $name ) ); |
|
105 | + $name = str_replace('.php', '', strtolower($name)); |
|
106 | 106 | |
107 | 107 | $this->detectAction($name); |
108 | 108 | |
109 | - $this->collectOptions( $name, $quiet ); |
|
109 | + $this->collectOptions($name, $quiet); |
|
110 | 110 | |
111 | 111 | $data = [ |
112 | 112 | 'name' => $name, |
113 | 113 | 'clean_name' => ucwords(str_replace('_', ' ', $name)), |
114 | - 'today' => date( 'Y-m-d H:ia' ), |
|
115 | - 'fields' => trim( $this->stringify( $this->fields ), ', '), |
|
114 | + 'today' => date('Y-m-d H:ia'), |
|
115 | + 'fields' => trim($this->stringify($this->fields), ', '), |
|
116 | 116 | 'raw_fields' => $this->fields, |
117 | 117 | 'action' => $this->action, |
118 | 118 | 'table' => $this->table, |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | 'column' => $this->column |
121 | 121 | ]; |
122 | 122 | |
123 | - if (! empty($this->column) && array_key_exists($this->column, $this->fields)) |
|
123 | + if ( ! empty($this->column) && array_key_exists($this->column, $this->fields)) |
|
124 | 124 | { |
125 | - $data['column_string'] = trim( $this->stringify($this->fields[$this->column]), ', '); |
|
125 | + $data['column_string'] = trim($this->stringify($this->fields[$this->column]), ', '); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $this->load->library('migration'); |
@@ -130,17 +130,17 @@ discard block |
||
130 | 130 | // todo Allow different migration "types" |
131 | 131 | $type = 'app'; |
132 | 132 | |
133 | - if (! empty($this->module)) |
|
133 | + if ( ! empty($this->module)) |
|
134 | 134 | { |
135 | - $type = 'mod:'. $this->module; |
|
135 | + $type = 'mod:'.$this->module; |
|
136 | 136 | } |
137 | 137 | $destination = $this->migration->determine_migration_path($type, true); |
138 | 138 | |
139 | 139 | $file = $this->migration->make_name($name); |
140 | 140 | |
141 | - $destination = rtrim($destination, '/') .'/'. $file; |
|
141 | + $destination = rtrim($destination, '/').'/'.$file; |
|
142 | 142 | |
143 | - if (! $this->copyTemplate( 'migration', $destination, $data, true) ) |
|
143 | + if ( ! $this->copyTemplate('migration', $destination, $data, true)) |
|
144 | 144 | { |
145 | 145 | CLI::error('Error creating seed file.'); |
146 | 146 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $action = $this->actionMap[$action]; |
174 | 174 | } |
175 | 175 | |
176 | - if (! in_array($action, $this->allowedActions)) |
|
176 | + if ( ! in_array($action, $this->allowedActions)) |
|
177 | 177 | { |
178 | 178 | return; |
179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | // The name of the table is assumed to be the one |
189 | 189 | // prior to the $index found. |
190 | - $this->table = plural( implode('_', array_slice($segments, 0, $index) ) ); |
|
190 | + $this->table = plural(implode('_', array_slice($segments, 0, $index))); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // Are we referencing a column? |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | |
200 | 200 | //-------------------------------------------------------------------- |
201 | 201 | |
202 | - public function collectOptions($name, $quiet=false) |
|
202 | + public function collectOptions($name, $quiet = false) |
|
203 | 203 | { |
204 | 204 | $options = CLI::getOptions(); |
205 | 205 | |
206 | 206 | // Use existing db table? |
207 | - if (array_key_exists('fromdb', $options) ) |
|
207 | + if (array_key_exists('fromdb', $options)) |
|
208 | 208 | { |
209 | 209 | $this->readTable($this->table); |
210 | 210 | } |
@@ -217,10 +217,9 @@ discard block |
||
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | - $fields = empty( $fields ) ? |
|
221 | - CLI::prompt( 'Fields? (name:type)' ) : |
|
222 | - $options['fields']; |
|
223 | - $this->fields = $this->parseFields( $fields ); |
|
220 | + $fields = empty($fields) ? |
|
221 | + CLI::prompt('Fields? (name:type)') : $options['fields']; |
|
222 | + $this->fields = $this->parseFields($fields); |
|
224 | 223 | } |
225 | 224 | } |
226 | 225 | |
@@ -244,7 +243,7 @@ discard block |
||
244 | 243 | $fields = []; |
245 | 244 | $segments = explode(' ', $str); |
246 | 245 | |
247 | - if (! count($segments)) |
|
246 | + if ( ! count($segments)) |
|
248 | 247 | { |
249 | 248 | return $fields; |
250 | 249 | } |
@@ -252,7 +251,7 @@ discard block |
||
252 | 251 | foreach ($segments as $segment) |
253 | 252 | { |
254 | 253 | $pop = [null, null, null]; |
255 | - list($field, $type, $size) = array_merge( explode(':', $segment), $pop); |
|
254 | + list($field, $type, $size) = array_merge(explode(':', $segment), $pop); |
|
256 | 255 | $type = strtolower($type); |
257 | 256 | |
258 | 257 | // Is type one of our convenience mapped items? |
@@ -261,7 +260,7 @@ discard block |
||
261 | 260 | $type = $this->map[$type]; |
262 | 261 | } |
263 | 262 | |
264 | - $f = [ 'type' => $type ]; |
|
263 | + $f = ['type' => $type]; |
|
265 | 264 | |
266 | 265 | // Creating a primary key? |
267 | 266 | if ($type == 'id') |
@@ -275,9 +274,9 @@ discard block |
||
275 | 274 | } |
276 | 275 | |
277 | 276 | // Constraint? |
278 | - if (! empty($size)) |
|
277 | + if ( ! empty($size)) |
|
279 | 278 | { |
280 | - $f['constraint'] = (int)$size; |
|
279 | + $f['constraint'] = (int) $size; |
|
281 | 280 | } |
282 | 281 | else if (array_key_exists($type, $this->defaultSizes)) |
283 | 282 | { |
@@ -319,7 +318,7 @@ discard block |
||
319 | 318 | } |
320 | 319 | |
321 | 320 | // Table exists? |
322 | - if (! $this->db->table_exists($table)) |
|
321 | + if ( ! $this->db->table_exists($table)) |
|
323 | 322 | { |
324 | 323 | return false; |
325 | 324 | } |
@@ -327,7 +326,7 @@ discard block |
||
327 | 326 | $fields = $this->db->field_data($table); |
328 | 327 | |
329 | 328 | // Any fields? |
330 | - if (! is_array($fields) || ! count($fields)) |
|
329 | + if ( ! is_array($fields) || ! count($fields)) |
|
331 | 330 | { |
332 | 331 | return false; |
333 | 332 | } |
@@ -336,30 +335,30 @@ discard block |
||
336 | 335 | |
337 | 336 | foreach ($fields as $field) |
338 | 337 | { |
339 | - $f = [ 'type' => $field->type ]; |
|
338 | + $f = ['type' => $field->type]; |
|
340 | 339 | |
341 | 340 | // Constraint |
342 | - if (! empty($field->max_length)) |
|
341 | + if ( ! empty($field->max_length)) |
|
343 | 342 | { |
344 | 343 | $f['constraint'] = $field->max_length; |
345 | 344 | } |
346 | 345 | else if (array_key_exists($field->type, $this->defaultSizes)) |
347 | 346 | { |
348 | - $f['constraint'] = $this->defaultSizes[ $field->type ]; |
|
347 | + $f['constraint'] = $this->defaultSizes[$field->type]; |
|
349 | 348 | } |
350 | 349 | |
351 | 350 | // Default |
352 | - if (! empty($field->default)) $f['default'] = $field->default; |
|
351 | + if ( ! empty($field->default)) $f['default'] = $field->default; |
|
353 | 352 | |
354 | 353 | // Primary Key? |
355 | - if (! empty($field->primary_key) && $field->primary_key == 1) |
|
354 | + if ( ! empty($field->primary_key) && $field->primary_key == 1) |
|
356 | 355 | { |
357 | 356 | $this->primary_key = $field->name; |
358 | 357 | $f['auto_increment'] = true; |
359 | 358 | $f['unsigned'] = true; |
360 | 359 | } |
361 | 360 | |
362 | - $new_fields[ $field->name ] = $f; |
|
361 | + $new_fields[$field->name] = $f; |
|
363 | 362 | } |
364 | 363 | |
365 | 364 | $this->fields = $new_fields; |
@@ -17,13 +17,13 @@ |
||
17 | 17 | \$this->dbforge->add_field(\$fields); |
18 | 18 | "; |
19 | 19 | |
20 | - if (! empty($primary_key)) |
|
20 | + if ( ! empty($primary_key)) |
|
21 | 21 | { |
22 | 22 | $up .= " \$this->dbforge->add_key('{$primary_key}', true); |
23 | 23 | "; |
24 | 24 | } |
25 | 25 | |
26 | - $up .=" \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
26 | + $up .= " \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
27 | 27 | "; |
28 | 28 | |
29 | 29 | $down = "\$this->dbforge->drop_table('{$table}');"; |
@@ -56,47 +56,47 @@ discard block |
||
56 | 56 | |
57 | 57 | //-------------------------------------------------------------------- |
58 | 58 | |
59 | - public function run( $segments = [ ], $quiet = false ) |
|
59 | + public function run($segments = [], $quiet = false) |
|
60 | 60 | { |
61 | - $name = array_shift( $segments ); |
|
61 | + $name = array_shift($segments); |
|
62 | 62 | |
63 | 63 | $options = CLI::getOptions(); |
64 | 64 | |
65 | - $this->options['table_name'] = array_shift( $segments ); |
|
65 | + $this->options['table_name'] = array_shift($segments); |
|
66 | 66 | |
67 | - if ( empty( $name ) ) |
|
67 | + if (empty($name)) |
|
68 | 68 | { |
69 | - $name = CLI::prompt( 'Model name' ); |
|
69 | + $name = CLI::prompt('Model name'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Format to CI Standards |
73 | - if ( substr( $name, - 6 ) !== '_model' ) |
|
73 | + if (substr($name, - 6) !== '_model') |
|
74 | 74 | { |
75 | 75 | $name .= '_model'; |
76 | 76 | } |
77 | - $name = ucfirst( $name ); |
|
77 | + $name = ucfirst($name); |
|
78 | 78 | |
79 | - if ( $quiet === false ) |
|
79 | + if ($quiet === false) |
|
80 | 80 | { |
81 | - $this->collectOptions( $name, $options ); |
|
81 | + $this->collectOptions($name, $options); |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - $this->quietSetOptions( $name, $options ); |
|
85 | + $this->quietSetOptions($name, $options); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $data = [ |
89 | 89 | 'model_name' => $name, |
90 | - 'today' => date( 'Y-m-d H:ia' ) |
|
90 | + 'today' => date('Y-m-d H:ia') |
|
91 | 91 | ]; |
92 | 92 | |
93 | - $data = array_merge( $data, $this->options ); |
|
93 | + $data = array_merge($data, $this->options); |
|
94 | 94 | |
95 | - $destination = $this->determineOutputPath( 'models' ) . $name . '.php'; |
|
95 | + $destination = $this->determineOutputPath('models').$name.'.php'; |
|
96 | 96 | |
97 | - if ( ! $this->copyTemplate( 'model', $destination, $data, $this->overwrite ) ) |
|
97 | + if ( ! $this->copyTemplate('model', $destination, $data, $this->overwrite)) |
|
98 | 98 | { |
99 | - CLI::error( 'Error creating new files' ); |
|
99 | + CLI::error('Error creating new files'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return TRUE; |
@@ -107,70 +107,67 @@ discard block |
||
107 | 107 | /* |
108 | 108 | * Customizes our settings |
109 | 109 | */ |
110 | - protected function collectOptions( $model_name, $options=[] ) |
|
110 | + protected function collectOptions($model_name, $options = []) |
|
111 | 111 | { |
112 | - $this->load->helper( 'inflector' ); |
|
112 | + $this->load->helper('inflector'); |
|
113 | 113 | |
114 | 114 | // Table Name? |
115 | - if ( empty( $this->options['table_name'] ) ) |
|
115 | + if (empty($this->options['table_name'])) |
|
116 | 116 | { |
117 | - $this->options['table_name'] = empty( $options['table'] ) ? |
|
118 | - CLI::prompt( 'Table name', plural( strtolower( str_replace( '_model', '', $model_name ) ) ) ) : |
|
119 | - $options['table']; |
|
117 | + $this->options['table_name'] = empty($options['table']) ? |
|
118 | + CLI::prompt('Table name', plural(strtolower(str_replace('_model', '', $model_name)))) : $options['table']; |
|
120 | 119 | } |
121 | 120 | |
122 | - $this->options['fields'] = $this->table_info( $this->options['table_name'], $options ); |
|
121 | + $this->options['fields'] = $this->table_info($this->options['table_name'], $options); |
|
123 | 122 | |
124 | 123 | // Primary Key |
125 | 124 | if (empty($this->options['primary_key'])) |
126 | 125 | { |
127 | - $this->options['primary_key'] = empty( $options['primary_key'] ) ? |
|
128 | - CLI::prompt( 'Primary Key', 'id' ) : |
|
129 | - $options['primary_key']; |
|
126 | + $this->options['primary_key'] = empty($options['primary_key']) ? |
|
127 | + CLI::prompt('Primary Key', 'id') : $options['primary_key']; |
|
130 | 128 | } |
131 | 129 | |
132 | - $this->options['protected'] = [ $this->options['primary_key'] ]; |
|
130 | + $this->options['protected'] = [$this->options['primary_key']]; |
|
133 | 131 | |
134 | 132 | // Set Created? |
135 | - if ( empty( $options['set_created'] ) ) |
|
133 | + if (empty($options['set_created'])) |
|
136 | 134 | { |
137 | - $ans = CLI::prompt( 'Set Created date?', [ 'y', 'n' ] ); |
|
138 | - if ( $ans == 'n' ) |
|
135 | + $ans = CLI::prompt('Set Created date?', ['y', 'n']); |
|
136 | + if ($ans == 'n') |
|
139 | 137 | { |
140 | 138 | $this->options['set_created'] = FALSE; |
141 | 139 | } |
142 | 140 | } |
143 | 141 | |
144 | 142 | // Set Modified? |
145 | - if ( empty( $options['set_modified'] ) ) |
|
143 | + if (empty($options['set_modified'])) |
|
146 | 144 | { |
147 | - $ans = CLI::prompt( 'Set Modified date?', [ 'y', 'n' ] ); |
|
148 | - if ( $ans == 'n' ) |
|
145 | + $ans = CLI::prompt('Set Modified date?', ['y', 'n']); |
|
146 | + if ($ans == 'n') |
|
149 | 147 | { |
150 | 148 | $this->options['set_modified'] = FALSE; |
151 | 149 | } |
152 | 150 | } |
153 | 151 | |
154 | 152 | // Date Format |
155 | - $this->options['date_format'] = empty( $options['date_format'] ) ? |
|
156 | - CLI::prompt( 'Date Format?', [ 'datetime', 'date', 'int' ] ) : |
|
157 | - $options['date_format']; |
|
153 | + $this->options['date_format'] = empty($options['date_format']) ? |
|
154 | + CLI::prompt('Date Format?', ['datetime', 'date', 'int']) : $options['date_format']; |
|
158 | 155 | |
159 | 156 | // Log User? |
160 | - if ( empty( $options['log_user'] ) ) |
|
157 | + if (empty($options['log_user'])) |
|
161 | 158 | { |
162 | - $ans = CLI::prompt( 'Log User actions?', [ 'y', 'n' ] ); |
|
163 | - if ( $ans == 'y' ) |
|
159 | + $ans = CLI::prompt('Log User actions?', ['y', 'n']); |
|
160 | + if ($ans == 'y') |
|
164 | 161 | { |
165 | 162 | $this->options['log_user'] = TRUE; |
166 | 163 | } |
167 | 164 | } |
168 | 165 | |
169 | 166 | // Soft Deletes |
170 | - if ( empty( $options['soft_delete'] ) ) |
|
167 | + if (empty($options['soft_delete'])) |
|
171 | 168 | { |
172 | - $ans = CLI::prompt( 'Use Soft Deletes?', [ 'y', 'n' ] ); |
|
173 | - if ( $ans == 'n' ) |
|
169 | + $ans = CLI::prompt('Use Soft Deletes?', ['y', 'n']); |
|
170 | + if ($ans == 'n') |
|
174 | 171 | { |
175 | 172 | $this->options['soft_delete'] = false; |
176 | 173 | } |
@@ -180,21 +177,21 @@ discard block |
||
180 | 177 | |
181 | 178 | //-------------------------------------------------------------------- |
182 | 179 | |
183 | - protected function quietSetOptions( $model_name, $options=[] ) |
|
180 | + protected function quietSetOptions($model_name, $options = []) |
|
184 | 181 | { |
185 | - $this->load->helper( 'inflector' ); |
|
182 | + $this->load->helper('inflector'); |
|
186 | 183 | |
187 | 184 | if (empty($this->options['table_name'])) |
188 | 185 | { |
189 | - $this->options['table_name'] = plural( strtolower( str_replace( '_model', '', $model_name ) ) ); |
|
186 | + $this->options['table_name'] = plural(strtolower(str_replace('_model', '', $model_name))); |
|
190 | 187 | } |
191 | 188 | |
192 | 189 | // Try to set it from the database first, |
193 | 190 | // otherwise, try to pull from fields |
194 | - $this->options['fields'] = $this->table_info( $this->options['table_name'], $options ); |
|
191 | + $this->options['fields'] = $this->table_info($this->options['table_name'], $options); |
|
195 | 192 | |
196 | - $this->options['primary_key'] = ! empty( $this->options['primary_key'] ) ? $this->options['primary_key'] : 'id'; |
|
197 | - $this->options['protected'] = [ $this->options['primary_key'] ]; |
|
193 | + $this->options['primary_key'] = ! empty($this->options['primary_key']) ? $this->options['primary_key'] : 'id'; |
|
194 | + $this->options['protected'] = [$this->options['primary_key']]; |
|
198 | 195 | } |
199 | 196 | |
200 | 197 | //-------------------------------------------------------------------- |
@@ -206,12 +203,12 @@ discard block |
||
206 | 203 | * |
207 | 204 | * @return mixed An array of fields or false if the table does not exist |
208 | 205 | */ |
209 | - protected function table_info( $table_name, $options=[] ) |
|
206 | + protected function table_info($table_name, $options = []) |
|
210 | 207 | { |
211 | 208 | $this->load->database(); |
212 | 209 | |
213 | 210 | // Check whether the table exists in this database |
214 | - if ( ! $this->db->table_exists( $table_name ) ) |
|
211 | + if ( ! $this->db->table_exists($table_name)) |
|
215 | 212 | { |
216 | 213 | if (empty($options['fields'])) |
217 | 214 | { |
@@ -222,12 +219,12 @@ discard block |
||
222 | 219 | } |
223 | 220 | else |
224 | 221 | { |
225 | - $fields = $this->db->field_data( $table_name ); |
|
222 | + $fields = $this->db->field_data($table_name); |
|
226 | 223 | } |
227 | 224 | |
228 | 225 | // There may be something wrong or the database driver may not return |
229 | 226 | // field data |
230 | - if ( empty( $fields ) ) |
|
227 | + if (empty($fields)) |
|
231 | 228 | { |
232 | 229 | return FALSE; |
233 | 230 | } |
@@ -237,9 +234,9 @@ discard block |
||
237 | 234 | $this->options['use_soft_deletes'] = false; |
238 | 235 | |
239 | 236 | // Use the primary key if the table has one already set. |
240 | - foreach ( $fields as $field ) |
|
237 | + foreach ($fields as $field) |
|
241 | 238 | { |
242 | - if ( ! empty( $field->primary_key ) && $field->primary_key == 1 ) |
|
239 | + if ( ! empty($field->primary_key) && $field->primary_key == 1) |
|
243 | 240 | { |
244 | 241 | $this->options['primary_key'] = $field->name; |
245 | 242 | } |
@@ -261,7 +258,7 @@ discard block |
||
261 | 258 | } |
262 | 259 | |
263 | 260 | // Set our validation rules based on these fields |
264 | - $this->options['rules'] = $this->buildValidationRules( $fields ); |
|
261 | + $this->options['rules'] = $this->buildValidationRules($fields); |
|
265 | 262 | |
266 | 263 | return $fields; |
267 | 264 | } |
@@ -274,20 +271,20 @@ discard block |
||
274 | 271 | */ |
275 | 272 | protected function parseFieldString($fields) |
276 | 273 | { |
277 | - if ( empty( $fields ) ) |
|
274 | + if (empty($fields)) |
|
278 | 275 | { |
279 | 276 | return NULL; |
280 | 277 | } |
281 | 278 | |
282 | - $fields = explode( ' ', $fields ); |
|
279 | + $fields = explode(' ', $fields); |
|
283 | 280 | |
284 | - $new_fields = [ ]; |
|
281 | + $new_fields = []; |
|
285 | 282 | |
286 | - foreach ( $fields as $field ) |
|
283 | + foreach ($fields as $field) |
|
287 | 284 | { |
288 | - $pop = [ NULL, NULL, NULL ]; |
|
289 | - list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
290 | - $type = strtolower( $type ); |
|
285 | + $pop = [NULL, NULL, NULL]; |
|
286 | + list($field, $type, $size) = array_merge(explode(':', $field), $pop); |
|
287 | + $type = strtolower($type); |
|
291 | 288 | |
292 | 289 | // Strings |
293 | 290 | if (in_array($type, ['char', 'varchar', 'string'])) |
@@ -328,7 +325,7 @@ discard block |
||
328 | 325 | |
329 | 326 | // Convert to objects |
330 | 327 | array_walk($new_fields, function(&$item, $key) { |
331 | - $item = (object)$item; |
|
328 | + $item = (object) $item; |
|
332 | 329 | }); |
333 | 330 | |
334 | 331 | return $new_fields; |
@@ -345,7 +342,7 @@ discard block |
||
345 | 342 | * |
346 | 343 | * @return array |
347 | 344 | */ |
348 | - public function buildValidationrules($fields=[]) |
|
345 | + public function buildValidationrules($fields = []) |
|
349 | 346 | { |
350 | 347 | if (empty($fields) || ! is_array($fields) || ! count($fields)) |
351 | 348 | { |
@@ -390,7 +387,7 @@ discard block |
||
390 | 387 | break; |
391 | 388 | } |
392 | 389 | |
393 | - if (! empty($field->max_length)) |
|
390 | + if ( ! empty($field->max_length)) |
|
394 | 391 | { |
395 | 392 | $rule[] = "max_length[{$field->max_length}]"; |
396 | 393 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | protected \$deleted_by_field = 'deleted_by'; |
36 | 36 | "; |
37 | 37 | |
38 | -$protect = "'". implode("', '", $protected) . "'"; |
|
38 | +$protect = "'".implode("', '", $protected)."'"; |
|
39 | 39 | |
40 | 40 | //-------------------------------------------------------------------- |
41 | 41 | // Create the full model |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | |
43 | 43 | //-------------------------------------------------------------------- |
44 | 44 | |
45 | - public function run($segments = [ ], $quiet = false) |
|
45 | + public function run($segments = [], $quiet = false) |
|
46 | 46 | { |
47 | - $name = array_shift( $segments ); |
|
47 | + $name = array_shift($segments); |
|
48 | 48 | |
49 | 49 | // If a table already exists then we don't need a migration |
50 | 50 | $this->load->database(); |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | // exists, then we need to provide some default fields. |
62 | 62 | if (empty($this->fields)) |
63 | 63 | { |
64 | - if (! $this->table_exists) |
|
64 | + if ( ! $this->table_exists) |
|
65 | 65 | { |
66 | 66 | $this->fields = "id:int id:id title:string created_on:datetime modified_on:datetime"; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Perform the steps. |
71 | - if (! $this->table_exists) |
|
71 | + if ( ! $this->table_exists) |
|
72 | 72 | { |
73 | - $this->makeMigration( $name ); |
|
73 | + $this->makeMigration($name); |
|
74 | 74 | } |
75 | 75 | $this->makeSeed($name); |
76 | 76 | $this->makeModel($name); |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | // If a table exists, we can build it from that |
115 | 115 | if ($this->table_exists) |
116 | 116 | { |
117 | - $this->generate( "model {$name}", "-table $name -primary_key id", TRUE ); |
|
117 | + $this->generate("model {$name}", "-table $name -primary_key id", TRUE); |
|
118 | 118 | } |
119 | 119 | // Otherwise, we need to provide the fields to make the model out of. |
120 | 120 | else |
121 | 121 | { |
122 | - $this->generate( "model {$name}", "-fields '{$this->fields}'", TRUE ); |
|
122 | + $this->generate("model {$name}", "-fields '{$this->fields}'", TRUE); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | $options = "-model {$this->model_name} -create_views"; |
131 | 131 | |
132 | - if (! empty($this->fields)) |
|
132 | + if ( ! empty($this->fields)) |
|
133 | 133 | { |
134 | 134 | $options .= " -fields '{$this->fields}'"; |
135 | 135 | } |
@@ -34,36 +34,36 @@ |
||
34 | 34 | |
35 | 35 | class SeedGenerator extends \Myth\Forge\BaseGenerator { |
36 | 36 | |
37 | - public function run($segments=[], $quiet=false) |
|
37 | + public function run($segments = [], $quiet = false) |
|
38 | 38 | { |
39 | - $name = array_shift( $segments ); |
|
39 | + $name = array_shift($segments); |
|
40 | 40 | |
41 | - if ( empty( $name ) ) |
|
41 | + if (empty($name)) |
|
42 | 42 | { |
43 | - $name = CLI::prompt( 'Seed name' ); |
|
43 | + $name = CLI::prompt('Seed name'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // Format to CI Standards |
47 | - $name = str_replace('.php', '', strtolower( $name ) ); |
|
48 | - if (substr( $name, -4) == 'seed') |
|
47 | + $name = str_replace('.php', '', strtolower($name)); |
|
48 | + if (substr($name, -4) == 'seed') |
|
49 | 49 | { |
50 | 50 | $name = substr($name, 0, strlen($name) - 4); |
51 | 51 | } |
52 | - $name = ucfirst($name) .'Seeder'; |
|
52 | + $name = ucfirst($name).'Seeder'; |
|
53 | 53 | |
54 | 54 | $data = [ |
55 | 55 | 'seed_name' => $name, |
56 | - 'today' => date( 'Y-m-d H:ia' ) |
|
56 | + 'today' => date('Y-m-d H:ia') |
|
57 | 57 | ]; |
58 | 58 | |
59 | - $destination = $this->determineOutputPath( 'database/seeds' ) . $name . '.php'; |
|
59 | + $destination = $this->determineOutputPath('database/seeds').$name.'.php'; |
|
60 | 60 | |
61 | 61 | if (strpos($destination, 'modules') !== false) |
62 | 62 | { |
63 | 63 | $destination = str_replace('database/', '', $destination); |
64 | 64 | } |
65 | 65 | |
66 | - if (! $this->copyTemplate( 'seed', $destination, $data, $this->overwrite) ) |
|
66 | + if ( ! $this->copyTemplate('seed', $destination, $data, $this->overwrite)) |
|
67 | 67 | { |
68 | 68 | CLI::error('Error creating seed file.'); |
69 | 69 | } |
@@ -34,21 +34,21 @@ |
||
34 | 34 | |
35 | 35 | class ViewGenerator extends \Myth\Forge\BaseGenerator { |
36 | 36 | |
37 | - public function run($segments=[], $quiet=false) |
|
37 | + public function run($segments = [], $quiet = false) |
|
38 | 38 | { |
39 | - $name = array_shift( $segments ); |
|
39 | + $name = array_shift($segments); |
|
40 | 40 | |
41 | - if ( empty( $name ) ) |
|
41 | + if (empty($name)) |
|
42 | 42 | { |
43 | - $name = CLI::prompt( 'View name' ); |
|
43 | + $name = CLI::prompt('View name'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // Format to CI Standards |
47 | - $name = str_replace('.php', '', strtolower( $name ) ); |
|
47 | + $name = str_replace('.php', '', strtolower($name)); |
|
48 | 48 | |
49 | - $destination = $this->determineOutputPath( 'views' ) . $name . '.php'; |
|
49 | + $destination = $this->determineOutputPath('views').$name.'.php'; |
|
50 | 50 | |
51 | - if (! $this->createFile($destination, "The {$name}.php view file.", $this->overwrite) ) |
|
51 | + if ( ! $this->createFile($destination, "The {$name}.php view file.", $this->overwrite)) |
|
52 | 52 | { |
53 | 53 | CLI::error('Error creating view file.'); |
54 | 54 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * Start the timer... tick tock tick tock... |
186 | 186 | * ------------------------------------------------------ |
187 | 187 | */ |
188 | - $BM =& load_class('Benchmark', 'core'); |
|
188 | + $BM = & load_class('Benchmark', 'core'); |
|
189 | 189 | $BM->mark('total_execution_time_start'); |
190 | 190 | $BM->mark('loading_time:_base_classes_start'); |
191 | 191 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * Instantiate the hooks class |
195 | 195 | * ------------------------------------------------------ |
196 | 196 | */ |
197 | - $EXT =& load_class('Hooks', 'core'); |
|
197 | + $EXT = & load_class('Hooks', 'core'); |
|
198 | 198 | |
199 | 199 | /* |
200 | 200 | * ------------------------------------------------------ |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * depending on another class that uses it. |
214 | 214 | * |
215 | 215 | */ |
216 | - $CFG =& load_class('Config', 'core'); |
|
216 | + $CFG = & load_class('Config', 'core'); |
|
217 | 217 | |
218 | 218 | // Do we have any manually set config items in the index.php file? |
219 | 219 | if (isset($assign_to_config) && is_array($assign_to_config)) |
@@ -291,28 +291,28 @@ discard block |
||
291 | 291 | * Instantiate the UTF-8 class |
292 | 292 | * ------------------------------------------------------ |
293 | 293 | */ |
294 | - $UNI =& load_class('Utf8', 'core'); |
|
294 | + $UNI = & load_class('Utf8', 'core'); |
|
295 | 295 | |
296 | 296 | /* |
297 | 297 | * ------------------------------------------------------ |
298 | 298 | * Instantiate the URI class |
299 | 299 | * ------------------------------------------------------ |
300 | 300 | */ |
301 | - $URI =& load_class('URI', 'core'); |
|
301 | + $URI = & load_class('URI', 'core'); |
|
302 | 302 | |
303 | 303 | /* |
304 | 304 | * ------------------------------------------------------ |
305 | 305 | * Instantiate the routing class and set the routing |
306 | 306 | * ------------------------------------------------------ |
307 | 307 | */ |
308 | - $RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL); |
|
308 | + $RTR = & load_class('Router', 'core', isset($routing) ? $routing : NULL); |
|
309 | 309 | |
310 | 310 | /* |
311 | 311 | * ------------------------------------------------------ |
312 | 312 | * Instantiate the output class |
313 | 313 | * ------------------------------------------------------ |
314 | 314 | */ |
315 | - $OUT =& load_class('Output', 'core'); |
|
315 | + $OUT = & load_class('Output', 'core'); |
|
316 | 316 | |
317 | 317 | /* |
318 | 318 | * ------------------------------------------------------ |
@@ -329,21 +329,21 @@ discard block |
||
329 | 329 | * Load the security class for xss and csrf support |
330 | 330 | * ----------------------------------------------------- |
331 | 331 | */ |
332 | - $SEC =& load_class('Security', 'core'); |
|
332 | + $SEC = & load_class('Security', 'core'); |
|
333 | 333 | |
334 | 334 | /* |
335 | 335 | * ------------------------------------------------------ |
336 | 336 | * Load the Input class and sanitize globals |
337 | 337 | * ------------------------------------------------------ |
338 | 338 | */ |
339 | - $IN =& load_class('Input', 'core'); |
|
339 | + $IN = & load_class('Input', 'core'); |
|
340 | 340 | |
341 | 341 | /* |
342 | 342 | * ------------------------------------------------------ |
343 | 343 | * Load the Language class |
344 | 344 | * ------------------------------------------------------ |
345 | 345 | */ |
346 | - $LANG =& load_class('Lang', 'core'); |
|
346 | + $LANG = & load_class('Lang', 'core'); |
|
347 | 347 | |
348 | 348 | /* |
349 | 349 | * ------------------------------------------------------ |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | if (empty($_config)) |
298 | 298 | { |
299 | 299 | // references cannot be directly assigned to static variables, so we use an array |
300 | - $_config[0] =& get_config(); |
|
300 | + $_config[0] = & get_config(); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | return isset($_config[0][$item]) ? $_config[0][$item] : NULL; |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $exit_status = 1; // EXIT_ERROR |
423 | 423 | } |
424 | 424 | |
425 | - $_error =& load_class('Exceptions', 'core'); |
|
425 | + $_error = & load_class('Exceptions', 'core'); |
|
426 | 426 | echo $_error->show_error($heading, $message, 'error_general', $status_code); |
427 | 427 | exit($exit_status); |
428 | 428 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | function show_404($page = '', $log_error = TRUE) |
447 | 447 | { |
448 | - $_error =& load_class('Exceptions', 'core'); |
|
448 | + $_error = & load_class('Exceptions', 'core'); |
|
449 | 449 | $_error->show_404($page, $log_error); |
450 | 450 | exit(4); // EXIT_UNKNOWN_FILE |
451 | 451 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | if ($_log === NULL) |
473 | 473 | { |
474 | 474 | // references cannot be directly assigned to static variables, so we use an array |
475 | - $_log[0] =& load_class('Log', 'core'); |
|
475 | + $_log[0] = & load_class('Log', 'core'); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | $_log[0]->write_log($level, $message); |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | return; |
619 | 619 | } |
620 | 620 | |
621 | - $_error =& load_class('Exceptions', 'core'); |
|
621 | + $_error = & load_class('Exceptions', 'core'); |
|
622 | 622 | $_error->log_exception($severity, $message, $filepath, $line); |
623 | 623 | |
624 | 624 | // Should we display the error? |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | */ |
654 | 654 | function _exception_handler($exception) |
655 | 655 | { |
656 | - $_error =& load_class('Exceptions', 'core'); |
|
656 | + $_error = & load_class('Exceptions', 'core'); |
|
657 | 657 | $_error->log_exception('error', 'Exception: '.$exception->getMessage(), $exception->getFile(), $exception->getLine()); |
658 | 658 | |
659 | 659 | // Should we display the error? |
@@ -716,11 +716,11 @@ discard block |
||
716 | 716 | // carriage return (dec 13) and horizontal tab (dec 09) |
717 | 717 | if ($url_encoded) |
718 | 718 | { |
719 | - $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 |
|
720 | - $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 |
|
719 | + $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 |
|
720 | + $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 |
|
721 | 721 | } |
722 | 722 | |
723 | - $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 |
|
723 | + $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 |
|
724 | 724 | |
725 | 725 | do |
726 | 726 | { |