Skip to content

Commit dc67b41

Browse files
committed
Merge branch 'master' into report-memory-improvements
Conflicts: package.xml
2 parents 07acf2a + b8fa536 commit dc67b41

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private function _shouldIgnoreUse(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
124124
}
125125

126126
// Ignore USE keywords for traits.
127-
if ($phpcsFile->hasCondition($stackPtr, T_CLASS) === true) {
127+
if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_TRAIT)) === true) {
128128
return true;
129129
}
130130

CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.1.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ class Container extends Component implements IContainer
2424
{
2525
use TContainer;
2626
}
27+
28+
trait HelloWorld
29+
{
30+
use Hello, World;
31+
}

CodeSniffer/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,34 @@ class PSR2_Tests_Namespaces_UseDeclarationUnitTest extends AbstractSniffUnitTest
3636
* The key of the array should represent the line number and the value
3737
* should represent the number of errors that should occur on that line.
3838
*
39+
* @param string $testFile The name of the file being tested.
40+
*
3941
* @return array(int => int)
4042
*/
4143
public function getErrorList($testFile='')
4244
{
4345
switch ($testFile) {
46+
case 'UseDeclarationUnitTest.1.inc':
47+
// The trait test will only work in PHP versions where traits exist
48+
// and will throw errors in earlier versions.
49+
if (version_compare(PHP_VERSION, '5.4.0') < 0) {
50+
return array(
51+
30 => 2,
52+
);
53+
}
54+
55+
return array();
4456
case 'UseDeclarationUnitTest.2.inc':
4557
return array(
4658
5 => 1,
4759
10 => 2,
4860
);
49-
break;
5061
case 'UseDeclarationUnitTest.3.inc':
5162
return array(
5263
5 => 1,
5364
);
54-
break;
5565
default:
5666
return array();
57-
break;
5867
}//end switch
5968

6069
}//end getErrorList()

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
6767
- Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier'
6868
-- Thanks to Renat Akhmedyanov for the patch
6969
- The PSR2 standard no longer throws errors for additional spacing after a type hint
70+
- PSR UseDeclarationSniff no longer throws errors for USE statements inside TRAITs
7071
- Fixed cases where code was incorrectly assigned the T_GOTO_LABEL token when used in a complex CASE condition
7172
- Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong
7273
-- Adds new error message for single-line arrays that end with a comma

0 commit comments

Comments
 (0)