getwarp/type
Runtime type checking and casting in PHP
Maintainers
3.1.2
2023-03-14 15:08 UTC
Requires
- php: ^7.4|^8.0
- getwarp/common: ^3.1
Requires (Dev)
- ext-json: *
- phpspec/prophecy: ^1.13
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 2a4df528eb21558e183b9858f8835551bd901a30
- Constantine Karnaukhov <genteelknight.woop@gmail.com>
README
getwarp/type
Runtime type checking and casting in PHP
GitHub • Packagist • Installation • Usage
Installation
Via Composer
$ composer require getwarp/type
Usage
use Warp\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
use Warp\Type\Factory\TypeFactoryAggregate; use Warp\Type\Factory\MemoizedTypeFactory; $factory = new MemoizedTypeFactory(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.
