8000 Fix PHP 8.1 return type deprecation errors by cedric-anne · Pull Request #865 · atoum/atoum · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix PHP 8.1 return type deprecation errors #865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions classes/asserters/generator/asserterProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,31 @@ protected function checkIfProxySupportsArrayAccess()
}
}

#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
$this->checkIfProxySupportsArrayAccess();
return $this->proxyfyAsserter($this->proxiedAsserter->offsetExists($offset));
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
$this->checkIfProxySupportsArrayAccess();
return $this->proxyfyAsserter($this->proxiedAsserter->offsetGet($offset));
}

#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->checkIfProxySupportsArrayAccess();
return $this->proxyfyAsserter($this->proxiedAsserter->offsetSet($offset, $value));
$this->proxyfyAsserter($this->proxiedAsserter->offsetSet($offset, $value));
}

#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
$this->checkIfProxySupportsArrayAccess();
return $this->proxyfyAsserter($this->proxiedAsserter->offsetUnset($offset));
$this->proxyfyAsserter($this->proxiedAsserter->offsetUnset($offset));
}
}
4 changes: 4 additions & 0 deletions classes/asserters/phpArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function reset()
return parent::reset()->resetInnerAsserter();
}

#[\ReturnTypeWillChange]
public function offsetGet($key)
{
if ($this->innerAsserter === null) {
Expand All @@ -108,16 +109,19 @@ public function offsetGet($key)
return $this;
}

#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
throw new exceptions\logic('Tested array is read only');
}

#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
throw new exceptions\logic('Array is read only');
}

#[\ReturnTypeWillChange]
public function offsetExists($key)
{
$value = ($this->innerAsserter === null ? $this->value : $this->innerValue);
Expand Down
1 change: 1 addition & 0 deletions classes/asserters/phpArray/child.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ protected function containsValue($value, $failMessage, $strict)
return $this->parentIsSet()->parent->containsValue($value, $failMessage, $strict);
}

#[\ReturnTypeWillChange]
public function offsetGet($key)
{
$asserter = new self($this);
Expand Down
3 changes: 2 additions & 1 deletion classes/extension/aggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class aggregator extends \splObjectStorage
{
public function getHash($object): string
#[\ReturnTypeWillChange]
public function getHash($object)
{
if (is_object($object) === false) {
throw new invalidArgument(__METHOD__ . ' expects parameter 1 to be object, ' . gettype($object) . ' given');
Expand Down
2 changes: 2 additions & 0 deletions classes/iterators/filters/recursives/closure.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function getClosures()
return $this->closures;
}

#[\ReturnTypeWillChange]
public function accept()
{
foreach ($this->closures as $closure) {
Expand All @@ -40,6 +41,7 @@ public function accept()
return true;
}

#[\ReturnTypeWillChange]
public function getChildren()
{
return new static(
Expand Down
1 change: 1 addition & 0 deletions classes/iterators/filters/recursives/dot.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function __construct($mixed, \closure $iteratorFactory = null)
}
}

#[\ReturnTypeWillChange]
public function accept()
{
return (substr($this->getInnerIterator()->current()->getBasename(), 0, 1) != '.');
Expand Down
2 changes: 2 additions & 0 deletions classes/iterators/filters/recursives/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function getAcceptedExtensions()
return $this->acceptedExtensions;
}

#[\ReturnTypeWillChange]
public function accept()
{
$path = basename((string) $this->getInnerIterator()->current());
Expand All @@ -44,6 +45,7 @@ public function accept()
return ($extension == '' || in_array($extension, $this->acceptedExtensions) === true);
}

#[\ReturnTypeWillChange]
public function getChildren()
{
return new self($this->getInnerIterator()->getChildren(), $this->acceptedExtensions);
Expand Down
6 changes: 6 additions & 0 deletions classes/iterators/recursives/atoum/source.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,39 @@ public function getPharDirectory()
return $this->pharDirectory;
}

#[\ReturnTypeWillChange]
public function getInnerIterator()
{
return $this->innerIterator;
}

#[\ReturnTypeWillChange]
public function current()
{
$current = $this->innerIterator->current();

return $current === null ? null : (string) $current;
}

#[\ReturnTypeWillChange]
public function key()
{
return ($this->pharDirectory === null ? $this->innerIterator->key() : (preg_replace('#^(:[^:]+://)?' . preg_quote($this->sourceDirectory, '#') . '#', $this->pharDirectory, $this->innerIterator->current()) ?: null));
}

#[\ReturnTypeWillChange]
public function next()
{
return $this->innerIterator->next();
}

#[\ReturnTypeWillChange]
public function rewind()
{
return $this->innerIterator->rewind();
}

#[\ReturnTypeWillChange]
public function valid()
{
return $this->innerIterator->valid();
Expand Down
1 change: 1 addition & 0 deletions classes/mock/controller/iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __set($keyword, $mixed)
return $this;
}

#[\ReturnTypeWillChange]
public function getIterator()
{
return new \arrayIterator($this->getMethods());
Expand Down
3 changes: 2 additions & 1 deletion classes/mock/stream/invoker.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ public function getMethodName()
return $this->methodName;
}

#[\ReturnTypeWillChange]
public function offsetSet($call = null, $mixed = null)
{
if ($this->methodName == 'dir_readdir' && $mixed instanceof \atoum\atoum\mock\stream\controller) {
$mixed = $mixed->getBasename();
}

return parent::offsetSet($call, $mixed);
parent::offsetSet($call, $mixed);
}
}
1 change: 1 addition & 0 deletions classes/php/tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct()
$this->resetIterator();
}

#[\ReturnTypeWillChange]
public function getIterator()
{
return $this->iterator;
Expand Down
6 changes: 6 additions & 0 deletions classes/php/tokenizer/iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ public function __toString()
return $string;
}

#[\ReturnTypeWillChange]
public function valid()
{
return (current($this->values) !== false);
}

#[\ReturnTypeWillChange]
public function current()
{
$value = null;
Expand All @@ -41,6 +43,7 @@ public function current()
return $value;
}

#[\ReturnTypeWillChange]
public function key()
{
return $this->key < 0 || $this->key >= $this->size ? null : $this->key;
Expand Down Expand Up @@ -76,6 +79,7 @@ public function prev($offset = 1)
return $this;
}

#[\ReturnTypeWillChange]
public function next($offset = 1)
{
while (($valid = $this->valid()) === true && $offset > 0) {
Expand Down Expand Up @@ -106,6 +110,7 @@ public function next($offset = 1)
return $this;
}

#[\ReturnTypeWillChange]
public function rewind()
{
if ($this->size > 0) {
Expand Down Expand Up @@ -198,6 +203,7 @@ public function append(value $value)
return $this;
}

#[\ReturnTypeWillChange]
public function count()
{
return $this->size;
Expand Down 6851
6 changes: 6 additions & 0 deletions classes/php/tokenizer/token.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __toString()
return (string) ($this->string ?: $this->tag);
}

#[\ReturnTypeWillChange]
public function count()
{
return 1;
Expand All @@ -47,16 +48,19 @@ public function getLine()
return $this->line;
}

#[\ReturnTypeWillChange]
public function key()
{
return $this->key === 0 ? 0 : null;
}

#[\ReturnTypeWillChange]
public function current()
{
return $this->key !== 0 ? null : $this;
}

#[\ReturnTypeWillChange]
public function rewind()
{
$this->key = 0;
Expand All @@ -71,11 +75,13 @@ public function end()
return $this;
}

#[\ReturnTypeWillChange]
public function valid()
{
return ($this->key === 0);
}

#[\ReturnTypeWillChange]
public function next()
{
if ($this->valid() === true) {
Expand Down
3 changes: 2 additions & 1 deletion classes/score/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,8 @@ public function getExcludedDirectories()
return $this->excludedDirectories;
}

public function count(): int
#[\ReturnTypeWillChange]
public function count()
{
return count($this->methods);
}
Expand Down
3 changes: 2 additions & 1 deletion classes/script/arguments/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function getPriorities()
return $this->priorities;
}

public function getIterator(): \traversable
#[\ReturnTypeWillChange]
public function getIterator()
{
return new \arrayIterator($this->getValues());
}
Expand Down
6 changes: 6 additions & 0 deletions classes/template/iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,41 @@ public function __call($method, $arguments)
return $this;
}

#[\ReturnTypeWillChange]
public function rewind()
{
reset($this->tags);

return $this;
}

#[\ReturnTypeWillChange]
public function valid()
{
return (key($this->tags) !== null);
}

#[\ReturnTypeWillChange]
public function current()
{
return current($this->tags) ?: null;
}

#[\ReturnTypeWillChange]
public function key()
{
return key($this->tags);
}

#[\ReturnTypeWillChange]
public function next()
{
next($this->tags);

return $this;
}

#[\ReturnTypeWillChange]
public function count()
{
return count($this->tags);
Expand Down
3 changes: 2 additions & 1 deletion classes/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,8 @@ public function getCoverage()
return $this->score->getCoverage();
}

public function count(): int
#[\ReturnTypeWillChange]
public function count()
{
return count($this->runTestMethods);
}
Expand Down
10 changes: 7 additions & 3 deletions classes/test/adapter/calls.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,29 @@ public function __toString()
return $this->decorator->decorate($this);
}

#[\ReturnTypeWillChange]
public function count()
{
return $this->size;
}

#[\ReturnTypeWillChange]
public function offsetSet($functionName = null, $call = null)
{
if ($functionName !== null) {
$call->setFunction($functionName);
}

return $this->addCall($call);
$this->addCall($call);
}

#[\ReturnTypeWillChange]
public function offsetGet($mixed)
{
return $this->getEqualTo(self::buildCall($mixed));
}

#[\ReturnTypeWillChange]
public function offsetUnset($mixed)
{
$key = self::getKey(self::buildCall($mixed));
Expand All @@ -56,15 +60,15 @@ public function offsetUnset($mixed)

unset($this->calls[$key]);
}

return $this;
}

#[\ReturnTypeWillChange]
public function offsetExists($mixed)
{
return (isset($this->calls[self::getKey(self::buildCall($mixed))]) === true);
}

#[\ReturnTypeWillChange]
public function getIterator()
{
return new \arrayIterator($this());
Expand Down
Loading
0