src/PhpFile.php
public function createScript($value, ?int $ttl): string
    {
        $macro = var_export($value, true);

        if (strpos($macro, 'stdClass::__set_state') !== false) {
            $macro = preg_replace_callback("/('([^'\\\\]++|''\\.)')|stdClass::__set_state/", $macro, function($match) {
                return empty($match[1]) ? '(object)' : $match[1];
            });
        }

        return $ttl !== null
            ? "<?php return time() < {$ttl} ? {$macro} : false;"
            : "<?php return {$macro};";
    }
public function createScript($value, ?int $ttl): string
    {
        $macro = var_export($value, true);

        if (strpos($macro, 'stdClass::__set_state') !== false) {
            $macro = preg_replace_callback("/('([^'\\\\]++|''\\.)')|stdClass::__set_state/", $macro, function($match) {
                return empty($match[1]) ? '(object)' : $match[1];
            });
        }

        return $ttl !== null
            ? "<?php return time() < {$ttl} ? {$macro} : false;"
            : "<?php return {$macro};";
    }
public function createScript ( $ value , ? int $ ttl ) : string { $ macro = var_export ( $ value , true ) ; if ( strpos ( $ macro , 'stdClass::__set_state' ) !== false ) { $ macro = preg_replace_callback ( "/('([^'\\\\]++|''\\.)')|stdClass::__set_state/" , $ macro , function ( $ match ) { return empty ( $ match [ 1 ] ) ? '(object)' : $ match [ 1 ] ; } ) ; } return $ ttl !== null ? "<?php return time() < {$ttl} ? {$macro} : false;" : "<?php return {$macro};" ; }
Create a PHP script returning the cached value

@param mixed    $value
@param int|null $ttl
@return string
Create a PHP script returning the cached value