diff --git a/.travis.yml b/.travis.yml index 51ad41bee..13dcb7355 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,8 @@ language: php matrix: include: - php: 7.3 - env: - - DEPS=lowest - - php: 7.3 - env: - - DEPS=latest - - php: 7.4 - env: - - DEPS=lowest - php: 7.4 - env: - - DEPS=latest - - php: nightly - env: - - DEPS=lowest - - COMPOSER_FLAGS="--ignore-platform-reqs" - - php: nightly - env: - - DEPS=latest - - COMPOSER_FLAGS="--ignore-platform-reqs" + - php: 8.0 before_install: - | @@ -31,12 +14,11 @@ before_install: fi install: - - if [[ $DEPS == 'latest' ]]; then travis_retry composer update --no-interaction $COMPOSER_FLAGS ; fi - - if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable --no-interaction $COMPOSER_FLAGS ; fi + - travis_retry composer update --no-interaction script: - | - if [[ $TRAVIS_PHP_VERSION == 'nightly' ]]; then + if [[ $TRAVIS_PHP_VERSION == '8.0' ]]; then ./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite PHP8"; else ./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite PHP7"; @@ -66,4 +48,3 @@ deploy: on: branch: master php: '7.3' - condition: $DEPS = latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c24868af..f5a81ee15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,19 @@ * Added provisional support for PHP 8.0 (#1068, #1072,#1079) * Fix mocking methods with iterable return type without specifying a return value (#1075) +## 1.3.3 (2020-08-11) +* Fix array to string conversion in ConstantsPass (#1086) +* Fixed nullable PHP 8.0 union types (#1088) +* Fixed support for PHP 8.0 parent type (#1088) +* Fixed PHP 8.0 mixed type support (#1088) +* Fixed PHP 8.0 union return types (#1088) + +## 1.3.2 (2020-07-09) +* Fix mocking with anonymous classes (#1039) +* Fix andAnyOthers() to properly match earlier expectations (#1051) +* Added provisional support for PHP 8.0 (#1068, #1072,#1079) +* Fix mocking methods with iterable return type without specifying a return value (#1075) + ## 1.4.0 (2020-05-19) * Fix mocking with anonymous classes (#1039) diff --git a/library/Mockery/Reflector.php b/library/Mockery/Reflector.php index fe9fb77da..2f67a9cd1 100644 --- a/library/Mockery/Reflector.php +++ b/library/Mockery/Reflector.php @@ -94,9 +94,11 @@ private static function typeToString(\ReflectionType $type, \ReflectionClass $de { // PHP 8 union types can be recursively processed if ($type instanceof \ReflectionUnionType) { - return \implode('|', \array_map(function (\ReflectionType $type) use ($declaringClass) { - return self::typeToString($type, $declaringClass); - }, $type->getTypes())); + return \implode('|', \array_filter(\array_map(function (\ReflectionType $type) use ($declaringClass) { + $typeHint = self::typeToString($type, $declaringClass); + + return $typeHint === 'null' ? null : $typeHint; + }, $type->getTypes()))); } // $type must be an instance of \ReflectionNamedType diff --git a/tests/PHP80/Php80LanguageFeaturesTest.php b/tests/PHP80/Php80LanguageFeaturesTest.php index fbecee555..11ffa232e 100644 --- a/tests/PHP80/Php80LanguageFeaturesTest.php +++ b/tests/PHP80/Php80LanguageFeaturesTest.php @@ -29,6 +29,15 @@ public function it_can_mock_a_class_with_a_union_argument_type_hint() $mock->foo($object); } + /** @test */ + public function it_can_mock_a_class_with_a_union_argument_type_hint_including_null() + { + $mock = mock(ArgumentUnionTypeHintWithNull::class); + $mock->allows()->foo(null); + + $mock->foo(null); + } + /** @test */ public function it_can_mock_a_class_with_a_parent_argument_type_hint() { @@ -78,6 +87,13 @@ public function foo(string|array|self $foo) } } +class ArgumentUnionTypeHintWithNull +{ + public function foo(string|array|null $foo) + { + } +} + class ArgumentParentTypeHint extends \stdClass { public function foo(parent $foo)