Skip to content

Commit

Permalink
Merge pull request #432 from smoench/fix-compatibility-with-php74
Browse files Browse the repository at this point in the history
fix compatibility with PHP 7.4
  • Loading branch information
stof authored Aug 23, 2019
2 parents 1927e75 + 4ab322a commit dcf5389
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ matrix:
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4snapshot
- php: 5.3
dist: precise
fast_finish: true
allow_failures:
- php: 7.4snapshot

install:
- export COMPOSER_ROOT_VERSION=dev-master
Expand Down
4 changes: 2 additions & 2 deletions src/Prophecy/Doubler/Generator/ClassMirror.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private function reflectMethodToNode(ReflectionMethod $method, Node\ClassNode $c
}

if (version_compare(PHP_VERSION, '7.0', '>=') && $method->hasReturnType()) {
$returnType = (string) $method->getReturnType();
$returnType = PHP_VERSION_ID >= 70100 ? $method->getReturnType()->getName() : (string) $method->getReturnType();
$returnTypeLower = strtolower($returnType);

if ('self' === $returnTypeLower) {
Expand Down Expand Up @@ -231,7 +231,7 @@ private function getTypeHint(ReflectionParameter $parameter)
}

if (version_compare(PHP_VERSION, '7.0', '>=') && true === $parameter->hasType()) {
return (string) $parameter->getType();
return PHP_VERSION_ID >= 70100 ? $parameter->getType()->getName() : (string) $parameter->getType();
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Prophecy/Prophecy/MethodProphecy.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(ObjectProphecy $objectProphecy, $methodName, $argume
}

if (version_compare(PHP_VERSION, '7.0', '>=') && true === $reflectedMethod->hasReturnType()) {
$type = (string) $reflectedMethod->getReturnType();
$type = PHP_VERSION_ID >= 70100 ? $reflectedMethod->getReturnType()->getName() : (string) $reflectedMethod->getReturnType();

if ('void' === $type) {
$this->voidReturnType = true;
Expand Down

0 comments on commit dcf5389

Please sign in to comment.