From 516d506f4e1128e7497a7ed2d91409e3aec55f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 18 Sep 2020 17:18:48 +0300 Subject: [PATCH] flushStack function re-factor --- .../Illuminate/View/Concers/ManagesStacks.php | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/overrides/Illuminate/View/Concers/ManagesStacks.php b/overrides/Illuminate/View/Concers/ManagesStacks.php index e36448b05..1825bc7e1 100644 --- a/overrides/Illuminate/View/Concers/ManagesStacks.php +++ b/overrides/Illuminate/View/Concers/ManagesStacks.php @@ -177,18 +177,25 @@ trait ManagesStacks $this->pushStack = []; } + /** + * Flush stack by key. + * + * @return void + */ public function flushStack($key = null) - { - if (array_key_exists($key, $this->pushes)) { - unset($this->pushes[$key]); - } + { + $properties = [ + 'pushes', + 'prepends', + 'pushStack', + ]; - if (array_key_exists($key, $this->prepends)) { - unset($this->prepends[$key]); - } + foreach ($properties as $property) { + if (!array_key_exists($key, $this->$property)) { + continue; + } - if (array_key_exists($key, $this->pushStack)) { - unset($this->pushStack[$key]); + unset($this->$property[$key]); } } }