[PhpUnitBridge] fix reporting deprecations from DebugClassLoader
This commit is contained in:
parent
a78fb1832b
commit
cb68aeab38
@ -76,6 +76,11 @@ class Deprecation
|
|||||||
$this->triggeringFile = isset($trace[1 + $j]['args'][1]) ? realpath($trace[1 + $j]['args'][1]) : (new \ReflectionClass($class))->getFileName();
|
$this->triggeringFile = isset($trace[1 + $j]['args'][1]) ? realpath($trace[1 + $j]['args'][1]) : (new \ReflectionClass($class))->getFileName();
|
||||||
$this->getOriginalFilesStack();
|
$this->getOriginalFilesStack();
|
||||||
array_splice($this->originalFilesStack, 0, $j, [$this->triggeringFile]);
|
array_splice($this->originalFilesStack, 0, $j, [$this->triggeringFile]);
|
||||||
|
|
||||||
|
if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "([^:]++))/', $message, $m) || preg_match('/^(?:The|Method) "([^":]++)/', $message, $m)) {
|
||||||
|
$this->triggeringFile = (new \ReflectionClass($m[1]))->getFileName();
|
||||||
|
array_unshift($this->originalFilesStack, $this->triggeringFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
--TEST--
|
||||||
|
Test that a deprecation from the DebugClassLoader triggered by an app class extending a vendor one is considered direct.
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$k = 'SYMFONY_DEPRECATIONS_HELPER';
|
||||||
|
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[total]=0');
|
||||||
|
putenv('ANSICON');
|
||||||
|
putenv('ConEmuANSI');
|
||||||
|
putenv('TERM');
|
||||||
|
|
||||||
|
$vendor = __DIR__;
|
||||||
|
while (!file_exists($vendor.'/vendor')) {
|
||||||
|
$vendor = dirname($vendor);
|
||||||
|
}
|
||||||
|
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
|
||||||
|
require PHPUNIT_COMPOSER_INSTALL;
|
||||||
|
require_once __DIR__.'/../../bootstrap.php';
|
||||||
|
eval(<<<'EOPHP'
|
||||||
|
namespace PHPUnit\Util;
|
||||||
|
|
||||||
|
class Test
|
||||||
|
{
|
||||||
|
public static function getGroups()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOPHP
|
||||||
|
);
|
||||||
|
require __DIR__.'/fake_vendor/autoload.php';
|
||||||
|
|
||||||
|
\Symfony\Component\ErrorHandler\DebugClassLoader::enable();
|
||||||
|
new \App\Services\ExtendsDeprecatedFromVendor();
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Remaining direct deprecation notices (1)
|
||||||
|
|
||||||
|
1x: The "App\Services\ExtendsDeprecatedFromVendor" class extends "fcy\lib\DeprecatedClass" that is deprecated.
|
||||||
|
1x in DebugClassLoader::loadClass from Symfony\Component\ErrorHandler
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use fcy\lib\DeprecatedClass;
|
||||||
|
|
||||||
|
final class ExtendsDeprecatedFromVendor extends DeprecatedClass
|
||||||
|
{
|
||||||
|
}
|
Reference in New Issue
Block a user