| Methods | ||
|---|---|---|
| 
					
	public
					static
					
				 | map(Type $type, callable(Type $type, callable(Type): Type $traverse): Type $cb): Type
		Map a Type recursively
	 Map a Type recursively For every Type instance, the callback can return a new Type, and/or decide to traverse inner types or to ignore them. The following example converts constant strings to objects, while preserving unions and intersections: TypeTraverser::map($type, function (Type $type, callable $traverse): Type { if ($type instanceof UnionType || $type instanceof IntersectionType) { // Traverse inner types return $traverse($type); } if ($type instanceof ConstantStringType) { // Replaces the current type, and don't traverse return new ObjectType($type->getValue()); } // Replaces the current type, and don't traverse return new MixedType(); }); | # |