@@ -13,13 +13,16 @@ |
||
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
16 | - class DBextended extends DBlayer { // Bad. |
|
16 | + class DBextended extends DBlayer { |
|
17 | +// Bad. |
|
17 | 18 | } |
18 | 19 | |
19 | - class DBextender implements PDO { // Ok -> resolves to \My\PDO. |
|
20 | + class DBextender implements PDO { |
|
21 | +// Ok -> resolves to \My\PDO. |
|
20 | 22 | } |
21 | 23 | |
22 | - class DBextendes implements \PDO { // Bad -> fully qualified as \PDO. |
|
24 | + class DBextendes implements \PDO { |
|
25 | +// Bad -> fully qualified as \PDO. |
|
23 | 26 | } |
24 | 27 | |
25 | 28 | $db0 = new \DBlayer; // Ok - fully qualified as \DBlayer. |
@@ -2,24 +2,24 @@ discard block |
||
2 | 2 | |
3 | 3 | // Bad, needs nonce check. |
4 | 4 | function bar() { |
5 | - if ( ! isset( $_POST['test'] ) ) { // Bad. |
|
5 | + if ( ! isset( $_POST[ 'test' ] ) ) { // Bad. |
|
6 | 6 | return; |
7 | 7 | } |
8 | 8 | |
9 | - do_something( $_POST['test'] ); // Bad. |
|
9 | + do_something( $_POST[ 'test' ] ); // Bad. |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | // Good, has an nonce check. |
13 | 13 | function ajax_process() { |
14 | 14 | check_ajax_referer( 'something' ); |
15 | 15 | |
16 | - update_post_meta( (int) $_POST['id'], 'a_key', $_POST['a_value'] ); |
|
16 | + update_post_meta( (int) $_POST[ 'id' ], 'a_key', $_POST[ 'a_value' ] ); |
|
17 | 17 | } |
18 | 18 | add_action( 'wp_ajax_process', 'ajax_process' ); |
19 | 19 | |
20 | 20 | // It's also OK to check with isset() before the the nonce check. |
21 | 21 | function foo() { |
22 | - if ( ! isset( $_POST['test'] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
22 | + if ( ! isset( $_POST[ 'test' ] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
23 | 23 | exit; |
24 | 24 | } |
25 | 25 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | // Doing other things with the request params before the nonce check is prohibited. |
30 | 30 | function process() { |
31 | - do_something( $_POST['foo'] ); // Bad. |
|
31 | + do_something( $_POST[ 'foo' ] ); // Bad. |
|
32 | 32 | |
33 | - if ( ! isset( $_POST['test'] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
33 | + if ( ! isset( $_POST[ 'test' ] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
34 | 34 | exit; |
35 | 35 | } |
36 | 36 | |
@@ -41,23 +41,23 @@ discard block |
||
41 | 41 | |
42 | 42 | // Bad, needs nonce check. |
43 | 43 | function bar() { |
44 | - if ( ! isset( $_POST['test'] ) ) { // Bad. |
|
44 | + if ( ! isset( $_POST[ 'test' ] ) ) { // Bad. |
|
45 | 45 | return; |
46 | 46 | } |
47 | 47 | |
48 | - do_something( $_POST['test'] ); // Bad. |
|
48 | + do_something( $_POST[ 'test' ] ); // Bad. |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // Good, has an nonce check. |
52 | 52 | function ajax_process() { |
53 | 53 | check_ajax_referer( 'something' ); |
54 | 54 | |
55 | - update_post_meta( (int) $_POST['id'], 'a_key', $_POST['a_value'] ); |
|
55 | + update_post_meta( (int) $_POST[ 'id' ], 'a_key', $_POST[ 'a_value' ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // It's also OK to check with isset() before the the nonce check. |
59 | 59 | function foo() { |
60 | - if ( ! isset( $_POST['test'] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
60 | + if ( ! isset( $_POST[ 'test' ] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
61 | 61 | exit; |
62 | 62 | } |
63 | 63 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | |
67 | 67 | // Doing other things with the request params before the nonce check is prohibited. |
68 | 68 | function process() { |
69 | - do_something( $_POST['foo'] ); // Bad. |
|
69 | + do_something( $_POST[ 'foo' ] ); // Bad. |
|
70 | 70 | |
71 | - if ( ! isset( $_POST['test'] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
71 | + if ( ! isset( $_POST[ 'test' ] ) || ! wp_verify_nonce( 'some_action' ) ) { |
|
72 | 72 | exit; |
73 | 73 | } |
74 | 74 | |
@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | // Assignments are allowed. |
80 | 80 | function foo_2() { |
81 | 81 | $_POST = array( 'a' => 'b' ); // OK. |
82 | - $_POST['test'] = somethin(); // OK. |
|
83 | - $_POST['settings'][ $setting ] = 'bb'; // OK. |
|
82 | + $_POST[ 'test' ] = somethin(); // OK. |
|
83 | + $_POST[ 'settings' ][ $setting ] = 'bb'; // OK. |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Particular cases can be whitelisted with a comment. |
87 | 87 | function foo_3() { |
88 | - bar( $_POST['var'] ); // WPCS: CSRF OK. |
|
89 | - bar( $_POST['var'] ); // Bad. |
|
88 | + bar( $_POST[ 'var' ] ); // WPCS: CSRF OK. |
|
89 | + bar( $_POST[ 'var' ] ); // Bad. |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // We need to account for when there are multiple vars in a single isset(). |
93 | 93 | function foo_4() { |
94 | - if ( ! isset( $_POST['foo'], $_POST['bar'], $_POST['_wpnonce'] ) ) { // OK. |
|
94 | + if ( ! isset( $_POST[ 'foo' ], $_POST[ 'bar' ], $_POST[ '_wpnonce' ] ) ) { // OK. |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | // Sanitization before the nonce check is permitted. |
102 | 102 | function sanitization_allowed() { |
103 | 103 | |
104 | - $foo = (int) $_POST['foo']; // OK. |
|
105 | - $bar = sanitize_key( $_POST['bar'] ); // OK. |
|
104 | + $foo = (int) $_POST[ 'foo' ]; // OK. |
|
105 | + $bar = sanitize_key( $_POST[ 'bar' ] ); // OK. |
|
106 | 106 | |
107 | 107 | check_ajax_referer( "something-{$foo}-{$bar}" ); |
108 | 108 | } |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | // The value must only be sanitized though. |
111 | 111 | function foo_5() { |
112 | 112 | |
113 | - do_something( (int) $_POST['foo'] ); // Bad. |
|
114 | - do_something( sanitize_key( $_POST['bar'] ) ); // Bad. |
|
113 | + do_something( (int) $_POST[ 'foo' ] ); // Bad. |
|
114 | + do_something( sanitize_key( $_POST[ 'bar' ] ) ); // Bad. |
|
115 | 115 | |
116 | 116 | check_ajax_referer( 'something' ); |
117 | 117 | } |
@@ -2,7 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | // Bad, needs nonce check. |
4 | 4 | function bar() { |
5 | - if ( ! isset( $_POST['test'] ) ) { // Bad. |
|
5 | + if ( ! isset( $_POST['test'] ) ) { |
|
6 | +// Bad. |
|
6 | 7 | return; |
7 | 8 | } |
8 | 9 | |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | |
42 | 43 | // Bad, needs nonce check. |
43 | 44 | function bar() { |
44 | - if ( ! isset( $_POST['test'] ) ) { // Bad. |
|
45 | + if ( ! isset( $_POST['test'] ) ) { |
|
46 | +// Bad. |
|
45 | 47 | return; |
46 | 48 | } |
47 | 49 | |
@@ -91,7 +93,8 @@ discard block |
||
91 | 93 | |
92 | 94 | // We need to account for when there are multiple vars in a single isset(). |
93 | 95 | function foo_4() { |
94 | - if ( ! isset( $_POST['foo'], $_POST['bar'], $_POST['_wpnonce'] ) ) { // OK. |
|
96 | + if ( ! isset( $_POST['foo'], $_POST['bar'], $_POST['_wpnonce'] ) ) { |
|
97 | +// OK. |
|
95 | 98 | return; |
96 | 99 | } |
97 | 100 |
@@ -6,12 +6,12 @@ |
||
6 | 6 | do_action( "admin_head-$hook_suffix" ); |
7 | 7 | do_action( 'admin_head-media-upload_popup' ); |
8 | 8 | apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); |
9 | -apply_filters( "current_theme-supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); |
|
9 | +apply_filters( "current_theme-supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); |
|
10 | 10 | |
11 | 11 | // These should still give warnings. |
12 | 12 | do_action( "admin_head*$hook_suffix" ); // Warning - use underscore. |
13 | 13 | do_action( 'admin_head.media.upload_popup' ); // Warning - use underscore. |
14 | 14 | apply_filters( "bulk_actions {$this->screen->id}", $this->_actions ); // Warning - use underscore. |
15 | -apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); // Warning - use underscore. |
|
15 | +apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // Warning - use underscore. |
|
16 | 16 | |
17 | 17 | // @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters _ |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | do_action( "admin_head-$hook_suffix" ); // Warning - use underscore. |
9 | 9 | do_action( 'admin_head.media.upload_popup' ); // Warning - use underscore. |
10 | 10 | apply_filters( "bulk_actions {$this->screen->id}", $this->_actions ); // Warning - use underscore. |
11 | -apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); // Warning - use underscore. |
|
11 | +apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // Warning - use underscore. |
|
12 | 12 | |
13 | 13 | // Simple strings. |
14 | 14 | do_action( "adminHead" ); // Error - use lowercase. |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | |
23 | 23 | // Compound hook names. |
24 | 24 | do_action( 'admin_head_' . $Type . '_action' ); // ok. |
25 | -do_action( 'admin_head_' . get_ID() . '_action' ); // Ok. |
|
25 | +do_action( 'admin_head_' . get_ID() . '_action' ); // Ok. |
|
26 | 26 | do_action( 'admin_head_' . $post->ID . '_action' ); // Ok. |
27 | 27 | |
28 | 28 | do_action( 'admin_Head_' . $Type . '_Action' ); // Error - use lowercase. |
29 | -do_action( 'admin_Head_' . get_ID() . '_Action' ); // Error - use lowercase. |
|
29 | +do_action( 'admin_Head_' . get_ID() . '_Action' ); // Error - use lowercase. |
|
30 | 30 | do_action( 'admin_Head_' . $post->ID . '_Action' ); // Error - use lowercase. |
31 | 31 | |
32 | 32 | do_action( |
@@ -36,47 +36,47 @@ discard block |
||
36 | 36 | |
37 | 37 | // More complex strings. |
38 | 38 | do_action( "admin_head_$Post" ); // Ok. |
39 | -do_action( "admin_head_$Post[1]_action" ); // Ok. |
|
40 | -do_action( "admin_head_$Post[Test]_action" ); // Ok. |
|
39 | +do_action( "admin_head_$Post[ 1 ]_action" ); // Ok. |
|
40 | +do_action( "admin_head_$Post[ Test ]_action" ); // Ok. |
|
41 | 41 | do_action( "admin_head_${Post}_action" ); // Ok. |
42 | 42 | do_action( "admin_head_$Post->ID" ); // Ok. |
43 | 43 | do_action( "admin_head_{$Post}" ); // Ok. |
44 | -do_action( "admin_head_{$Post['Key']}_action" ); // Ok. |
|
45 | -do_action( "admin_head_{$Post[1][2]}_action" ); // Ok. |
|
44 | +do_action( "admin_head_{$Post[ 'Key' ]}_action" ); // Ok. |
|
45 | +do_action( "admin_head_{$Post[ 1 ][ 2 ]}_action" ); // Ok. |
|
46 | 46 | do_action( "admin_head_{$post->ID}_action" ); // Ok. |
47 | -do_action( "admin_head_{$obj->Values[3]->name}_action" ); // Ok. |
|
47 | +do_action( "admin_head_{$obj->Values[ 3 ]->name}_action" ); // Ok. |
|
48 | 48 | do_action( "admin_head_{${$Name}}_action" ); // Ok. |
49 | -do_action( "admin_head_{$foo->{$baz[1]}}_action" ); // Ok. |
|
49 | +do_action( "admin_head_{$foo->{$baz[ 1 ]}}_action" ); // Ok. |
|
50 | 50 | do_action( "admin_head_{${getName()}}_action" ); // Ok. |
51 | 51 | do_action( "admin_head_{${$object->getName()}}_action" ); // Ok. |
52 | 52 | |
53 | 53 | do_action( "admin_Head_$Post" ); // Error - use lowercase. |
54 | -do_action( "admin_Head_$Post[1]_Action" ); // Error - use lowercase. |
|
55 | -do_action( "admin_Head_$Post[Test]_Action" ); // Error - use lowercase. |
|
54 | +do_action( "admin_Head_$Post[ 1 ]_Action" ); // Error - use lowercase. |
|
55 | +do_action( "admin_Head_$Post[ Test ]_Action" ); // Error - use lowercase. |
|
56 | 56 | do_action( "admin_Head_${Post}_Action" ); // Error - use lowercase. |
57 | 57 | do_action( "admin_Head_$Post->ID" ); // Error - use lowercase. |
58 | -do_action( "admin_Head_{$Post}" ); // Error - use lowercase. |
|
59 | -do_action( "admin_Head_{$Post['Key']}_Action" ); // Error - use lowercase. |
|
60 | -do_action( "admin_Head_{$Post[1][2]}_Action" ); // Error - use lowercase. |
|
58 | +do_action( "admin_Head_{$Post}" ); // Error - use lowercase. |
|
59 | +do_action( "admin_Head_{$Post[ 'Key' ]}_Action" ); // Error - use lowercase. |
|
60 | +do_action( "admin_Head_{$Post[ 1 ][ 2 ]}_Action" ); // Error - use lowercase. |
|
61 | 61 | do_action( "admin_Head_{$post->ID}_Action" ); // Error - use lowercase. |
62 | -do_action( "admin_Head_{$obj->Values[3]->name}_Action" ); // Error - use lowercase. |
|
62 | +do_action( "admin_Head_{$obj->Values[ 3 ]->name}_Action" ); // Error - use lowercase. |
|
63 | 63 | do_action( "admin_Head_{${$Name}}_Action" ); // Error - use lowercase. |
64 | -do_action( "admin_Head_{$foo->{$baz[1]}}_Action" ); // Error - use lowercase. |
|
64 | +do_action( "admin_Head_{$foo->{$baz[ 1 ]}}_Action" ); // Error - use lowercase. |
|
65 | 65 | do_action( "admin_Head_{${getName()}}_Action" ); // Error - use lowercase. |
66 | 66 | do_action( "admin_Head_{${$object->getName()}}_Action" ); // Error - use lowercase. |
67 | 67 | |
68 | 68 | do_action( "admin_Head_$Post admin_Head_$Post" ); // Error - use lowercase + warning about space. |
69 | -do_action( "admin_Head_$Post[1]_Action_$Post[1]_Action" ); // Error - use lowercase. |
|
70 | -do_action( "admin_Head_$Post[Test]_Action_$Post[Test]_Action" ); // Error - use lowercase. |
|
69 | +do_action( "admin_Head_$Post[ 1 ]_Action_$Post[ 1 ]_Action" ); // Error - use lowercase. |
|
70 | +do_action( "admin_Head_$Post[ Test ]_Action_$Post[ Test ]_Action" ); // Error - use lowercase. |
|
71 | 71 | do_action( "admin_Head_${Post}_Action_${Post}_Action" ); // Error - use lowercase. |
72 | 72 | do_action( "admin_Head_$Post->ID admin_Head_$Post->ID" ); // Error - use lowercase + warning about space. |
73 | -do_action( "admin_Head_{$Post}_admin_Head_{$Post}" ); // Error - use lowercase. |
|
74 | -do_action( "admin_Head_{$Post['Key']}_Action_{$Post['Key']}_Action" ); // Error - use lowercase. |
|
75 | -do_action( "admin_Head_{$Post[1][2]}_Action_{$Post[1][2]}_Action" ); // Error - use lowercase. |
|
73 | +do_action( "admin_Head_{$Post}_admin_Head_{$Post}" ); // Error - use lowercase. |
|
74 | +do_action( "admin_Head_{$Post[ 'Key' ]}_Action_{$Post[ 'Key' ]}_Action" ); // Error - use lowercase. |
|
75 | +do_action( "admin_Head_{$Post[ 1 ][ 2 ]}_Action_{$Post[ 1 ][ 2 ]}_Action" ); // Error - use lowercase. |
|
76 | 76 | do_action( "admin_Head_{$post->ID}_Action_{$post->ID}_Action" ); // Error - use lowercase. |
77 | -do_action( "admin_Head_{$obj->Values[3]->name}-Action_{$obj->Values[3]->name}_Action" ); // Error - use lowercase + warning about dash. |
|
77 | +do_action( "admin_Head_{$obj->Values[ 3 ]->name}-Action_{$obj->Values[ 3 ]->name}_Action" ); // Error - use lowercase + warning about dash. |
|
78 | 78 | do_action( "admin_Head_{${$Name}}_Action_{${$Name}}_Action" ); // Error - use lowercase. |
79 | -do_action( "admin_Head_{$foo->{$baz[1]}}_Action_{$foo->{$baz[1]}}_Action" ); // Error - use lowercase. |
|
79 | +do_action( "admin_Head_{$foo->{$baz[ 1 ]}}_Action_{$foo->{$baz[ 1 ]}}_Action" ); // Error - use lowercase. |
|
80 | 80 | do_action( "admin_Head_{${getName()}}_Action_{${getName()}}_Action" ); // Error - use lowercase. |
81 | 81 | do_action( "admin_Head_{${$object->getName()}}_Action_{${$object->getName()}}_Action" ); // Error - use lowercase. |
82 | 82 |
@@ -6,12 +6,12 @@ |
||
6 | 6 | do_action( "admin_head-$hook_suffix" ); |
7 | 7 | do_action( 'admin_head.media-upload_popup' ); |
8 | 8 | apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); |
9 | -apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); |
|
9 | +apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); |
|
10 | 10 | |
11 | 11 | // These should still give warnings. |
12 | 12 | do_action( "admin_head*$hook_suffix" ); // Warning - use underscore. |
13 | 13 | do_action( 'admin_head&media+upload_popup' ); // Warning - use underscore. |
14 | 14 | apply_filters( "bulk_actions {$this->screen->id}", $this->_actions ); // Warning - use underscore. |
15 | -apply_filters( "current_theme#supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); // Warning - use underscore. |
|
15 | +apply_filters( "current_theme#supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // Warning - use underscore. |
|
16 | 16 | |
17 | 17 | // @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters _ |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | echo "Hello $varname"; |
38 | 38 | echo "Hello $_varName"; // Bad. |
39 | 39 | |
40 | -echo 'Hello '.$varName; // Bad. |
|
41 | -echo 'Hello '.$var_name; |
|
42 | -echo 'Hello '.$varname; |
|
43 | -echo 'Hello '.$_varName; // Bad. |
|
40 | +echo 'Hello ' . $varName; // Bad. |
|
41 | +echo 'Hello ' . $var_name; |
|
42 | +echo 'Hello ' . $varname; |
|
43 | +echo 'Hello ' . $_varName; // Bad. |
|
44 | 44 | |
45 | -echo $_SERVER['var_name']; |
|
46 | -echo $_REQUEST['var_name']; |
|
47 | -echo $_GET['var_name']; |
|
48 | -echo $_POST['var_name']; |
|
49 | -echo $GLOBALS['var_name']; |
|
45 | +echo $_SERVER[ 'var_name' ]; |
|
46 | +echo $_REQUEST[ 'var_name' ]; |
|
47 | +echo $_GET[ 'var_name' ]; |
|
48 | +echo $_POST[ 'var_name' ]; |
|
49 | +echo $GLOBALS[ 'var_name' ]; |
|
50 | 50 | |
51 | 51 | echo MyClass::$varName; // Bad. |
52 | 52 | echo MyClass::$var_name; |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | echo $object_name->_varName2; // Bad. |
65 | 65 | echo $object_name->VAR_name; // Bad. |
66 | 66 | |
67 | -echo $this->myFunction($one, $two); |
|
68 | -echo $object->myFunction($one_two); |
|
67 | +echo $this->myFunction( $one, $two ); |
|
68 | +echo $object->myFunction( $one_two ); |
|
69 | 69 | |
70 | 70 | $error = "format is \$GLOBALS['$varName']"; // Bad. |
71 | 71 | |
72 | -echo $_SESSION['var_name']; |
|
73 | -echo $_FILES['var_name']; |
|
74 | -echo $_ENV['var_name']; |
|
75 | -echo $_COOKIE['var_name']; |
|
72 | +echo $_SESSION[ 'var_name' ]; |
|
73 | +echo $_FILES[ 'var_name' ]; |
|
74 | +echo $_ENV[ 'var_name' ]; |
|
75 | +echo $_COOKIE[ 'var_name' ]; |
|
76 | 76 | |
77 | 77 | $XML = 'hello'; // Bad. |
78 | 78 | $myXML = 'hello'; // Bad. |
@@ -96,7 +96,8 @@ discard block |
||
96 | 96 | public $_public_leading_underscore; |
97 | 97 | private $private_no_underscore_loading; |
98 | 98 | |
99 | - function Bar( $VARname ) { // Bad. |
|
99 | + function Bar( $VARname ) { |
|
100 | +// Bad. |
|
100 | 101 | $localVariable = false; // Bad. |
101 | 102 | echo Some_Class::$VarName; // Bad. |
102 | 103 | echo $this->VAR_name; // Bad. |
@@ -105,7 +106,8 @@ discard block |
||
105 | 106 | echo $this->_VAR_name; // Bad. |
106 | 107 | } |
107 | 108 | |
108 | - function Baz( $var_name ) { // Ok. |
|
109 | + function Baz( $var_name ) { |
|
110 | +// Ok. |
|
109 | 111 | $local_variable = false; // Ok. |
110 | 112 | echo Some_Class::$var_name; // Ok. |
111 | 113 | echo $this->var_name; // Ok. |
@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | class WpMyPluginName {} // Good. |
6 | 6 | |
7 | -class wpMyPluginName{} // Bad, not in camel caps. |
|
7 | +class wpMyPluginName {} // Bad, not in camel caps. |
@@ -52,30 +52,30 @@ |
||
52 | 52 | |
53 | 53 | // This is OK. |
54 | 54 | class A_Class_With_Really_Long_Name |
55 | - extends Another_Class_With_A_Really_Long_Name { |
|
55 | + extends Another_Class_With_A_Really_Long_Name { |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
59 | 59 | // This is OK too. |
60 | 60 | class A_Class_With_Really_Long_Name_2 |
61 | - extends Another_Class_With_A_Really_Long_Name |
|
62 | - implements Some_Interface_With_A_Long_Name, |
|
63 | - Another_Interface_With_A_Long_Name { |
|
61 | + extends Another_Class_With_A_Really_Long_Name |
|
62 | + implements Some_Interface_With_A_Long_Name, |
|
63 | + Another_Interface_With_A_Long_Name { |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
67 | 67 | // But this is not. |
68 | 68 | class A_Class_With_Really_Long_Name_3 |
69 | - extends Another_Class_With_A_Really_Long_Name |
|
69 | + extends Another_Class_With_A_Really_Long_Name |
|
70 | 70 | { |
71 | 71 | |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Nor is this. |
75 | 75 | class A_Class_With_Really_Long_Name_4 |
76 | - extends Another_Class_With_A_Really_Long_Name |
|
77 | - implements Some_Interface_With_A_Long_Name, |
|
78 | - Another_Interface_With_A_Long_Name |
|
76 | + extends Another_Class_With_A_Really_Long_Name |
|
77 | + implements Some_Interface_With_A_Long_Name, |
|
78 | + Another_Interface_With_A_Long_Name |
|
79 | 79 | { |
80 | 80 | |
81 | 81 | } |
@@ -35,16 +35,16 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | // These should all be flagged for wrong whitespace before opening brace. |
38 | -interface Test_Interface_Bad_C { |
|
38 | +interface Test_Interface_Bad_C { |
|
39 | 39 | } |
40 | 40 | |
41 | -class Test_Class_Bad_G { |
|
41 | +class Test_Class_Bad_G { |
|
42 | 42 | } |
43 | 43 | |
44 | -class Test_Class_Bad_H extends Test_Class_Bad_G { |
|
44 | +class Test_Class_Bad_H extends Test_Class_Bad_G { |
|
45 | 45 | } |
46 | 46 | |
47 | -class Test_Class_Bad_I implements Test_Interface_Bad_C{ |
|
47 | +class Test_Class_Bad_I implements Test_Interface_Bad_C { |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // This one should be flagged as a potential parse error. |
@@ -15,36 +15,31 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | // These are all incorrect. |
18 | -interface Test_Interface_Bad_A |
|
19 | -{ // There should be no content after the brace. |
|
18 | +interface Test_Interface_Bad_A { |
|
19 | +// There should be no content after the brace. |
|
20 | 20 | } |
21 | 21 | |
22 | -class Test_Class_Bad_A |
|
23 | - { |
|
22 | +class Test_Class_Bad_A { |
|
24 | 23 | } |
25 | 24 | |
26 | -class Test_Class_Bad_B extends Test_Class_Bad_A |
|
27 | - |
|
28 | -{ // There should be no content after the brace. |
|
25 | +class Test_Class_Bad_B extends Test_Class_Bad_A { |
|
26 | +// There should be no content after the brace. |
|
29 | 27 | } |
30 | 28 | |
31 | -class Test_Class_Bad_C implements Test_Interface_Bad_A |
|
32 | - |
|
33 | - |
|
34 | -{ |
|
29 | +class Test_Class_Bad_C implements Test_Interface_Bad_A { |
|
35 | 30 | } |
36 | 31 | |
37 | 32 | // These should all be flagged for wrong whitespace before opening brace. |
38 | -interface Test_Interface_Bad_C { |
|
33 | +interface Test_Interface_Bad_C { |
|
39 | 34 | } |
40 | 35 | |
41 | -class Test_Class_Bad_G { |
|
36 | +class Test_Class_Bad_G { |
|
42 | 37 | } |
43 | 38 | |
44 | -class Test_Class_Bad_H extends Test_Class_Bad_G { |
|
39 | +class Test_Class_Bad_H extends Test_Class_Bad_G { |
|
45 | 40 | } |
46 | 41 | |
47 | -class Test_Class_Bad_I implements Test_Interface_Bad_C{ |
|
42 | +class Test_Class_Bad_I implements Test_Interface_Bad_C { |
|
48 | 43 | } |
49 | 44 | |
50 | 45 | // This one should be flagged as a potential parse error. |
@@ -66,8 +61,7 @@ discard block |
||
66 | 61 | |
67 | 62 | // But this is not. |
68 | 63 | class A_Class_With_Really_Long_Name_3 |
69 | - extends Another_Class_With_A_Really_Long_Name |
|
70 | - { |
|
64 | + extends Another_Class_With_A_Really_Long_Name { |
|
71 | 65 | |
72 | 66 | } |
73 | 67 |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | // Issue:#53. |
23 | 23 | function custom_column_display( $column, $post_id ) |
24 | 24 | { |
25 | - global $post; |
|
26 | - switch ( $column ) { |
|
27 | - case 'some_number' : |
|
28 | - echo (int) $test; |
|
29 | - echo (int) get_post_meta( $post_id, SOME_NUMBER, true ); |
|
30 | - break; |
|
31 | - } |
|
25 | + global $post; |
|
26 | + switch ( $column ) { |
|
27 | + case 'some_number' : |
|
28 | + echo (int) $test; |
|
29 | + echo (int) get_post_meta( $post_id, SOME_NUMBER, true ); |
|
30 | + break; |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | esc_html_e( 'Something' ); // Ok. |
161 | 161 | |
162 | 162 | echo $something // Bad. |
163 | - . esc_attr( 'baz-' // Rest is OK. |
|
164 | - . $r |
|
165 | - . ( $r === $active_round ? ' foo' : '' ) |
|
166 | - . ( $r < $active_round ? ' bar' : '' ) |
|
163 | + . esc_attr( 'baz-' // Rest is OK. |
|
164 | + . $r |
|
165 | + . ( $r === $active_round ? ' foo' : '' ) |
|
166 | + . ( $r < $active_round ? ' bar' : '' ) |
|
167 | 167 | ) . 'something'; |
168 | 168 | |
169 | 169 | echo implode( '<br>', $items ); // Bad. |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | echo join( '<br>', array_map( 'esc_html', $items ) ); // Ok. |
175 | 175 | |
176 | 176 | echo '<option name="' . esc_attr( $name ) . '"' . |
177 | - ( $name === $selected ? ' selected' : '' ) . |
|
178 | - '>' . esc_html( $value ) |
|
179 | - . '</option>'; |
|
177 | + ( $name === $selected ? ' selected' : '' ) . |
|
178 | + '>' . esc_html( $value ) |
|
179 | + . '</option>'; |
|
180 | 180 | |
181 | 181 | _deprecated_hook( 'some_filter', '1.3.0', esc_html__( 'The $arg is deprecated.' ), 'some_other_filter' ); // Ok. |
182 | 182 | _deprecated_hook( "filter_{$context}", '1.3.0', __( 'The $arg is deprecated.' ), sprintf( __( 'Some parsed message %s', $variable ) ) ); // Bad. |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | |
35 | 35 | $foo = 'abc'; |
36 | 36 | echo $foo; // Bad, should have escaping function. |
37 | -echo 'Some Raw String'; // Good. |
|
37 | +echo 'Some Raw String'; // Good. |
|
38 | 38 | |
39 | 39 | echo '' . $bad; // Bad, should not validate. |
40 | 40 | echo "this is $bad"; // Bad. |
41 | 41 | echo esc_html( $good . $better ) . $foo; // Bad, should escape all concatenated elements. |
42 | -echo esc_html( $food . 'include' ); // Good, eveything inside the escaping/sanitizing function should pass. |
|
42 | +echo esc_html( $food . 'include' ); // Good, eveything inside the escaping/sanitizing function should pass. |
|
43 | 43 | echo esc_html( strtoupper( $ok ) ) . $foo; // Bad, again. |
44 | 44 | echo esc_html( strtoupper( $ok ) ) . ' ' . esc_html( strtolower( $ok ) ); // Ok. |
45 | 45 | |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | _deprecated_function( __FUNCTION__, '1.3.0', esc_html( $another_func ) ); // Ok. |
133 | 133 | _deprecated_file( __FILE__, '1.3.0' ); // Ok. |
134 | 134 | _deprecated_argument( __METHOD__, '1.3.0', 'The $arg is deprecated.' ); // Ok. |
135 | -_doing_it_wrong( __METHOD__, "Invalid value for the 'bob' argument {$args['bob']}." ); // Bad. |
|
136 | -_doing_it_wrong( __METHOD__, "Invalid value for the 'bob' argument " . esc_html( $args['bob'] ) . "." ); // Ok. |
|
135 | +_doing_it_wrong( __METHOD__, "Invalid value for the 'bob' argument {$args[ 'bob' ]}." ); // Bad. |
|
136 | +_doing_it_wrong( __METHOD__, "Invalid value for the 'bob' argument " . esc_html( $args[ 'bob' ] ) . "." ); // Ok. |
|
137 | 137 | |
138 | 138 | trigger_error( "There was an error: {$message}", E_USER_NOTICE ); // Bad. |
139 | 139 | trigger_error( "There was an error: " . esc_html( $message ), E_USER_NOTICE ); // Ok. |
140 | 140 | |
141 | -echo '<p>' . sprintf( esc_html__( 'Some text -> %sLink text%s', 'textdomain' ), '<a href="' . esc_url( add_query_arg( array( 'page' => 'my_page' ), admin_url( 'admin.php' ) ) ) . '">', '</a>' ). '</p>'; // Ok. |
|
141 | +echo '<p>' . sprintf( esc_html__( 'Some text -> %sLink text%s', 'textdomain' ), '<a href="' . esc_url( add_query_arg( array( 'page' => 'my_page' ), admin_url( 'admin.php' ) ) ) . '">', '</a>' ) . '</p>'; // Ok. |
|
142 | 142 | |
143 | 143 | echo '<br/><strong>' . sprintf( esc_html__( 'Found %d results', 'textdomain' ), (int) $result_count ) . '</strong><br/><br/>'; // Ok. |
144 | 144 |
@@ -20,8 +20,7 @@ |
||
20 | 20 | |
21 | 21 | <?php |
22 | 22 | // Issue:#53. |
23 | -function custom_column_display( $column, $post_id ) |
|
24 | -{ |
|
23 | +function custom_column_display( $column, $post_id ) { |
|
25 | 24 | global $post; |
26 | 25 | switch ( $column ) { |
27 | 26 | case 'some_number' : |