Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
renderThrowable example
if
(
\
function_exists
(
'putenv'
)
)
{
@
putenv
(
'LINES='.
$this
->terminal->
getHeight
(
)
)
;
@
putenv
(
'COLUMNS='.
$this
->terminal->
getWidth
(
)
)
;
}
$input
??=
new
ArgvInput
(
)
;
$output
??=
new
ConsoleOutput
(
)
;
$renderException
=
function
D\Throwable
$e
)
use
(
$output
)
{
if
(
$output
instanceof ConsoleOutputInterface
)
{
$this
->
renderThrowable
(
$e
,
$output
->
getErrorOutput
(
)
)
;
}
else
{
$this
->
renderThrowable
(
$e
,
$output
)
;
}
}
;
if
(
$phpHandler
=
set_exception_handler
(
$renderException
)
)
{
restore_exception_handler
(
)
;
if
(
!\
is_array
(
$phpHandler
)
|| !
$phpHandler
[
0
]
instanceof ErrorHandler
)
{
$errorHandler
= true;
}
elseif
(
$errorHandler
=
$phpHandler
[
0
]
->
setExceptionHandler
(
$renderException
)
)
{
$phpHandler
[
0
]
->
setExceptionHandler
(
$errorHandler
)
;
}
}
if
(
\
function_exists
(
'putenv'
)
)
{
@
putenv
(
'LINES='.
$this
->terminal->
getHeight
(
)
)
;
@
putenv
(
'COLUMNS='.
$this
->terminal->
getWidth
(
)
)
;
}
$input
??=
new
ArgvInput
(
)
;
$output
??=
new
ConsoleOutput
(
)
;
$renderException
=
function
D\Throwable
$e
)
use
(
$output
)
{
if
(
$output
instanceof ConsoleOutputInterface
)
{
$this
->
renderThrowable
(
$e
,
$output
->
getErrorOutput
(
)
)
;
}
else
{
$this
->
renderThrowable
(
$e
,
$output
)
;
}
}
;
if
(
$phpHandler
=
set_exception_handler
(
$renderException
)
)
{
restore_exception_handler
(
)
;
if
(
!\
is_array
(
$phpHandler
)
|| !
$phpHandler
[
0
]
instanceof ErrorHandler
)
{
$errorHandler
= true;
}
elseif
(
$errorHandler
=
$phpHandler
[
0
]
->
setExceptionHandler
(
$renderException
)
)
{
$phpHandler
[
0
]
->
setExceptionHandler
(
$errorHandler
)
;
}
}
$hasRun
= true;
$kernel
->
terminateWithException
(
$e
,
$request
)
;
}
;
}
}
elseif
(
$event
instanceof ConsoleEvent &&
$app
=
$event
->
getCommand
(
)
->
getApplication
(
)
)
{
$output
=
$event
->
getOutput
(
)
;
if
(
$output
instanceof ConsoleOutputInterface
)
{
$output
=
$output
->
getErrorOutput
(
)
;
}
$this
->exceptionHandler =
static
function
D\Throwable
$e
)
use
(
$app
,
$output
)
{
$app
->
renderThrowable
(
$e
,
$output
)
;
}
;
}
}
if
(
$this
->exceptionHandler
)
{
$handler
=
set_exception_handler
(
'is_int'
)
;
$handler
= \
is_array
(
$handler
)
?
$handler
[
0
]
: null;
restore_exception_handler
(
)
;
if
(
!
$handler
instanceof ErrorHandler
)
{
$handler
=
$this
->earlyHandler;
}
$hasRun
= true;
$kernel
->
terminateWithException
(
$e
,
$request
)
;
}
;
}
}
elseif
(
$event
instanceof ConsoleEvent &&
$app
=
$event
->
getCommand
(
)
->
getApplication
(
)
)
{
$output
=
$event
->
getOutput
(
)
;
if
(
$output
instanceof ConsoleOutputInterface
)
{
$output
=
$output
->
getErrorOutput
(
)
;
}
$this
->exceptionHandler =
static
function
D\Throwable
$e
)
use
(
$app
,
$output
)
{
$app
->
renderThrowable
(
$e
,
$output
)
;
}
;
}
}
if
(
$this
->exceptionHandler
)
{
$handler
=
set_exception_handler
(
static
fn
(
)
=> null
)
;
$handler
= \
is_array
(
$handler
)
?
$handler
[
0
]
: null;
restore_exception_handler
(
)
;
if
(
!
$handler
instanceof ErrorHandler
)
{
$handler
=
$this
->earlyHandler;
}