Blob Blame History Raw
From 97d14c110e91adc8387b7cb584b99c58ad23715d Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 13 Sep 2019 15:41:13 +0200
Subject: [PATCH] fix Trying to access array offset on value of type null

---
 src/Compiler.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/Compiler.php b/src/Compiler.php
index d22d0a35..95131df9 100644
--- a/src/Compiler.php
+++ b/src/Compiler.php
@@ -2552,7 +2552,9 @@ protected function shouldEval($value)
      */
     protected function reduce($value, $inExp = false)
     {
-
+        if (is_null($value)) {
+            return null;
+        }
         switch ($value[0]) {
             case Type::T_EXPRESSION:
                 list(, $op, $left, $right, $inParens) = $value;
@@ -4373,7 +4375,7 @@ protected function sortArgs($prototype, $args)
         foreach ($args as $arg) {
             list($key, $value) = $arg;
 
-            $key = $key[1];
+            $key = (isset($key[1]) ? $key[1] : '');
 
             if (empty($key)) {
                 $posArgs[] = empty($arg[2]) ? $value : $arg;
@@ -5889,7 +5891,7 @@ protected function libStrSlice($args)
             $start--;
         }
 
-        $end    = (int) $args[2][1];
+        $end    = (isset($args[2][1]) ? (int) $args[2][1] : 0);
         $length = $end < 0 ? $end + 1 : ($end > 0 ? $end - $start : $end);
 
         $string[2] = $length