MDL-76355 lib: apply a patch to googleapi for php 8.1 compatibility

This commit is contained in:
Marina Glancy
2022-11-28 12:01:05 +01:00
parent 0ea3d45e04
commit a7e7cd71cb
3 changed files with 23 additions and 13 deletions
+2
View File
@@ -43,6 +43,8 @@ Local changes (to reapply until upstream upgrades contain them):
* MDL-73523 php80 compliance. openssl_xxx_free() methods deprecated. I've been unable to
find any issue upstream and the current library versions are way different from the ones
we are using here.
* MDL-76355 php81 compliance. Class methods require overriding methods to declare a
compatible return type.
Information
-----------
+17 -10
View File
@@ -13,7 +13,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable
{
protected $collection_key = 'items';
public function rewind()
public function rewind(): void
{
if (isset($this->modelData[$this->collection_key])
&& is_array($this->modelData[$this->collection_key])) {
@@ -21,34 +21,38 @@ class Google_Collection extends Google_Model implements Iterator, Countable
}
}
#[\ReturnTypeWillChange]
public function current()
{
$this->coerceType($this->key());
if (is_array($this->modelData[$this->collection_key])) {
return current($this->modelData[$this->collection_key]);
}
return null;
}
#[\ReturnTypeWillChange]
public function key()
{
if (isset($this->modelData[$this->collection_key])
&& is_array($this->modelData[$this->collection_key])) {
return key($this->modelData[$this->collection_key]);
}
return null;
}
public function next()
public function next(): void
{
return next($this->modelData[$this->collection_key]);
next($this->modelData[$this->collection_key]);
}
public function valid()
public function valid(): bool
{
$key = $this->key();
return $key !== null && $key !== false;
}
public function count()
public function count(): int
{
if (!isset($this->modelData[$this->collection_key])) {
return 0;
@@ -56,7 +60,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable
return count($this->modelData[$this->collection_key]);
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
if (!is_numeric($offset)) {
return parent::offsetExists($offset);
@@ -64,6 +68,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable
return isset($this->modelData[$this->collection_key][$offset]);
}
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
if (!is_numeric($offset)) {
@@ -73,18 +78,20 @@ class Google_Collection extends Google_Model implements Iterator, Countable
return $this->modelData[$this->collection_key][$offset];
}
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
if (!is_numeric($offset)) {
return parent::offsetSet($offset, $value);
parent::offsetSet($offset, $value);
return;
}
$this->modelData[$this->collection_key][$offset] = $value;
}
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
if (!is_numeric($offset)) {
return parent::offsetUnset($offset);
parent::offsetUnset($offset);
return;
}
unset($this->modelData[$this->collection_key][$offset]);
}
+4 -3
View File
@@ -246,11 +246,12 @@ class Google_Model implements ArrayAccess
}
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->$offset) || isset($this->modelData[$offset]);
}
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return isset($this->$offset) ?
@@ -258,7 +259,7 @@ class Google_Model implements ArrayAccess
$this->__get($offset);
}
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
if (property_exists($this, $offset)) {
$this->$offset = $value;
@@ -268,7 +269,7 @@ class Google_Model implements ArrayAccess
}
}
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->modelData[$offset]);
}