Skip to content

Commit d663d42

Browse files
committed
refactor
1 parent 4087bfc commit d663d42

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
@@ -338,7 +338,7 @@ public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
338338
return new BooleanType();
339339
}
340340

341-
public function getKeysArray(): Type
341+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
342342
{
343343
return new NonEmptyArrayType();
344344
}

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
@@ -158,7 +158,7 @@ public function unsetOffset(Type $offsetType): Type
158158
return new ErrorType();
159159
}
160160

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

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
@@ -165,7 +165,7 @@ public function generalizeValues(): self
165165
return new self($this->keyType, $this->itemType->generalize(GeneralizePrecision::lessSpecific()));
166166
}
167167

168-
public function getKeysArray(): Type
168+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
169169
{
170170
return TypeCombinator::intersect(new self(new IntegerType(), $this->getIterableKeyType()), new AccessoryArrayListType());
171171
}

src/Type/Constant/ConstantArrayType.php

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

1248-
public function getKeysArray(): self
1248+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
12491249
{
1250-
return $this->getKeysOrValuesArray($this->keyTypes);
1250+
$keysArray = $this->getKeysOrValuesArray($this->keyTypes);
1251+
1252+
if ($filterValueType !== null) {
1253+
return TypeCombinator::intersect(
1254+
new ArrayType(
1255+
$keysArray->getIterableKeyType()->generalize(GeneralizePrecision::lessSpecific()),
1256+
$keysArray->getIterableValueType()->generalize(GeneralizePrecision::lessSpecific()),
1257+
),
1258+
new AccessoryArrayListType(),
1259+
);
1260+
}
1261+
1262+
return $keysArray;
12511263
}
12521264

12531265
public function getValuesArray(): self

src/Type/IntersectionType.php

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

784-
public function getKeysArray(): Type
784+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
785785
{
786-
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray());
786+
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray($filterValueType, $strict));
787787
}
788788

789789
public function getValuesArray(): Type

src/Type/MixedType.php

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

181-
public function getKeysArray(): Type
181+
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
182182
{
183183
if ($this->isArray()->no()) {
184184
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)