Skip to content

Commit

Permalink
[PHPStan] Introduced role policy map array shape as TPolicyMap
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Jun 13, 2024
1 parent c4fab36 commit 0c7a838
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/contracts/Repository/RoleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

/**
* This service provides methods for managing Roles and Policies.
*
* @phpstan-type TPolicyMap array<string, array<string, array<string, boolean|null>>>
*/
interface RoleService
{
Expand Down
11 changes: 6 additions & 5 deletions src/lib/Base/Container/ApiLoader/RepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,23 @@

/**
* @internal
*
* @phpstan-import-type TPolicyMap from \Ibexa\Contracts\Core\Repository\RoleService
*/
final class RepositoryFactory implements LoggerAwareInterface
{
use LoggerAwareTrait;

/**
* Policies map.
*
* @var array
*/
/** @phpstan-var TPolicyMap */
private array $policyMap;

private LanguageResolver $languageResolver;

private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider;

/**
* @phpstan-param TPolicyMap $policyMap
*/
public function __construct(
array $policyMap,
LanguageResolver $languageResolver,
Expand Down
12 changes: 5 additions & 7 deletions src/lib/Repository/RoleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

/**
* This service provides methods for managing Roles and Policies.
*
* @phpstan-import-type TPolicyMap from \Ibexa\Contracts\Core\Repository\RoleService
*/
class RoleService implements RoleServiceInterface
{
Expand All @@ -57,20 +59,16 @@ class RoleService implements RoleServiceInterface
/** @var \Ibexa\Core\Repository\Mapper\RoleDomainMapper */
protected $roleDomainMapper;

/** @var array */
protected $settings;
/** @phpstan-var array{policyMap: TPolicyMap}|array{} */
protected array $settings;

/** @var \Ibexa\Contracts\Core\Repository\PermissionResolver */
private $permissionResolver;

/**
* Setups service with reference to repository object that created it & corresponding handler.
*
* @param \Ibexa\Contracts\Core\Repository\Repository $repository
* @param \Ibexa\Contracts\Core\Persistence\User\Handler $userHandler
* @param \Ibexa\Core\Repository\Permission\LimitationService $limitationService
* @param \Ibexa\Core\Repository\Mapper\RoleDomainMapper $roleDomainMapper
* @param array $settings
* @phpstan-param array{policyMap: TPolicyMap}|array{} $settings
*/
public function __construct(
RepositoryInterface $repository,
Expand Down

0 comments on commit 0c7a838

Please sign in to comment.