@@ -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 ) {
@@ -584,14 +577,6 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
584577							$ result'( ' ;
585578						}
586579
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- 
595580						$ result$ this printNodeFormatPreserving ($ delayedAddNode$ originalTokens
596581						if  ($ parenthesesNeeded
597582							$ result') ' ;
@@ -608,21 +593,14 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
608593				}
609594
610595				$ parenthesesNeededisset ($ this parenthesesListMap [$ mapKey
611- 					&& in_array (get_class ($ arrItem $ this parenthesesListMap [$ mapKeytrue )
612- 					&& !in_array (get_class ($ origArrayItem $ this parenthesesListMap [$ mapKeytrue );
596+ 					&& in_array (get_class ($ newNode $ this parenthesesListMap [$ mapKeytrue )
597+ 					&& !in_array (get_class ($ originalNode $ this parenthesesListMap [$ mapKeytrue );
613598				$ addParentheses$ parenthesesNeeded$ originalTokenshasParentheses ($ itemStartPos$ itemEndPos
614599				if  ($ addParentheses
615600					$ result'( ' ;
616601				}
617602
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
603+ 				$ result$ this printNodeFormatPreserving ($ newNode$ originalTokens
626604				if  ($ addParentheses
627605					$ result') ' ;
628606				}
@@ -632,25 +610,25 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
632610				if  ($ insertStrnull ) {
633611					return  null ;
634612				}
635- 				if  (!$ arrItem instanceof  Node) {
613+ 				if  (!$ newNode instanceof  Node) {
636614					return  null ;
637615				}
638616
639- 				if  ($ insertStr',  '  && $ isMultilinecount ($ arrItem getAttribute (Attribute::COMMENTS ) ?? []) > 0 ) {
617+ 				if  ($ insertStr',  '  && $ isMultilinecount ($ newNode getAttribute (Attribute::COMMENTS ) ?? []) > 0 ) {
640618					$ insertStr', ' ;
641619					$ insertNewlinetrue ;
642620				}
643621
644622				if  ($ beforeFirstKeepOrReplace
645623					// Will be inserted at the next "replace" or "keep" element 
646- 					$ delayedAdd$ arrItem 
624+ 					$ delayedAdd$ newNode 
647625					continue ;
648626				}
649627
650628				/** @var int $itemEndPos */ 
651629				$ itemEndPos$ tokenIndex1 ;
652630				if  ($ insertNewline
653- 					$ comments$ arrItem getAttribute (Attribute::COMMENTS ) ?? [];
631+ 					$ comments$ newNode getAttribute (Attribute::COMMENTS ) ?? [];
654632					$ result$ insertStr
655633					if  (count ($ comments0 ) {
656634						$ resultsprintf ('%s%s*%s ' , $ originalTokensgetDetectedNewline () ?? "\n" , $ beforeAsteriskIndent$ afterAsteriskIndent
@@ -662,28 +640,28 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
662640				}
663641
664642				$ parenthesesNeededisset ($ this parenthesesListMap [$ mapKey
665- 					&& in_array (get_class ($ arrItem $ this parenthesesListMap [$ mapKeytrue );
643+ 					&& in_array (get_class ($ newNode $ this parenthesesListMap [$ mapKeytrue );
666644				if  ($ parenthesesNeeded
667645					$ result'( ' ;
668646				}
669647
670- 				$ result$ this printNodeFormatPreserving ($ arrItem $ originalTokens
648+ 				$ result$ this printNodeFormatPreserving ($ newNode $ originalTokens
671649				if  ($ parenthesesNeeded
672650					$ result') ' ;
673651				}
674652
675653				$ tokenIndex$ itemEndPos1 ;
676654
677655			} elseif  ($ diffTypeTYPE_REMOVE ) {
678- 				if  (!$ origArrayItem instanceof  Node) {
656+ 				if  (!$ originalNode instanceof  Node) {
679657					return  null ;
680658				}
681659
682660				/** @var int $itemStartPos */ 
683- 				$ itemStartPos$ origArrayItem getAttribute (Attribute::START_INDEX );
661+ 				$ itemStartPos$ originalNode getAttribute (Attribute::START_INDEX );
684662
685663				/** @var int $itemEndPos */ 
686- 				$ itemEndPos$ origArrayItem getAttribute (Attribute::END_INDEX );
664+ 				$ itemEndPos$ originalNode getAttribute (Attribute::END_INDEX );
687665				if  ($ itemStartPos0  || $ itemEndPos0 ) {
688666					throw  new  LogicException ();
689667				}
0 commit comments