[Debug] Remove false-positive deprecation from DebugClassLoader
This commit is contained in:
parent
f1a11817cf
commit
5edd4135ca
@ -31,7 +31,6 @@ class DebugClassLoader
|
||||
private static $final = array();
|
||||
private static $finalMethods = array();
|
||||
private static $deprecated = array();
|
||||
private static $deprecatedMethods = array();
|
||||
private static $internal = array();
|
||||
private static $internalMethods = array();
|
||||
private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
|
||||
@ -204,12 +203,11 @@ class DebugClassLoader
|
||||
}
|
||||
}
|
||||
|
||||
// Inherit @final and @deprecated annotations for methods
|
||||
// Inherit @final and @internal annotations for methods
|
||||
self::$finalMethods[$name] = array();
|
||||
self::$deprecatedMethods[$name] = array();
|
||||
self::$internalMethods[$name] = array();
|
||||
foreach ($parentAndTraits as $use) {
|
||||
foreach (array('finalMethods', 'deprecatedMethods', 'internalMethods') as $property) {
|
||||
foreach (array('finalMethods', 'internalMethods') as $property) {
|
||||
if (isset(self::${$property}[$use])) {
|
||||
self::${$property}[$name] = array_merge(self::${$property}[$name], self::${$property}[$use]);
|
||||
}
|
||||
@ -233,12 +231,6 @@ class DebugClassLoader
|
||||
}
|
||||
|
||||
foreach ($parentAndTraits as $use) {
|
||||
if (isset(self::$deprecatedMethods[$use][$method->name])) {
|
||||
list($declaringClass, $message) = self::$deprecatedMethods[$use][$method->name];
|
||||
if (strncmp($ns, $declaringClass, $len)) {
|
||||
@trigger_error(sprintf('The "%s::%s()" method is deprecated%s. You should not extend it from "%s".', $declaringClass, $method->name, $message, $name), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
if (isset(self::$internalMethods[$use][$method->name])) {
|
||||
list($declaringClass, $message) = self::$internalMethods[$use][$method->name];
|
||||
if (strncmp($ns, $declaringClass, $len)) {
|
||||
@ -252,7 +244,7 @@ class DebugClassLoader
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (array('final', 'deprecated', 'internal') as $annotation) {
|
||||
foreach (array('final', 'internal') as $annotation) {
|
||||
if (false !== strpos($doc, '@'.$annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
|
||||
$message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
|
||||
self::${$annotation.'Methods'}[$name][$method->name] = array($name, $message);
|
||||
|
@ -332,7 +332,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
$this->assertSame($xError, $lastError);
|
||||
}
|
||||
|
||||
public function testExtendedDeprecatedMethod()
|
||||
public function testExtendedDeprecatedMethodDoesntTriggerAnyNotice()
|
||||
{
|
||||
set_error_handler(function () { return false; });
|
||||
$e = error_reporting(0);
|
||||
@ -346,12 +346,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
$lastError = error_get_last();
|
||||
unset($lastError['file'], $lastError['line']);
|
||||
|
||||
$xError = array(
|
||||
'type' => E_USER_DEPRECATED,
|
||||
'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\AnnotatedClass::deprecatedMethod()" method is deprecated since version 3.4. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsAnnotatedClass".',
|
||||
);
|
||||
|
||||
$this->assertSame($xError, $lastError);
|
||||
$this->assertSame(array('type' => E_USER_NOTICE, 'message' => ''), $lastError);
|
||||
}
|
||||
|
||||
public function testInternalsUse()
|
||||
|
Reference in New Issue
Block a user