Skip to content

Commit

Permalink
Make this work with PHP >= 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed May 9, 2021
1 parent 7710685 commit 9704f1b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions build/scripts/generate-global-assert-wrappers.php
Expand Up @@ -47,11 +47,15 @@
$constraintMethods = '';

foreach ($class->getMethods() as $method) {
if (!$method->hasReturnType() || $method->getReturnType()->isBuiltin()) {
$returnType = $method->getReturnType();

assert($returnType instanceof ReflectionNamedType || $returnType instanceof ReflectionUnionType);

if ($returnType instanceof ReflectionNamedType && $returnType->isBuiltin()) {
continue;
}

$returnType = new ReflectionClass($method->getReturnType()->getName());
$returnType = new ReflectionClass($returnType->getName());

if (!$returnType->isSubclassOf(Constraint::class)) {
continue;
Expand Down Expand Up @@ -86,7 +90,7 @@
$docComment = \str_replace(
['*/', ' *'],
["*\n * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit\n * @see Assert::" . $method->getName() . "\n */", ' *'],
$method->getDocComment()
(string) $method->getDocComment()
);

$signature = \str_replace('public static ', '', \trim($lines[$method->getStartLine() - 1]));
Expand Down

0 comments on commit 9704f1b

Please sign in to comment.