8000 [Debug] Removed deprecated interfaces · symfony/symfony@d64c380 · GitHub
[go: up one dir, main page]

Skip to content

Commit d64c380

Browse files
[Debug] Removed deprecated interfaces
1 parent 8d6929b commit d64c380

File tree

16 files changed

+33
-391
lines changed

16 files changed

+33
-391
lines changed

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Bundle\TwigBundle\Controller;
1313

1414
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
15-
use Symfony\Component\HttpKernel\Exception\FlattenException;
15+
use Symfony\Component\Debug\Exception\FlattenException;
1616
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;

src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\Controller;
1313

14-
use Symfony\Component\HttpKernel\Exception\FlattenException;
14+
use Symfony\Component\Debug\Exception\FlattenException;
1515
use Symfony\Component\HttpKernel\HttpKernelInterface;
1616
use Symfony\Component\HttpFoundation\Request;
1717

src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
use Symfony\Bundle\TwigBundle\Tests\TestCase;
1515
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
16-
use Symfony\Component\HttpKernel\Exception\FlattenException;
16+
use Symfony\Component\Debug\Exception\FlattenException;
1717
use Symfony\Component\HttpFoundation\Request;
1818

1919
class ExceptionControllerTest extends TestCase
2020
{
2121
public function testOnlyClearOwnOutputBuffers()
2222
{
23-
$flatten = $this->getMock('Symfony\Component\Debug\Exception\FlattenException');
23+
$flatten = $this->getMock(FlattenException::class);
2424
$flatten
2525
->expects($this->once())
2626
->method('getStatusCode')

src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController;
1515
use Symfony\Bundle\TwigBundle\Tests\TestCase;
16+
use Symfony\Component\Debug\Exception\FlattenException;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\HttpFoundation\Request;
1819
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -36,7 +37,7 @@ public function testForwardRequestToConfiguredController()
3637
$this->assertEquals($logicalControllerName, $request->attributes->get('_controller'));
3738

3839
$exception = $request->attributes->get('exception');
39-
$this->assertInstanceOf('Symfony\Component\HttpKernel\Exception\FlattenException', $exception);
40+
$this->assertInstanceOf(FlattenException::class, $exception);
4041
$this->assertEquals($code, $exception->getStatusCode());
4142
$this->assertFalse($request->attributes->get('showException'));
4243

src/Symfony/Component/Debug/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* removed classes, methods and interfaces deprecated in 2.x
8+
9+
2.7.0
10+
-----
11+
12+
* added deprecations checking for parent interfaces/classes to DebugClassLoader
13+
* added symfony_debug_backtrace() to sumfony_debug extension
14+
to track the backtrace of fatal errors
15+
416
2.6.0
517
-----
618

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,20 @@ class DebugClassLoader
2828
{
2929
private $classLoader;
3030
private $isFinder;
31-
private $wasFinder;
3231
private static $caseCheck;
3332
private static $deprecated = array();
3433

3534
/**
3635
* Constructor.
3736
*
38-
* @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0
37+
* @param callable $classLoader A class loader.
3938
*
4039
* @api
4140
*/
42-
public function __construct($classLoader)
41+
public function __construct(callable $classLoader)
4342
{
44-
$this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile');
45-
46-
if ($this->wasFinder) {
47-
trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
48-
$this->classLoader = array($classLoader, 'loadClass');
49-
$this->isFinder = true;
50-
} else {
51-
$this->classLoader = $classLoader;
52-
$this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');
53-
}
43+
$this->classLoader = $classLoader;
44+
$this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');
5445

5546
if (!isset(self::$caseCheck)) {
5647
self::$caseCheck = false !== stripos(PHP_OS, 'win') ? (false !== stripos(PHP_OS, 'darwin') ? 2 : 1) : 0;
@@ -60,11 +51,11 @@ public function __construct($classLoader)
6051
/**
6152
* Gets the wrapped class loader.
6253
*
63-
* @return callable|object A class loader. Since version 2.5, returning an object is @deprecated and support for it will be removed in 3.0
54+
* @return callable The wrapped class loader.
6455
*/
6556
public function getClassLoader()
6657
{
67-
return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
58+
return $this->classLoader;
6859
}
6960

7061
/**
@@ -115,24 +106,6 @@ public static function disable()
115106
}
116107
}
117108

118-
/**
119-
* Finds a file by class name
120-
*
121-
* @param string $class A class name to resolve to file
122-
*
123-
* @return string|null
124-
*
125-
* @deprecated since version 2.5, to be removed in 3.0.
126-
*/
127-
public function findFile($class)
128-
{
129-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
130-
131-
if ($this->wasFinder) {
132-
return $this->classLoader[0]->findFile($class);
133-
}
134-
}
135-
136109
/**
137110
* Loads the given class or interface.
138111
*

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 4 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
*/
4646
class ErrorHandler
4747
{
48-
/**
49-
* @deprecated since version 2.6, to be removed in 3.0.
50-
*/
51-
const TYPE_DEPRECATION = -100;
52-
5348
private $levels = array(
5449
E_DEPRECATED => 'Deprecated',
5550
E_USER_DEPRECATED => 'User Deprecated',
@@ -100,22 +95,15 @@ class ErrorHandler
10095
private static $stackedErrors = array();
10196
private static $stackedErrorLevels = array();
10297

103-
/**
104-
* Same init value as thrownErrors
105-
*
106-
* @deprecated since version 2.6, to be removed in 3.0.
107-
*/
108-
private $displayErrors = 0x1FFF;
109-
11098
/**
11199
* Registers the error handler.
112100
*
113-
* @param self|null|int $handler The handler to register, or @deprecated (since version 2.6, to be removed in 3.0) bit field of thrown levels
114-
* @param bool $replace Whether to replace or not any existing handler
101+
* @param self|null $handler The handler to register.
102+
* @param bool $replace Whether to replace or not any existing handler.
115103
*
116104
* @return self The registered error handler
117105
*/
118-
public static function register($handler = null, $replace = true)
106+
public static function register(self $handler = null, $replace = true)
119107
{
120108
if (null === self::$reservedMemory) {
121109
self::$reservedMemory = str_repeat('x', 10240);
@@ -124,12 +112,7 @@ public static function register($handler = null, $replace = true)
124112

125113
$levels = -1;
126114

127-
if ($handlerIsNew = !$handler instanceof self) {
128-
// @deprecated polymorphism, to be removed in 3.0
129-
if (null !== $handler) {
130-
$levels = $replace ? $handler : 0;
131-
$replace = true;
132-
}
115+
if ($handlerIsNew = null === $handler) {
133116 8C7E
$handler = new static();
134117
}
135118

@@ -256,9 +239,6 @@ public function throwAt($levels, $replace = false)
256239
}
257240
$this->reRegister($prev | $this->loggedErrors);
258241

259-
// $this->displayErrors is @deprecated since version 2.6
260-
$this->displayErrors = $this->thrownErrors;
261-
262242
return $prev;
263243
}
264244

@@ -566,91 +546,4 @@ protected function getFatalErrorHandlers()
566546
new ClassNotFoundFatalErrorHandler(),
567547
);
568548
}
569-
570-
/**
571-
* Sets the level at which the conversion to Exception is done.
572-
*
573-
* @param int|null $level The level (null to use the error_reporting() value and 0 to disable)
574-
*
575-
* @deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.
576-
*/
577-
public function setLevel($level)
578-
{
579-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the throwAt() method instead.', E_USER_DEPRECATED);
580-
581-
$level = null === $level ? error_reporting() : $level;
582-
$this->throwAt($level, true);
583-
}
584-
585-
/**
586-
* Sets the display_errors flag value.
587-
*
588-
* @param int $displayErrors The display_errors flag value
589-
*
590-
* @deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.
591-
*/
592-
public function setDisplayErrors($displayErrors)
593-
{
594-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the throwAt() method instead.', E_USER_DEPRECATED);
595-
596-
if ($displayErrors) {
597-
$this->throwAt($this->displayErrors, true);
598-
} else {
599-
$displayErrors = $this->displayErrors;
600-
$this->throwAt(0, true);
601-
$this->displayErrors = $displayErrors;
602-
}
603-
}
604-
605-
/**
606-
* Sets a logger for the given channel.
607-
*
608-
* @param LoggerInterface $logger A logger interface
609-
* @param string $channel The channel associated with the logger (deprecation, emergency or scream)
610-
*
611-
* @deprecated since version 2.6, to be removed in 3.0. Use setLoggers() or setDefaultLogger() instead.
612-
*/
613-
public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
614-
{
615-
trigger_error('The '.__METHOD__.' static method is deprecated since version 2.6 and will be removed in 3.0. Use the setLoggers() or setDefaultLogger() methods instead.', E_USER_DEPRECATED);
616-
617-
$handler = set_error_handler('var_dump', 0);
618-
$handler = is_array($handler) ? $handler[0] : null;
619-
restore_error_handler();
620-
if (!$handler instanceof self) {
621-
return;
622-
}
623-
if ('deprecation' === $channel) {
624-
$handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
625-
$handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
626-
} elseif ('scream' === $channel) {
627-
$handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
628-
$handler->screamAt(E_ALL | E_STRICT);
629-
} elseif ('emergency' === $channel) {
630-
$handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
631-
$handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
632-
}
633-
}
634-
635-
/**
636-
* @deprecated since version 2.6, to be removed in 3.0. Use handleError() instead.
637-
*/
638-
public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
639-
{
640-
$this->handleError(E_USER_DEPRECATED, 'The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the handleError() method instead.', __FILE__, __LINE__, array());
641-
642-
return $this->handleError($level, $message, $file, $line, (array) $context);
643-
}
644-
645-
/**
646-
* Handles PHP fatal errors.
647-
*
648-
* @deprecated since version 2.6, to be removed in 3.0. Use handleFatalError() instead.
649-
*/
650-
public function handleFatal()
651-
{
652-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the handleFatalError() method instead.', E_USER_DEPRECATED);
653-
654-
static::handleFatalError();
655-
}
656549
}

src/Symfony/Component/Debug/Exception/DummyException.php

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

src/Symfony/Component/Debug/Exception/FatalErrorException.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\HttpKernel\Exception;
13-
14-
/**
15-
* Fatal Error Exception.
16-
*
17-
* @author Fabien Potencier <fabien@symfony.com>
18-
* @author Konstanton Myakshin <koc-dp@yandex.ru>
19-
* @author Nicolas Grekas <p@tchwork.com>
20-
*
21-
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
22-
*/
23-
class FatalErrorException extends \ErrorException
24-
{
25-
}
26-
2712
namespace Symfony\Component\Debug\Exception;
2813

29-
use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
30-
3114
/**
3215
* Fatal Error Exception.
3316
*
3417
* @author Konstanton Myakshin <koc-dp@yandex.ru>
3518
*/
36-
class FatalErrorException extends LegacyFatalErrorException
19+
class FatalErrorException extends \ErrorException
3720
{
3821
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true)
3922
{

0 commit comments

Comments
 (0)
0