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 object
 *
 * @param null|class-string<T> $class
 *
 * @return ($class is null ? Type<class-string> : Type<class-string<T>>)
 */
type_class_string(?string $class) : Type
/**
 * @template T of UnitEnum
 *
 * @param class-string<T> $class
 *
 * @return Type<T>
 */
type_enum(string $class) : Type
/**
 * @template T of object
 *
 * @param class-string<T> $class
 *
 * @return Type<T>
 */
type_instance_of(string $class) : Type
/**
 * @template T
 *
 * @param Type<T> $first
 * @param Type<T> $second
 * @param Type<T> ...$types
 *
 * @return Type<T>
 */
type_intersection(Type $first, Type $second, Type $types) : Type
/**
 * @template T
 *
 * @param Type<T> $element
 *
 * @return ListType<T>
 */
type_list(Type $element) : ListType
/**
 * @template T of bool|float|int|string
 *
 * @param T $value
 *
 * @return LiteralType<T>
 */
type_literal(string|int|float|bool $value) : LiteralType
/**
 * @template TKey of array-key
 * @template TValue
 *
 * @param Type<TKey> $key_type
 * @param Type<TValue> $value_type
 *
 * @return Type<array<TKey, TValue>>
 */
type_map(Type $key_type, Type $value_type) : Type
/**
 * @template T
 *
 * @param Type<T> $type
 *
 * @return Type<T>
 */
type_optional(Type $type) : Type
/**
 * @template T
 *
 * @param array<string, Type<T>> $elements
 * @param array<string, Type<T>> $optional_elements
 *
 * @return Type<array<string, T>>
 */
type_structure(array $elements, array $optional_elements, bool $allow_extra) : Type
/**
 * @template T
 * @template T
 * @template T
 *
 * @param Type<T> $first
 * @param Type<T> $second
 * @param Type<T> ...$types
 *
 * @return Type<T>
 */
type_union(Type $first, Type $second, Type $types) : Type

HELPER


/**
 * @template T
 *
 * @param Type<T> ...$types
 *
 * @return Types<T>
 */
types(Type $types) : Types
/**
 * @param Type<mixed> $left
 * @param Type<mixed> $right
 */
type_equals(Type $left, Type $right) : bool
/**
 * @param array<string, 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