Via Composer
$ composer require getwarp/typeuseWarp\Type\BuiltinType;
$int = BuiltinType::int();
\assert(true === $int->check(1));
\assert(false === $int->check('string'));You can also use factory to create type object from string
useWarp\Type\Factory\TypeFactoryAggregate;
useWarp\Type\Factory\MemoizedTypeFactory;
$factory = newMemoizedTypeFactory(TypeFactoryAggregate::default());
$factory->make('int');
$factory->make('string[]');
$factory->make('array<string,object>');
$factory->make('int|null');
$factory->make('Traversable|iterable|null');
$factory->make('Traversable&JsonSerializable');Please see CHANGELOG for more information on what has changed recently.
Report issues and send pull requests in the main Warp repository. Please see contributing guide and code of conduct for details.
The MIT License (MIT). Please see license file for more information.