-
-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Util\Debug: export parent class private attributes and DateTimeImmutable #729
Conversation
@@ -109,10 +109,10 @@ public static function export($var, $maxDepth) | |||
} | |||
} else if ($isObj) { | |||
$return = new \stdclass(); | |||
if ($var instanceof \DateTime) { | |||
$return->__CLASS__ = "DateTime"; | |||
if ($var instanceof \DateTime || $var instanceof \DateTimeInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can actually simply check against DateTimeInterface
, since we don't support older PHP versions anymore
Changes done. In the last commit I applied "Replace Nested Conditional with Guard Clauses" pattern: if you don't want such a big change I can revert it (but if you ask me that I'll unfollow you in Twitter) |
Note: I don't know if I did what you wanted saying "Can you move this block to a private method?", to me it was not strictly necessary, btw done it too. |
The complexity of the method was starting to become a bit too much: splitting it simplifies things :) |
do { | ||
$currentClassName = $reflClass->getName(); | ||
|
||
foreach ($reflClass->getProperties() as $reflProperty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last test scenario needed (although it's just to prevent regressions):
class A
{
private $a;
protected $b;
public $c;
}
class B extends A
{
private $a;
protected $b;
public $c;
}
The resulting dump of dump(new B)
should show following properties, if I'm not mistaken:
A#$a
B#$a
B#$b
B#$c
Indeed there was a bug, fixed :P |
@Slamdunk awesome, thanks! |
This patch enhances DateTime export for the new DateTimeImmutable and fixes the behaviour dumping also the private attributes of parent class emulating
print_r