@@ -593,38 +593,38 @@ private function processObject($data, Context $options, $path, $result = null)
593
593
594
594
if ($ this ->useObjectAsArray ) {
595
595
$ result = array ();
596
- } else /*if (!$result instanceof ObjectItemContract || null !== $this->objectItemClass)*/ {
596
+ } else {
597
597
//* todo check performance impact
598
598
if (null === $ this ->objectItemClass ) {
599
- $ result = new ObjectItem ();
599
+ if (!$ result instanceof ObjectItemContract) {
600
+ $ result = new ObjectItem ();
601
+ $ result ->setDocumentPath ($ path );
602
+ }
600
603
} else {
601
604
$ className = $ this ->objectItemClass ;
602
605
if ($ options ->objectItemClassMapping !== null ) {
603
606
if (isset ($ options ->objectItemClassMapping [$ className ])) {
604
607
$ className = $ options ->objectItemClassMapping [$ className ];
605
608
}
606
609
}
607
- $ result = new $ className ;
608
- }
609
- //*/
610
-
611
-
612
- if ($ result instanceof ClassStructure) {
613
- if ($ result ->__validateOnSet ) {
614
- $ result ->__validateOnSet = false ;
615
- /** @noinspection PhpUnusedLocalVariableInspection */
616
- /* todo check performance impact
617
- $validateOnSetHandler = new ScopeExit(function () use ($result) {
618
- $result->__validateOnSet = true;
619
- });
610
+ if (null !== $ result && get_class ($ result ) !== $ className ) {
611
+ $ result = new $ className ;
612
+ //* todo check performance impact
613
+ if ($ result instanceof ClassStructure) {
614
+ $ result ->setDocumentPath ($ path );
615
+ if ($ result ->__validateOnSet ) {
616
+ $ result ->__validateOnSet = false ;
617
+ /** @noinspection PhpUnusedLocalVariableInspection */
618
+ /* todo check performance impact
619
+ $validateOnSetHandler = new ScopeExit(function () use ($result) {
620
+ $result->__validateOnSet = true;
621
+ });
622
+ //*/
623
+ }
624
+ }
620
625
//*/
621
626
}
622
627
}
623
-
624
- //* todo check performance impact
625
- if ($ result instanceof ObjectItemContract) {
626
- $ result ->setDocumentPath ($ path );
627
- }
628
628
//*/
629
629
}
630
630
}
0 commit comments