Skip to content

Commit f61820d

Browse files
authored
Merge pull request #326 from PHPCSStandards/feature/cs-ruleset-tweak
CS: add the RequireExplicitBooleanOperatorPrecedence sniff to PHPCS native ruleset
2 parents cd52283 + 0144b0c commit f61820d

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

phpcs.xml.dist

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@
129129
<!-- Do not allow unreachable code. -->
130130
<rule ref="Squiz.PHP.NonExecutableCode"/>
131131

132+
<!-- Do not allow ambiguous conditions. -->
133+
<rule ref="Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence"/>
134+
132135
<!-- The testing bootstrap file uses string concats to stop IDEs seeing the class aliases -->
133136
<rule ref="Generic.Strings.UnnecessaryStringConcat">
134137
<exclude-pattern>tests/bootstrap\.php</exclude-pattern>

src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public function register()
6060
public function process(File $phpcsFile, $stackPtr)
6161
{
6262
$scopeModifier = $phpcsFile->getMethodProperties($stackPtr)['scope'];
63-
if ($scopeModifier === 'protected'
64-
&& $this->minimumVisibility === 'public'
65-
|| $scopeModifier === 'private'
66-
&& ($this->minimumVisibility === 'public' || $this->minimumVisibility === 'protected')
63+
if (($scopeModifier === 'protected'
64+
&& $this->minimumVisibility === 'public')
65+
|| ($scopeModifier === 'private'
66+
&& ($this->minimumVisibility === 'public' || $this->minimumVisibility === 'protected'))
6767
) {
6868
return;
6969
}

src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
108108

109109
// Remove the newline after the docblock, and any entirely
110110
// empty lines before the member var.
111-
if ($tokens[$i]['code'] === T_WHITESPACE
112-
&& $tokens[$i]['line'] === $tokens[$prev]['line']
111+
if (($tokens[$i]['code'] === T_WHITESPACE
112+
&& $tokens[$i]['line'] === $tokens[$prev]['line'])
113113
|| ($tokens[$i]['column'] === 1
114114
&& $tokens[$i]['line'] !== $tokens[($i + 1)]['line'])
115115
) {

src/Tokenizers/PHP.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ protected function tokenize($string)
17271727
|| (stripos($newContent, '0b') === 0 && bindec(str_replace('_', '', $newContent)) > PHP_INT_MAX)
17281728
|| (stripos($newContent, '0o') === 0 && octdec(str_replace('_', '', $newContent)) > PHP_INT_MAX)
17291729
|| (stripos($newContent, '0x') !== 0
1730-
&& stripos($newContent, 'e') !== false || strpos($newContent, '.') !== false)
1730+
&& (stripos($newContent, 'e') !== false || strpos($newContent, '.') !== false))
17311731
|| (strpos($newContent, '0') === 0 && stripos($newContent, '0x') !== 0
17321732
&& stripos($newContent, '0b') !== 0 && octdec(str_replace('_', '', $newContent)) > PHP_INT_MAX)
17331733
|| (strpos($newContent, '0') !== 0 && str_replace('_', '', $newContent) > PHP_INT_MAX))

0 commit comments

Comments
 (0)