for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fluentd;
class Observer_Td extends \Orm\Observer {
public static $td_config;
public function __construct($class)
{
\Config::load('observer', true);
$ob_config = \Config::get('observer');
self::$td_config = $ob_config['td'];
}
public function after_save(\Orm\Model $obj)
$save_data = array();
foreach(array_keys($obj->properties()) as $p){
$save_data[$p] = $obj->{$p};
$host = empty(self::$td_config['host']) ? null : self::$td_config['host'];
$port = empty(self::$td_config['port']) ? null : self::$td_config['port'];
$options = empty(self::$td_config['options']) ? array() : self::$td_config['options'];
$packer = empty(self::$td_config['packer']) ? null : self::$td_config['packer'];
$database = empty(self::$td_config['database']) ? 'default' : self::$td_config['database'];
$table_name = $obj->table();
\Fluent\Autoloader::register();
$logger = new \Fluent\Logger\FluentLogger($host,$port,$options,$packer);
$res = $logger->post('td.'.$database.'.'.$table_name,$save_data);
$res
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.