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

Skip to content

Commit 84a5483

Browse files
committed
feature #21388 [Debug] Deprecate ContextErrorException (nicolas-grekas)
This PR was merged into the 3.3-dev branch. Discussion ---------- [Debug] Deprecate ContextErrorException | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Since the `$context` argument is going to be deprecated in PHP 7.2 (see https://wiki.php.net/rfc/deprecations_php_7_2#errcontext_argument_of_error_handler), let's deprecate ContextErrorException altogether. Commits ------- c379707 [Debug] Deprecate ContextErrorException
2 parents dad0c2f + c379707 commit 84a5483

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

UPGRADE-3.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ ClassLoader
66

77
* The component is deprecated and will be removed in 4.0. Use Composer instead.
88

9+
Debug
10+
-----
11+
12+
* The `ContextErrorException` class is deprecated. `\ErrorException` will be used instead in 4.0.
13+
914
DependencyInjection
1015
-------------------
1116

UPGRADE-4.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Console
1515
Debug
1616
-----
1717

18+
19+
* The `ContextErrorException` class has been removed. Use `\ErrorException` instead.
20+
1821
* `FlattenException::getTrace()` now returns additional type descriptions
1922
`integer` and `float`.
2023

src/Symfony/Component/Debug/CHANGELOG.md

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

4+
3.3.0
5+
-----
6+
7+
* deprecated the `ContextErrorException` class: use \ErrorException directly now
8+
49
3.2.0
510
-----
611

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,6 @@ public function handleException($exception, array $error = null)
521521
}
522522
} elseif ($exception instanceof \ErrorException) {
523523
$message = 'Uncaught '.$exception->getMessage();
524-
if ($exception instanceof ContextErrorException) {
525-
$e['context'] = $exception->getContext();
526-
}
527524
} else {
528525
$message = 'Uncaught Exception: '.$exception->getMessage();
529526
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Error Exception with Variable Context.
1616
*
1717
* @author Christian Sciberras <[email protected]>
18+
*
19+
* @deprecated since version 3.3. Instead, \ErrorException will be used directly in 4.0.
1820
*/
1921
class ContextErrorException extends \ErrorException
2022
{
@@ -31,6 +33,8 @@ public function __construct($message, $code, $severity, $filename, $lineno, $con
3133
*/
3234
public function getContext()
3335
{
36+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
37+
3438
return $this->context;
3539
}
3640
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Psr\Log\LogLevel;
1515
use Symfony\Component\Debug\BufferingLogger;
1616
use Symfony\Component\Debug\ErrorHandler;
17-
use Symfony\Component\Debug\Exception\ContextErrorException;
1817
use Symfony\Component\Debug\Exception\SilencedErrorContext;
1918

2019
/**
@@ -71,13 +70,12 @@ public function testNotice()
7170

7271
try {
7372
self::triggerNotice($this);
74-
$this->fail('ContextErrorException expected');
75-
} catch (ContextErrorException $exception) {
73+
$this->fail('ErrorException expected');
74+
} catch (\ErrorException $exception) {
7675
// if an exception is thrown, the test passed
7776
$this->assertEquals(E_NOTICE, $exception->getSeverity());
7877
$this->assertEquals(__FILE__, $exception->getFile());
7978
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
80-
$this->assertArrayHasKey('foobar', $exception->getContext());
8179

8280
$trace = $exception->getTrace();
8381

0 commit comments

Comments
 (0)