Skip to content

Commit

Permalink
Update ConstantStringType.php
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 31, 2025
1 parent cb7ffb0 commit 3cc2226
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Type/Constant/ConstantStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ public function isUppercaseString(): TrinaryLogic
public function hasOffsetValueType(Type $offsetType): TrinaryLogic
{
if ($offsetType->isInteger()->yes()) {
$strLenType = IntegerRangeType::fromInterval(-strlen($this->value), strlen($this->value) - 1);
$strlen = strlen($this->value);
$strLenType = IntegerRangeType::fromInterval(-$strlen, $strlen - 1);
return $strLenType->isSuperTypeOf($offsetType);
}

Expand All @@ -376,7 +377,8 @@ public function hasOffsetValueType(Type $offsetType): TrinaryLogic
public function getOffsetValueType(Type $offsetType): Type
{
if ($offsetType->isInteger()->yes()) {
$strLenType = IntegerRangeType::fromInterval(-strlen($this->value), strlen($this->value) - 1);
$strlen = strlen($this->value);
$strLenType = IntegerRangeType::fromInterval(-$strlen, $strlen - 1);

if ($offsetType instanceof ConstantIntegerType) {
if ($strLenType->isSuperTypeOf($offsetType)->yes()) {
Expand Down

0 comments on commit 3cc2226

Please sign in to comment.