PHP code example of innmind / type
1. Go to this page and download the library: Download innmind/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/ */
innmind / type example snippets
use Innmind\Type\{
Build,
Primitive,
};
final class Example
{
private int $id;
}
$type = Build::fromReflection((new \ReflectionProperty(Example::class, 'id'))->getType());
$type->allows(42); // true
$type->allows('some-uuid'); // false
$type->accepts(Primitive::int()); // true
$type->accepts(Primitive::string()); // false