15
15
16
16
use Symfony \Component \TypeInfo \Type ;
17
17
use Symfony \Component \TypeInfo \Type \CollectionType ;
18
- use Symfony \Component \TypeInfo \Type \CompositeTypeInterface ;
19
18
use Symfony \Component \TypeInfo \Type \ObjectType ;
20
- use Symfony \Component \TypeInfo \Type \WrappingTypeInterface ;
21
19
22
20
/**
23
21
* @internal
@@ -30,50 +28,9 @@ private function __construct()
30
28
{
31
29
}
32
30
33
- /**
34
- * https://github.com/symfony/symfony/pull/59845.
35
- *
36
- * @return iterable<Type>
37
- */
38
- public static function traverse (Type $ type , bool $ traverseComposite = true , bool $ traverseWrapped = true ): iterable
39
- {
40
- yield $ type ;
41
-
42
- if ($ type instanceof CompositeTypeInterface && $ traverseComposite ) {
43
- foreach ($ type ->getTypes () as $ t ) {
44
- yield $ t ;
45
- }
46
-
47
- // prevent yielding twice when having a type that is both composite and wrapped
48
- return ;
49
- }
50
-
51
- if ($ type instanceof WrappingTypeInterface && $ traverseWrapped ) {
52
- yield $ type ->getWrappedType ();
53
- }
54
- }
55
-
56
- /**
57
- * https://github.com/symfony/symfony/pull/59844.
58
- *
59
- * @param callable(Type): bool $specification
60
- */
61
- public static function isSatisfiedBy (Type $ type , callable $ specification ): bool
62
- {
63
- if ($ type instanceof WrappingTypeInterface && $ type ->wrappedTypeIsSatisfiedBy ($ specification )) {
64
- return true ;
65
- }
66
-
67
- if ($ type instanceof CompositeTypeInterface && $ type ->composedTypesAreSatisfiedBy ($ specification )) {
68
- return true ;
69
- }
70
-
71
- return $ specification ($ type );
72
- }
73
-
74
31
public static function getCollectionValueType (Type $ type ): ?Type
75
32
{
76
- foreach (self :: traverse ( $ type ) as $ t ) {
33
+ foreach ($ type-> traverse ( ) as $ t ) {
77
34
if ($ t instanceof CollectionType) {
78
35
return $ t ->getCollectionValueType ();
79
36
}
@@ -87,7 +44,7 @@ public static function getCollectionValueType(Type $type): ?Type
87
44
*/
88
45
public static function getClassName (Type $ type ): ?string
89
46
{
90
- foreach (self :: traverse ( $ type ) as $ t ) {
47
+ foreach ($ type-> traverse ( ) as $ t ) {
91
48
if ($ t instanceof ObjectType) {
92
49
return $ t ->getClassName ();
93
50
}
0 commit comments