Skip to content

Commit cae9aaa

Browse files
committed
Optimize AbstractList::__toString()
1 parent 15e6297 commit cae9aaa

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/Types/AbstractList.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,16 @@ public function __toString(): string
8383
return 'array';
8484
}
8585

86+
$valueTypeString = (string) $this->valueType;
87+
8688
if ($this->keyType) {
87-
return 'array<' . $this->keyType . ', ' . $this->valueType . '>';
89+
return 'array<' . $this->keyType . ', ' . $valueTypeString . '>';
8890
}
8991

90-
if (
91-
!preg_match('/[^\w\\\\]/', (string) $this->valueType) ||
92-
substr((string) $this->valueType, -2, 2) === '[]'
93-
) {
94-
return $this->valueType . '[]';
92+
if (!preg_match('/[^\w\\\\]/', $valueTypeString) || substr($valueTypeString, -2, 2) === '[]') {
93+
return $valueTypeString . '[]';
9594
}
9695

97-
return 'array<' . $this->valueType . '>';
96+
return 'array<' . $valueTypeString . '>';
9897
}
9998
}

0 commit comments

Comments
 (0)