-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from mlocati/league-url-php8.1
Patch league/url & sunra/php-simple-html-dom-parser for PHP 8.1 compatibility
- Loading branch information
Showing
3 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
From: Michele Locati <michele@locati.it> | ||
Date: Tue, 15 Mar 2022 12:11:04 +0100 | ||
Subject: [PATCH] Fix PHP 8.1 compatibility | ||
|
||
|
||
--- a/src/Components/AbstractArray.php | ||
+++ b/src/Components/AbstractArray.php | ||
@@ -60,6 +60,7 @@ abstract class AbstractArray implements IteratorAggregate, Countable | ||
* | ||
* @return ArrayIterator | ||
*/ | ||
+ #[\ReturnTypeWillChange] | ||
public function getIterator() | ||
{ | ||
return new ArrayIterator($this->data); | ||
@@ -72,6 +73,7 @@ abstract class AbstractArray implements IteratorAggregate, Countable | ||
* | ||
* @return integer | ||
*/ | ||
+ #[\ReturnTypeWillChange] | ||
public function count($mode = COUNT_NORMAL) | ||
{ | ||
return count($this->data, $mode); | ||
@@ -84,6 +86,7 @@ abstract class AbstractArray implements IteratorAggregate, Countable | ||
* | ||
* @return bool | ||
*/ | ||
+ #[\ReturnTypeWillChange] | ||
public function offsetExists($offset) | ||
{ | ||
return isset($this->data[$offset]); | ||
@@ -94,6 +97,7 @@ abstract class AbstractArray implements IteratorAggregate, Countable | ||
* | ||
* @param int|string $offset | ||
*/ | ||
+ #[\ReturnTypeWillChange] | ||
public function offsetUnset($offset) | ||
{ | ||
unset($this->data[$offset]); | ||
@@ -106,6 +110,7 @@ abstract class AbstractArray implements IteratorAggregate, Countable | ||
* | ||
* @return null | ||
*/ | ||
+ #[\ReturnTypeWillChange] | ||
public function offsetGet($offset) | ||
{ | ||
if (isset($this->data[$offset])) { | ||
|
||
--- a/src/Components/AbstractComponent.php | ||
+++ b/src/Components/AbstractComponent.php | ||
@@ -64,7 +64,7 @@ abstract class AbstractComponent implements ComponentInterface | ||
*/ | ||
public function __toString() | ||
{ | ||
- return str_replace(null, '', $this->get()); | ||
+ return (string) $this->get(); | ||
} | ||
|
||
/** | ||
|
||
--- a/src/Components/AbstractSegment.php | ||
+++ b/src/Components/AbstractSegment.php | ||
@@ -115,6 +115,7 @@ abstract class AbstractSegment extends AbstractArray implements ArrayAccess | ||
* @param int|string $offset | ||
* @param mixed $value | ||
*/ | ||
+ #[\ReturnTypeWillChange] | ||
public function offsetSet($offset, $value) | ||
{ | ||
$data = $this->data; | ||
|
||
--- a/src/Components/Query.php | ||
+++ b/src/Components/Query.php | ||
@@ -133,6 +133,7 @@ class Query extends AbstractArray implements QueryInterface, ArrayAccess | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
+ #[\ReturnTypeWillChange] | ||
public function offsetSet($offset, $value) | ||
{ | ||
if (is_null($offset)) { |
16 changes: 16 additions & 0 deletions
16
sunra/php-simple-html-dom-parser/php8.1-compatibility.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
From: Michele Locati <michele@locati.it> | ||
Date: Tue, 15 Mar 2022 14:28:50 +0100 | ||
Subject: [PATCH] Fix PHP 8.1 compatibility | ||
|
||
|
||
--- a/Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php | ||
+++ b/Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php | ||
@@ -715,7 +715,7 @@ class simple_html_dom_node | ||
if (!empty($m[6])) {$val=$m[6];} | ||
|
||
// convert to lowercase | ||
- if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);} | ||
+ if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower((string) $key);} | ||
//elements that do NOT have the specified attribute | ||
if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;} | ||
|