flow php

DSL stands for Domain Specific Language. In the case of Flow, the DSL is used to define simple functions that can be used to transform data. Most of those functions are initializing a new instance of a class under the hood since Flow is fully object-oriented. Please look at the examples below to get a better understanding of how to use the DSL functions.

TYPE


/**
 * @template T of UnitEnum
 *
 * @param class-string<T> $class
 *
 * @return EnumType<T>
 */
type_enum(string $class) : EnumType
/**
 * @template T of object
 *
 * @param class-string<T> $class
 *
 * @return InstanceOfType<T>
 */
type_instance_of(string $class) : InstanceOfType
/**
 * @template T
 *
 * @param Type<T> $element
 *
 * @return ListType<T>
 */
type_list(Type $element) : ListType
/**
 * @template T
 *
 * @param Type<T> $value_type
 *
 * @return MapType<array-key, T>
 */
type_map(StringType|IntegerType $key_type, Type $value_type) : MapType
/**
 * @template T
 *
 * @param Type<T> $type
 *
 * @return OptionalType<T>
 */
type_optional(Type $type) : OptionalType
/**
 * @template T of array
 *
 * @param T $elements
 *
 * @return StructureType<T>
 */
type_structure(array $elements) : StructureType
/**
 * @template T
 *
 * @param Type<T> $first
 * @param Type<T> $second
 * @param Type<T> ...$types
 *
 * @return UnionType<T, T>
 */
type_union(Type $first, Type $second, Type $types) : UnionType

HELPER


/**
 * @param Type<mixed> ...$types
 */
types(Type $types) : Types
/**
 * @template TLeft
 * @template TRight
 *
 * @param Type<TLeft> $left
 * @param Type<TRight> $right
 */
type_equals(Type $left, Type $right) : bool
/**
 * @param array<mixed> $data
 *
 * @return Type<mixed>
 */
type_from_array(array $data) : Type
/**
 * @template T
 *
 * @param Type<T> $type
 * @param class-string<Type<mixed>> $typeClass
 */
type_is(Type $type, string $typeClass) : bool
/**
 * @template T
 *
 * @param Type<T> $type
 * @param class-string<Type<mixed>> $typeClass
 * @param class-string<Type<mixed>> ...$typeClasses
 */
type_is_any(Type $type, string $typeClass, string $typeClasses) : bool

Contributors

Join us on GitHub external resource
scroll back to top