Skip to content

Commit ae05ff6

Browse files
committed
refactor
1 parent 95ca06d commit ae05ff6

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
@@ -1268,9 +1268,21 @@ public function generalizeValues(): self
12681268
return new self($this->keyTypes, $valueTypes, $this->nextAutoIndexes, $this->optionalKeys, $this->isList);
12691269
}
12701270

1271-
public function getKeysArray(): self
1271+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
12721272
{
1273-
return $this->getKeysOrValuesArray($this->keyTypes);
1273+
$keysArray = $this->getKeysOrValuesArray($this->keyTypes);
1274+
1275+
if ($filterValueType !== null) {
1276+
return TypeCombinator::intersect(
1277+
new ArrayType(
1278+
$keysArray->getIterableKeyType()->generalize(GeneralizePrecision::lessSpecific()),
1279+
$keysArray->getIterableValueType()->generalize(GeneralizePrecision::lessSpecific()),
1280+
),
1281+
new AccessoryArrayListType(),
1282+
);
1283+
}
1284+
1285+
return $keysArray;
12741286
}
12751287

12761288
public function getValuesArray(): self

src/Type/IntersectionType.php

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

842-
public function getKeysArray(): Type
842+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
843843
{
844-
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray());
844+
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray($filterValueType, $strict));
845845
}
846846

847847
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)