Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ff0927

Browse files
committed
[Debug] added the component (closes#6828,closes#6834,closes#7330)
1 parent22adfdf commit2ff0927

20 files changed

+872
-648
lines changed

‎UPGRADE-3.0.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ UPGRADE FROM 2.x to 3.0
33

44
###ClassLoader
55

6-
* The`UniversalClassLoader` class has been removed in favor of`ClassLoader`. The only difference is that some method
7-
names are different:
6+
* The`UniversalClassLoader` class has been removed in favor of
7+
`ClassLoader`. The only difference is that some method names are different:
88

99
* `registerNamespaces()` -> `addPrefixes()`
1010
* `registerPrefixes()` -> `addPrefixes()`
@@ -34,6 +34,16 @@ UPGRADE FROM 2.x to 3.0
3434
*`Symfony\Bridge\Monolog\Logger`
3535
*`Symfony\Component\HttpKernel\Log\NullLogger`
3636

37+
* The`Symfony\Component\HttpKernel\Kernel::init()` method has been removed.
38+
39+
* The following classes have been renamed as they have been moved to the
40+
Debug component:
41+
42+
*`Symfony\Component\HttpKernel\Debug\ErrorHandler` ->`Symfony\Component\Debug\ErrorHandler`
43+
*`Symfony\Component\HttpKernel\Debug\ExceptionHandler` ->`Symfony\Component\Debug\ExceptionHandler`
44+
*`Symfony\Component\HttpKernel\Exception\FatalErrorException` ->`Symfony\Component\Debug\Exception\FatalErrorException`
45+
*`Symfony\Component\HttpKernel\Exception\FlattenException` ->`Symfony\Component\Debug\Exception\FlattenException`
46+
3747
###Routing
3848

3949
* Some route settings have been renamed:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vendor/
2+
composer.lock
3+
phpunit.xml
4+
Tests/ProjectContainer.php
5+
Tests/classes.map
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG
2+
=========
3+
4+
2.3.0
5+
-----
6+
7+
* added the component
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Debug;
13+
14+
useSymfony\Component\Debug\Exception\FatalErrorException;
15+
usePsr\Log\LoggerInterface;
16+
17+
/**
18+
* ErrorHandler.
19+
*
20+
* @author Fabien Potencier <fabien@symfony.com>
21+
*/
22+
class ErrorHandler
23+
{
24+
constTYPE_DEPRECATION = -100;
25+
26+
private$levels =array(
27+
E_WARNING =>'Warning',
28+
E_NOTICE =>'Notice',
29+
E_USER_ERROR =>'User Error',
30+
E_USER_WARNING =>'User Warning',
31+
E_USER_NOTICE =>'User Notice',
32+
E_STRICT =>'Runtime Notice',
33+
E_RECOVERABLE_ERROR =>'Catchable Fatal Error',
34+
E_DEPRECATED =>'Deprecated',
35+
E_USER_DEPRECATED =>'User Deprecated',
36+
E_ERROR =>'Error',
37+
E_CORE_ERROR =>'Core Error',
38+
E_COMPILE_ERROR =>'Compile Error',
39+
E_PARSE =>'Parse',
40+
);
41+
42+
private$level;
43+
44+
private$reservedMemory;
45+
46+
/** @var LoggerInterface */
47+
privatestatic$logger;
48+
49+
/**
50+
* Register the error handler.
51+
*
52+
* @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable)
53+
*
54+
* @return The registered error handler
55+
*/
56+
publicstaticfunctionregister($level =null)
57+
{
58+
$handler =newstatic();
59+
$handler->setLevel($level);
60+
61+
ini_set('display_errors',0);
62+
set_error_handler(array($handler,'handle'));
63+
register_shutdown_function(array($handler,'handleFatal'));
64+
$handler->reservedMemory =str_repeat('x',10240);
65+
66+
return$handler;
67+
}
68+
69+
publicfunctionsetLevel($level)
70+
{
71+
$this->level =null ===$level ?error_reporting() :$level;
72+
}
73+
74+
publicstaticfunctionsetLogger(LoggerInterface$logger)
75+
{
76+
self::$logger =$logger;
77+
}
78+
79+
/**
80+
* @throws \ErrorException When error_reporting returns error
81+
*/
82+
publicfunctionhandle($level,$message,$file,$line,$context)
83+
{
84+
if (0 ===$this->level) {
85+
returnfalse;
86+
}
87+
88+
if ($level & (E_USER_DEPRECATED |E_DEPRECATED)) {
89+
if (null !==self::$logger) {
90+
$stack =version_compare(PHP_VERSION,'5.4','<') ?array_slice(debug_backtrace(false),0,10) :debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,10);
91+
92+
self::$logger->warning($message,array('type' =>self::TYPE_DEPRECATION,'stack' =>$stack));
93+
}
94+
95+
returntrue;
96+
}
97+
98+
if (error_reporting() &$level &&$this->level &$level) {
99+
thrownew \ErrorException(sprintf('%s: %s in %s line %d',isset($this->levels[$level]) ?$this->levels[$level] :$level,$message,$file,$line),0,$level,$file,$line);
100+
}
101+
102+
returnfalse;
103+
}
104+
105+
publicfunctionhandleFatal()
106+
{
107+
if (null ===$error =error_get_last()) {
108+
return;
109+
}
110+
111+
unset($this->reservedMemory);
112+
$type =$error['type'];
113+
if (0 ===$this->level || !in_array($type,array(E_ERROR,E_CORE_ERROR,E_COMPILE_ERROR,E_PARSE))) {
114+
return;
115+
}
116+
117+
// get current exception handler
118+
$exceptionHandler =set_exception_handler(function() {});
119+
restore_exception_handler();
120+
121+
if (is_array($exceptionHandler) &&$exceptionHandler[0]instanceof ExceptionHandler) {
122+
$level =isset($this->levels[$type]) ?$this->levels[$type] :$type;
123+
$message =sprintf('%s: %s in %s line %d',$level,$error['message'],$error['file'],$error['line']);
124+
$exception =newFatalErrorException($message,0,$type,$error['file'],$error['line']);
125+
$exceptionHandler[0]->handle($exception);
126+
}
127+
}
128+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Debug\Exception;
13+
14+
/**
15+
* Fatal Error Exception.
16+
*
17+
* @author Konstanton Myakshin <koc-dp@yandex.ru>
18+
*/
19+
class FatalErrorExceptionextends \ErrorException
20+
{
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp