Skip to content

Commit 520bee4

Browse files
committed
Merge branch 'fixUseDeclaration' of https://github.com/VincentLanglet/PHP_CodeSniffer
2 parents a71246d + 657a6d2 commit 520bee4

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ public function process(File $phpcsFile, $stackPtr)
8888
}
8989

9090
$lastValidContent = $i;
91+
92+
continue;
9193
}
9294

9395
break;
94-
}
96+
}//end for
9597

9698
if ($tokens[$lastValidContent]['line'] !== ($tokens[$opener]['line'] + 1)) {
9799
$error = 'The first trait import statement must be declared on the first non-comment line after the %s opening brace';

src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.inc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,40 @@ class MyExample
170170
use Trait3;
171171

172172
}
173+
174+
class Foo implements Bar
175+
{
176+
/*
177+
* Comment here;
178+
*/
179+
use Baz;
180+
}
181+
182+
class Foo implements Bar
183+
{
184+
// Comment here;
185+
use Baz;
186+
}
187+
188+
class Foo implements Bar
189+
{
190+
/**
191+
* Comment here;
192+
*/
193+
/**
194+
* Another Comment here;
195+
*/
196+
use Baz;
197+
}
198+
199+
class Foo implements Bar
200+
{
201+
/**
202+
* Comment here;
203+
*/
204+
public $foo;
205+
/**
206+
* Comment here;
207+
*/
208+
use Baz;
209+
}

src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.inc.fixed

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,40 @@ class MyExample
164164
// comment here
165165
use Trait3;
166166
}
167+
168+
class Foo implements Bar
169+
{
170+
/*
171+
* Comment here;
172+
*/
173+
use Baz;
174+
}
175+
176+
class Foo implements Bar
177+
{
178+
// Comment here;
179+
use Baz;
180+
}
181+
182+
class Foo implements Bar
183+
{
184+
/**
185+
* Comment here;
186+
*/
187+
/**
188+
* Another Comment here;
189+
*/
190+
use Baz;
191+
}
192+
193+
class Foo implements Bar
194+
{
195+
/**
196+
* Comment here;
197+
*/
198+
public $foo;
199+
/**
200+
* Comment here;
201+
*/
202+
use Baz;
203+
}

src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function getErrorList()
4646
157 => 1,
4747
165 => 1,
4848
170 => 1,
49+
208 => 1,
4950
];
5051

5152
}//end getErrorList()

0 commit comments

Comments
 (0)