Skip to content

Commit

Permalink
Merge pull request #7 from mlocati/league-url-php8.1
Browse files Browse the repository at this point in the history
Patch league/url & sunra/php-simple-html-dom-parser for PHP 8.1 compatibility
  • Loading branch information
aembler authored Mar 15, 2022
2 parents 43f3a75 + 97efec6 commit 6716e26
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"Fix ArrayObject::unserialize()": "zendframework/zend-stdlib/ArrayObject-unserialize-continue.patch"
},
"sunra/php-simple-html-dom-parser:1.5.2": {
"Fix minus in regular expressions": "sunra/php-simple-html-dom-parser/minus-in-regular-expressions.patch"
"Fix minus in regular expressions": "sunra/php-simple-html-dom-parser/minus-in-regular-expressions.patch",
"Add PHP 8.1 compability to league/url version 3.3.5": "sunra/php-simple-html-dom-parser/php8.1-compatibility.patch"
},
"phpunit/phpunit:4.8.36": {
"Avoid each() in Getopt": "phpunit/phpunit/Getopt-each.patch"
Expand All @@ -57,6 +58,9 @@
},
"lcobucci/jwt:3.4.6": {
"Adds php 8 compability to jwt version 3.4.6": "lcobucci/jwt/php8-compatibility.patch"
},
"league/url:3.3.5": {
"Add PHP 8.1 compability to league/url version 3.3.5": "league/url/php8.1-compatibility.patch"
}
}
}
Expand Down
81 changes: 81 additions & 0 deletions league/url/php8.1-compatibility.patch
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 sunra/php-simple-html-dom-parser/php8.1-compatibility.patch
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;}

0 comments on commit 6716e26

Please sign in to comment.