for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nickcheek\USPSLookup\Service;
use Nickcheek\USPSLookup\USPSLookup;
class Price extends USPSLookup
{
public function __construct(){}
public static function getRate($to,$from,$pounds,$ounces,$service)
$rate = new \SimpleXMLElement("<RateV4Request></RateV4Request>");
$rate->addAttribute('USERID', self::$user);
$revision = $rate->addChild("Revision",'2');
$revision
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
$pack = $rate->addChild('Package');
$pack->addAttribute('ID','0');
$pack->addChild('Service',$service);
$pack->addChild('ZipOrigination',$from);
$pack->addChild('ZipDestination',$to);
$pack->addChild('Pounds',$pounds);
$pack->addChild('Ounces',$ounces);
$pack->addChild('Container','VARIABLE');
$pack->addChild('Size','Regular');
$url = self::$service . '&XML='.$rate->asXML();
return simplexml_load_file($url);
}
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.