Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Debug] Removed deprecated interfaces #14169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Bundle\TwigBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bundle\TwigBundle\Controller;

use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request;

class ExceptionControllerTest extends TestCase
{
public function testOnlyClearOwnOutputBuffers()
{
$flatten = $this->getMock('Symfony\Component\Debug\Exception\FlattenException');
$flatten = $this->getMock(FlattenException::class);
$flatten
->expects($this->once())
->method('getStatusCode')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

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

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

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Debug/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

3.0.0
-----

* removed classes, methods and interfaces deprecated in 2.x

2.6.0
-----

Expand Down
39 changes: 6 additions & 33 deletions src/Symfony/Component/Debug/DebugClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,20 @@ class DebugClassLoader
{
private $classLoader;
private $isFinder;
private $wasFinder;
private static $caseCheck;
private static $deprecated = array();

/**
* Constructor.
*
* @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0
* @param callable $classLoader A class loader
*
* @api
*/
public function __construct($classLoader)
public function __construct(callable $classLoader)
{
$this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile');

if ($this->wasFinder) {
trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
$this->classLoader = array($classLoader, 'loadClass');
$this->isFinder = true;
} else {
$this->classLoader = $classLoader;
$this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');
}
$this->classLoader = $classLoader;
$this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');

if (!isset(self::$caseCheck)) {
self::$caseCheck = false !== stripos(PHP_OS, 'win') ? (false !== stripos(PHP_OS, 'darwin') ? 2 : 1) : 0;
Expand All @@ -60,11 +51,11 @@ public function __construct($classLoader)
/**
* Gets the wrapped class loader.
*
* @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
* @return callable The wrapped class loader
*/
public function getClassLoader()
{
return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
return $this->classLoader;
}

/**
Expand Down Expand Up @@ -115,24 +106,6 @@ public static function disable()
}
}

/**
* Finds a file by class name
*
* @param string $class A class name to resolve to file
*
* @return string|null
*
* @deprecated since version 2.5, to be removed in 3.0.
*/
public function findFile($class)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);

if ($this->wasFinder) {
return $this->classLoader[0]->findFile($class);
}
}

/**
* Loads the given class or interface.
*
Expand Down
115 changes: 4 additions & 111 deletions src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
*/
class ErrorHandler
{
/**
* @deprecated since version 2.6, to be removed in 3.0.
*/
const TYPE_DEPRECATION = -100;

private $levels = array(
E_DEPRECATED => 'Deprecated',
E_USER_DEPRECATED => 'User Deprecated',
Expand Down Expand Up @@ -100,22 +95,15 @@ class ErrorHandler
private static $stackedErrors = array();
private static $stackedErrorLevels = array();

/**
* Same init value as thrownErrors
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
private $displayErrors = 0x1FFF;

/**
* Registers the error handler.
*
* @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
* @param bool $replace Whether to replace or not any existing handler
* @param self|null $handler The handler to register
* @param bool $replace Whether to replace or not any existing handler
*
* @return self The registered error handler
*/
public static function register($handler = null, $replace = true)
public static function register(self $handler = null, $replace = true)
{
if (null === self::$reservedMemory) {
self::$reservedMemory = str_repeat('x', 10240);
Expand All @@ -124,12 +112,7 @@ public static function register($handler = null, $replace = true)

$levels = -1;

if ($handlerIsNew = !$handler instanceof self) {
// @deprecated polymorphism, to be removed in 3.0
if (null !== $handler) {
$levels = $replace ? $handler : 0;
$replace = true;
}
if ($handlerIsNew = null === $handler) {
$handler = new static();
}

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

// $this->displayErrors is @deprecated since version 2.6
$this->displayErrors = $this->thrownErrors;

return $prev;
}

Expand Down Expand Up @@ -566,91 +546,4 @@ protected function getFatalErrorHandlers()
new ClassNotFoundFatalErrorHandler(),
);
}

/**
* Sets the level at which the conversion to Exception is done.
*
* @param int|null $level The level (null to use the error_reporting() value and 0 to disable)
*
* @deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.
*/
public function setLevel($level)
{
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);

$level = null === $level ? error_reporting() : $level;
$this->throwAt($level, true);
}

/**
* Sets the display_errors flag value.
*
* @param int $displayErrors The display_errors flag value
*
* @deprecated since version 2.6, to be removed in 3.0. Use throwAt() instead.
*/
public function setDisplayErrors($displayErrors)
{
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);

if ($displayErrors) {
$this->throwAt($this->displayErrors, true);
} else {
$displayErrors = $this->displayErrors;
$this->throwAt(0, true);
$this->displayErrors = $displayErrors;
}
}

/**
* Sets a logger for the given channel.
*
* @param LoggerInterface $logger A logger interface
* @param string $channel The channel associated with the logger (deprecation, emergency or scream)
*
* @deprecated since version 2.6, to be removed in 3.0. Use setLoggers() or setDefaultLogger() instead.
*/
public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
{
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);

$handler = set_error_handler('var_dump', 0);
$handler = is_array($handler) ? $handler[0] : null;
restore_error_handler();
if (!$handler instanceof self) {
return;
}
if ('deprecation' === $channel) {
$handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
$handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
} elseif ('scream' === $channel) {
$handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
$handler->screamAt(E_ALL | E_STRICT);
} elseif ('emergency' === $channel) {
$handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
$handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
}
}

/**
* @deprecated since version 2.6, to be removed in 3.0. Use handleError() instead.
*/
public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
{
$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());

return $this->handleError($level, $message, $file, $line, (array) $context);
}

/**
* Handles PHP fatal errors.
*
* @deprecated since version 2.6, to be removed in 3.0. Use handleFatalError() instead.
*/
public function handleFatal()
{
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);

static::handleFatalError();
}
}
23 changes: 0 additions & 23 deletions src/Symfony/Component/Debug/Exception/DummyException.php

This file was deleted.

19 changes: 1 addition & 18 deletions src/Symfony/Component/Debug/Exception/FatalErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,14 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\Exception;

/**
* Fatal Error Exception.
*
* @author Fabien Potencier <[email protected]>
* @author Konstanton Myakshin <[email protected]>
* @author Nicolas Grekas <[email protected]>
*
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
*/
class FatalErrorException extends \ErrorException
{
}

namespace Symfony\Component\Debug\Exception;

use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;

/**
* Fatal Error Exception.
*
* @author Konstanton Myakshin <[email protected]>
*/
class FatalErrorException extends LegacyFatalErrorException
class FatalErrorException extends \ErrorException
{
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true)
{
Expand Down
Loading