PHP Class mpyw\Co\Internal\YieldableUtils

显示文件 Open project: mpyw/co Class Usage Examples

Public Methods

Method Description
getApplier ( mixed $yielded, array $yieldables, callable $next = null ) : mixed Return function that apply changes in yieldables.
getYieldables ( mixed $value, array $keylist = [], array &$runners = [] ) : array Recursively search yieldable values.
normalize ( mixed $value, mixed $yield_key = null ) : mixed Recursively normalize value.
safePromise ( React\Promise\PromiseInterface $promise ) : React\Promise\PromiseInterface Return Promise that absorbs rejects, excluding fatal Throwable.

Method Details

getApplier() public static method

Return function that apply changes in yieldables.
public static getApplier ( mixed $yielded, array $yieldables, callable $next = null ) : mixed
$yielded mixed
$yieldables array
$next callable
return mixed

getYieldables() public static method

Each entries are assoc those contain keys 'value' and 'keylist'. value -> the value itself. keylist -> position of the value. nests are represented as array values.
public static getYieldables ( mixed $value, array $keylist = [], array &$runners = [] ) : array
$value mixed Must be already normalized.
$keylist array Internally used.
$runners array
return array

normalize() public static method

Generator Closure -> GeneratorContainer Array -> Array (children's are normalized) Others -> Others
public static normalize ( mixed $value, mixed $yield_key = null ) : mixed
$value mixed
$yield_key mixed
return mixed

safePromise() public static method

Return Promise that absorbs rejects, excluding fatal Throwable.
public static safePromise ( React\Promise\PromiseInterface $promise ) : React\Promise\PromiseInterface
$promise React\Promise\PromiseInterface
return React\Promise\PromiseInterface