@@ -139,9 +139,9 @@ private function dumpArray(array &$var, array $parents, int $level, int $column)
139
139
private function dumpObject (object $ var , array $ parents , int $ level ): string
140
140
{
141
141
$ class = $ var ::class;
142
- if ( method_exists ( $ var , ' __serialize ' )) {
143
- $ data = $ this -> dump ( $ var -> __serialize ());
144
- return '\\' . self :: class . " ::createObject( \\ $ class ::class , $ data ) " ;
142
+
143
+ if ( in_array ( $ class , [\DateTime::class, \DateTimeImmutable::class], true )) {
144
+ return $ this -> format ( " new \\ $ class(?, new \\ DateTimeZone(?)) " , $ var -> format ( ' Y-m-d H:i:s.u ' ) , $ var -> getTimeZone ()-> getName ()) ;
145
145
146
146
} elseif ($ var instanceof \Serializable) { // deprecated
147
147
return 'unserialize( ' . $ this ->dumpString (serialize ($ var )) . ') ' ;
@@ -158,29 +158,28 @@ private function dumpObject(object $var, array $parents, int $level): string
158
158
}
159
159
160
160
throw new Nette \InvalidArgumentException ('Cannot dump closure. ' );
161
- }
162
161
163
- if ((new \ReflectionObject ($ var ))->isAnonymous ()) {
162
+ } elseif ((new \ReflectionObject ($ var ))->isAnonymous ()) {
164
163
throw new Nette \InvalidArgumentException ('Cannot dump anonymous class. ' );
165
164
166
- } elseif (in_array ($ class , [\DateTime::class, \DateTimeImmutable::class] , true )) {
167
- return $ this -> format ( " new \\ $ class (?, new \\ DateTimeZone(?)) " , $ var -> format ( ' Y-m-d H:i:s.u ' ), $ var -> getTimeZone ()-> getName () );
165
+ } elseif ($ level > $ this -> maxDepth || in_array ($ var , $ parents , true )) {
166
+ throw new Nette \ InvalidArgumentException ( ' Nesting level too deep or recursive dependency. ' );
168
167
}
169
168
170
- $ arr = (array ) $ var ;
171
- $ space = str_repeat ($ this ->indentation , $ level );
172
-
173
- if ($ level > $ this ->maxDepth || in_array ($ var , $ parents , true )) {
174
- throw new Nette \InvalidArgumentException ('Nesting level too deep or recursive dependency. ' );
169
+ if (method_exists ($ var , '__serialize ' )) {
170
+ $ arr = $ var ->__serialize ();
171
+ } else {
172
+ $ arr = (array ) $ var ;
173
+ if (method_exists ($ var , '__sleep ' )) {
174
+ foreach ($ var ->__sleep () as $ v ) {
175
+ $ props [$ v ] = $ props ["\x00* \x00$ v " ] = $ props ["\x00$ class \x00$ v " ] = true ;
176
+ }
177
+ }
175
178
}
176
179
180
+ $ space = str_repeat ($ this ->indentation , $ level );
177
181
$ out = "\n" ;
178
182
$ parents [] = $ var ;
179
- if (method_exists ($ var , '__sleep ' )) {
180
- foreach ($ var ->__sleep () as $ v ) {
181
- $ props [$ v ] = $ props ["\x00* \x00$ v " ] = $ props ["\x00$ class \x00$ v " ] = true ;
182
- }
183
- }
184
183
185
184
foreach ($ arr as $ k => &$ v ) {
186
185
if (!isset ($ props ) || isset ($ props [$ k ])) {
@@ -195,7 +194,7 @@ private function dumpObject(object $var, array $parents, int $level): string
195
194
$ out .= $ space ;
196
195
return $ class === \stdClass::class
197
196
? "(object) [ $ out] "
198
- : '\\' . self ::class . "::createObject(' $ class' , [$ out]) " ;
197
+ : '\\' . self ::class . "::createObject( \\ $ class::class , [$ out]) " ;
199
198
}
200
199
201
200
0 commit comments