@@ -550,30 +550,23 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
550550
551551		foreach  ($ diffas  $ i$ diffElem
552552			$ diffType$ diffElemtype ;
553- 			$ arrItem $ diffElemnew ;
554- 			$ origArrayItem $ diffElemold ;
553+ 			$ newNode $ diffElemnew ;
554+ 			$ originalNode $ diffElemold ;
555555			if  ($ diffTypeTYPE_KEEP  || $ diffTypeTYPE_REPLACE ) {
556556				$ beforeFirstKeepOrReplacefalse ;
557- 				if  (!$ arrItem instanceof  Node || !$ origArrayItem instanceof  Node) {
557+ 				if  (!$ newNode instanceof  Node || !$ originalNode instanceof  Node) {
558558					return  null ;
559559				}
560560
561561				/** @var int $itemStartPos */ 
562- 				$ itemStartPos$ origArrayItem getAttribute (Attribute::START_INDEX );
562+ 				$ itemStartPos$ originalNode getAttribute (Attribute::START_INDEX );
563563
564564				/** @var int $itemEndPos */ 
565- 				$ itemEndPos$ origArrayItemgetAttribute (Attribute::END_INDEX );
566- 
565+ 				$ itemEndPos$ originalNodegetAttribute (Attribute::END_INDEX );
567566				if  ($ itemStartPos0  || $ itemEndPos0  || $ itemStartPos$ tokenIndex
568567					throw  new  LogicException ();
569568				}
570569
571- 				$ comments$ arrItemgetAttribute (Attribute::COMMENTS ) ?? [];
572- 				$ origComments$ origArrayItemgetAttribute (Attribute::COMMENTS ) ?? [];
573- 
574- 				$ commentStartPoscount ($ origComments0  ? $ origComments0 ]->startIndex  : $ itemStartPos
575- 				assert ($ commentStartPos0 );
576- 
577570				$ result$ originalTokensgetContentBetween ($ tokenIndex$ itemStartPos
578571
579572				if  (count ($ delayedAdd0 ) {
@@ -583,15 +576,6 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
583576						if  ($ parenthesesNeeded
584577							$ result'( ' ;
585578						}
586- 
587- 						if  ($ insertNewline
588- 							$ delayedAddComments$ delayedAddNodegetAttribute (Attribute::COMMENTS ) ?? [];
589- 							if  (count ($ delayedAddComments0 ) {
590- 								$ result$ this printComments ($ delayedAddComments$ beforeAsteriskIndent$ afterAsteriskIndent
591- 								$ resultsprintf ('%s%s*%s ' , $ originalTokensgetDetectedNewline () ?? "\n" , $ beforeAsteriskIndent$ afterAsteriskIndent
592- 							}
593- 						}
594- 
595579						$ result$ this printNodeFormatPreserving ($ delayedAddNode$ originalTokens
596580						if  ($ parenthesesNeeded
597581							$ result') ' ;
@@ -608,21 +592,14 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
608592				}
609593
610594				$ parenthesesNeededisset ($ this parenthesesListMap [$ mapKey
611- 					&& in_array (get_class ($ arrItem $ this parenthesesListMap [$ mapKeytrue )
612- 					&& !in_array (get_class ($ origArrayItem $ this parenthesesListMap [$ mapKeytrue );
595+ 					&& in_array (get_class ($ newNode $ this parenthesesListMap [$ mapKeytrue )
596+ 					&& !in_array (get_class ($ originalNode $ this parenthesesListMap [$ mapKeytrue );
613597				$ addParentheses$ parenthesesNeeded$ originalTokenshasParentheses ($ itemStartPos$ itemEndPos
614598				if  ($ addParentheses
615599					$ result'( ' ;
616600				}
617601
618- 				if  ($ comments$ origComments
619- 					if  (count ($ comments0 ) {
620- 						$ result$ this printComments ($ comments$ beforeAsteriskIndent$ afterAsteriskIndent
621- 						$ resultsprintf ('%s%s*%s ' , $ originalTokensgetDetectedNewline () ?? "\n" , $ beforeAsteriskIndent$ afterAsteriskIndent
622- 					}
623- 				}
624- 
625- 				$ result$ this printNodeFormatPreserving ($ arrItem$ originalTokens
602+ 				$ result$ this printNodeFormatPreserving ($ newNode$ originalTokens
626603				if  ($ addParentheses
627604					$ result') ' ;
628605				}
@@ -632,58 +609,52 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
632609				if  ($ insertStrnull ) {
633610					return  null ;
634611				}
635- 				if  (!$ arrItem instanceof  Node) {
612+ 				if  (!$ newNode instanceof  Node) {
636613					return  null ;
637614				}
638615
639- 				if  ($ insertStr',  '  && $ isMultilinecount ($ arrItem getAttribute (Attribute::COMMENTS ) ?? []) > 0 ) {
616+ 				if  ($ insertStr',  '  && $ isMultilinecount ($ newNode getAttribute (Attribute::COMMENTS ) ?? []) > 0 ) {
640617					$ insertStr', ' ;
641618					$ insertNewlinetrue ;
642619				}
643620
644621				if  ($ beforeFirstKeepOrReplace
645622					// Will be inserted at the next "replace" or "keep" element 
646- 					$ delayedAdd$ arrItem 
623+ 					$ delayedAdd$ newNode 
647624					continue ;
648625				}
649626
650627				/** @var int $itemEndPos */ 
651628				$ itemEndPos$ tokenIndex1 ;
652629				if  ($ insertNewline
653- 					$ comments$ arrItemgetAttribute (Attribute::COMMENTS ) ?? [];
654- 					$ result$ insertStr
655- 					if  (count ($ comments0 ) {
656- 						$ resultsprintf ('%s%s*%s ' , $ originalTokensgetDetectedNewline () ?? "\n" , $ beforeAsteriskIndent$ afterAsteriskIndent
657- 						$ result$ this printComments ($ comments$ beforeAsteriskIndent$ afterAsteriskIndent
658- 					}
659- 					$ resultsprintf ('%s%s*%s ' , $ originalTokensgetDetectedNewline () ?? "\n" , $ beforeAsteriskIndent$ afterAsteriskIndent
630+ 					$ result$ insertStrsprintf ('%s%s*%s ' , $ originalTokensgetDetectedNewline () ?? "\n" , $ beforeAsteriskIndent$ afterAsteriskIndent
660631				} else  {
661632					$ result$ insertStr
662633				}
663634
664635				$ parenthesesNeededisset ($ this parenthesesListMap [$ mapKey
665- 					&& in_array (get_class ($ arrItem $ this parenthesesListMap [$ mapKeytrue );
636+ 					&& in_array (get_class ($ newNode $ this parenthesesListMap [$ mapKeytrue );
666637				if  ($ parenthesesNeeded
667638					$ result'( ' ;
668639				}
669640
670- 				$ result$ this printNodeFormatPreserving ($ arrItem $ originalTokens
641+ 				$ result$ this printNodeFormatPreserving ($ newNode $ originalTokens
671642				if  ($ parenthesesNeeded
672643					$ result') ' ;
673644				}
674645
675646				$ tokenIndex$ itemEndPos1 ;
676647
677648			} elseif  ($ diffTypeTYPE_REMOVE ) {
678- 				if  (!$ origArrayItem instanceof  Node) {
649+ 				if  (!$ originalNode instanceof  Node) {
679650					return  null ;
680651				}
681652
682653				/** @var int $itemStartPos */ 
683- 				$ itemStartPos$ origArrayItem getAttribute (Attribute::START_INDEX );
654+ 				$ itemStartPos$ originalNode getAttribute (Attribute::START_INDEX );
684655
685656				/** @var int $itemEndPos */ 
686- 				$ itemEndPos$ origArrayItem getAttribute (Attribute::END_INDEX );
657+ 				$ itemEndPos$ originalNode getAttribute (Attribute::END_INDEX );
687658				if  ($ itemStartPos0  || $ itemEndPos0 ) {
688659					throw  new  LogicException ();
689660				}
0 commit comments