Skip to content

Commit 7afe44a

Browse files
committed
Update ConstantStringType.php
1 parent 859bf7d commit 7afe44a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Type/Constant/ConstantStringType.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ public function isUppercaseString(): TrinaryLogic
366366
public function hasOffsetValueType(Type $offsetType): TrinaryLogic
367367
{
368368
if ($offsetType->isInteger()->yes()) {
369-
$strLenType = IntegerRangeType::fromInterval(-strlen($this->value), strlen($this->value) - 1);
369+
$strlen = strlen($this->value);
370+
$strLenType = IntegerRangeType::fromInterval(-$strlen, $strlen - 1);
370371
return $strLenType->isSuperTypeOf($offsetType);
371372
}
372373

@@ -376,7 +377,8 @@ public function hasOffsetValueType(Type $offsetType): TrinaryLogic
376377
public function getOffsetValueType(Type $offsetType): Type
377378
{
378379
if ($offsetType->isInteger()->yes()) {
379-
$strLenType = IntegerRangeType::fromInterval(-strlen($this->value), strlen($this->value) - 1);
380+
$strlen = strlen($this->value);
381+
$strLenType = IntegerRangeType::fromInterval(-$strlen, $strlen - 1);
380382

381383
if ($offsetType instanceof ConstantIntegerType) {
382384
if ($strLenType->isSuperTypeOf($offsetType)->yes()) {

0 commit comments

Comments
 (0)