From 249982e353f35b8b2693956046d030853213557f Mon Sep 17 00:00:00 2001 From: Adam Wight Date: Sat, 23 Nov 2019 01:03:42 +0100 Subject: [PATCH] Rewrite loop in ReferenceStack Change-Id: I3bdf26fd14573abdcad989c7ebfea48e49ef42aa --- src/ReferenceStack.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ReferenceStack.php b/src/ReferenceStack.php index ca057c23c..80e8087f2 100644 --- a/src/ReferenceStack.php +++ b/src/ReferenceStack.php @@ -139,12 +139,13 @@ class ReferenceStack { if ( $follow ) { $ref['follow'] = $follow; - // insert broken follow at the end of any other broken follows. - $groupsCount = count( $this->refs[$group] ); - for ( $k = 0; $k < $groupsCount; $k++ ) { - if ( !isset( $this->refs[$group][$k]['follow'] ) ) { + // This inserts the broken "follow" at the end of all other broken "follow" + $k = 0; + foreach ( $this->refs[$group] as $value ) { + if ( !isset( $value['follow'] ) ) { break; } + $k++; } array_splice( $this->refs[$group], $k, 0, [ $ref ] ); array_splice( $this->refCallStack, $k, 0,