PHP code example of thorough-php / type-guard

1. Go to this page and download the library: Download thorough-php/type-guard 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/ */

    

thorough-php / type-guard example snippets


(new TypeGuard('string'))->match('foo'); // => true

(new TypeGuard('stdClass'))->match(new stdClass()); // => true

$guard = new TypeGuard('string|integer');
$guard->match('foo'); // => true
$guard->match(1); // => true

(new TypeGuard('ArrayAccess&Countable'))->match(new ArrayIterator()); // => true

(new TypeGuard('?string'))->match(null); // => true