for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* BB's Zend Framework 2 Components
*
* AdminModule
* @package [MyApplication]
* @package BB's Zend Framework 2 Components
* @package AdminModule
* @author Björn Bartels <[email protected]>
* @link https://gitlab.bjoernbartels.earth/groups/zf2
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @copyright copyright (c) 2016 Björn Bartels <[email protected]>
*/
namespace Admin\Form;
use Zend\Form\Form;
use Admin\Module;
class ApplicationsForm extends Form
{
public function __construct($name = null)
// we want to ignore the name passed
parent::__construct('applications');
$oModule = new Module();
$cfg = $oModule->getConfig();
$cfg
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->setAttribute('method', 'post');
$this->add(
array(
'name' => 'application_id',
'attributes' => array(
'type' => 'hidden',
),
)
);
'name' => 'name',
'type' => 'text',
'options' => array(
'label' => 'name',
'name' => 'shortname',
'label' => 'shortname',
'name' => 'path',
'label' => 'path',
'name' => 'url',
'type' => 'url',
'label' => 'url',
'name' => 'email',
'type' => 'email',
'label' => 'admin email',
'name' => 'client_id',
'type' => 'select',
'options' => array(),
'label' => 'client',
'name' => 'submit',
'type' => 'submit',
'value' => 'save',
'id' => 'submitbutton',
'label' => 'save',
'name' => 'reset',
'type' => 'reset',
'value' => 'reset',
'id' => 'resetbutton',
'label' => 'reset',
}
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.