From 75880fbe2d1f7bc2f00dc08070a5029e93ff0f48 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 5 Oct 2017 18:50:48 +0200 Subject: [PATCH] Make code more explicit --- lib/PhpParser/PrettyPrinterAbstract.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/PhpParser/PrettyPrinterAbstract.php b/lib/PhpParser/PrettyPrinterAbstract.php index c4735db..7f0a457 100644 --- a/lib/PhpParser/PrettyPrinterAbstract.php +++ b/lib/PhpParser/PrettyPrinterAbstract.php @@ -653,13 +653,14 @@ abstract class PrettyPrinterAbstract for ($i = 0; $i < $len; $i++) { $arrItem = $nodes[$i]; $origArrItem = $origNodes[$i]; - if ($arrItem === $origArrItem) { - // Unchanged, can reuse old code - continue; - } + // We can only handle arrays of nodes meaningfully if (!$arrItem instanceof Node || !$origArrItem instanceof Node) { - // We can only handle arrays of nodes meaningfully + // Destructing can also contain null elements. If they occur symmetrically, this is + // fine as well + if ($arrItem === null && $origArrItem === null) { + continue; + } return null; }