8000 [Debug] Remove false-positive deprecation from DebugClassLoader · symfony/symfony@fa4e88d · GitHub
[go: up one dir, main page]

Skip to content

Commit 8000 fa4e88d

Browse files
[Debug] Remove false-positive deprecation from DebugClassLoader
1 parent f1a1181 commit fa4e88d

File tree

3 files changed

+3
-50
lines changed

3 files changed

+3
-50
lines changed

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class DebugClassLoader
3131
private static $final = array();
3232
private static $finalMethods = array();
3333
private static $deprecated = array();
34-
private static $deprecatedMethods = array();
3534
private static $internal = array();
3635
private static $internalMethods = array();
3736
private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
@@ -204,12 +203,11 @@ public function loadClass($class)
204203
}
205204
}
206205

207-
// Inherit @final and @deprecated annotations for methods
206+
// Inherit @final and @internal annotations for methods
208207
self::$finalMethods[$name] = array();
209-
self::$deprecatedMethods[$name] = array();
210208
self::$internalMethods[$name] = array();
211209
foreach ($parentAndTraits as $use) {
212-
foreach (array('finalMethods', 'deprecatedMethods', 'internalMethods') as $property) {
210+
foreach (array('finalMethods', 'internalMethods') as $property) {
213211
if (isset(self::${$property}[$use])) {
214212
self::${$property}[$name] = array_merge(self::${$property}[$name], self::${$property}[$use]);
215213
}
@@ -233,12 +231,6 @@ public function loadClass($class)
233231
}
234232

235233
foreach ($parentAndTraits as $use) {
236-
if (isset(self::$deprecatedMethods[$use][$method->name])) {
237-
list($declaringClass, $message) = self::$deprecatedMethods[$use][$method->name];
238-
if (strncmp($ns, $declaringClass, $len)) {
239-
@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);
240-
}
241-
}
242234
if (isset(self::$internalMethods[$use][$method->name])) {
243235
list($declaringClass, $message) = self::$internalMethods[$use][$method->name];
244236
if (strncmp($ns, $declaringClass, $len)) {
@@ -252,7 +244,7 @@ public function loadClass($class)
252244
continue;
253245
}
254246

255-
foreach (array('final', 'deprecated', 'internal') as $annotation) {
247+
foreach (array('final', 'internal') as $annotation) {
256248
if (false !== strpos($doc, '@'.$annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
257249
$message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
258250
self::${$annotation.'Methods'}[$name][$method->name] = array($name, $message);

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -332,28 +332,6 @@ class_exists(__NAMESPACE__.'\\Fixtures\\ExtendedFinalMethod', true);
332332
$this->assertSame($xError, $lastError);
333333
}
334334

335-
public function testExtendedDeprecatedMethod()
336-
{
337-
set_error_handler(function () { return false; });
338-
$e = error_reporting(0);
339-
trigger_error('', E_USER_NOTICE);
340-
341-
class_exists('Test\\'.__NAMESPACE__.'\\ExtendsAnnotatedClass', true);
342-
343-
error_reporting($e);
344-
restore_error_handler();
345-
346-
$lastError = error_get_last();
347-
unset($lastError['file'], $lastError['line']);
348-
349-
$xError = array(
350-
'type' => E_USER_DEPRECATED,
351-
'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".',
352-
);
353-
354-
$this->assertSame($xError, $lastError);
355-
}
356-
357335
public function testInternalsUse()
358336
{
359337
$deprecations = array();
@@ -413,10 +391,6 @@ public function findFile($class)
413391
eval('namespace Test\\'.__NAMESPACE__.'; class Float {}');
414392
} elseif ('Test\\'.__NAMESPACE__.'\ExtendsFinalClass' === $class) {
415393
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsFinalClass extends \\'.__NAMESPACE__.'\Fixtures\FinalClass {}');
416-
} elseif ('Test\\'.__NAMESPACE__.'\ExtendsAnnotatedClass' === $class) {
417-
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsAnnotatedClass extends \\'.__NAMESPACE__.'\Fixtures\AnnotatedClass {
418-
public function deprecatedMethod() { }
419-
}');
420394
} elseif ('Test\\'.__NAMESPACE__.'\ExtendsInternals' === $class) {
421395
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsInternals extends ExtendsInternalsParent {
422396
use \\'.__NAMESPACE__.'\Fixtures\InternalTrait;

src/Symfony/Component/Debug/Tests/Fixtures/AnnotatedClass.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0