Skip to content

Commit 8467479

Browse files
committed
refactor
1 parent e4ca868 commit 8467479

17 files changed

+40
-39
lines changed

src/Type/Accessory/AccessoryArrayListType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function unsetOffset(Type $offsetType): Type
172172
return new ErrorType();
173173
}
174174

175-
public function getKeysArray(): Type
175+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
176176
{
177177
return $this;
178178
}

src/Type/Accessory/HasOffsetType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
343343
return new BooleanType();
344344
}
345345

346-
public function getKeysArray(): Type
346+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
347347
{
348348
return new NonEmptyArrayType();
349349
}

src/Type/Accessory/HasOffsetValueType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function unsetOffset(Type $offsetType): Type
195195
return $this;
196196
}
197197

198-
public function getKeysArray(): Type
198+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
199199
{
200200
return new NonEmptyArrayType();
201201
}

src/Type/Accessory/NonEmptyArrayType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function unsetOffset(Type $offsetType): Type
159159
return new ErrorType();
160160
}
161161

162-
public function getKeysArray(): Type
162+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
163163
{
164164
return $this;
165165
}

src/Type/Accessory/OversizedArrayType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function unsetOffset(Type $offsetType): Type
154154
return new ErrorType();
155155
}
156156

157-
public function getKeysArray(): Type
157+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
158158
{
159159
return $this;
160160
}

src/Type/ArrayType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function generalizeValues(): self
170170
return new self($this->keyType, $this->itemType->generalize(GeneralizePrecision::lessSpecific()));
171171
}
172172

173-
public function getKeysArray(): Type
173+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
174174
{
175175
return TypeCombinator::intersect(new self(new IntegerType(), $this->getIterableKeyType()), new AccessoryArrayListType());
176176
}

src/Type/Constant/ConstantArrayType.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,9 +1261,21 @@ public function generalizeValues(): self
12611261
return new self($this->keyTypes, $valueTypes, $this->nextAutoIndexes, $this->optionalKeys, $this->isList);
12621262
}
12631263

1264-
public function getKeysArray(): self
1264+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
12651265
{
1266-
return $this->getKeysOrValuesArray($this->keyTypes);
1266+
$keysArray = $this->getKeysOrValuesArray($this->keyTypes);
1267+
1268+
if ($filterValueType !== null) {
1269+
return TypeCombinator::intersect(
1270+
new ArrayType(
1271+
$keysArray->getIterableKeyType()->generalize(GeneralizePrecision::lessSpecific()),
1272+
$keysArray->getIterableValueType()->generalize(GeneralizePrecision::lessSpecific()),
1273+
),
1274+
new AccessoryArrayListType(),
1275+
);
1276+
}
1277+
1278+
return $keysArray;
12671279
}
12681280

12691281
public function getValuesArray(): self

src/Type/IntersectionType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,9 @@ public function unsetOffset(Type $offsetType): Type
799799
return $this->intersectTypes(static fn (Type $type): Type => $type->unsetOffset($offsetType));
800800
}
801801

802-
public function getKeysArray(): Type
802+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
803803
{
804-
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray());
804+
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray($filterValueType, $strict));
805805
}
806806

807807
public function getValuesArray(): Type

src/Type/MixedType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function unsetOffset(Type $offsetType): Type
179179
return $this;
180180
}
181181

182-
public function getKeysArray(): Type
182+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
183183
{
184184
if ($this->isArray()->no()) {
185185
return new ErrorType();

src/Type/NeverType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function unsetOffset(Type $offsetType): Type
273273
return new NeverType();
274274
}
275275

276-
public function getKeysArray(): Type
276+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
277277
{
278278
return new NeverType();
279279
}

0 commit comments

Comments
 (0)