Skip to content

Commit

Permalink
fix: prevent exception caused by passing null arguments to strpos in …
Browse files Browse the repository at this point in the history
…php 8.1
  • Loading branch information
Pol Torrent i Soler committed Sep 22, 2023
1 parent ef64511 commit 36638e0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions integration/lib/php/Boot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function unshift($x) {
}

// ArrayAccess methods:
#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
function offsetExists($offset) {
return isset($this->»a[$offset]);
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public function hasNext() {
}

#[\ReturnTypeWillChange]
public function current(){
public function current() {
if (!$this->hasNext()) return false;
return $this->»a[$this->»i];
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -459,7 +463,7 @@ public function current() {
if (!$this->hasNext()) return null;
return $this->»h[0];
}

#[\ReturnTypeWillChange]
public function key() {
return $this->»counter;
Expand Down

0 comments on commit 36638e0

Please sign in to comment.