[ErrorHandler][Bridge/PhpUnit] display deprecations for not-autoloaded classes
This commit is contained in:
parent
727aa7ed9e
commit
2ba3cc0aba
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestResult;
|
||||
use PHPUnit\Util\ErrorHandler;
|
||||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
|
||||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
|
||||
use Symfony\Component\ErrorHandler\DebugClassLoader;
|
||||
|
||||
/**
|
||||
* Catch deprecation notices and print a summary report at the end of the test suite.
|
||||
@ -178,6 +179,9 @@ class DeprecationErrorHandler
|
||||
return;
|
||||
}
|
||||
|
||||
if (method_exists(DebugClassLoader::class, 'checkClasses')) {
|
||||
DebugClassLoader::checkClasses();
|
||||
}
|
||||
$currErrorHandler = set_error_handler('var_dump');
|
||||
restore_error_handler();
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
// Please update when phpunit needs to be reinstalled with fresh deps:
|
||||
// Cache-Id: 2019-08-09 13:00 UTC
|
||||
// Cache-Id: 2019-09-02 16:00 UTC
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
|
@ -11,7 +11,11 @@
|
||||
|
||||
namespace Symfony\Component\ErrorHandler;
|
||||
|
||||
use Doctrine\Common\Persistence\Proxy;
|
||||
use PHPUnit\Framework\MockObject\Matcher\StatelessInvocation;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Prophecy\Prophecy\ProphecySubjectInterface;
|
||||
use ProxyManager\Proxy\ProxyInterface;
|
||||
|
||||
/**
|
||||
* Autoloader checking if the class is really defined in the file found.
|
||||
@ -230,22 +234,57 @@ class DebugClassLoader
|
||||
spl_autoload_unregister($function);
|
||||
}
|
||||
|
||||
$loader = null;
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (\is_array($function) && $function[0] instanceof self) {
|
||||
$loader = $function[0];
|
||||
$function = $function[0]->getClassLoader();
|
||||
}
|
||||
|
||||
spl_autoload_register($function);
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $loader) {
|
||||
foreach (array_merge(get_declared_interfaces(), get_declared_traits(), get_declared_classes()) as $class) {
|
||||
$loader->checkClass($class);
|
||||
public static function checkClasses(): bool
|
||||
{
|
||||
if (!\is_array($functions = spl_autoload_functions())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$loader = null;
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (\is_array($function) && $function[0] instanceof self) {
|
||||
$loader = $function[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $loader) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static $offsets = [
|
||||
'get_declared_interfaces' => 0,
|
||||
'get_declared_traits' => 0,
|
||||
'get_declared_classes' => 0,
|
||||
];
|
||||
|
||||
foreach ($offsets as $getSymbols => $i) {
|
||||
$symbols = $getSymbols();
|
||||
|
||||
for (; $i < \count($symbols); ++$i) {
|
||||
if (!is_subclass_of($symbols[$i], MockObject::class)
|
||||
&& !is_subclass_of($symbols[$i], ProphecySubjectInterface::class)
|
||||
&& !is_subclass_of($symbols[$i], Proxy::class)
|
||||
&& !is_subclass_of($symbols[$i], ProxyInterface::class)
|
||||
) {
|
||||
$loader->checkClass($symbols[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$offsets[$getSymbols] = $i;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function findFile(string $class): ?string
|
||||
|
Reference in New Issue
Block a user