From 36638e0363495fb6f63f9b56792b63909e145766 Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Fri, 22 Sep 2023 15:41:43 +0200 Subject: [PATCH] fix: prevent exception caused by passing null arguments to strpos in php 8.1 --- integration/lib/php/Boot.class.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/integration/lib/php/Boot.class.php b/integration/lib/php/Boot.class.php index 05d60f9d..5b092593 100755 --- a/integration/lib/php/Boot.class.php +++ b/integration/lib/php/Boot.class.php @@ -138,7 +138,7 @@ function unshift($x) { } // ArrayAccess methods: - #[\ReturnTypeWillChange] + #[\ReturnTypeWillChange] function offsetExists($offset) { return isset($this->»a[$offset]); } @@ -184,7 +184,7 @@ public function hasNext() { } #[\ReturnTypeWillChange] - public function current(){ + public function current() { if (!$this->hasNext()) return false; return $this->»a[$this->»i]; } @@ -377,6 +377,10 @@ function _hx_has_field($o, $field) { } function _hx_index_of($s, $value, $startIndex = null) { + if ($s == null || $value == null) { + return -1; + } + if ($startIndex == null) { $x = strpos($s, $value); } else { @@ -416,11 +420,11 @@ function _hx_is_numeric($v) function _hx_last_index_of($s, $value, $startIndex = null) { if ($startIndex == null) { - $x = strrpos($s, $value); - } - else { + $x = strrpos($s, $value); + } else { $x = strrpos($s, $value, strlen($s) - $startIndex); } + if($x === false) return -1; else @@ -459,7 +463,7 @@ public function current() { if (!$this->hasNext()) return null; return $this->»h[0]; } - + #[\ReturnTypeWillChange] public function key() { return $this->»counter;