for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the zibios/sharep.
*
* (c) Zbigniew Ślązak
*/
namespace App\Service\Functional;
use App\Entity\Access\User;
use App\Entity\Parking\Member;
use App\Enum\Functional\ApplicationEnum;
use App\Enum\Functional\RoleEnum;
use App\Repository\Entity\Account\UserRepository;
use App\Traits\AssertTrait;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class ApplicationInitializeService
{
use AssertTrait;
/** @var UserRepository */
private $userRepository;
/** @var ValidatorInterface */
private $validator;
public function __construct(UserRepository $userRepository, ValidatorInterface $validator)
$this->userRepository = $userRepository;
$this->validator = $validator;
}
public function createSystemMember(): Member
if ($this->userRepository->isAny()) {
throw new \OverflowException('Already Initialized');
$user = new User();
$user->setEmail(ApplicationEnum::SYSTEM_MEMBER_EMAIL);
$this->assertIsValidObject($this->validator, $user);
$user
object<App\Entity\Access\User>
object<App\Traits\object>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$member = new Member(
ApplicationEnum::SYSTEM_MEMBER_NAME,
RoleEnum::SYSTEM(),
);
$this->assertIsValidObject($this->validator, $member);
$member
object<App\Entity\Parking\Member>
$this->userRepository->saveAllInTransaction($user, $member);
return $member;
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: