Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/DI/Attributes/IgnoreDumping.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/

declare(strict_types=1);

namespace Nette\DI\Attributes;

use Attribute;

#[Attribute(Attribute::TARGET_CLASS)]
class IgnoreDumping
{
}
2 changes: 2 additions & 0 deletions src/DI/PhpGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Nette;
use Nette\DI\Definitions\Reference;
use Nette\DI\Definitions\Statement;
use Nette\DI\Attributes\IgnoreDumping;
use Nette\PhpGenerator as Php;
use function array_walk_recursive, is_array, is_object, is_string, ksort, sprintf, str_contains, str_ends_with, str_starts_with, substr;

Expand Down Expand Up @@ -186,6 +187,7 @@ public function convertArguments(array $args): array
} elseif (
is_object($val)
&& !$val instanceof Php\Literal && !$val instanceof \DateTimeInterface
&& !(new \ReflectionObject($val))->getAttributes(IgnoreDumping::class)
&& (new \ReflectionObject($val))->getProperties(\ReflectionProperty::IS_PRIVATE | \ReflectionProperty::IS_PROTECTED)
) {
trigger_error(sprintf('Nette DI: suspicious dumping of objects %s when generating the container', $val::class));
Expand Down