Skip to content

Commit 8644045

Browse files
Rework
1 parent 6657e32 commit 8644045

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
use function max;
9292
use function min;
9393
use function sprintf;
94+
use function str_starts_with;
9495
use function strtolower;
9596
use const INF;
9697

@@ -506,9 +507,9 @@ public function resolveConcatType(Type $left, Type $right): Type
506507

507508
$leftNumericStringNonEmpty = TypeCombinator::remove($leftStringType, new ConstantStringType(''));
508509
if ($leftNumericStringNonEmpty->isNumericString()->yes()) {
509-
$allowedRightPattern = $left->isInteger()->yes()
510-
? '#^(\d+|\d+.\d+)([eE][+-]?\d+)?$#' // non-negative integer, float or scientific string
511-
: '#^\d+$#'; // non-negative integer string
510+
$validationCallback = $left->isInteger()->yes()
511+
? static fn (string $value): bool => !str_starts_with($value, '-')
512+
: static fn (string $value): bool => Strings::match($value, '#^\d+$#') !== null;
512513

513514
$allRightConstantsZeroOrMore = false;
514515
foreach ($rightConstantStrings as $rightConstantString) {
@@ -518,7 +519,7 @@ public function resolveConcatType(Type $left, Type $right): Type
518519

519520
if (
520521
!is_numeric($rightConstantString->getValue())
521-
|| Strings::match($rightConstantString->getValue(), $allowedRightPattern) === null
522+
|| !$validationCallback($rightConstantString->getValue())
522523
) {
523524
$allRightConstantsZeroOrMore = false;
524525
break;

0 commit comments

Comments
 (0)