for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sco\Admin\Form\Elements;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class MultiSelect extends Select
{
protected $defaultValue = [];
public function getValue()
$value = $this->getValueFromModel();
if (empty($value)) {
return $value;
}
if ($this->isOptionsModel() && $this->isRelation()) {
$model = $this->getOptionsModel();
$key = $this->getOptionsValueAttribute() ?: $model->getKeyName();
$value = $value->pluck($key)->map(function ($item) {
return (string)$item;
});
protected function isOptionsModel()
return is_string($this->options) || $this->options instanceof Model;
protected function isRelation()
return method_exists($this->getModel(), $this->getName());
public function save()
if (!($this->isOptionsModel() && $this->isRelation())) {
parent::save();
public function finishSave()
return;
$attribute = $this->getName();
$relation = $this->getModel()->{$attribute}();
$relation
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
public function toArray()
return parent::toArray() + [
'multiple' => true,
];
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.