PHP code example of getwarp / type
1. Go to this page and download the library: Download getwarp/type library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
getwarp / type example snippets
use Warp\Type\BuiltinType;
$int = BuiltinType::int();
\assert(true === $int->check(1));
\assert(false === $int->check('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');