Skip to content

Commit ec6cd4c

Browse files
Rework
1 parent 6657e32 commit ec6cd4c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ public function resolveConcatType(Type $left, Type $right): Type
506506

507507
$leftNumericStringNonEmpty = TypeCombinator::remove($leftStringType, new ConstantStringType(''));
508508
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
509+
$validationCallback = $left->isInteger()->yes()
510+
? static fn (string $value): bool => !str_starts_with($value, '-')
511+
: static fn (string $value): bool => Strings::match($value, '#^\d+$#') !== null;
512512

513513
$allRightConstantsZeroOrMore = false;
514514
foreach ($rightConstantStrings as $rightConstantString) {
@@ -518,7 +518,7 @@ public function resolveConcatType(Type $left, Type $right): Type
518518

519519
if (
520520
!is_numeric($rightConstantString->getValue())
521-
|| Strings::match($rightConstantString->getValue(), $allowedRightPattern) === null
521+
|| !$validationCallback($rightConstantString->getValue())
522522
) {
523523
$allRightConstantsZeroOrMore = false;
524524
break;

0 commit comments

Comments
 (0)