diff --git a/src/Proxy/ProxyGenerator.php b/src/Proxy/ProxyGenerator.php index 70d64bed1..8adbf5dc4 100644 --- a/src/Proxy/ProxyGenerator.php +++ b/src/Proxy/ProxyGenerator.php @@ -44,11 +44,14 @@ use function mkdir; use function preg_match; use function preg_match_all; +use function preg_replace; +use function preg_split; use function random_bytes; use function rename; use function rtrim; use function sprintf; use function str_replace; +use function strpos; use function strrev; use function strtolower; use function strtr; @@ -58,6 +61,7 @@ use const DIRECTORY_SEPARATOR; use const PHP_VERSION_ID; +use const PREG_SPLIT_DELIM_CAPTURE; /** * This factory is used to generate proxy classes. @@ -1124,6 +1128,17 @@ private function getParameterDefaultValue(ReflectionParameter $parameter) $value = rtrim(substr(explode('$' . $parameter->getName() . ' = ', (string) $parameter, 2)[1], 0, -2)); + if (strpos($value, '\\') !== false || strpos($value, '::') !== false) { + $value = preg_split("/('(?:[^'\\\\]*+(?:\\\\.)*+)*+')/", $value, -1, PREG_SPLIT_DELIM_CAPTURE); + foreach ($value as $i => $part) { + if ($i % 2 === 0) { + $value[$i] = preg_replace('/(?