Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
davedevelopment committed Dec 11, 2020
2 parents 6a4cf9d + 9243ac2 commit 14a510d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
25 changes: 3 additions & 22 deletions .travis.yml
Expand Up @@ -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:
- |
Expand All @@ -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";
Expand Down Expand Up @@ -66,4 +48,3 @@ deploy:
on:
branch: master
php: '7.3'
condition: $DEPS = latest
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions library/Mockery/Reflector.php
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/PHP80/Php80LanguageFeaturesTest.php
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 14a510d

Please sign in to comment.