File tree Expand file tree Collapse file tree 1 file changed +25
-16
lines changed
src/Standards/Generic/Sniffs/PHP Expand file tree Collapse file tree 1 file changed +25
-16
lines changed Original file line number Diff line number Diff line change 16
16
class LowerCaseTypeSniff implements Sniff
17
17
{
18
18
19
+ /**
20
+ * Native types supported by PHP.
21
+ *
22
+ * @var array
23
+ */
24
+ private $ phpTypes = [
25
+ 'self ' => true ,
26
+ 'parent ' => true ,
27
+ 'array ' => true ,
28
+ 'callable ' => true ,
29
+ 'bool ' => true ,
30
+ 'float ' => true ,
31
+ 'int ' => true ,
32
+ 'string ' => true ,
33
+ 'iterable ' => true ,
34
+ 'void ' => true ,
35
+ 'object ' => true ,
36
+ 'mixed ' => true ,
37
+ 'static ' => true ,
38
+ 'false ' => true ,
39
+ 'null ' => true ,
40
+ ];
41
+
19
42
20
43
/**
21
44
* Returns an array of tokens this test wants to listen for.
@@ -71,28 +94,14 @@ public function process(File $phpcsFile, $stackPtr)
71
94
return ;
72
95
}//end if
73
96
74
- $ phpTypes = [
75
- 'self ' => true ,
76
- 'parent ' => true ,
77
- 'array ' => true ,
78
- 'callable ' => true ,
79
- 'bool ' => true ,
80
- 'float ' => true ,
81
- 'int ' => true ,
82
- 'string ' => true ,
83
- 'iterable ' => true ,
84
- 'void ' => true ,
85
- 'object ' => true ,
86
- ];
87
-
88
97
$ props = $ phpcsFile ->getMethodProperties ($ stackPtr );
89
98
90
99
// Strip off potential nullable indication.
91
100
$ returnType = ltrim ($ props ['return_type ' ], '? ' );
92
101
$ returnTypeLower = strtolower ($ returnType );
93
102
94
103
if ($ returnType !== ''
95
- && isset ($ phpTypes [$ returnTypeLower ]) === true
104
+ && isset ($ this -> phpTypes [$ returnTypeLower ]) === true
96
105
) {
97
106
// A function return type.
98
107
if ($ returnTypeLower !== $ returnType ) {
@@ -129,7 +138,7 @@ public function process(File $phpcsFile, $stackPtr)
129
138
$ typeHintLower = strtolower ($ typeHint );
130
139
131
140
if ($ typeHint !== ''
132
- && isset ($ phpTypes [$ typeHintLower ]) === true
141
+ && isset ($ this -> phpTypes [$ typeHintLower ]) === true
133
142
) {
134
143
// A function return type.
135
144
if ($ typeHintLower !== $ typeHint ) {
You can’t perform that action at this time.
0 commit comments