@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | if ( ! $table_info ) { |
16 | 16 | $table_info = array(); |
17 | 17 | foreach ( $db->get_tables() as $table ) { |
18 | - $table_info[] = array( |
|
18 | + $table_info[ ] = array( |
|
19 | 19 | 'title' => $table->get_title(), |
20 | 20 | 'count' => $table->count_records(), |
21 | 21 | 'url' => $table->get_url(), |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | // Reports. |
32 | 32 | $reports_table = $db->get_table( \WordPress\Tabulate\DB\Reports::reports_table_name() ); |
33 | - $template->reports = ($reports_table) ? $reports_table->get_records( false ) : array(); |
|
33 | + $template->reports = ( $reports_table ) ? $reports_table->get_records( false ) : array(); |
|
34 | 34 | |
35 | 35 | return $template->render(); |
36 | 36 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * Save a record. |
80 | 80 | * |
81 | 81 | * @param string[] $args The request arguments. |
82 | - * @return boolean |
|
82 | + * @return false|null |
|
83 | 83 | */ |
84 | 84 | public function save( $args ) { |
85 | 85 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * Delete (or ask for confirmation of deleting) a single record. |
132 | 132 | * |
133 | 133 | * @param string[] $args The request arguments. |
134 | - * @return type |
|
134 | + * @return null|string |
|
135 | 135 | */ |
136 | 136 | public function delete( $args ) { |
137 | 137 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | public function index( $args ) { |
38 | 38 | // Get database and table. |
39 | 39 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
40 | - $table = $db->get_table( $args['table'] ); |
|
40 | + $table = $db->get_table( $args[ 'table' ] ); |
|
41 | 41 | |
42 | 42 | // Give it all to the template. |
43 | 43 | $template = $this->get_template( $table ); |
44 | - if ( isset( $args['ident'] ) ) { |
|
45 | - $template->record = $table->get_record( $args['ident'] ); |
|
44 | + if ( isset( $args[ 'ident' ] ) ) { |
|
45 | + $template->record = $table->get_record( $args[ 'ident' ] ); |
|
46 | 46 | // Check permission. |
47 | 47 | if ( ! Grants::current_user_can( Grants::UPDATE, $table->get_name() ) ) { |
48 | 48 | $template->add_notice( 'error', 'You do not have permission to update data in this table.' ); |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $template->add_notice( 'error', 'You do not have permission to create records in this table.' ); |
56 | 56 | } |
57 | 57 | // Add query-string values. |
58 | - if ( isset( $args['defaults'] ) ) { |
|
59 | - $template->record->set_multiple( $args['defaults'] ); |
|
58 | + if ( isset( $args[ 'defaults' ] ) ) { |
|
59 | + $template->record->set_multiple( $args[ 'defaults' ] ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | // Don't save to non-updatable views. |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | wp_enqueue_script( 'dashboard' ); |
69 | 69 | |
70 | 70 | // Return to URL. |
71 | - if ( isset( $args['return_to'] ) ) { |
|
72 | - $template->return_to = $args['return_to']; |
|
71 | + if ( isset( $args[ 'return_to' ] ) ) { |
|
72 | + $template->return_to = $args[ 'return_to' ]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return $template->render(); |
@@ -83,21 +83,21 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function save( $args ) { |
85 | 85 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
86 | - $table = $db->get_table( $args['table'] ); |
|
86 | + $table = $db->get_table( $args[ 'table' ] ); |
|
87 | 87 | if ( ! $table ) { |
88 | 88 | // It shouldn't be possible to get here via the UI, so no message. |
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | 92 | // Guard against non-post requests. c.f. wp-comments-post.php. |
93 | - if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
93 | + if ( ! isset( $_SERVER[ 'REQUEST_METHOD' ] ) || 'POST' !== $_SERVER[ 'REQUEST_METHOD' ] ) { |
|
94 | 94 | header( 'Allow: POST' ); |
95 | 95 | header( 'HTTP/1.1 405 Method Not Allowed' ); |
96 | 96 | header( 'Content-Type: text/plain' ); |
97 | 97 | return false; |
98 | 98 | } |
99 | 99 | |
100 | - $record_ident = isset( $args['ident'] ) ? $args['ident'] : false; |
|
100 | + $record_ident = isset( $args[ 'ident' ] ) ? $args[ 'ident' ] : false; |
|
101 | 101 | $this->verify_nonce( 'tabulate-record-' . $record_ident ); |
102 | 102 | $template = $this->get_template( $table ); |
103 | 103 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $existing = $table->get_record( $pk ); |
108 | 108 | if ( ! $record_ident && $existing ) { |
109 | 109 | $template->add_notice( 'updated', "The record identified by '$pk' already exists." ); |
110 | - $_REQUEST['return_to'] = $existing->get_url(); |
|
110 | + $_REQUEST[ 'return_to' ] = $existing->get_url(); |
|
111 | 111 | } else { |
112 | 112 | // Otherwise, create a new one. |
113 | 113 | try { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | } |
124 | 124 | // Redirect back to the edit form. |
125 | - $return_to = ( ! empty( $_REQUEST['return_to'] ) ) ? $_REQUEST['return_to'] : $template->record->get_url(); |
|
125 | + $return_to = ( ! empty( $_REQUEST[ 'return_to' ] ) ) ? $_REQUEST[ 'return_to' ] : $template->record->get_url(); |
|
126 | 126 | wp_safe_redirect( $return_to ); |
127 | 127 | exit; |
128 | 128 | } |
@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function delete( $args ) { |
137 | 137 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
138 | - $table = $db->get_table( $args['table'] ); |
|
139 | - $record_ident = isset( $args['ident'] ) ? $args['ident'] : false; |
|
138 | + $table = $db->get_table( $args[ 'table' ] ); |
|
139 | + $record_ident = isset( $args[ 'ident' ] ) ? $args[ 'ident' ] : false; |
|
140 | 140 | if ( ! $record_ident ) { |
141 | 141 | wp_safe_redirect( $table->get_url() ); |
142 | 142 | exit; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Ask for confirmation. |
146 | - if ( ! isset( $_POST['confirm_deletion'] ) ) { |
|
146 | + if ( ! isset( $_POST[ 'confirm_deletion' ] ) ) { |
|
147 | 147 | $template = new \WordPress\Tabulate\Template( 'record/delete.html' ); |
148 | 148 | $template->table = $table; |
149 | 149 | $template->record = $table->get_record( $record_ident ); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | /** |
118 | 118 | * Get the valid options for this column; only applies to ENUM and SET. |
119 | 119 | * |
120 | - * @return array The available options. |
|
120 | + * @return string[] The available options. |
|
121 | 121 | */ |
122 | 122 | public function get_options() { |
123 | 123 | return $this->options; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | /** |
271 | 271 | * Get the default value for this column. |
272 | 272 | * |
273 | - * @return mixed |
|
273 | + * @return string|null |
|
274 | 274 | */ |
275 | 275 | public function get_default() { |
276 | 276 | if ( 'CURRENT_TIMESTAMP' === $this->default_value ) { |
@@ -144,33 +144,33 @@ discard block |
||
144 | 144 | protected function parse_info( $info ) { |
145 | 145 | |
146 | 146 | // Name. |
147 | - $this->name = $info['Field']; |
|
147 | + $this->name = $info[ 'Field' ]; |
|
148 | 148 | |
149 | 149 | // Type. |
150 | - $this->parse_type( $info['Type'] ); |
|
150 | + $this->parse_type( $info[ 'Type' ] ); |
|
151 | 151 | |
152 | 152 | // Default. |
153 | - $this->default_value = $info['Default']; |
|
153 | + $this->default_value = $info[ 'Default' ]; |
|
154 | 154 | |
155 | 155 | // Primary key. |
156 | - if ( 'PRI' === strtoupper( $info['Key'] ) ) { |
|
156 | + if ( 'PRI' === strtoupper( $info[ 'Key' ] ) ) { |
|
157 | 157 | $this->is_primary_key = true; |
158 | - if ( 'auto_increment' === $info['Extra'] ) { |
|
158 | + if ( 'auto_increment' === $info[ 'Extra' ] ) { |
|
159 | 159 | $this->is_auto_increment = true; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Unique key. |
164 | - $this->is_unique = ( 'UNI' === strtoupper( $info['Key'] ) ); |
|
164 | + $this->is_unique = ( 'UNI' === strtoupper( $info[ 'Key' ] ) ); |
|
165 | 165 | |
166 | 166 | // Comment. |
167 | - $this->comment = $info['Comment']; |
|
167 | + $this->comment = $info[ 'Comment' ]; |
|
168 | 168 | |
169 | 169 | // Collation. |
170 | - $this->collation = $info['Collation']; |
|
170 | + $this->collation = $info[ 'Collation' ]; |
|
171 | 171 | |
172 | 172 | // Is this column NULL? |
173 | - $this->nullable = ( 'YES' === $info['Null'] ); |
|
173 | + $this->nullable = ( 'YES' === $info[ 'Null' ] ); |
|
174 | 174 | |
175 | 175 | // Is this a foreign key? |
176 | 176 | if ( in_array( $this->get_name(), $this->get_table()->get_foreign_key_names(), true ) ) { |
@@ -309,14 +309,14 @@ discard block |
||
309 | 309 | public function get_xtype() { |
310 | 310 | $xtypes = self::get_xtypes(); |
311 | 311 | if ( $this->is_foreign_key() ) { |
312 | - return $xtypes['fk']; |
|
312 | + return $xtypes[ 'fk' ]; |
|
313 | 313 | } |
314 | 314 | if ( $this->is_boolean() ) { |
315 | - return $xtypes['boolean']; |
|
315 | + return $xtypes[ 'boolean' ]; |
|
316 | 316 | } |
317 | 317 | // Otherwise fall back on the first xtype with a matching type. |
318 | 318 | foreach ( $xtypes as $xtype ) { |
319 | - if ( strtoupper( $this->get_type() ) === $xtype['type'] ) { |
|
319 | + if ( strtoupper( $this->get_type() ) === $xtype[ 'type' ] ) { |
|
320 | 320 | return $xtype; |
321 | 321 | } |
322 | 322 | } |
@@ -516,22 +516,22 @@ discard block |
||
516 | 516 | $this->scale = null; |
517 | 517 | $this->options = null; |
518 | 518 | if ( preg_match( $varchar_pattern, $type_string, $matches ) ) { |
519 | - $this->type = $matches[1]; |
|
520 | - $this->size = (int) $matches[2]; |
|
519 | + $this->type = $matches[ 1 ]; |
|
520 | + $this->size = ( int ) $matches[ 2 ]; |
|
521 | 521 | } elseif ( preg_match( $decimal_pattern, $type_string, $matches ) ) { |
522 | 522 | $this->type = 'decimal'; |
523 | - $this->precision = $matches[1]; |
|
524 | - $this->scale = $matches[2]; |
|
523 | + $this->precision = $matches[ 1 ]; |
|
524 | + $this->scale = $matches[ 2 ]; |
|
525 | 525 | } elseif ( preg_match( $float_pattern, $type_string, $matches ) ) { |
526 | 526 | $this->type = 'float'; |
527 | - $this->precision = $matches[1]; |
|
528 | - $this->scale = $matches[2]; |
|
527 | + $this->precision = $matches[ 1 ]; |
|
528 | + $this->scale = $matches[ 2 ]; |
|
529 | 529 | } elseif ( preg_match( $integer_pattern, $type_string, $matches ) ) { |
530 | - $this->type = $matches[1]; |
|
531 | - $this->size = (int) $matches[2]; |
|
530 | + $this->type = $matches[ 1 ]; |
|
531 | + $this->size = ( int ) $matches[ 2 ]; |
|
532 | 532 | } elseif ( preg_match( $enum_pattern, $type_string, $matches ) ) { |
533 | - $this->type = $matches[1]; |
|
534 | - $values = explode( "','", $matches[2] ); |
|
533 | + $this->type = $matches[ 1 ]; |
|
534 | + $values = explode( "','", $matches[ 2 ] ); |
|
535 | 535 | $this->options = array_combine( $values, $values ); |
536 | 536 | } |
537 | 537 | } |
@@ -542,14 +542,14 @@ discard block |
||
542 | 542 | * @return string |
543 | 543 | */ |
544 | 544 | public function __toString() { |
545 | - $pk = ($this->is_primary_key) ? ' PK' : ''; |
|
546 | - $auto = ($this->is_auto_increment) ? ' AI' : ''; |
|
545 | + $pk = ( $this->is_primary_key ) ? ' PK' : ''; |
|
546 | + $auto = ( $this->is_auto_increment ) ? ' AI' : ''; |
|
547 | 547 | if ( $this->references ) { |
548 | 548 | $ref = ' References ' . $this->references . '.'; |
549 | 549 | } else { |
550 | 550 | $ref = ''; |
551 | 551 | } |
552 | - $size = ($this->size > 0) ? "($this->size)" : ''; |
|
552 | + $size = ( $this->size > 0 ) ? "($this->size)" : ''; |
|
553 | 553 | return $this->name . ' ' . strtoupper( $this->type ) . $size . $pk . $auto . $ref; |
554 | 554 | } |
555 | 555 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | public function get_current_column_definition() { |
562 | 562 | return self::get_column_definition( |
563 | 563 | $this->get_name(), |
564 | - $this->get_xtype()['name'], |
|
564 | + $this->get_xtype()[ 'name' ], |
|
565 | 565 | $this->get_size(), |
566 | 566 | $this->nullable(), |
567 | 567 | $this->get_default(), |
@@ -590,14 +590,14 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function alter( $new_name = null, $xtype_name = null, $size = null, $nullable = null, $default = null, $auto_increment = null, $unique = null, $comment = null, $target_table = null, $after = null ) { |
592 | 592 | // Any that have not been set explicitely should be unchanged. |
593 | - $new_name = ! is_null( $new_name ) ? (string) $new_name : $this->get_name(); |
|
594 | - $xtype_name = ! is_null( $xtype_name ) ? (string) $xtype_name : $this->get_xtype()['name']; |
|
593 | + $new_name = ! is_null( $new_name ) ? ( string ) $new_name : $this->get_name(); |
|
594 | + $xtype_name = ! is_null( $xtype_name ) ? ( string ) $xtype_name : $this->get_xtype()[ 'name' ]; |
|
595 | 595 | $size = ! is_null( $size ) ? $size : $this->get_size(); |
596 | - $nullable = ! is_null( $nullable ) ? (boolean) $nullable : $this->nullable(); |
|
597 | - $default = ! is_null( $default ) ? (string) $default : $this->get_default(); |
|
598 | - $auto_increment = ! is_null( $auto_increment ) ? (boolean) $auto_increment : $this->is_auto_increment(); |
|
599 | - $unique = ! is_null( $unique ) ? (boolean) $unique : $this->is_unique(); |
|
600 | - $comment = ! is_null( $comment ) ? (string) $comment : $this->get_comment(); |
|
596 | + $nullable = ! is_null( $nullable ) ? ( boolean ) $nullable : $this->nullable(); |
|
597 | + $default = ! is_null( $default ) ? ( string ) $default : $this->get_default(); |
|
598 | + $auto_increment = ! is_null( $auto_increment ) ? ( boolean ) $auto_increment : $this->is_auto_increment(); |
|
599 | + $unique = ! is_null( $unique ) ? ( boolean ) $unique : $this->is_unique(); |
|
600 | + $comment = ! is_null( $comment ) ? ( string ) $comment : $this->get_comment(); |
|
601 | 601 | $target_table = ! is_null( $target_table ) ? $target_table : $this->get_referenced_table(); |
602 | 602 | |
603 | 603 | // Check the current column definition. |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | if ( $this->is_unique() ) { |
613 | 613 | $sql = 'SHOW INDEXES FROM `' . $table->get_name() . '` WHERE Column_name LIKE "' . $this->get_name() . '"'; |
614 | 614 | foreach ( $wpdb->get_results( $sql, ARRAY_A ) as $index ) { |
615 | - $sql = "DROP INDEX `" . $index['Key_name'] . "` ON `" . $table->get_name() . "`"; |
|
615 | + $sql = "DROP INDEX `" . $index[ 'Key_name' ] . "` ON `" . $table->get_name() . "`"; |
|
616 | 616 | $wpdb->query( $sql ); |
617 | 617 | } |
618 | 618 | } |
@@ -670,12 +670,12 @@ discard block |
||
670 | 670 | public static function get_column_definition( $name, $xtype_name = null, $size = null, $nullable = true, $default = null, $auto_increment = null, $unique = null, $comment = null, $target_table = null, $after = null ) { |
671 | 671 | // Type. |
672 | 672 | $xtypes = self::get_xtypes(); |
673 | - $xtype = ( isset( $xtypes[ $xtype_name ] ) ) ? $xtypes[ $xtype_name ] : $xtypes['text_short']; |
|
674 | - $type_str = $xtype['type']; |
|
673 | + $xtype = ( isset( $xtypes[ $xtype_name ] ) ) ? $xtypes[ $xtype_name ] : $xtypes[ 'text_short' ]; |
|
674 | + $type_str = $xtype[ 'type' ]; |
|
675 | 675 | // Size or options. |
676 | 676 | $size_str = ''; |
677 | - if ( is_numeric( $xtype['sizes'] ) && $xtype['sizes'] > 0 ) { |
|
678 | - $size_str = '(' . ( $size ? : 50 ) . ')'; |
|
677 | + if ( is_numeric( $xtype[ 'sizes' ] ) && $xtype[ 'sizes' ] > 0 ) { |
|
678 | + $size_str = '(' . ( $size ?: 50 ) . ')'; |
|
679 | 679 | } |
680 | 680 | if ( 'enum' === $xtype_name ) { |
681 | 681 | // If not already wraped in quotes, explode and quote each option. |
@@ -688,14 +688,14 @@ discard block |
||
688 | 688 | $size_str = '(1)'; |
689 | 689 | } |
690 | 690 | // Nullable. |
691 | - $null_str = (true === $nullable) ? 'NULL' : 'NOT NULL'; |
|
691 | + $null_str = ( true === $nullable ) ? 'NULL' : 'NOT NULL'; |
|
692 | 692 | // Default. |
693 | 693 | $default_str = ''; |
694 | 694 | if ( 'text_long' !== $xtype_name ) { |
695 | 695 | $default_str = ! empty( $default ) ? "DEFAULT '$default'" : ( $nullable ? 'DEFAULT NULL' : '' ); |
696 | 696 | } |
697 | 697 | $auto_increment_str = ''; |
698 | - if ( $auto_increment && 'integer' === $xtype['name'] ) { |
|
698 | + if ( $auto_increment && 'integer' === $xtype[ 'name' ] ) { |
|
699 | 699 | $auto_increment_str = 'AUTO_INCREMENT'; |
700 | 700 | } |
701 | 701 | $unique_str = $unique ? 'UNIQUE' : ''; |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | . ' (`' . $pk_col->get_name() . '`)'; |
717 | 717 | $type_str = $pk_col->get_type(); |
718 | 718 | $size_str = '(' . $pk_col->get_size() . ')'; |
719 | - $sign_str = ($pk_col->is_unsigned()) ? 'UNSIGNED' : ''; |
|
719 | + $sign_str = ( $pk_col->is_unsigned() ) ? 'UNSIGNED' : ''; |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | // Put it all together. |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * View a report. |
22 | 22 | * |
23 | 23 | * @param string[] $args The request arguments. |
24 | - * @return type |
|
24 | + * @return null|string |
|
25 | 25 | */ |
26 | 26 | public function index( $args ) { |
27 | 27 | $db = new Database( $this->wpdb ); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | public function index( $args ) { |
27 | 27 | $db = new Database( $this->wpdb ); |
28 | - $id = isset( $args['id'] ) ? $args['id'] : Reports::DEFAULT_REPORT_ID; |
|
28 | + $id = isset( $args[ 'id' ] ) ? $args[ 'id' ] : Reports::DEFAULT_REPORT_ID; |
|
29 | 29 | $reports = new Reports( $db ); |
30 | 30 | $template = $reports->get_template( $id ); |
31 | 31 | $out = $template->render(); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $db = new Database( $this->wpdb ); |
48 | 48 | $out = array(); |
49 | 49 | foreach ( $db->get_tables( false ) as $table ) { |
50 | - $out[] = array( |
|
50 | + $out[ ] = array( |
|
51 | 51 | 'value' => $table->get_name(), |
52 | 52 | 'label' => $table->get_title(), |
53 | 53 | ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $out = array(); |
66 | 66 | foreach ( $tables as $table ) { |
67 | 67 | if ( Grants::current_user_can( Grants::CREATE, $table->get_name() ) ) { |
68 | - $out[] = $table->get_name(); |
|
68 | + $out[ ] = $table->get_name(); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | return $out; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return array |
82 | 82 | */ |
83 | 83 | public function foreign_key_values( \WP_REST_Request $request ) { |
84 | - if ( ! isset( $this->get['term'] ) ) { |
|
84 | + if ( ! isset( $this->get[ 'term' ] ) ) { |
|
85 | 85 | return array(); |
86 | 86 | } |
87 | 87 | $db = new Database( $this->wpdb ); |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | return array(); |
91 | 91 | } |
92 | 92 | // First get any exact matches. |
93 | - $out = $this->foreign_key_values_build( $table, '=', $this->get['term'] ); |
|
93 | + $out = $this->foreign_key_values_build( $table, '=', $this->get[ 'term' ] ); |
|
94 | 94 | // Then get any 'contains' matches. |
95 | - $out += $this->foreign_key_values_build( $table, 'like', '%' . $this->get['term'] . '%' ); |
|
95 | + $out += $this->foreign_key_values_build( $table, 'like', '%' . $this->get[ 'term' ] . '%' ); |
|
96 | 96 | return $out; |
97 | 97 | } |
98 | 98 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public static function add_path( $new_path ) { |
83 | 83 | $path = realpath( $new_path ); |
84 | 84 | if ( ! in_array( $path, self::$paths, true ) ) { |
85 | - self::$paths[] = $path; |
|
85 | + self::$paths[ ] = $path; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | foreach ( self::$paths as $path ) { |
106 | 106 | $dir = $path . '/' . ltrim( $directory, '/' ); |
107 | 107 | foreach ( preg_grep( '/^[^\.].*\.(twig|html)$/', scandir( $dir ) ) as $file ) { |
108 | - $templates[] = $directory . '/' . $file; |
|
108 | + $templates[ ] = $directory . '/' . $file; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | return $templates; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | * @param string $message The message to display. |
151 | 151 | */ |
152 | 152 | public function add_notice( $type, $message ) { |
153 | - $this->data['notices'][] = array( |
|
153 | + $this->data[ 'notices' ][ ] = array( |
|
154 | 154 | 'type' => $type, |
155 | 155 | 'message' => $message, |
156 | 156 | ); |
157 | - set_transient( $this->transient_notices, $this->data['notices'] ); |
|
157 | + set_transient( $this->transient_notices, $this->data[ 'notices' ] ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $twig->addFunction( $f, new \Twig_SimpleFunction( $f, $f ) ); |
183 | 183 | } |
184 | 184 | // Handle wp_nonce_field() differently in order to default it to returning the string. |
185 | - $wp_nonce_field = new \Twig_SimpleFunction( 'wp_nonce_field', function ( $action = -1, $name = "_wpnonce", $referer = true, $echo = false ) { |
|
185 | + $wp_nonce_field = new \Twig_SimpleFunction( 'wp_nonce_field', function( $action = -1, $name = "_wpnonce", $referer = true, $echo = false ) { |
|
186 | 186 | return wp_nonce_field( $action, $name, $referer, $echo ); |
187 | 187 | } ); |
188 | 188 | $twig->addFunction( $wp_nonce_field ); |
@@ -135,7 +135,7 @@ |
||
135 | 135 | * Get an item from this template's data. |
136 | 136 | * |
137 | 137 | * @param string $name The name of the template variable. |
138 | - * @return mixed |
|
138 | + * @return string |
|
139 | 139 | */ |
140 | 140 | public function __get( $name ) { |
141 | 141 | return $this->data[ $name ]; |
@@ -163,10 +163,10 @@ |
||
163 | 163 | ); |
164 | 164 | // Daft workaround for https://core.trac.wordpress.org/ticket/15158 . |
165 | 165 | if ( ! is_null( $old_val ) ) { |
166 | - $data['old_value'] = $old_val; |
|
166 | + $data[ 'old_value' ] = $old_val; |
|
167 | 167 | } |
168 | 168 | if ( ! is_null( $new_val ) ) { |
169 | - $data['new_value'] = $new_val; |
|
169 | + $data[ 'new_value' ] = $new_val; |
|
170 | 170 | } |
171 | 171 | // Save the change record. |
172 | 172 | $this->wpdb->insert( $this->changes_name(), $data ); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @param Table $table The table into which the record is being saved. |
118 | 118 | * @param string $pk_value The primary key of the record being saved. May be null. |
119 | - * @return boolean |
|
119 | + * @return false|null |
|
120 | 120 | */ |
121 | 121 | public function before_save( Table $table, $pk_value ) { |
122 | 122 | // Don't save changes to the changes tables. |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @param Table $table The table the record is being saved in. |
139 | 139 | * @param Record $new_record The record, after being saved. |
140 | - * @return boolean |
|
140 | + * @return false|null |
|
141 | 141 | */ |
142 | 142 | public function after_save( Table $table, Record $new_record ) { |
143 | 143 | // Don't save changes to the changes tables. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct( $table, $data = array() ) { |
43 | 43 | $this->table = $table; |
44 | - $this->data = (object) $data; |
|
44 | + $this->data = ( object ) $data; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $title_parts = array(); |
176 | 176 | foreach ( $this->table->get_columns() as $col ) { |
177 | 177 | $col_name = $col->get_name() . self::FKTITLE; |
178 | - $title_parts[] = $this->$col_name(); |
|
178 | + $title_parts[ ] = $this->$col_name(); |
|
179 | 179 | } |
180 | 180 | return '[ ' . join( ' | ', $title_parts ) . ' ]'; |
181 | 181 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'table' => $this->table->get_name(), |
228 | 228 | ); |
229 | 229 | if ( $include_ident && false !== $this->get_primary_key() ) { |
230 | - $params['ident'] = $this->get_primary_key(); |
|
230 | + $params[ 'ident' ] = $this->get_primary_key(); |
|
231 | 231 | } |
232 | 232 | if ( is_array( $extra_params ) ) { |
233 | 233 | $params = array_merge( $params, $extra_params ); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected function set_up( $args ) { |
40 | 40 | $db = new Database( $this->wpdb ); |
41 | - $this->table = $db->get_table( $args['table'] ); |
|
41 | + $this->table = $db->get_table( $args[ 'table' ] ); |
|
42 | 42 | |
43 | 43 | // Check that a point column exists. |
44 | 44 | $points = $this->table->get_columns( 'point' ); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->point_col_name = $point_col->get_name(); |
50 | 50 | |
51 | 51 | // Apply filters. |
52 | - $filter_param = (isset( $args['filter'] )) ? $args['filter'] : array(); |
|
52 | + $filter_param = ( isset( $args[ 'filter' ] ) ) ? $args[ 'filter' ] : array(); |
|
53 | 53 | $this->table->add_filters( $filter_param ); |
54 | 54 | $this->table->add_filter( $this->point_col_name, 'not empty', '' ); |
55 | 55 | } |