for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Asset Packagist.
*
* @link https://github.com/hiqdev/asset-packagist
* @package asset-packagist
* @license BSD-3-Clause
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
*/
namespace hiqdev\assetpackagist\log;
use yii\helpers\Console;
use yii\helpers\VarDumper;
use yii\log\Logger;
use yii\log\Target;
class StdoutTarget extends Target
{
* Exports log [[messages]] to a specific destination.
* Child classes must implement this method.
public function export()
foreach ($this->messages as $message) {
list($text, $level, $category, $timestamp) = $message;
$timestamp
list($first,,$third)
This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.
list(...)
Consider the following code example.
<?php function returnThreeValues() { return array('a', 'b', 'c'); } list($a, $b, $c) = returnThreeValues(); print $a . " - " . $c;
Only the variables $a and $c are used. There was no need to assign $b.
$a
$c
$b
Instead, the list call could have been.
list($a,, $c) = returnThreeValues();
if (!is_string($text)) {
// exceptions may not be serializable if in the call stack somewhere is a Closure
if ($text instanceof \Throwable || $text instanceof \Exception) {
$text = (string) $text;
} else {
$text = VarDumper::export($text);
}
$string = "[$level][$category] $text";
if ($level === Logger::LEVEL_ERROR) {
Console::stderr($string);
Console::stdout($string);
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.