Completed
Push — master ( b4d6a5...352f6d )
by Basil
02:42
created

ErrorHandler::renderException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace luya\web;
4
5
use luya\traits\ErrorHandlerTrait;
6
7
/**
8
 * LUYA ErrorHandler wrapper with error handler trait
9
 *
10
 * @author Basil Suter <[email protected]>
11
 * @since 1.0.0
12
 */
13
class ErrorHandler extends \yii\web\ErrorHandler
14
{
15
    /**
16
     * @var string Event will be trigger before the ErrorHandler starts to render the exception.
17
     */
18
    const EVENT_BEFORE_EXCEPTION_RENDER = 'onBeforeExceptionRender';
19
    
20
    use ErrorHandlerTrait {
21
        renderException as protected traitRenderException;
22
    }
23
    
24
    /**
25
     * @inheritdoc
26
     */
27
    public function renderException($exception)
28
    {
29
        $event = new ErrorHandlerExceptionRenderEvent();
30
        $event->exception = $exception;
0 ignored issues
show
Documentation Bug introduced by
$exception is of type object<Exception>, but the property $exception was declared to be of type object<yii\base\Exception>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
31
        $this->trigger(self::EVENT_BEFORE_EXCEPTION_RENDER, $event);
32
        
33
        return $this->traitRenderException($exception);
34
    }
35
}
36