This commit is contained in:
Sebastian Bergmann 2024-06-21 10:38:47 +02:00
parent 119dedae41
commit 2dce761b61
No known key found for this signature in database
GPG Key ID: 4AA394086372C20A
1 changed files with 14 additions and 9 deletions

View File

@ -130,18 +130,10 @@ final readonly class Exporter
}
if (is_object($value)) {
if ($this->canBeReflected($value)) {
$numberOfProperties = count((new ReflectionObject($value))->getProperties());
} else {
// @codeCoverageIgnoreStart
$numberOfProperties = count($this->toArray($value));
// @codeCoverageIgnoreEnd
}
return sprintf(
'%s Object (%s)',
$value::class,
$numberOfProperties > 0 ? '...' : '',
$this->countProperties($value) > 0 ? '...' : '',
);
}
@ -208,6 +200,19 @@ final readonly class Exporter
return $array;
}
public function countProperties(object $value): int
{
if ($this->canBeReflected($value)) {
$numberOfProperties = count((new ReflectionObject($value))->getProperties());
} else {
// @codeCoverageIgnoreStart
$numberOfProperties = count($this->toArray($value));
// @codeCoverageIgnoreEnd
}
return $numberOfProperties;
}
private function shortenedCountedRecursiveExport(array &$data, RecursionContext $processed, int &$counter): string
{
$result = [];