Completed
Push — 1.x ( 4ef91b...9e4f11 )
by Akihito
02:23
created

src/Provide/Error/ExceptionAsString.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This file is part of the BEAR.Package package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\Package\Provide\Error;
8
9
use BEAR\Sunday\Extension\Router\RouterMatch as Request;
10
11
class ExceptionAsString
12
{
13 3
    public function summery(\Exception $e, $log)
14
    {
15 3
        return sprintf("\n\n[%s]\n%s\n %s", get_class($e), $e->getMessage(), $log);
16
    }
17
18
    /**
19
     * @param Request $request
0 ignored issues
show
Doc comment for parameter $request does not match actual variable name $e
Loading history...
20
     * @param string  $lastErrorLog
0 ignored issues
show
There is no parameter named $lastErrorLog. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
Doc comment for parameter $lastErrorLog does not match actual variable name $request
Loading history...
21
     *
22
     * @return string
23
     */
24 3
    public function detail(\Exception $e, Request $request)
25
    {
26 3
        $eSummery = sprintf("[%s]\n%s\nin file %s on line %s\n\n%s",
27 3
            get_class($e),
28 3
            $e->getMessage(),
29 3
            $e->getFile(),
30 3
            $e->getLine(),
31 3
            $e->getTraceAsString()
32 3
        );
33
34 3
        return sprintf("%s\n%s\n\n%s\n%s", date(DATE_RFC2822), $request, $eSummery, $this->getPhpVariables($_SERVER));
35
    }
36
37
    /**
38
     * @param array $server
39
     *
40
     * @return string
41
     */
42 3
    private function getPhpVariables(array $server)
43
    {
44 3
        if (PHP_SAPI === 'cli') {
45 3
            return '';
46
        }
47
48
        return sprintf("\nPHP Variables\n\n\$_SERVER => %s",  print_r($server, true));
0 ignored issues
show
Expected 1 space instead of 2 after comma in function call.
Loading history...
49
    }
50
}
51