@@ -123,27 +123,42 @@ public function getReferencedClasses(): array
123
123
124
124
public function getObjectClassNames (): array
125
125
{
126
- return array_values (array_unique ($ this ->pickFromTypes (static fn (Type $ type ) => $ type ->getObjectClassNames ())));
126
+ return array_values (array_unique ($ this ->pickFromTypes (
127
+ static fn (Type $ type ) => $ type ->getObjectClassNames (),
128
+ static fn (Type $ type ) => $ type ->isObject ()->yes (),
129
+ )));
127
130
}
128
131
129
132
public function getObjectClassReflections (): array
130
133
{
131
- return $ this ->pickFromTypes (static fn (Type $ type ) => $ type ->getObjectClassReflections ());
134
+ return $ this ->pickFromTypes (
135
+ static fn (Type $ type ) => $ type ->getObjectClassReflections (),
136
+ static fn (Type $ type ) => $ type ->isObject ()->yes (),
137
+ );
132
138
}
133
139
134
140
public function getArrays (): array
135
141
{
136
- return $ this ->pickFromTypes (static fn (Type $ type ) => $ type ->getArrays ());
142
+ return $ this ->pickFromTypes (
143
+ static fn (Type $ type ) => $ type ->getArrays (),
144
+ static fn (Type $ type ) => $ type ->isArray ()->yes (),
145
+ );
137
146
}
138
147
139
148
public function getConstantArrays (): array
140
149
{
141
- return $ this ->pickFromTypes (static fn (Type $ type ) => $ type ->getConstantArrays ());
150
+ return $ this ->pickFromTypes (
151
+ static fn (Type $ type ) => $ type ->getConstantArrays (),
152
+ static fn (Type $ type ) => $ type ->isArray ()->yes (),
153
+ );
142
154
}
143
155
144
156
public function getConstantStrings (): array
145
157
{
146
- return $ this ->pickFromTypes (static fn (Type $ type ) => $ type ->getConstantStrings ());
158
+ return $ this ->pickFromTypes (
159
+ static fn (Type $ type ) => $ type ->getConstantStrings (),
160
+ static fn (Type $ type ) => $ type ->isString ()->yes (),
161
+ );
147
162
}
148
163
149
164
public function accepts (Type $ type , bool $ strictTypes ): TrinaryLogic
@@ -718,7 +733,10 @@ public function shuffleArray(): Type
718
733
719
734
public function getEnumCases (): array
720
735
{
721
- return $ this ->pickFromTypes (static fn (Type $ type ) => $ type ->getEnumCases ());
736
+ return $ this ->pickFromTypes (
737
+ static fn (Type $ type ) => $ type ->getEnumCases (),
738
+ static fn (Type $ type ) => $ type ->isObject ()->yes (),
739
+ );
722
740
}
723
741
724
742
public function isCallable (): TrinaryLogic
@@ -1069,15 +1087,19 @@ protected function unionTypes(callable $getType): Type
1069
1087
*/
1070
1088
protected function pickTypes (callable $ getTypes ): array
1071
1089
{
1072
- return $ this ->pickFromTypes ($ getTypes );
1090
+ return $ this ->pickFromTypes ($ getTypes, static fn () => false );
1073
1091
}
1074
1092
1075
1093
/**
1076
1094
* @template T
1077
1095
* @param callable(Type $type): list<T> $getValues
1096
+ * @param callable(Type $type): bool $criteria
1078
1097
* @return list<T>
1079
1098
*/
1080
- protected function pickFromTypes (callable $ getValues ): array
1099
+ protected function pickFromTypes (
1100
+ callable $ getValues ,
1101
+ callable $ criteria ,
1102
+ ): array
1081
1103
{
1082
1104
$ values = [];
1083
1105
foreach ($ this ->types as $ type ) {
0 commit comments