Issues (98)

application/controllers/ErrorController.php (4 issues)

1
<?php
2
3
class ErrorController extends Zend_Controller_Action
4
{
5 1
    public function errorAction(): void
6
    {
7 1
        $errors = $this->_getParam('error_handler');
8
9 1
        if (!$errors || !$errors instanceof ArrayObject) {
10
            $this->view->message = 'You have reached the error page';
11
12
            return;
13
        }
14
15 1
        switch ($errors->type) {
0 ignored issues
show
The property type does not seem to exist on ArrayObject.
Loading history...
16
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
17
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
18
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
19
                // 404 error -- controller or action not found
20
                $this->getResponse()->setHttpResponseCode(404);
21
                $priority = Zend_Log::NOTICE;
22
                $this->view->message = 'Page not found';
23
24
                break;
25
            default:
26
                // application error
27 1
                $this->getResponse()->setHttpResponseCode(500);
28 1
                $priority = Zend_Log::CRIT;
29 1
                $this->view->message = 'Application error';
30
31 1
                break;
32
        }
33
34
        // Log exception, if logger available
35 1
        if ($log = $this->getLog()) {
36
            $log->log($this->view->message, $priority, $errors->exception);
0 ignored issues
show
Accessing message on the interface Zend_View_Interface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
The property exception does not seem to exist on ArrayObject.
Loading history...
37
            $log->log('Request Parameters', $priority, $errors->request->getParams());
0 ignored issues
show
The property request does not seem to exist on ArrayObject.
Loading history...
38
        }
39
40
        // conditionally display exceptions
41 1
        if ($this->getInvokeArg('displayExceptions') == true) {
42 1
            $this->view->exception = $errors->exception;
43
        }
44
45 1
        $this->view->request = $errors->request;
46 1
    }
47
48 1
    public function getLog()
49
    {
50 1
        $bootstrap = $this->getInvokeArg('bootstrap');
51 1
        if (!$bootstrap->hasResource('Log')) {
52 1
            return false;
53
        }
54
        $log = $bootstrap->getResource('Log');
55
56
        return $log;
57
    }
58
}
59