Skip to content

Commit c44475c

Browse files
authored
Merge pull request #311 from PHPCSStandards/feature/generic-lowercasetype-bug-fix-intersection-types
Generic/LowerCaseType: bug fix in intersection type ignore code
2 parents 4869898 + afc03c6 commit c44475c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function process(File $phpcsFile, $stackPtr)
135135
$error = 'PHP property type declarations must be lowercase; expected "%s" but found "%s"';
136136
$errorCode = 'PropertyTypeFound';
137137

138-
if ($props['type_token'] === T_TYPE_INTERSECTION) {
138+
if (strpos($type, '&') !== false) {
139139
// Intersection types don't support simple types.
140140
} else if (strpos($type, '|') !== false) {
141141
$this->processUnionType(
@@ -167,7 +167,7 @@ public function process(File $phpcsFile, $stackPtr)
167167
$error = 'PHP return type declarations must be lowercase; expected "%s" but found "%s"';
168168
$errorCode = 'ReturnTypeFound';
169169

170-
if ($props['return_type_token'] === T_TYPE_INTERSECTION) {
170+
if (strpos($returnType, '&') !== false) {
171171
// Intersection types don't support simple types.
172172
} else if (strpos($returnType, '|') !== false) {
173173
$this->processUnionType(
@@ -199,7 +199,7 @@ public function process(File $phpcsFile, $stackPtr)
199199
$error = 'PHP parameter type declarations must be lowercase; expected "%s" but found "%s"';
200200
$errorCode = 'ParamTypeFound';
201201

202-
if ($param['type_hint_token'] === T_TYPE_INTERSECTION) {
202+
if (strpos($typeHint, '&') !== false) {
203203
// Intersection types don't support simple types.
204204
} else if (strpos($typeHint, '|') !== false) {
205205
$this->processUnionType(

0 commit comments

Comments
 (0)