Skip to content

Repository files navigation

getwarp/type

Runtime type checking and casting in PHP

GitHubPackagistInstallationUsage

Installation

Via Composer

$ composer require getwarp/type

Usage

useWarp\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');

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Report issues and send pull requests in the main Warp repository. Please see contributing guide and code of conduct for details.

Credits

License

The MIT License (MIT). Please see license file for more information.

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages