for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PerfectOblivion\Valid\ValidationService\Concerns;
use stdClass;
use Illuminate\Support\Arr;
trait InteractsWithValidationData
{
/**
* Get all data under validation.
*
* @return array
*/
public function all()
return $this->data;
data
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Get the validated data from the request.
public function validated()
$rules = $this->container->call([$this, 'rules']);
container
return $this->only(collect($rules)->keys()->map(function ($rule) {
return explode('.', $rule)[0];
})->unique()->toArray());
* Get a subset containing the provided keys with values from the given data.
* @param array|mixed $keys
public function only($keys)
$results = [];
$input = $this->all();
$placeholder = new stdClass;
foreach (is_array($keys) ? $keys : func_get_args() as $key) {
$value = data_get($input, $key, $placeholder);
if ($value !== $placeholder) {
Arr::set($results, $key, $value);
return $results;
* Replaces the current parameters by a new set.
* @param array $parameters
$parameters
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 replace(array $data)
$this->data = $data;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: