Skip to content

Commit 8043283

Browse files
committed
Merged changelog
2 parents 7cb9781 + 43313f3 commit 8043283

File tree

15 files changed

+96
-30
lines changed

15 files changed

+96
-30
lines changed

CodeSniffer.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
$phpCodeSnifferConfig = array (
3+
)
4+
?>

CodeSniffer.sample.conf

Lines changed: 0 additions & 6 deletions
This file was deleted.

CodeSniffer/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ private function _parse($contents=null)
616616
$contents = str_replace($this->eolChar, '', $contents);
617617
$contents = str_replace("\n", '\n', $contents);
618618
$contents = str_replace("\r", '\r', $contents);
619-
if (preg_match('/(\\\\.)+/', $contents) === 1) {
619+
if (strpos($contents, '\\') !== false) {
620620
$error = 'File has mixed line endings; this may cause incorrect results';
621621
$this->addWarning($error, 0, 'Internal.LineEndings.Mixed');
622622
}

CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,16 @@ protected function getDeclarationNameWithNamespace(array $tokens, $stackPtr)
150150
*/
151151
protected function getNamespaceOfScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
152152
{
153-
$namespaceDeclaration = $phpcsFile->findPrevious(T_NAMESPACE, $stackPtr);
154-
$endOfNamespaceDeclaration = $phpcsFile->findNext(T_SEMICOLON, $namespaceDeclaration);
155-
156-
$namespace = $this->getDeclarationNameWithNamespace(
157-
$phpcsFile->getTokens(),
158-
($endOfNamespaceDeclaration - 1)
159-
);
153+
$namespace = '\\';
154+
$namespaceDeclaration = $phpcsFile->findPrevious(T_NAMESPACE, $stackPtr);
155+
156+
if ($namespaceDeclaration !== false) {
157+
$endOfNamespaceDeclaration = $phpcsFile->findNext(T_SEMICOLON, $namespaceDeclaration);
158+
$namespace = $this->getDeclarationNameWithNamespace(
159+
$phpcsFile->getTokens(),
160+
($endOfNamespaceDeclaration - 1)
161+
);
162+
}
160163

161164
return $namespace;
162165

CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ protected function getPatterns()
5858
'if (...) {EOL',
5959
'foreach (...) {EOL',
6060
'} else if (...) {EOL',
61+
'} elseif (...) {EOL',
6162
'} else {EOL',
6263
);
6364

CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
136136
// a minus value or returning one.
137137
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
138138
if ($tokens[$prev]['code'] === T_RETURN) {
139-
// Just returning a negative value; eg. return -1.
139+
// Just returning a negative value; eg. (return -1).
140140
return;
141141
}
142142

@@ -150,6 +150,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
150150
return;
151151
}
152152

153+
if (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true) {
154+
// Just trying to assign a negative value; eg. ($var = -1).
155+
return;
156+
}
157+
153158
// A list of tokens that indicate that the token is not
154159
// part of an arithmetic operation.
155160
$invalidTokens = array(
@@ -159,24 +164,14 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
159164
T_DOUBLE_ARROW,
160165
T_COLON,
161166
T_INLINE_THEN,
167+
T_INLINE_ELSE,
162168
T_CASE,
163169
);
164170

165171
if (in_array($tokens[$prev]['code'], $invalidTokens) === true) {
166172
// Just trying to use a negative value; eg. myFunction($var, -2).
167173
return;
168174
}
169-
170-
$number = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
171-
if (in_array($tokens[$number]['code'], array(T_LNUMBER, T_VARIABLE)) === true) {
172-
$semi = $phpcsFile->findNext(T_WHITESPACE, ($number + 1), null, true);
173-
if ($tokens[$semi]['code'] === T_SEMICOLON) {
174-
if ($prev !== false && (in_array($tokens[$prev]['code'], PHP_CodeSniffer_Tokens::$assignmentTokens) === true)) {
175-
// This is a negative assignment.
176-
return;
177-
}
178-
}
179-
}
180175
}//end if
181176

182177
$operator = $tokens[$stackPtr]['content'];

CodeSniffer/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ class MyClass {
6464

6565
MyClass::walk();
6666

67+
class Controller
68+
{
69+
public function Action()
70+
{
71+
Doctrine\Common\Util\Debug::dump();
72+
}
73+
}
74+
6775
namespace TYPO3\CMS\Reports;
6876

6977
class Status {

CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,10 @@ try { $code = 'this'; } catch (Exception $e) {
152152
do { echo $i;
153153
} while ($i > 0);
154154

155-
?>
155+
if ($a) {
156+
157+
}
158+
elseif ($b) {
159+
160+
}
161+
?>

CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function getErrorList($testFile='ControlSignatureUnitTest.inc')
7272
139 => 1,
7373
148 => 1,
7474
152 => 1,
75+
158 => 1,
7576
);
7677
break;
7778
case 'ControlSignatureUnitTest.js':

CodeSniffer/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,22 @@ $boo = -$foo;
105105
function foo($boo = -1) {}
106106
$foo = array('boo' => -1);
107107
$x = $test ? -1 : 1;
108+
$y = $test ? 1 : -1;
108109

109110
$closureWithDefaultParamter = function (array $testArray=array()) {};
110111

111112
switch ($foo) {
112113
case -1:
113114
break;
114115
}
116+
117+
$y = 1 * -1;
118+
$y = -1 * 1;
119+
$y = -1 * $var;
120+
$y = 10 / -2;
121+
$y = -10 / 2;
122+
$y = (-10 / 2);
123+
$y = (-10 / $var);
124+
$y = 10 + -2;
125+
$y = -10 + 2;
115126
?>

0 commit comments

Comments
 (0)