Skip to content

Commit 93ce29d

Browse files
committed
add separate Type method
1 parent 0887d78 commit 93ce29d

17 files changed

+112
-36
lines changed

src/Type/Accessory/AccessoryArrayListType.php

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

175-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
175+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
176+
{
177+
return $this->getKeysArray();
178+
}
179+
180+
public function getKeysArray(): Type
176181
{
177182
return $this;
178183
}

src/Type/Accessory/HasOffsetType.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,12 @@ public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
352352
return new BooleanType();
353353
}
354354

355-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
355+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
356+
{
357+
return $this->getKeysArray();
358+
}
359+
360+
public function getKeysArray(): Type
356361
{
357362
return new NonEmptyArrayType();
358363
}

src/Type/Accessory/HasOffsetValueType.php

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

198-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
198+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
199+
{
200+
return $this->getKeysArray();
201+
}
202+
203+
public function getKeysArray(): Type
199204
{
200205
return new NonEmptyArrayType();
201206
}

src/Type/Accessory/NonEmptyArrayType.php

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

162-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
162+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
163+
{
164+
return $this->getKeysArray();
165+
}
166+
167+
public function getKeysArray(): Type
163168
{
164169
return $this;
165170
}

src/Type/Accessory/OversizedArrayType.php

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

157-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
157+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
158+
{
159+
return $this->getKeysArray();
160+
}
161+
162+
public function getKeysArray(): Type
158163
{
159164
return $this;
160165
}

src/Type/ArrayType.php

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

173-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
173+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
174+
{
175+
return $this->getKeysArray();
176+
}
177+
178+
public function getKeysArray(): Type
174179
{
175180
return TypeCombinator::intersect(new self(new IntegerType(), $this->getIterableKeyType()), new AccessoryArrayListType());
176181
}

src/Type/Constant/ConstantArrayType.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,21 +1372,22 @@ private function degradeToGeneralArray(): Type
13721372
return $builder->getArray();
13731373
}
13741374

1375-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
1375+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
13761376
{
13771377
$keysArray = $this->getKeysOrValuesArray($this->keyTypes);
13781378

1379-
if ($filterValueType !== null) {
1380-
return TypeCombinator::intersect(
1381-
new ArrayType(
1382-
$keysArray->getIterableKeyType()->generalize(GeneralizePrecision::lessSpecific()),
1383-
$keysArray->getIterableValueType()->generalize(GeneralizePrecision::lessSpecific()),
1384-
),
1385-
new AccessoryArrayListType(),
1386-
);
1387-
}
1379+
return TypeCombinator::intersect(
1380+
new ArrayType(
1381+
$keysArray->getIterableKeyType()->generalize(GeneralizePrecision::lessSpecific()),
1382+
$keysArray->getIterableValueType()->generalize(GeneralizePrecision::lessSpecific()),
1383+
),
1384+
new AccessoryArrayListType(),
1385+
);
1386+
}
13881387

1389-
return $keysArray;
1388+
public function getKeysArray(): self
1389+
{
1390+
return $this->getKeysOrValuesArray($this->keyTypes);
13901391
}
13911392

13921393
public function getValuesArray(): self

src/Type/IntersectionType.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,14 @@ public function unsetOffset(Type $offsetType): Type
842842
return $this->intersectTypes(static fn (Type $type): Type => $type->unsetOffset($offsetType));
843843
}
844844

845-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
845+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
846846
{
847-
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray($filterValueType, $strict));
847+
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArrayFiltered($filterValueType, $strict));
848+
}
849+
850+
public function getKeysArray(): Type
851+
{
852+
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArray());
848853
}
849854

850855
public function getValuesArray(): Type

src/Type/MixedType.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@ public function unsetOffset(Type $offsetType): Type
180180
return $this;
181181
}
182182

183-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
183+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
184+
{
185+
return $this->getKeysArray();
186+
}
187+
188+
public function getKeysArray(): Type
184189
{
185190
if ($this->isArray()->no()) {
186191
return new ErrorType();

src/Type/NeverType.php

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

276-
public function getKeysArray(?Type $filterValueType = null, bool $strict = false): Type
276+
public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
277+
{
278+
return $this->getKeysArray();
279+
}
280+
281+
public function getKeysArray(): Type
277282
{
278283
return new NeverType();
279284
}

0 commit comments

Comments
 (0)