Skip to content

Add #[ReturnTypeWillChange] and related @return #855

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 1 commit into from
Aug 13, 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
6 changes: 6 additions & 0 deletions src/ChangeStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use MongoDB\Driver\Exception\ServerException;
use MongoDB\Exception\ResumeTokenException;
use MongoDB\Model\ChangeStreamIterator;
use ReturnTypeWillChange;

use function call_user_func;
use function in_array;
Expand Down Expand Up @@ -102,6 +103,7 @@ public function __construct(ChangeStreamIterator $iterator, callable $resumeCall
* @see http://php.net/iterator.current
* @return mixed
*/
#[ReturnTypeWillChange]
public function current()
{
return $this->iterator->current();
Expand Down Expand Up @@ -133,6 +135,7 @@ public function getResumeToken()
* @see http://php.net/iterator.key
* @return mixed
*/
#[ReturnTypeWillChange]
public function key()
{
if ($this->valid()) {
Expand All @@ -147,6 +150,7 @@ public function key()
* @return void
* @throws ResumeTokenException
*/
#[ReturnTypeWillChange]
public function next()
{
try {
Expand All @@ -162,6 +166,7 @@ public function next()
* @return void
* @throws ResumeTokenException
*/
#[ReturnTypeWillChange]
public function rewind()
{
try {
Expand All @@ -179,6 +184,7 @@ public function rewind()
* @see http://php.net/iterator.valid
* @return boolean
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->iterator->valid();
Expand Down
2 changes: 2 additions & 0 deletions src/MapReduceResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace MongoDB;

use IteratorAggregate;
use ReturnTypeWillChange;
use stdClass;
use Traversable;

Expand Down Expand Up @@ -87,6 +88,7 @@ public function getExecutionTimeMS()
* @see http://php.net/iteratoraggregate.getiterator
* @return Traversable
*/
#[ReturnTypeWillChange]
public function getIterator()
{
return call_user_func($this->getIterator);
Expand Down
2 changes: 2 additions & 0 deletions src/Model/BSONArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use JsonSerializable;
use MongoDB\BSON\Serializable;
use MongoDB\BSON\Unserializable;
use ReturnTypeWillChange;

use function array_values;
use function MongoDB\recursive_copy;
Expand Down Expand Up @@ -95,6 +96,7 @@ public function bsonUnserialize(array $data)
* @see http://php.net/jsonserializable.jsonserialize
* @return array
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return array_values($this->getArrayCopy());
Expand Down
2 changes: 2 additions & 0 deletions src/Model/BSONDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use JsonSerializable;
use MongoDB\BSON\Serializable;
use MongoDB\BSON\Unserializable;
use ReturnTypeWillChange;

use function MongoDB\recursive_copy;

Expand Down Expand Up @@ -102,6 +103,7 @@ public function bsonUnserialize(array $data)
* @see http://php.net/jsonserializable.jsonserialize
* @return object
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return (object) $this->getArrayCopy();
Expand Down
6 changes: 6 additions & 0 deletions src/Model/BSONIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Iterator;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException;
use ReturnTypeWillChange;

use function is_array;
use function MongoDB\BSON\toPHP;
Expand Down Expand Up @@ -86,6 +87,7 @@ public function __construct($data, array $options = [])
* @see http://php.net/iterator.current
* @return mixed
*/
#[ReturnTypeWillChange]
public function current()
{
return $this->current;
Expand All @@ -95,6 +97,7 @@ public function current()
* @see http://php.net/iterator.key
* @return mixed
*/
#[ReturnTypeWillChange]
public function key()
{
return $this->key;
Expand All @@ -104,6 +107,7 @@ public function key()
* @see http://php.net/iterator.next
* @return void
*/
#[ReturnTypeWillChange]
public function next()
{
$this->key++;
Expand All @@ -115,6 +119,7 @@ public function next()
* @see http://php.net/iterator.rewind
* @return void
*/
#[ReturnTypeWillChange]
public function rewind()
{
$this->key = 0;
Expand All @@ -127,6 +132,7 @@ public function rewind()
* @see http://php.net/iterator.valid
* @return boolean
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->current !== null;
Expand Down
7 changes: 7 additions & 0 deletions src/Model/CachingIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Countable;
use Iterator;
use IteratorIterator;
use ReturnTypeWillChange;
use Traversable;

use function count;
Expand Down Expand Up @@ -71,6 +72,7 @@ public function __construct(Traversable $traversable)
* @see http://php.net/countable.count
* @return integer
*/
#[ReturnTypeWillChange]
public function count()
{
$this->exhaustIterator();
Expand All @@ -82,6 +84,7 @@ public function count()
* @see http://php.net/iterator.current
* @return mixed
*/
#[ReturnTypeWillChange]
public function current()
{
return current($this->items);
Expand All @@ -91,6 +94,7 @@ public function current()
* @see http://php.net/iterator.key
* @return mixed
*/
#[ReturnTypeWillChange]
public function key()
{
return key($this->items);
Expand All @@ -100,6 +104,7 @@ public function key()
* @see http://php.net/iterator.next
* @return void
*/
#[ReturnTypeWillChange]
public function next()
{
if (! $this->iteratorExhausted) {
Expand All @@ -118,6 +123,7 @@ public function next()
* @see http://php.net/iterator.rewind
* @return void
*/
#[ReturnTypeWillChange]
public function rewind()
{
/* If the iterator has advanced, exhaust it now so that future iteration
Expand All @@ -134,6 +140,7 @@ public function rewind()
* @see http://php.net/iterator.valid
* @return boolean
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->key() !== null;
Expand Down
6 changes: 6 additions & 0 deletions src/Model/CallbackIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Closure;
use Iterator;
use IteratorIterator;
use ReturnTypeWillChange;
use Traversable;

/**
Expand All @@ -45,6 +46,7 @@ public function __construct(Traversable $traversable, Closure $callback)
* @see http://php.net/iterator.current
* @return mixed
*/
#[ReturnTypeWillChange]
public function current()
{
return ($this->callback)($this->iterator->current());
Expand All @@ -54,6 +56,7 @@ public function current()
* @see http://php.net/iterator.key
* @return mixed
*/
#[ReturnTypeWillChange]
public function key()
{
return $this->iterator->key();
Expand All @@ -63,6 +66,7 @@ public function key()
* @see http://php.net/iterator.next
* @return void
*/
#[ReturnTypeWillChange]
public function next()
{
$this->iterator->next();
Expand All @@ -72,6 +76,7 @@ public function next()
* @see http://php.net/iterator.rewind
* @return void
*/
#[ReturnTypeWillChange]
public function rewind()
{
$this->iterator->rewind();
Expand All @@ -81,6 +86,7 @@ public function rewind()
* @see http://php.net/iterator.valid
* @return boolean
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->iterator->valid();
Expand Down
6 changes: 6 additions & 0 deletions src/Model/ChangeStreamIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\ResumeTokenException;
use MongoDB\Exception\UnexpectedValueException;
use ReturnTypeWillChange;

use function count;
use function is_array;
Expand Down Expand Up @@ -139,6 +140,7 @@ final public function commandSucceeded(CommandSucceededEvent $event)
* @see https://php.net/iteratoriterator.current
* @return mixed
*/
#[ReturnTypeWillChange]
public function current()
{
return $this->isValid ? parent::current() : null;
Expand Down Expand Up @@ -170,6 +172,7 @@ public function getServer(): Server
* @see https://php.net/iteratoriterator.key
* @return mixed
*/
#[ReturnTypeWillChange]
public function key()
{
return $this->isValid ? parent::key() : null;
Expand All @@ -179,6 +182,7 @@ public function key()
* @see https://php.net/iteratoriterator.rewind
* @return void
*/
#[ReturnTypeWillChange]
public function next()
{
/* Determine if advancing the iterator will execute a getMore command
Expand Down Expand Up @@ -206,6 +210,7 @@ public function next()
* @see https://php.net/iteratoriterator.rewind
* @return void
*/
#[ReturnTypeWillChange]
public function rewind()
{
if ($this->isRewindNop) {
Expand All @@ -220,6 +225,7 @@ public function rewind()
* @see https://php.net/iteratoriterator.valid
* @return boolean
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->isValid;
Expand Down
7 changes: 7 additions & 0 deletions src/Model/CollectionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use ArrayAccess;
use MongoDB\Exception\BadMethodCallException;
use ReturnTypeWillChange;

use function array_key_exists;

Expand Down Expand Up @@ -156,6 +157,7 @@ public function isCapped()
* @param mixed $key
* @return boolean
*/
#[ReturnTypeWillChange]
public function offsetExists($key)
{
return array_key_exists($key, $this->info);
Expand All @@ -168,6 +170,7 @@ public function offsetExists($key)
* @param mixed $key
* @return mixed
*/
#[ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->info[$key];
Expand All @@ -180,7 +183,9 @@ public function offsetGet($key)
* @param mixed $key
* @param mixed $value
* @throws BadMethodCallException
* @return void
*/
#[ReturnTypeWillChange]
public function offsetSet($key, $value)
{
throw BadMethodCallException::classIsImmutable(self::class);
Expand All @@ -192,7 +197,9 @@ public function offsetSet($key, $value)
* @see http://php.net/arrayaccess.offsetunset
* @param mixed $key
* @throws BadMethodCallException
* @return void
*/
#[ReturnTypeWillChange]
public function offsetUnset($key)
{
throw BadMethodCallException::classIsImmutable(self::class);
Expand Down
2 changes: 2 additions & 0 deletions src/Model/CollectionInfoIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace MongoDB\Model;

use Iterator;
use ReturnTypeWillChange;

/**
* CollectionInfoIterator interface.
Expand All @@ -34,5 +35,6 @@ interface CollectionInfoIterator extends Iterator
*
* @return CollectionInfo
*/
#[ReturnTypeWillChange]
public function current();
}
7 changes: 7 additions & 0 deletions src/Model/DatabaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use ArrayAccess;
use MongoDB\Exception\BadMethodCallException;
use ReturnTypeWillChange;

use function array_key_exists;

Expand Down Expand Up @@ -94,6 +95,7 @@ public function isEmpty()
* @param mixed $key
* @return boolean
*/
#[ReturnTypeWillChange]
public function offsetExists($key)
{
return array_key_exists($key, $this->info);
Expand All @@ -106,6 +108,7 @@ public function offsetExists($key)
* @param mixed $key
* @return mixed
*/
#[ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->info[$key];
Expand All @@ -118,7 +121,9 @@ public function offsetGet($key)
* @param mixed $key
* @param mixed $value
* @throws BadMethodCallException
* @return void
*/
#[ReturnTypeWillChange]
public function offsetSet($key, $value)
{
throw BadMethodCallException::classIsImmutable(self::class);
Expand All @@ -130,7 +135,9 @@ public function offsetSet($key, $value)
* @see http://php.net/arrayaccess.offsetunset
* @param mixed $key
* @throws BadMethodCallException
* @return void
*/
#[ReturnTypeWillChange]
public function offsetUnset($key)
{
throw BadMethodCallException::classIsImmutable(self::class);
Expand Down
Loading