Skip to content

Commit b6b7b49

Browse files
committed
resolves feedback
Addresses phpstan#3613 (comment)
1 parent 3c6a7b3 commit b6b7b49

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,13 @@ public function resolveConcatType(Type $left, Type $right): Type
482482
$accessoryTypes[] = new AccessoryLiteralStringType();
483483
}
484484

485-
$this->appendAccessoryCasedStringTypes($leftStringType, $rightStringType, $accessoryTypes);
485+
if ($leftStringType->isLowercaseString()->and($rightStringType->isLowercaseString())->yes()) {
486+
$accessoryTypes[] = new AccessoryLowercaseStringType();
487+
}
488+
489+
if ($leftStringType->isUppercaseString()->and($rightStringType->isUppercaseString())->yes()) {
490+
$accessoryTypes[] = new AccessoryUppercaseStringType();
491+
}
486492

487493
$leftNumericStringNonEmpty = TypeCombinator::remove($leftStringType, new ConstantStringType(''));
488494
if ($leftNumericStringNonEmpty->isNumericString()->yes()) {
@@ -518,26 +524,6 @@ public function resolveConcatType(Type $left, Type $right): Type
518524
return new StringType();
519525
}
520526

521-
protected function appendAccessoryCasedStringTypes($leftStringType, $rightStringType, array &$accessoryTypes): void
522-
{
523-
$lower = $leftStringType->isLowercaseString()->and($rightStringType->isLowercaseString())->yes();
524-
$upper = $leftStringType->isUppercaseString()->and($rightStringType->isUppercaseString())->yes();
525-
526-
if ($lower && $upper) {
527-
return;
528-
}
529-
530-
if ($lower) {
531-
$accessoryTypes[] = new AccessoryLowercaseStringType();
532-
return;
533-
}
534-
535-
if ($upper) {
536-
$accessoryTypes[] = new AccessoryUppercaseStringType();
537-
return;
538-
}
539-
}
540-
541527
/**
542528
* @param callable(Expr): Type $getTypeCallback
543529
*/

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ public function testArrayUdiffCallback(): void
636636
6,
637637
],
638638
[
639-
'Parameter #3 $data_comp_func of function array_udiff expects callable(1|2|3|4|5|6, 1|2|3|4|5|6): int, Closure(int, int): (literal-string&non-falsy-string&numeric-string) given.',
639+
'Parameter #3 $data_comp_func of function array_udiff expects callable(1|2|3|4|5|6, 1|2|3|4|5|6): int, Closure(int, int): (literal-string&lowercase-string&non-falsy-string&numeric-string&uppercase-string) given.',
640640
14,
641641
],
642642
[

0 commit comments

Comments
 (0)