for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace andmemasin\myabstract\traits;
use yii\console\Application;
trait Consoleable
{
/**
* @param $message
* @param string $level
*/
protected function log($message, $level = "info")
if (\Yii::$app instanceof Application) {
echo $message . PHP_EOL;
}
switch ($level) {
case 'error':
return \Yii::error($message, __METHOD__);
Yii::error($message, __METHOD__)
yii\BaseYii::error()
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.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
case 'warning':
return \Yii::warning($message, __METHOD__);
Yii::warning($message, __METHOD__)
yii\BaseYii::warning()
case 'info':
return \Yii::info($message, __METHOD__);
Yii::info($message, __METHOD__)
yii\BaseYii::info()
case 'debug':
return \Yii::debug($message, __METHOD__);
Yii::debug($message, __METHOD__)
yii\BaseYii::debug()
default:
throw new \Exception('Unexpected value');
This check looks for function or method calls that always return null and whose return value is used.
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.