for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Imanghafoori\Relativity;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
class RelationStore
{
/**
* List of all relations
*
* @var array
*/
public $relations = [];
* Retrieve all relations.
* @param Model $model
* @return array
public function all(Model $model)
$model
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return $this->relations;
}
* Retrieve key
* @param string $key
* @return string
public function getKey(Model $model, $key)
return $key;
* Retrieve a relation.
* @param mixed $default
* @return mixed
public function get(Model $model, $key, $default = null)
return Arr::get($this->relations, $this->getKey($model, $key), $default);
* Set a relation.
* @param mixed $value
public function set(Model $model, $key, $value)
Arr::set($this->relations, $this->getKey($model, $key), $value);
$default
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
public function has(Model $model, $key)
return Arr::has($this->relations, $this->getKey($model, $key));
* Remove a relation.
public function unset(Model $model, $key)
Arr::forget($this->relations, $this->getKey($model, $key));
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.