Skip to content

Commit

Permalink
Merge pull request #311 from PHPCSStandards/feature/generic-lowercase…
Browse files Browse the repository at this point in the history
…type-bug-fix-intersection-types

Generic/LowerCaseType: bug fix in intersection type ignore code
  • Loading branch information
jrfnl authored Jan 31, 2024
2 parents 4869898 + afc03c6 commit c44475c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function process(File $phpcsFile, $stackPtr)
$error = 'PHP property type declarations must be lowercase; expected "%s" but found "%s"';
$errorCode = 'PropertyTypeFound';

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

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

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

0 comments on commit c44475c

Please sign in to comment.