mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Fix var_export() not working for stdClass in PHP < 7.3
This commit is contained in:
parent
a2c9274681
commit
3f7f802585
8 changed files with 40 additions and 43 deletions
|
|
@ -409,6 +409,22 @@ function url2path($url)
|
|||
return Rhymix\Framework\URL::toServerPath($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function fixes some of the issues with var_export() so that the result executes cleanly.
|
||||
*
|
||||
* @param mixed $var
|
||||
* @return string
|
||||
*/
|
||||
function var_export_clean($var)
|
||||
{
|
||||
$result = var_export($var, true);
|
||||
if (version_compare(PHP_VERSION, '7.3', '<'))
|
||||
{
|
||||
$result = preg_replace('/stdClass::__set_state\((?=array\(\n)/', '(object)(', $result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert hexadecimal color codes to an array of R, G, B values.
|
||||
* This function can handle both 6-digit and 3-digit notations, optionally prefixed with '#'.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue