Skip to content

Commit 006d048

Browse files
committed
Add the documentation for the PSR12 Import Statement sniff
1 parent 269098e commit 006d048

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<documentation title="Import Statement">
2+
<standard>
3+
<![CDATA[
4+
Import statements must not begin with a leading backslash.
5+
]]>
6+
</standard>
7+
<code_comparison>
8+
<code title="Valid: Import statements are fully qualified and don't begin a leading backslash.">
9+
<![CDATA[
10+
<?php
11+
12+
/**
13+
* This is a file comment.
14+
*/
15+
16+
declare(strict_types=1);
17+
18+
namespace Vendor\Package;
19+
20+
use Vendor\Package\{ClassA as A, ClassB};
21+
22+
/**
23+
* FooBar is an example class.
24+
*/
25+
class FooBar
26+
{
27+
// ... additional PHP code ...
28+
}
29+
]]>
30+
</code>
31+
<code title="Invalid: Import statements begin with a leading backslash.">
32+
<![CDATA[
33+
<?php
34+
35+
/**
36+
* This is a file comment.
37+
*/
38+
39+
declare(strict_types=1);
40+
41+
namespace Vendor\Package;
42+
43+
use <em>\</em>Vendor\Package\{ClassA as A, ClassB};
44+
45+
/**
46+
* FooBar is an example class.
47+
*/
48+
class FooBar
49+
{
50+
// ... additional PHP code ...
51+
}
52+
]]>
53+
</code>
54+
</code_comparison>
55+
</documentation>

0 commit comments

Comments
 (0)