for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Xetaravel\Policies;
use Xetaravel\Models\User;
use Xetaravel\Models\DiscussPost;
use Illuminate\Auth\Access\HandlesAuthorization;
class DiscussPostPolicy
{
use HandlesAuthorization;
/**
* Authorize all actions if the user has the given permission.
*
* @param User $user
* @param string $ability
* @return true|void
*/
public function before(User $user, string $ability)
$ability
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function before(User $user, /** @scrutinizer ignore-unused */ string $ability)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
if ($user->hasPermissionTo('manage discuss post')) {
return true;
}
* Determine whether the user can create a discuss post.
* @return bool
public function create(User $user): bool
return $user->hasPermissionTo('create discuss post');
* Determine whether the user can update the discuss post.
* @param DiscussPost $discussPost
public function update(User $user, DiscussPost $discussPost): bool
return $user->id === $discussPost->user_id && $user->hasPermissionTo('update discuss post');
* Determine whether the user can delete the discuss post.
public function delete(User $user, DiscussPost $discussPost): bool
return $user->id === $discussPost->user_id && $user->hasPermissionTo('delete discuss post');
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.