PHP code example of internations / type-jail
1. Go to this page and download the library: Download internations/type-jail 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/ */
internations / type-jail example snippets
use InterNations\Component\TypeJail\Factory\SuperTypeFactory;
use InterNations\Component\TypeJail\Factory\JailFactory;
use InterNations\Component\TypeJail\Factory\SuperTypeJailFactory;
$file = new SplFileObject(__FILE__);
$factory = new JailFactory();
$file = $factory->createInstanceJail($file, 'SplFileInfo');
// Will return true
var_dump($file instanceof SplFileInfo);
// Will return the file path because that method is declared in SplFileInfo
$file->getFilePath();
// Will throw an exception indicating a type violation because that method
// is declared in SplFileObject
$file->flock();
$factory = new SuperTypeJailFactory();
$file = $factory->createInstanceJail($file, 'SplFileInfo');
// Will return false
var_dump($file instanceof SplFileInfo);
// Will return the file path because that method is declared in SplFileInfo
$file->getFilePath();
// Will throw an exception indicating a type violation because that method
// is declared in SplFileObject
$file->flock();
$factory = new SuperTypeFactory();
$file = $factory->createInstanceJail($file, 'SplFileInfo');
// Will return false
var_dump($file instanceof SplFileInfo);
// Will return the file path because that method is declared in SplFileInfo
$file->getFilePath();
// Fatal error: method not found
$file->flock();