File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Inpsyde/Sniffs/CodeQuality Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## not released
4
+ - Fix bug in ` Psr4Sniff ` when class has not namespace.
5
+
3
6
## 0.11.0
4
7
- Fix false positive in ` ReturnTypeDeclarationSniff ` with nullable types.
5
8
- Relax check for missing return type when ` {aType}|null ` doc bloc is present.
Original file line number Diff line number Diff line change 21
21
final class Psr4Sniff implements Sniff
22
22
{
23
23
/**
24
- * @var string|null
24
+ * @var array
25
25
*/
26
- public $ psr4 = null ;
26
+ public $ psr4 ;
27
27
28
28
/**
29
29
* @var array
@@ -74,6 +74,7 @@ private function checkFilenameOnly(
74
74
string $ className ,
75
75
string $ entityType
76
76
) {
77
+
77
78
if (basename ($ file ->getFilename ()) === "{$ className }.php " ) {
78
79
return ;
79
80
}
@@ -105,8 +106,9 @@ private function checkPsr4(
105
106
) {
106
107
107
108
list (, $ namespace ) = PhpcsHelpers::findNamespace ($ file , $ position );
109
+ $ namespace = is_string ($ namespace ) ? "{$ namespace }\\" : '' ;
108
110
109
- $ fullyQualifiedName = "{ $ namespace}\\{ $ className}" ;
111
+ $ fullyQualifiedName = $ namespace . $ className ;
110
112
foreach ($ this ->exclude as $ excluded ) {
111
113
if (strpos ($ fullyQualifiedName , $ excluded ) === 0 ) {
112
114
return ;
You can’t perform that action at this time.
0 commit comments