Issues (33)

app/Exceptions/LlfException.php (2 issues)

Labels
Severity
1
<?php
2
/**
3
 * 业务逻辑异常时抛出
4
 *
5
 * @author mybsdc <[email protected]>
6
 * @date 2018/8/10
7
 * @time 14:48
8
 */
9
10
namespace Luolongfei\App\Exceptions;
11
12
class LlfException extends \Exception
13
{
14
    public function __construct($code, $additional = null, \Exception $previous = null)
15
    {
16
        $message = lang('exception_msg.' . $code) ?: '';
17
18
        if ($additional !== null) {
19
            if (is_array($additional)) {
20
                array_unshift($additional, $message);
21
                $message = call_user_func_array('sprintf', $additional);
22
            } else if (is_string($additional)) {
23
                $message = sprintf($message, $additional);
0 ignored issues
show
It seems like $message can also be of type array; however, parameter $format of sprintf() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
                $message = sprintf(/** @scrutinizer ignore-type */ $message, $additional);
Loading history...
24
            }
25
        }
26
27
        parent::__construct($message . "(Error code: {$code})", $code, $previous);
0 ignored issues
show
Are you sure $message of type array|mixed|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        parent::__construct(/** @scrutinizer ignore-type */ $message . "(Error code: {$code})", $code, $previous);
Loading history...
28
    }
29
}