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

This commit is contained in:
Marina Glancy 2021-12-21 09:57:48 +01:00
parent 57c1e97bf1
commit b99a931f7f
3 changed files with 23 additions and 13 deletions

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 * 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 find any issue upstream and the current library versions are way different from the ones
we are using here. we are using here.
* MDL-76355 php81 compliance. Class methods require overriding methods to declare a
compatible return type.
Information Information
----------- -----------

View file

@ -13,7 +13,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable
{ {
protected $collection_key = 'items'; protected $collection_key = 'items';
public function rewind() public function rewind(): void
{ {
if (isset($this->modelData[$this->collection_key]) if (isset($this->modelData[$this->collection_key])
&& is_array($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() public function current()
{ {
$this->coerceType($this->key()); $this->coerceType($this->key());
if (is_array($this->modelData[$this->collection_key])) { if (is_array($this->modelData[$this->collection_key])) {
return current($this->modelData[$this->collection_key]); return current($this->modelData[$this->collection_key]);
} }
return null;
} }
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
if (isset($this->modelData[$this->collection_key]) if (isset($this->modelData[$this->collection_key])
&& is_array($this->modelData[$this->collection_key])) { && is_array($this->modelData[$this->collection_key])) {
return key($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(); $key = $this->key();
return $key !== null && $key !== false; return $key !== null && $key !== false;
} }
public function count() public function count(): int
{ {
if (!isset($this->modelData[$this->collection_key])) { if (!isset($this->modelData[$this->collection_key])) {
return 0; return 0;
@ -56,7 +60,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable
return count($this->modelData[$this->collection_key]); return count($this->modelData[$this->collection_key]);
} }
public function offsetExists($offset) public function offsetExists($offset): bool
{ {
if (!is_numeric($offset)) { if (!is_numeric($offset)) {
return parent::offsetExists($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]); return isset($this->modelData[$this->collection_key][$offset]);
} }
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
if (!is_numeric($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]; return $this->modelData[$this->collection_key][$offset];
} }
public function offsetSet($offset, $value) public function offsetSet($offset, $value): void
{ {
if (!is_numeric($offset)) { if (!is_numeric($offset)) {
return parent::offsetSet($offset, $value); parent::offsetSet($offset, $value);
return;
} }
$this->modelData[$this->collection_key][$offset] = $value; $this->modelData[$this->collection_key][$offset] = $value;
} }
public function offsetUnset($offset) public function offsetUnset($offset): void
{ {
if (!is_numeric($offset)) { if (!is_numeric($offset)) {
return parent::offsetUnset($offset); parent::offsetUnset($offset);
return;
} }
unset($this->modelData[$this->collection_key][$offset]); unset($this->modelData[$this->collection_key][$offset]);
} }

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]); return isset($this->$offset) || isset($this->modelData[$offset]);
} }
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
return isset($this->$offset) ? return isset($this->$offset) ?
@ -258,7 +259,7 @@ class Google_Model implements ArrayAccess
$this->__get($offset); $this->__get($offset);
} }
public function offsetSet($offset, $value) public function offsetSet($offset, $value): void
{ {
if (property_exists($this, $offset)) { if (property_exists($this, $offset)) {
$this->$offset = $value; $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]); unset($this->modelData[$offset]);
} }