1. Go to this page and download the library: Download brick/varexporter 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/ */
class Foo
{
public $a;
public $b;
public $c;
public static function __set_state(array $array) : self
{
$object = new self;
$object->a = $array['a'];
$object->b = $array['b'];
$object->c = $array['c'];
return $object;
}
}
public static function __set_state(array $array) : self
{
$object = new self;
foreach ($array as $key => $value) {
$object->{$key} = $value;
}
return $object;
}
namespace My\App;
use My\App\Model\Entity;
use function My\App\Functions\imported_function;
use const My\App\Constants\IMPORTED_CONSTANT;
use Brick\VarExporter\VarExporter;
echo VarExporter::export(function(Service $service) : Entity {
strlen(NON_NAMESPACED_CONSTANT);
imported_function(IMPORTED_CONSTANT);
\My\App\Functions\explicitly_namespaced_function(\My\App\Constants\EXPLICITLY_NAMESPACED_CONSTANT);
return new Entity();
});
function (\My\App\Service $service) : \My\App\Model\Entity {
strlen(NON_NAMESPACED_CONSTANT);
\My\App\Functions\imported_function(\My\App\Constants\IMPORTED_CONSTANT);
\My\App\Functions\explicitly_namespaced_function(\My\App\Constants\EXPLICITLY_NAMESPACED_CONSTANT);
return new \My\App\Model\Entity();
}
use Brick\VarExporter\VarExporter;
use Brick\VarExporter\ExportException;
try {
VarExporter::export(fopen('php://memory', 'r'));
} catch (ExportException $e) {
// Type "resource" is not supported.
}
public foo()
{
$data = {{exported}};
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.