Issues (36)

src/traits/Consoleable.php (4 issues)

Labels
Severity
1
<?php
2
3
4
namespace andmemasin\myabstract\traits;
5
6
use yii\console\Application;
7
8
trait Consoleable
9
{
10
    /**
11
     * @param $message
12
     * @param string $level
13
     */
14
    protected function log($message, $level = "info")
15
    {
16
        if (\Yii::$app instanceof Application) {
17
            echo $message . PHP_EOL;
18
        }
19
        switch ($level) {
20
            case 'error':
21
                return \Yii::error($message, __METHOD__);
0 ignored issues
show
Are you sure the usage of Yii::error($message, __METHOD__) targeting yii\BaseYii::error() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
22
            case 'warning':
23
                return \Yii::warning($message, __METHOD__);
0 ignored issues
show
Are you sure the usage of Yii::warning($message, __METHOD__) targeting yii\BaseYii::warning() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
24
            case 'info':
25
                return \Yii::info($message, __METHOD__);
0 ignored issues
show
Are you sure the usage of Yii::info($message, __METHOD__) targeting yii\BaseYii::info() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
26
            case 'debug':
27
                return \Yii::debug($message, __METHOD__);
0 ignored issues
show
Are you sure the usage of Yii::debug($message, __METHOD__) targeting yii\BaseYii::debug() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
            default:
29
                throw new \Exception('Unexpected value');
30
        }
31
    }
32
33
34
}