Skip to content

Commit

Permalink
Do not use is_callable() here as it behaves differently in PHP 8 (see #…
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 22, 2019
1 parent bde8364 commit c557764
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ private function handleDependencies(): bool
}

if (!isset($passedKeys[$dependency])) {
if (!\is_callable($dependency, false, $callableName) || $dependency !== $callableName) {
if (!$this->isCallableTestMethod($dependency)) {
$this->warnAboutDependencyThatDoesNotExist($dependency);
} else {
$this->markSkippedForMissingDependency($dependency);
Expand Down Expand Up @@ -2264,4 +2264,35 @@ private function recordDoubledType($originalClassName): void
}
}
}

private function isCallableTestMethod(string $dependency): bool
{
[$className, $methodName] = \explode('::', $dependency);

if (!\class_exists($className)) {
return false;
}

try {
$class = new \ReflectionClass($className);
} catch (\ReflectionException $e) {
return false;
}

if (!$class->isSubclassOf(__CLASS__)) {
return false;
}

if (!$class->hasMethod($methodName)) {
return false;
}

try {
$method = $class->getMethod($methodName);
} catch (\ReflectionException $e) {
return false;
}

return TestUtil::isTestMethod($method);
}
}

0 comments on commit c557764

Please sign in to comment.