Skip to content

PHPLIB-933: Test on PHP 8.2 #953

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 5 commits into from
Aug 5, 2022
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
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:
branches:
- "v*.*"
- "master"
- "feature/*"
push:
branches:
- "v*.*"
- "master"
- "feature/*"

jobs:
phpunit:
Expand All @@ -24,6 +26,7 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
mongodb-version:
- "4.4"
driver-version:
Expand Down
2 changes: 2 additions & 0 deletions src/Model/BSONArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static function __set_state(array $properties)
* @see https://php.net/mongodb-bson-serializable.bsonserialize
* @return array
*/
#[ReturnTypeWillChange]
public function bsonSerialize()
{
return array_values($this->getArrayCopy());
Expand All @@ -82,6 +83,7 @@ public function bsonSerialize()
* @see https://php.net/mongodb-bson-unserializable.bsonunserialize
* @param array $data Array data
*/
#[ReturnTypeWillChange]
public function bsonUnserialize(array $data)
{
self::__construct($data);
Expand Down
2 changes: 2 additions & 0 deletions src/Model/BSONDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static function __set_state(array $properties)
* @see https://php.net/mongodb-bson-serializable.bsonserialize
* @return object
*/
#[ReturnTypeWillChange]
public function bsonSerialize()
{
return (object) $this->getArrayCopy();
Expand All @@ -92,6 +93,7 @@ public function bsonSerialize()
* @see https://php.net/mongodb-bson-unserializable.bsonunserialize
* @param array $data Array data
*/
#[ReturnTypeWillChange]
public function bsonUnserialize(array $data)
{
parent::__construct($data, ArrayObject::ARRAY_AS_PROPS);
Expand Down
6 changes: 3 additions & 3 deletions src/Model/ChangeStreamIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ public function __construct(Cursor $cursor, $firstBatchSize, $initialResumeToken
}

/** @internal */
final public function commandFailed(CommandFailedEvent $event)
final public function commandFailed(CommandFailedEvent $event): void
{
}

/** @internal */
final public function commandStarted(CommandStartedEvent $event)
final public function commandStarted(CommandStartedEvent $event): void
{
if ($event->getCommandName() !== 'getMore') {
return;
Expand All @@ -117,7 +117,7 @@ final public function commandStarted(CommandStartedEvent $event)
}

/** @internal */
final public function commandSucceeded(CommandSucceededEvent $event)
final public function commandSucceeded(CommandSucceededEvent $event): void
{
if ($event->getCommandName() !== 'getMore') {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/Model/IndexInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use MongoDB\BSON\Serializable;
use MongoDB\Exception\InvalidArgumentException;
use ReturnTypeWillChange;

use function is_array;
use function is_float;
Expand Down Expand Up @@ -91,6 +92,7 @@ public function __toString()
* @see https://php.net/mongodb-bson-serializable.bsonserialize
* @return array
*/
#[ReturnTypeWillChange]
public function bsonSerialize()
{
return $this->index;
Expand Down
6 changes: 3 additions & 3 deletions src/Operation/Watch.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ public function __construct(Manager $manager, $databaseName, $collectionName, ar
}

/** @internal */
final public function commandFailed(CommandFailedEvent $event)
final public function commandFailed(CommandFailedEvent $event): void
{
}

/** @internal */
final public function commandStarted(CommandStartedEvent $event)
final public function commandStarted(CommandStartedEvent $event): void
{
if ($event->getCommandName() !== 'aggregate') {
return;
Expand All @@ -287,7 +287,7 @@ final public function commandStarted(CommandStartedEvent $event)
}

/** @internal */
final public function commandSucceeded(CommandSucceededEvent $event)
final public function commandSucceeded(CommandSucceededEvent $event): void
{
if ($event->getCommandName() !== 'aggregate') {
return;
Expand Down
2 changes: 2 additions & 0 deletions tests/GridFS/UnusableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

final class UnusableStream
{
public $context;

public static function register($protocol = 'unusable'): void
{
if (in_array($protocol, stream_get_wrappers())) {
Expand Down
4 changes: 2 additions & 2 deletions tests/UnifiedSpecTests/Constraint/IsBsonTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ private function assertResult($expected, Constraint $constraint, $value, string
// phpcs:disable Squiz.Classes.ClassFileName.NoMatch
class SerializableArray implements Serializable
{
public function bsonSerialize()
public function bsonSerialize(): array
{
return ['foo'];
}
}

class SerializableObject implements Serializable
{
public function bsonSerialize()
public function bsonSerialize(): array
{
return ['x' => 1];
}
Expand Down
3 changes: 3 additions & 0 deletions tests/UnifiedSpecTests/Constraint/Matches.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class Matches extends Constraint
/** @var ComparisonFailure|null */
private $lastFailure;

/** @var Factory */
private $comparatorFactory;

public function __construct($value, ?EntityMap $entityMap = null, $allowExtraRootKeys = true, $allowOperators = true)
{
$this->value = self::prepare($value);
Expand Down
11 changes: 8 additions & 3 deletions tests/UnifiedSpecTests/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ final class Operation
private $entityMap;

/** @var ExpectedError */
private $expectedError;
private $expectError;

/** @var ExpectedResult */
private $expectedResult;
private $expectResult;

/** @var bool */
private $ignoreResultAndError;
Expand Down Expand Up @@ -295,7 +295,12 @@ private function executeForCollection(Collection $collection)
assertIsArray($args['requests']);

return $collection->bulkWrite(
array_map('self::prepareBulkWriteRequest', $args['requests']),
array_map(
static function ($request) {
return self::prepareBulkWriteRequest($request);
},
$args['requests']
),
array_diff_key($args, ['requests' => 1])
);

Expand Down