Skip to content

Commit

Permalink
Add more specific phpdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Oct 21, 2020
1 parent e08ee47 commit 3b1c5fe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 37 deletions.
35 changes: 0 additions & 35 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -180,36 +180,11 @@ parameters:
count: 2
path: src/EventListener/LocaleEventListener.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Model\\\\Group\\:\\:__construct\\(\\) has parameter \\$roles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Group.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Model\\\\Group\\:\\:setRoles\\(\\) has parameter \\$roles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Group.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Model\\\\GroupInterface\\:\\:setRoles\\(\\) has parameter \\$roles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/GroupInterface.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Model\\\\GroupManagerInterface\\:\\:findGroupBy\\(\\) has parameter \\$criteria with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/GroupManagerInterface.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Model\\\\User\\:\\:setRoles\\(\\) has parameter \\$roles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/User.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Model\\\\UserInterface\\:\\:setRoles\\(\\) has parameter \\$roles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/UserInterface.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Model\\\\UserManagerInterface\\:\\:findUserBy\\(\\) has parameter \\$criteria with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -225,16 +200,6 @@ parameters:
count: 1
path: src/Noop/UserManager.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Security\\\\UserProvider\\:\\:loadUserByUsername\\(\\) has parameter \\$username with no typehint specified\\.$#"
count: 1
path: src/Security/UserProvider.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Security\\\\UserProvider\\:\\:supportsClass\\(\\) has parameter \\$class with no typehint specified\\.$#"
count: 1
path: src/Security/UserProvider.php

-
message: "#^Method Nucleos\\\\UserBundle\\\\Tests\\\\DependencyInjection\\\\NucleosUserExtensionTest\\:\\:getEmptyConfig\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
3 changes: 3 additions & 0 deletions src/Model/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ abstract class Group implements GroupInterface
*/
protected $roles;

/**
* @param string[] $roles
*/
public function __construct(string $name, array $roles = [])
{
$this->name = $name;
Expand Down
3 changes: 3 additions & 0 deletions src/Model/GroupInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ public function removeRole(string $role): void;

public function setName(string $name): void;

/**
* @param string[] $roles
*/
public function setRoles(array $roles): void;
}
2 changes: 2 additions & 0 deletions src/Model/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public function hasRole(string $role): bool;
* Sets the roles of the user.
*
* This overwrites any previous roles.
*
* @param string[] $roles
*/
public function setRoles(array $roles): void;

Expand Down
12 changes: 10 additions & 2 deletions src/Security/UserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public function __construct(UserManagerInterface $userManager)
$this->userManager = $userManager;
}

public function loadUserByUsername(/* string */ $username): UserInterface
/**
* @param string $username
*/
public function loadUserByUsername($username): UserInterface
{
$user = $this->findUser($username);

Expand Down Expand Up @@ -60,7 +63,12 @@ public function refreshUser(SecurityUserInterface $user): UserInterface
return $reloadedUser;
}

public function supportsClass(/* string */ $class): bool
/**
* @param string $class
*
* @phpstan-param class-string $class
*/
public function supportsClass($class): bool
{
$userClass = $this->userManager->getClass();

Expand Down

0 comments on commit 3b1c5fe

Please sign in to comment.