for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Innoflash\Events\Http\Requests;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Http\FormRequest;
use Innoflash\Events\Models\Event;
class CreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
return true;
return $this->user()->can('create', Event::class);
return $this->user()->ca...ts\Models\Event::class)
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.
return
die
exit
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.
return false
}
* Get the validation rules that apply to the request.
* @return array
public function rules()
return [
'name' => 'required|string',
'description' => 'required|string',
'location' => 'array',
'start' => 'required|date_format:Y-m-d H:i',
'end' => 'required|date_format:Y-m-d H:i',
'published' => 'required|boolean',
'url' => 'url',
'video_url' => 'url',
'banner' => 'base64image',
];
protected function failedAuthorization()
if (strcmp(auth()->user()->account->level, 'Free') === 0) {
throw new AuthorizationException('You need to upgrade to able to create events');
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.