KarlComSe /
mvc-report
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Entity; |
||
| 4 | |||
| 5 | use ApiPlatform\Metadata\ApiResource; |
||
| 6 | use App\Repository\UserRepository; |
||
| 7 | use Doctrine\Common\Collections\ArrayCollection; |
||
| 8 | use Doctrine\Common\Collections\Collection; |
||
| 9 | use Doctrine\ORM\Mapping as ORM; |
||
| 10 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
||
| 11 | use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; |
||
| 12 | use Symfony\Component\Security\Core\User\UserInterface; |
||
| 13 | |||
| 14 | #[ORM\Entity(repositoryClass: UserRepository::class)] |
||
| 15 | #[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])] |
||
| 16 | #[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')] |
||
| 17 | #[ApiResource] |
||
| 18 | class User implements UserInterface, PasswordAuthenticatedUserInterface |
||
| 19 | { |
||
| 20 | #[ORM\Id] |
||
| 21 | #[ORM\GeneratedValue] |
||
| 22 | #[ORM\Column] |
||
| 23 | private ?int $id = null; |
||
| 24 | |||
| 25 | #[ORM\Column(length: 180)] |
||
| 26 | private ?string $email = null; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var list<string> The user roles |
||
|
0 ignored issues
–
show
|
|||
| 30 | */ |
||
| 31 | #[ORM\Column] |
||
| 32 | private array $roles = []; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var string The hashed password |
||
| 36 | */ |
||
| 37 | #[ORM\Column] |
||
| 38 | private ?string $password = null; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @var Collection<int, Organization> |
||
| 42 | */ |
||
| 43 | #[ORM\ManyToMany(targetEntity: Organization::class, mappedBy: 'users')] |
||
| 44 | private Collection $organizations; |
||
| 45 | |||
| 46 | public function __construct() |
||
| 47 | { |
||
| 48 | $this->organizations = new ArrayCollection(); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function getId(): ?int |
||
| 52 | { |
||
| 53 | return $this->id; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function getEmail(): ?string |
||
| 57 | { |
||
| 58 | return $this->email; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function setEmail(string $email): static |
||
| 62 | { |
||
| 63 | $this->email = $email; |
||
| 64 | |||
| 65 | return $this; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * A visual identifier that represents this user. |
||
| 70 | * |
||
| 71 | * @see UserInterface |
||
| 72 | */ |
||
| 73 | public function getUserIdentifier(): string |
||
| 74 | { |
||
| 75 | return (string) $this->email; |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @see UserInterface |
||
| 80 | * |
||
| 81 | * @return string[] |
||
| 82 | */ |
||
| 83 | public function getRoles(): array |
||
| 84 | { |
||
| 85 | $roles = $this->roles; |
||
|
0 ignored issues
–
show
It seems like
$this->roles of type array is incompatible with the declared type App\Entity\list of property $roles.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 86 | // guarantee every user at least has ROLE_USER |
||
| 87 | $roles[] = 'ROLE_USER'; |
||
| 88 | |||
| 89 | return array_unique($roles); |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @param list<string> $roles |
||
| 94 | */ |
||
| 95 | public function setRoles(array $roles): static |
||
| 96 | { |
||
| 97 | $this->roles = $roles; |
||
|
0 ignored issues
–
show
It seems like
$roles of type array is incompatible with the declared type App\Entity\list of property $roles.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 98 | |||
| 99 | return $this; |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @see PasswordAuthenticatedUserInterface |
||
| 104 | */ |
||
| 105 | public function getPassword(): string |
||
| 106 | { |
||
| 107 | return $this->password; |
||
|
0 ignored issues
–
show
|
|||
| 108 | } |
||
| 109 | |||
| 110 | public function setPassword(string $password): static |
||
| 111 | { |
||
| 112 | $this->password = $password; |
||
| 113 | |||
| 114 | return $this; |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @see UserInterface |
||
| 119 | */ |
||
| 120 | public function eraseCredentials(): void |
||
| 121 | { |
||
| 122 | // If you store any temporary, sensitive data on the user, clear it here |
||
| 123 | // $this->plainPassword = null; |
||
| 124 | } |
||
| 125 | |||
| 126 | /** |
||
| 127 | * @return Collection<int, Organization> |
||
| 128 | */ |
||
| 129 | public function getOrganizations(): Collection |
||
| 130 | { |
||
| 131 | return $this->organizations; |
||
| 132 | } |
||
| 133 | |||
| 134 | public function addOrganization(Organization $organization): static |
||
| 135 | { |
||
| 136 | if (!$this->organizations->contains($organization)) { |
||
| 137 | $this->organizations->add($organization); |
||
| 138 | $organization->addUser($this); |
||
| 139 | } |
||
| 140 | |||
| 141 | return $this; |
||
| 142 | } |
||
| 143 | |||
| 144 | public function removeOrganization(Organization $organization): static |
||
| 145 | { |
||
| 146 | if ($this->organizations->removeElement($organization)) { |
||
| 147 | $organization->removeUser($this); |
||
| 148 | } |
||
| 149 | |||
| 150 | return $this; |
||
| 151 | } |
||
| 152 | } |
||
| 153 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths