This commit is contained in:
2025-05-12 14:25:25 +02:00
parent ab2db755ef
commit 9e378ca2b7
2719 changed files with 46505 additions and 60181 deletions

View File

@@ -219,7 +219,7 @@ abstract class AbstractCloner implements ClonerInterface
*
* @see addCasters
*/
public function __construct(array $casters = null)
public function __construct(?array $casters = null)
{
$this->addCasters($casters ?? static::$defaultCasters);
}

View File

@@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\VarDumper\Cloner\Internal;
/**
* Flags a typed property that has no default value.
*
* This dummy object is used to distinguish a property with a default value of null
* from a property that is uninitialized by default.
*
* @internal
*/
enum NoDefault
{
case NoDefault;
}

View File

@@ -11,6 +11,8 @@
namespace Symfony\Component\VarDumper\Cloner;
use Symfony\Component\VarDumper\Cloner\Internal\NoDefault;
/**
* Represents the main properties of a PHP variable.
*
@@ -50,15 +52,20 @@ class Stub
$properties = [];
if (!isset(self::$defaultProperties[$c = static::class])) {
self::$defaultProperties[$c] = get_class_vars($c);
$reflection = new \ReflectionClass($c);
self::$defaultProperties[$c] = [];
foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) {
unset(self::$defaultProperties[$c][$k]);
foreach ($reflection->getProperties() as $p) {
if ($p->isStatic()) {
continue;
}
self::$defaultProperties[$c][$p->name] = $p->hasDefaultValue() ? $p->getDefaultValue() : ($p->hasType() ? NoDefault::NoDefault : null);
}
}
foreach (self::$defaultProperties[$c] as $k => $v) {
if ($this->$k !== $v) {
if (NoDefault::NoDefault === $v || $this->$k !== $v) {
$properties[] = $k;
}
}