for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Application\Api\Field\Mutation;
use Application\Api\Field\FieldInterface;
use Application\Api\Helper;
use Application\DBAL\Types\RelationshipType;
use Application\Model\User;
use GraphQL\Type\Definition\Type;
use Zend\Expressive\Session\SessionInterface;
abstract class LeaveFamily implements FieldInterface
{
public static function build(): array
return [
'name' => 'leaveFamily',
'type' => Type::nonNull(_types()->getOutput(User::class)),
'description' => 'Make the given user independent from his family and inactive.',
'args' => [
'id' => Type::nonNull(_types()->getId(User::class)),
],
'resolve' => function ($root, array $args, SessionInterface $session): User {
$session
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
'resolve' => function ($root, array $args, /** @scrutinizer ignore-unused */ SessionInterface $session): User {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
/** @var User $user */
$user = $args['id']->getEntity();
// Check ACL
Helper::throwIfDenied($user, 'update');
// Set owner while pretending we are an admin to workaround normal security things
$previousCurrentUser = User::getCurrent();
User::setCurrent(new User(User::ROLE_ADMINISTRATOR));
$user->setOwner($user);
User::setCurrent($previousCurrentUser);
$user->setFamilyRelationship(RelationshipType::HOUSEHOLDER);
$user->setStatus(User::STATUS_INACTIVE);
_em()->flush();
return $user;
},
];
}
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.