Skip to content

PHP 8 support #793

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 10 commits into from
Nov 6, 2020
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
31 changes: 18 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: php
dist: xenial
php: "7.4"

addons:
apt:
Expand Down Expand Up @@ -32,7 +33,6 @@ jobs:
include:

- stage: Smoke Testing
php: "7.3"
env:
- CHECKS=phpunit
- stage: Smoke Testing
Expand All @@ -56,7 +56,7 @@ jobs:
- stage: Test
php: "7.2"
- stage: Test
php: "7.4"
php: "7.3"

# Test against lowest supported dependencies
- stage: Test
Expand Down Expand Up @@ -91,59 +91,64 @@ jobs:
env:
- SERVER_VERSION=3.6.19
- stage: Test
php: "7.3"
env:
- SERVER_VERSION=4.0.19
- stage: Test
php: "7.3"
env:
- SERVER_VERSION=4.2.8

# Test upcoming server version
#- stage: Test
# php: "7.3"
# env:
# - SERVER_VERSION=4.5.0

# Test other server configurations
- stage: Test
php: "7.3"
env:
- DEPLOYMENT=STANDALONE_AUTH
- stage: Test
php: "7.3"
env:
- DEPLOYMENT=STANDALONE_SSL
- stage: Test
php: "7.3"
env:
- SERVER_VERSION=3.6.13
- DEPLOYMENT=REPLICASET
- stage: Test
php: "7.3"
env:
- DEPLOYMENT=REPLICASET
- stage: Test
php: "7.3"
env:
- DEPLOYMENT=SHARDED_CLUSTER
- stage: Test
php: "7.3"
env:
- DEPLOYMENT=SHARDED_CLUSTER_RS

# Test next patch release for driver
- stage: Test
php: "7.3"
env:
- DRIVER_BRANCH="v1.8"

# Test next minor release for driver
- stage: Test
php: "7.3"
env:
- DRIVER_BRANCH="master"

# Test upcoming PHP version
- stage: Test
php: "nightly"
env:
- DRIVER_BRANCH="master"
- stage: Test
php: "nightly"
env:
- DRIVER_BRANCH="master"
- DEPLOYMENT=REPLICASET
- stage: Test
php: "nightly"
env:
- DRIVER_BRANCH="master"
- DEPLOYMENT=SHARDED_CLUSTER_RS

before_install:
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
- export SERVER_FILENAME=mongodb-linux-x86_64-${SERVER_DISTRO}-${SERVER_VERSION}
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ test suite. In addition to various PHPUnit options, it defines required
this configuration by creating your own `phpunit.xml` file based on the
`phpunit.xml.dist` file we provide.

By default, the `simple-phpunit` binary chooses the correct PHPUnit version for
the PHP version you are running. To run tests against a specific PHPUnit version,
use the `SYMFONY_PHPUNIT_VERSION` environment variable:

```
$ SYMFONY_PHPUNIT_VERSION=7.5 vendor/bin/simple-phpunit
```

## Checking coding standards

The library's code is checked using [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer),
Expand Down
19 changes: 5 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,28 @@
{ "name": "Jeremy Mikola", "email": "[email protected]" }
],
"require": {
"php": "^7.0",
"php": "^7.0 || ^8.0",
"ext-hash": "*",
"ext-json": "*",
"ext-mongodb": "^1.8.1",
"jean85/pretty-package-versions": "^1.2"
"jean85/pretty-package-versions": "^1.2",
"symfony/polyfill-php80": "^1.19"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5, <3.5.5",
"symfony/phpunit-bridge": "^5.2@beta"
"symfony/phpunit-bridge": "5.x-dev"
},
"autoload": {
"psr-4": { "MongoDB\\": "src/" },
"files": [ "src/functions.php" ]
},
"autoload-dev": {
"psr-4": { "MongoDB\\Tests\\": "tests/" },
"// Manually include assertion functions for PHPUnit 8.x and earlier ":"",
"// See: https://github.com/sebastianbergmann/phpunit/issues/3746 ":"",
"files": [
"vendor/bin/.phpunit/phpunit/src/Framework/Assert/Functions.php",
"tests/PHPUnit/FunctionsPolyfill.php"
]
"files": [ "tests/PHPUnit/Functions.php" ]
},
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
}
},
"scripts": {
"// Ensure PHPUnit is installed through the PHPUnit bridge before ":"",
"// dumping the autoloader to avoid errors due to missing files.":"",
"pre-autoload-dump": "if test -f vendor/bin/simple-phpunit; then vendor/bin/simple-phpunit --version > /dev/null; fi"
}
}
6 changes: 2 additions & 4 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
use MongoDB\Driver\Exception\InvalidArgumentException as DriverInvalidArgumentException;
use function array_pop;
use function count;
use function get_class;
use function gettype;
use function get_debug_type;
use function implode;
use function is_array;
use function is_object;
use function sprintf;

class InvalidArgumentException extends DriverInvalidArgumentException implements Exception
Expand Down Expand Up @@ -58,6 +56,6 @@ public static function invalidType($name, $value, $expectedType)
$expectedType = $typeString;
}

return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, is_object($value) ? get_class($value) : gettype($value)));
return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, get_debug_type($value)));
}
}
4 changes: 2 additions & 2 deletions src/Exception/ResumeTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace MongoDB\Exception;

use function gettype;
use function get_debug_type;
use function sprintf;

class ResumeTokenException extends RuntimeException
Expand All @@ -30,7 +30,7 @@ class ResumeTokenException extends RuntimeException
*/
public static function invalidType($value)
{
return new static(sprintf('Expected resume token to have type "array or object" but found "%s"', gettype($value)));
return new static(sprintf('Expected resume token to have type "array or object" but found "%s"', get_debug_type($value)));
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Collection/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ private function doTearDown()
}

$this->dropCollection();

parent::tearDown();
}
}
2 changes: 2 additions & 0 deletions tests/DocumentationExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ private function doTearDown()
}

$this->dropCollection();

parent::tearDown();
}

public function testExample_1_2()
Expand Down
2 changes: 2 additions & 0 deletions tests/Model/IndexInfoFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ private function doTearDown()
}

$this->collection->drop();

parent::tearDown();
}

public function testIs2dSphere()
Expand Down
2 changes: 2 additions & 0 deletions tests/Operation/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ private function doTearDown()
}

$this->dropCollection();

parent::tearDown();
}

protected function createDefaultReadConcern()
Expand Down
25 changes: 0 additions & 25 deletions tests/PHPUnit/ConstraintTrait.php

This file was deleted.

16 changes: 0 additions & 16 deletions tests/PHPUnit/ConstraintTraitForV6.php

This file was deleted.

26 changes: 0 additions & 26 deletions tests/PHPUnit/ConstraintTraitForV7.php

This file was deleted.

16 changes: 0 additions & 16 deletions tests/PHPUnit/ConstraintTraitForV9.php

This file was deleted.

25 changes: 0 additions & 25 deletions tests/PHPUnit/EvaluateTrait.php

This file was deleted.

Loading