for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Yiisoft\Composer\Config\Util;
use Riimu\Kit\PHPEncoder\PHPEncoder;
/**
* Helper class.
*/
class Helper
{
* Returns PHP-executable string representation of given value.
* Uses Riimu/Kit-PHPEncoder based `var_export` alternative.
* And Opis/Closure to dump closures as PHP code.
* @param mixed $value
* @return string
* @throws \ReflectionException
public static function exportVar($value): string
return static::getEncoder()->encode($value);
}
private static $encoder;
private static function getEncoder()
if (self::$encoder === null) {
self::$encoder = static::createEncoder();
return self::$encoder;
private static function createEncoder()
$encoder = new PHPEncoder([
'object.format' => 'serialize',
]);
$encoder->addEncoder(new ClosureEncoder(), true);
return $encoder;