@@ -33,48 +33,48 @@ |
||
33 | 33 | class ElseOnNewLineSniff implements Sniff |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * Returns an array of tokens this test wants to listen for. |
|
38 | - * |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function register() |
|
42 | - { |
|
43 | - return array( |
|
44 | - T_ELSE, |
|
45 | - T_ELSEIF, |
|
46 | - ); |
|
47 | - }//end register() |
|
36 | + /** |
|
37 | + * Returns an array of tokens this test wants to listen for. |
|
38 | + * |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function register() |
|
42 | + { |
|
43 | + return array( |
|
44 | + T_ELSE, |
|
45 | + T_ELSEIF, |
|
46 | + ); |
|
47 | + }//end register() |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Processes this test, when one of its tokens is encountered. |
|
52 | - * |
|
53 | - * @param File $phpcsFile The current file being scanned. |
|
54 | - * @param int $stackPtr The position of the current token |
|
55 | - * in the stack passed in $tokens. |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function process(File $phpcsFile, $stackPtr) |
|
60 | - { |
|
61 | - $tokens = $phpcsFile->getTokens(); |
|
50 | + /** |
|
51 | + * Processes this test, when one of its tokens is encountered. |
|
52 | + * |
|
53 | + * @param File $phpcsFile The current file being scanned. |
|
54 | + * @param int $stackPtr The position of the current token |
|
55 | + * in the stack passed in $tokens. |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function process(File $phpcsFile, $stackPtr) |
|
60 | + { |
|
61 | + $tokens = $phpcsFile->getTokens(); |
|
62 | 62 | |
63 | - $else_token = $tokens[$stackPtr]; |
|
64 | - $previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, null, true); |
|
63 | + $else_token = $tokens[$stackPtr]; |
|
64 | + $previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, null, true); |
|
65 | 65 | |
66 | - if (false === $previous_non_blank_token_ptr) { |
|
67 | - // else is no preceded with any symbol, but it is not the responsibility of this sniff. |
|
68 | - return; |
|
69 | - } |
|
66 | + if (false === $previous_non_blank_token_ptr) { |
|
67 | + // else is no preceded with any symbol, but it is not the responsibility of this sniff. |
|
68 | + return; |
|
69 | + } |
|
70 | 70 | |
71 | - $previous_non_blank_token = $tokens[$previous_non_blank_token_ptr]; |
|
72 | - if ($previous_non_blank_token['line'] === $else_token['line']) { |
|
73 | - $error = '"' . $else_token['content'] . '" should be on a new line.'; |
|
74 | - $phpcsFile->addError($error, $stackPtr); |
|
75 | - } |
|
71 | + $previous_non_blank_token = $tokens[$previous_non_blank_token_ptr]; |
|
72 | + if ($previous_non_blank_token['line'] === $else_token['line']) { |
|
73 | + $error = '"' . $else_token['content'] . '" should be on a new line.'; |
|
74 | + $phpcsFile->addError($error, $stackPtr); |
|
75 | + } |
|
76 | 76 | |
77 | - }//end process() |
|
77 | + }//end process() |
|
78 | 78 | |
79 | 79 | |
80 | 80 | }//end class |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | use PHP_CodeSniffer\Sniffs\Sniff; |
31 | 31 | use PHP_CodeSniffer\Files\File; |
32 | 32 | |
33 | -class ElseOnNewLineSniff implements Sniff |
|
34 | -{ |
|
33 | +class ElseOnNewLineSniff implements Sniff { |
|
35 | 34 | |
36 | 35 | /** |
37 | 36 | * Returns an array of tokens this test wants to listen for. |
@@ -63,13 +62,15 @@ discard block |
||
63 | 62 | $else_token = $tokens[$stackPtr]; |
64 | 63 | $previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, null, true); |
65 | 64 | |
66 | - if (false === $previous_non_blank_token_ptr) { |
|
65 | + if (false === $previous_non_blank_token_ptr) |
|
66 | + { |
|
67 | 67 | // else is no preceded with any symbol, but it is not the responsibility of this sniff. |
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $previous_non_blank_token = $tokens[$previous_non_blank_token_ptr]; |
72 | - if ($previous_non_blank_token['line'] === $else_token['line']) { |
|
72 | + if ($previous_non_blank_token['line'] === $else_token['line']) |
|
73 | + { |
|
73 | 74 | $error = '"' . $else_token['content'] . '" should be on a new line.'; |
74 | 75 | $phpcsFile->addError($error, $stackPtr); |
75 | 76 | } |
@@ -61,9 +61,9 @@ |
||
61 | 61 | $tokens = $phpcsFile->getTokens(); |
62 | 62 | |
63 | 63 | $else_token = $tokens[$stackPtr]; |
64 | - $previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, null, true); |
|
64 | + $previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, NULL, TRUE); |
|
65 | 65 | |
66 | - if (false === $previous_non_blank_token_ptr) { |
|
66 | + if (FALSE === $previous_non_blank_token_ptr) { |
|
67 | 67 | // else is no preceded with any symbol, but it is not the responsibility of this sniff. |
68 | 68 | return; |
69 | 69 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * Returns an array of tokens this test wants to listen for. |
37 | 37 | * |
38 | - * @return array |
|
38 | + * @return integer[] |
|
39 | 39 | */ |
40 | 40 | public function register() |
41 | 41 | { |
@@ -34,60 +34,60 @@ |
||
34 | 34 | class DisallowWitheSpaceAroundPhpTagsSniff implements Sniff |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * Returns an array of tokens this test wants to listen for. |
|
39 | - * |
|
40 | - * @return array |
|
41 | - */ |
|
42 | - public function register() |
|
43 | - { |
|
44 | - return array( |
|
45 | - T_OPEN_TAG, |
|
46 | - T_CLOSE_TAG |
|
47 | - ); |
|
37 | + /** |
|
38 | + * Returns an array of tokens this test wants to listen for. |
|
39 | + * |
|
40 | + * @return array |
|
41 | + */ |
|
42 | + public function register() |
|
43 | + { |
|
44 | + return array( |
|
45 | + T_OPEN_TAG, |
|
46 | + T_CLOSE_TAG |
|
47 | + ); |
|
48 | 48 | |
49 | - }//end register() |
|
49 | + }//end register() |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Processes this test, when one of its tokens is encountered. |
|
54 | - * |
|
55 | - * @param File $phpcsFile The current file being scanned. |
|
56 | - * @param int $stackPtr The position of the current token |
|
57 | - * in the stack passed in $tokens. |
|
58 | - * |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - public function process(File $phpcsFile, $stackPtr) |
|
62 | - { |
|
63 | - $tokens = $phpcsFile->getTokens(); |
|
52 | + /** |
|
53 | + * Processes this test, when one of its tokens is encountered. |
|
54 | + * |
|
55 | + * @param File $phpcsFile The current file being scanned. |
|
56 | + * @param int $stackPtr The position of the current token |
|
57 | + * in the stack passed in $tokens. |
|
58 | + * |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + public function process(File $phpcsFile, $stackPtr) |
|
62 | + { |
|
63 | + $tokens = $phpcsFile->getTokens(); |
|
64 | 64 | |
65 | - $php_tag_token = $tokens[$stackPtr]; |
|
66 | - $php_tag_code = $php_tag_token['code']; |
|
65 | + $php_tag_token = $tokens[$stackPtr]; |
|
66 | + $php_tag_code = $php_tag_token['code']; |
|
67 | 67 | |
68 | - if (T_OPEN_TAG === $php_tag_code) { |
|
69 | - // opening php tag should be the first token. |
|
70 | - // any whitespace beofre an opening php tag is tokenized |
|
71 | - // as T_INLINE_HTML, so no need to check the content of the token. |
|
72 | - $isFirst = 0 === $stackPtr; |
|
73 | - if ( ! $isFirst) { |
|
74 | - $error = 'Any char before the opening PHP tag is prohibited. Please remove newline or indentation before the opening PHP tag.'; |
|
75 | - $phpcsFile->addError($error, $stackPtr); |
|
76 | - } |
|
77 | - } else { |
|
78 | - // if (T_CLOSE_TAG === $php_tag_code) |
|
79 | - // closing php tag should be the last token |
|
80 | - // and it must not contain any whitespace. |
|
81 | - $php_tag_string = $php_tag_token['content']; |
|
82 | - $isLast = count($tokens) - 1 === $stackPtr; |
|
83 | - // both of the two closing php tags contains 2 chars exactly. |
|
84 | - $containsEndTagOnly = strlen($php_tag_string) > 2; |
|
85 | - if ( ! $isLast || ! $containsEndTagOnly ) { |
|
86 | - $error = 'Any char after the closing PHP tag is prohibited. Please removes newline or spaces after the closing PHP tag.'; |
|
87 | - $phpcsFile->addError($error, $stackPtr); |
|
88 | - } |
|
89 | - } |
|
90 | - }//end process() |
|
68 | + if (T_OPEN_TAG === $php_tag_code) { |
|
69 | + // opening php tag should be the first token. |
|
70 | + // any whitespace beofre an opening php tag is tokenized |
|
71 | + // as T_INLINE_HTML, so no need to check the content of the token. |
|
72 | + $isFirst = 0 === $stackPtr; |
|
73 | + if ( ! $isFirst) { |
|
74 | + $error = 'Any char before the opening PHP tag is prohibited. Please remove newline or indentation before the opening PHP tag.'; |
|
75 | + $phpcsFile->addError($error, $stackPtr); |
|
76 | + } |
|
77 | + } else { |
|
78 | + // if (T_CLOSE_TAG === $php_tag_code) |
|
79 | + // closing php tag should be the last token |
|
80 | + // and it must not contain any whitespace. |
|
81 | + $php_tag_string = $php_tag_token['content']; |
|
82 | + $isLast = count($tokens) - 1 === $stackPtr; |
|
83 | + // both of the two closing php tags contains 2 chars exactly. |
|
84 | + $containsEndTagOnly = strlen($php_tag_string) > 2; |
|
85 | + if ( ! $isLast || ! $containsEndTagOnly ) { |
|
86 | + $error = 'Any char after the closing PHP tag is prohibited. Please removes newline or spaces after the closing PHP tag.'; |
|
87 | + $phpcsFile->addError($error, $stackPtr); |
|
88 | + } |
|
89 | + } |
|
90 | + }//end process() |
|
91 | 91 | |
92 | 92 | |
93 | 93 | }//end class |
@@ -82,7 +82,7 @@ |
||
82 | 82 | $isLast = count($tokens) - 1 === $stackPtr; |
83 | 83 | // both of the two closing php tags contains 2 chars exactly. |
84 | 84 | $containsEndTagOnly = strlen($php_tag_string) > 2; |
85 | - if ( ! $isLast || ! $containsEndTagOnly ) { |
|
85 | + if ( ! $isLast || ! $containsEndTagOnly) { |
|
86 | 86 | $error = 'Any char after the closing PHP tag is prohibited. Please removes newline or spaces after the closing PHP tag.'; |
87 | 87 | $phpcsFile->addError($error, $stackPtr); |
88 | 88 | } |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | use PHP_CodeSniffer\Sniffs\Sniff; |
32 | 32 | use PHP_CodeSniffer\Files\File; |
33 | 33 | |
34 | -class DisallowWitheSpaceAroundPhpTagsSniff implements Sniff |
|
35 | -{ |
|
34 | +class DisallowWitheSpaceAroundPhpTagsSniff implements Sniff { |
|
36 | 35 | |
37 | 36 | /** |
38 | 37 | * Returns an array of tokens this test wants to listen for. |
@@ -65,16 +64,20 @@ discard block |
||
65 | 64 | $php_tag_token = $tokens[$stackPtr]; |
66 | 65 | $php_tag_code = $php_tag_token['code']; |
67 | 66 | |
68 | - if (T_OPEN_TAG === $php_tag_code) { |
|
67 | + if (T_OPEN_TAG === $php_tag_code) |
|
68 | + { |
|
69 | 69 | // opening php tag should be the first token. |
70 | 70 | // any whitespace beofre an opening php tag is tokenized |
71 | 71 | // as T_INLINE_HTML, so no need to check the content of the token. |
72 | 72 | $isFirst = 0 === $stackPtr; |
73 | - if ( ! $isFirst) { |
|
73 | + if ( ! $isFirst) |
|
74 | + { |
|
74 | 75 | $error = 'Any char before the opening PHP tag is prohibited. Please remove newline or indentation before the opening PHP tag.'; |
75 | 76 | $phpcsFile->addError($error, $stackPtr); |
76 | 77 | } |
77 | - } else { |
|
78 | + } |
|
79 | + else |
|
80 | + { |
|
78 | 81 | // if (T_CLOSE_TAG === $php_tag_code) |
79 | 82 | // closing php tag should be the last token |
80 | 83 | // and it must not contain any whitespace. |
@@ -82,7 +85,8 @@ discard block |
||
82 | 85 | $isLast = count($tokens) - 1 === $stackPtr; |
83 | 86 | // both of the two closing php tags contains 2 chars exactly. |
84 | 87 | $containsEndTagOnly = strlen($php_tag_string) > 2; |
85 | - if ( ! $isLast || ! $containsEndTagOnly ) { |
|
88 | + if ( ! $isLast || ! $containsEndTagOnly ) |
|
89 | + { |
|
86 | 90 | $error = 'Any char after the closing PHP tag is prohibited. Please removes newline or spaces after the closing PHP tag.'; |
87 | 91 | $phpcsFile->addError($error, $stackPtr); |
88 | 92 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * Returns an array of tokens this test wants to listen for. |
37 | 37 | * |
38 | - * @return array |
|
38 | + * @return integer[] |
|
39 | 39 | */ |
40 | 40 | public function register() |
41 | 41 | { |
@@ -33,53 +33,53 @@ |
||
33 | 33 | class DisallowSpaceIndentSniff implements Sniff |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * A list of tokenizers this sniff supports. |
|
38 | - * |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - public $supportedTokenizers = array( |
|
42 | - 'PHP', |
|
43 | - 'JS', |
|
44 | - 'CSS', |
|
45 | - ); |
|
36 | + /** |
|
37 | + * A list of tokenizers this sniff supports. |
|
38 | + * |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + public $supportedTokenizers = array( |
|
42 | + 'PHP', |
|
43 | + 'JS', |
|
44 | + 'CSS', |
|
45 | + ); |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Returns an array of tokens this test wants to listen for. |
|
50 | - * |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - public function register() |
|
54 | - { |
|
55 | - return array(T_WHITESPACE); |
|
56 | - }//end register() |
|
48 | + /** |
|
49 | + * Returns an array of tokens this test wants to listen for. |
|
50 | + * |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + public function register() |
|
54 | + { |
|
55 | + return array(T_WHITESPACE); |
|
56 | + }//end register() |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Processes this test, when one of its tokens is encountered. |
|
61 | - * |
|
62 | - * @param File $phpcsFile All the tokens found in the document. |
|
63 | - * @param int $stackPtr The position of the current token |
|
64 | - * in the stack passed in $tokens. |
|
65 | - * |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - public function process(File $phpcsFile, $stackPtr) |
|
69 | - { |
|
70 | - $tokens = $phpcsFile->getTokens(); |
|
59 | + /** |
|
60 | + * Processes this test, when one of its tokens is encountered. |
|
61 | + * |
|
62 | + * @param File $phpcsFile All the tokens found in the document. |
|
63 | + * @param int $stackPtr The position of the current token |
|
64 | + * in the stack passed in $tokens. |
|
65 | + * |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + public function process(File $phpcsFile, $stackPtr) |
|
69 | + { |
|
70 | + $tokens = $phpcsFile->getTokens(); |
|
71 | 71 | |
72 | - // Make sure this is whitespace used for indentation. |
|
73 | - $line = $tokens[$stackPtr]['line']; |
|
74 | - if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) { |
|
75 | - return; |
|
76 | - } |
|
72 | + // Make sure this is whitespace used for indentation. |
|
73 | + $line = $tokens[$stackPtr]['line']; |
|
74 | + if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) { |
|
75 | + return; |
|
76 | + } |
|
77 | 77 | |
78 | - if (strpos($tokens[$stackPtr]['content'], " ") !== false) { |
|
79 | - $error = 'Tabs must be used to indent lines; spaces are not allowed for code indentation'; |
|
80 | - $phpcsFile->addError($error, $stackPtr, 'SpacesUsedForIndentation'); |
|
81 | - } |
|
82 | - }//end process() |
|
78 | + if (strpos($tokens[$stackPtr]['content'], " ") !== false) { |
|
79 | + $error = 'Tabs must be used to indent lines; spaces are not allowed for code indentation'; |
|
80 | + $phpcsFile->addError($error, $stackPtr, 'SpacesUsedForIndentation'); |
|
81 | + } |
|
82 | + }//end process() |
|
83 | 83 | |
84 | 84 | |
85 | 85 | }//end class |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | use PHP_CodeSniffer\Sniffs\Sniff; |
31 | 31 | use PHP_CodeSniffer\Files\File; |
32 | 32 | |
33 | -class DisallowSpaceIndentSniff implements Sniff |
|
34 | -{ |
|
33 | +class DisallowSpaceIndentSniff implements Sniff { |
|
35 | 34 | |
36 | 35 | /** |
37 | 36 | * A list of tokenizers this sniff supports. |
@@ -71,11 +70,13 @@ discard block |
||
71 | 70 | |
72 | 71 | // Make sure this is whitespace used for indentation. |
73 | 72 | $line = $tokens[$stackPtr]['line']; |
74 | - if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) { |
|
73 | + if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) |
|
74 | + { |
|
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | - if (strpos($tokens[$stackPtr]['content'], " ") !== false) { |
|
78 | + if (strpos($tokens[$stackPtr]['content'], " ") !== false) |
|
79 | + { |
|
79 | 80 | $error = 'Tabs must be used to indent lines; spaces are not allowed for code indentation'; |
80 | 81 | $phpcsFile->addError($error, $stackPtr, 'SpacesUsedForIndentation'); |
81 | 82 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | - if (strpos($tokens[$stackPtr]['content'], " ") !== false) { |
|
78 | + if (strpos($tokens[$stackPtr]['content'], " ") !== FALSE) { |
|
79 | 79 | $error = 'Tabs must be used to indent lines; spaces are not allowed for code indentation'; |
80 | 80 | $phpcsFile->addError($error, $stackPtr, 'SpacesUsedForIndentation'); |
81 | 81 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * Returns an array of tokens this test wants to listen for. |
37 | 37 | * |
38 | - * @return array |
|
38 | + * @return integer[] |
|
39 | 39 | */ |
40 | 40 | public function register() |
41 | 41 | { |
@@ -33,47 +33,47 @@ |
||
33 | 33 | |
34 | 34 | class StrictComparisonOperatorSniff implements Sniff |
35 | 35 | { |
36 | - private static $_replacements = array( |
|
37 | - T_IS_EQUAL => '===', |
|
38 | - T_IS_NOT_EQUAL => '!==', |
|
39 | - ); |
|
36 | + private static $_replacements = array( |
|
37 | + T_IS_EQUAL => '===', |
|
38 | + T_IS_NOT_EQUAL => '!==', |
|
39 | + ); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Returns an array of tokens this test wants to listen for. |
|
43 | - * |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function register() |
|
47 | - { |
|
48 | - return array( |
|
49 | - T_IS_EQUAL, |
|
50 | - T_IS_NOT_EQUAL, |
|
51 | - ); |
|
52 | - }//end register() |
|
41 | + /** |
|
42 | + * Returns an array of tokens this test wants to listen for. |
|
43 | + * |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function register() |
|
47 | + { |
|
48 | + return array( |
|
49 | + T_IS_EQUAL, |
|
50 | + T_IS_NOT_EQUAL, |
|
51 | + ); |
|
52 | + }//end register() |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Processes this test, when one of its tokens is encountered. |
|
57 | - * |
|
58 | - * @param File $phpcsFile The current file being scanned. |
|
59 | - * @param int $stackPtr The position of the current token |
|
60 | - * in the stack passed in $tokens. |
|
61 | - * |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - public function process(File $phpcsFile, $stackPtr) |
|
65 | - { |
|
66 | - $tokens = $phpcsFile->getTokens(); |
|
55 | + /** |
|
56 | + * Processes this test, when one of its tokens is encountered. |
|
57 | + * |
|
58 | + * @param File $phpcsFile The current file being scanned. |
|
59 | + * @param int $stackPtr The position of the current token |
|
60 | + * in the stack passed in $tokens. |
|
61 | + * |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + public function process(File $phpcsFile, $stackPtr) |
|
65 | + { |
|
66 | + $tokens = $phpcsFile->getTokens(); |
|
67 | 67 | |
68 | - $operator_token = $tokens[$stackPtr]; |
|
69 | - $operator_string = $operator_token['content']; |
|
70 | - $operator_code = $operator_token['code']; |
|
68 | + $operator_token = $tokens[$stackPtr]; |
|
69 | + $operator_string = $operator_token['content']; |
|
70 | + $operator_code = $operator_token['code']; |
|
71 | 71 | |
72 | - $error_message = '"==" and "!=" are prohibited; use "' |
|
73 | - . self::$_replacements[$operator_code] . '" instead of "' |
|
74 | - . $operator_string . '".'; |
|
75 | - $phpcsFile->addError($error_message, $stackPtr, 'NonStrictComparisonUsed'); |
|
76 | - }//end process() |
|
72 | + $error_message = '"==" and "!=" are prohibited; use "' |
|
73 | + . self::$_replacements[$operator_code] . '" instead of "' |
|
74 | + . $operator_string . '".'; |
|
75 | + $phpcsFile->addError($error_message, $stackPtr, 'NonStrictComparisonUsed'); |
|
76 | + }//end process() |
|
77 | 77 | |
78 | 78 | |
79 | 79 | }//end class |
@@ -31,8 +31,7 @@ |
||
31 | 31 | use PHP_CodeSniffer\Sniffs\Sniff; |
32 | 32 | use PHP_CodeSniffer\Files\File; |
33 | 33 | |
34 | -class StrictComparisonOperatorSniff implements Sniff |
|
35 | -{ |
|
34 | +class StrictComparisonOperatorSniff implements Sniff { |
|
36 | 35 | private static $_replacements = array( |
37 | 36 | T_IS_EQUAL => '===', |
38 | 37 | T_IS_NOT_EQUAL => '!==', |
@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * Returns an array of tokens this test wants to listen for. |
37 | 37 | * |
38 | - * @return array |
|
38 | + * @return integer[] |
|
39 | 39 | */ |
40 | 40 | public function register() |
41 | 41 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | $file_patterns = [ |
5 | 5 | 'app/bootstrap.php', |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // [0] => token type constant |
34 | 34 | // [1] => raw sytax parsed to that token |
35 | 35 | // [2] => line number |
36 | - foreach($tokens as $token) |
|
36 | + foreach ($tokens as $token) |
|
37 | 37 | { |
38 | 38 | // Since we only care about opening docblocks, |
39 | 39 | // bail out when we get to the namespace token |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * Set the request body |
85 | 85 | * |
86 | - * @param FormBody|string $body |
|
86 | + * @param string $body |
|
87 | 87 | * @return self |
88 | 88 | */ |
89 | 89 | public function setBody($body): self |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * This is a dirty hack until I can fully track down where |
195 | 195 | * the dual-encoding happens |
196 | 196 | * |
197 | - * @param FormBody $formBody The form builder object to fix |
|
197 | + * @param \Amp\Artax\FormBody $formBody The form builder object to fix |
|
198 | 198 | * @return string |
199 | 199 | */ |
200 | 200 | private function fixBody(FormBody $formBody): string |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /** |
3 | 3 | * Anime List Client |
4 | 4 | * |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * This is a dirty hack until I can fully track down where |
71 | 71 | * the dual-encoding happens |
72 | 72 | * |
73 | - * @param FormBody $formBody The form builder object to fix |
|
73 | + * @param \Amp\Artax\FormBody $formBody The form builder object to fix |
|
74 | 74 | * @return string |
75 | 75 | */ |
76 | 76 | private function fixBody(FormBody $formBody): string |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string $type |
86 | 86 | * @param string $url |
87 | 87 | * @param array $options |
88 | - * @return \Amp\Promise |
|
88 | + * @return \Amp\Artax\Request |
|
89 | 89 | */ |
90 | 90 | public function setUpRequest(string $type, string $url, array $options = []) |
91 | 91 | { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | /** |
198 | 198 | * Remove some boilerplate for get requests |
199 | 199 | * |
200 | - * @param array $args |
|
200 | + * @param string $args |
|
201 | 201 | * @return array |
202 | 202 | */ |
203 | 203 | protected function getRequest(...$args): array |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /** |
3 | 3 | * Anime List Client |
4 | 4 | * |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | $config = $this->container->get('config'); |
103 | 103 | $logger = $this->container->getLogger('mal-request'); |
104 | 104 | |
105 | - $headers = array_merge($this->defaultHeaders, $options['headers'] ?? [], [ |
|
105 | + $headers = array_merge($this->defaultHeaders, $options['headers'] ?? [], [ |
|
106 | 106 | 'Authorization' => 'Basic ' . |
107 | - base64_encode($config->get(['mal','username']) . ':' .$config->get(['mal','password'])) |
|
107 | + base64_encode($config->get(['mal', 'username']) . ':' . $config->get(['mal', 'password'])) |
|
108 | 108 | ]); |
109 | 109 | |
110 | 110 | $query = $options['query'] ?? []; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | $response = $this->getResponse($type, $url, $options); |
185 | 185 | |
186 | - if ((int) $response->getStatus() > 299 || (int) $response->getStatus() < 200) |
|
186 | + if ((int)$response->getStatus() > 299 || (int)$response->getStatus() < 200) |
|
187 | 187 | { |
188 | 188 | if ($logger) |
189 | 189 | { |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - return XML::toArray((string) $response->getBody()); |
|
194 | + return XML::toArray((string)$response->getBody()); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $response = $this->getResponse('POST', ...$args); |
223 | 223 | $validResponseCodes = [200, 201]; |
224 | 224 | |
225 | - if ( ! in_array((int) $response->getStatus(), $validResponseCodes)) |
|
225 | + if ( ! in_array((int)$response->getStatus(), $validResponseCodes)) |
|
226 | 226 | { |
227 | 227 | if ($logger) |
228 | 228 | { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | private function getResponse(string $type, string $url, array $options = []) |
144 | 144 | { |
145 | - $logger = null; |
|
145 | + $logger = NULL; |
|
146 | 146 | if ($this->getContainer()) |
147 | 147 | { |
148 | 148 | $logger = $this->container->getLogger('mal-request'); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | private function request(string $type, string $url, array $options = []): array |
177 | 177 | { |
178 | - $logger = null; |
|
178 | + $logger = NULL; |
|
179 | 179 | if ($this->getContainer()) |
180 | 180 | { |
181 | 181 | $logger = $this->container->getLogger('mal-request'); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | protected function postRequest(...$args): array |
215 | 215 | { |
216 | - $logger = null; |
|
216 | + $logger = NULL; |
|
217 | 217 | if ($this->getContainer()) |
218 | 218 | { |
219 | 219 | $logger = $this->container->getLogger('mal-request'); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | /** |
49 | 49 | * Constructor |
50 | 50 | * |
51 | - * @param ContainerInterface $container |
|
51 | + * @param \Aviat\Ion\Di\ContainerInterface $container |
|
52 | 52 | */ |
53 | 53 | public function __construct(ContainerInterface $container) |
54 | 54 | { |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /** |
3 | 3 | * Anime List Client |
4 | 4 | * |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); |
|
1 | +<?php declare(strict_types = 1); |
|
2 | 2 | /** |
3 | 3 | * Anime List Client |
4 | 4 | * |