Your project should not use invalid default value types 2
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_default_value
- */
- class GuardPluginManager extends AbstractPluginManager
- {
- protected $instanceOf = GuardInterface::class;
- protected $factories = [
- RouteGuard::class => GuardFactory::class,
- RoutePermissionGuard::class => PermissionGuardFactory::class,
- ControllerGuard::class => GuardFactory::class,
- ControllerPermissionGuard::class => PermissionGuardFactory::class,
- */
- class GuardsProviderPluginManager extends AbstractPluginManager
- {
- protected $instanceOf = GuardsProviderInterface::class;
- protected $factories = [
- ArrayGuardsProvider::class => GuardsProviderFactory::class,
- ];
- protected $aliases = [
- 'arrayguardsprovider' => ArrayGuardsProvider::class,
Your project should not use invalid parameter and return typehints 7
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_typehint
- /**
- * @param ContainerInterface $container
- * @param $requestedName
- * @return ForbiddenHandler
- */
- public function __invoke(ContainerInterface $container, $requestedName)
- {
- $config = $container->get('config');
- $debug = (bool)$config['debug'] ?? false;
- $authorizationService = $container->get(AuthorizationInterface::class);
- * Class GuardFactory
- * @package Dot\Rbac\Guard\Factory
- */
- class GuardFactory
- {
- public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
- {
- $options = $options ?? [];
- $options['role_service'] = isset($options['role_service'])
- && is_string($options['role_service'])
- && $container->has($options['role_service'])
- * @param ContainerInterface $container
- * @param $requestedName
- * @param array $options
- * @return ArrayGuardsProvider
- */
- public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
- {
- $options = $options ?? [];
- $options['guard_factory'] = isset($options['guard_factory'])
- && is_string($options['guard_factory'])
- && $container->has($options['guard_factory'])
- * Class PermissionGuardFactory
- * @package Dot\Rbac\Guard\Factory
- */
- class PermissionGuardFactory
- {
- public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
- {
- $options = $options ?? [];
- $options['authorization_service'] = isset($options['authorization_service'])
- && is_string($options['authorization_service'])
- && $container->has($options['authorization_service'])
- /**
- * @param ContainerInterface $container
- * @param $requestedName
- * @return RbacGuardMiddleware
- */
- public function __invoke(ContainerInterface $container, $requestedName)
- {
- /** @var RbacGuardOptions $options */
- $options = $container->get(RbacGuardOptions::class);
- /** @var Factory $guardsProviderFactory */
- /**
- * @param ContainerInterface $container
- * @param $requestedName
- * @return RbacGuardOptions
- */
- public function __invoke(ContainerInterface $container, $requestedName)
- {
- return new $requestedName($container->get('config')['dot_authorization']);
- }
- }
- * @param $error
- * @param ServerRequestInterface $request
- * @return ResponseInterface
- * @throws \Exception
- */
- protected function handleForbiddenError(
- $error,
- ServerRequestInterface $request
- ): ResponseInterface {
- $event = $this->dispatchEvent(AuthorizationEvent::EVENT_FORBIDDEN, [
- 'request' => $request,
Your project should use return types 34
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.missing_return_typehint
- * Class GuardFactory
- * @package Dot\Rbac\Guard\Factory
- */
- class GuardFactory
- {
- public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
- {
- $options = $options ?? [];
- $options['role_service'] = isset($options['role_service'])
- && is_string($options['role_service'])
- && $container->has($options['role_service'])
- * Class PermissionGuardFactory
- * @package Dot\Rbac\Guard\Factory
- */
- class PermissionGuardFactory
- {
- public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
- {
- $options = $options ?? [];
- $options['authorization_service'] = isset($options['authorization_service'])
- && is_string($options['authorization_service'])
- && $container->has($options['authorization_service'])
- }
- /**
- * @param bool $debug
- */
- public function setDebug(bool $debug)
- {
- $this->debug = $debug;
- }
- }
- interface AuthorizationEventListenerInterface extends ListenerAggregateInterface
- {
- /**
- * @param AuthorizationEvent $e
- */
- public function onBeforeAuthorization(AuthorizationEvent $e);
- /**
- * @param AuthorizationEvent $e
- */
- public function onAfterAuthorization(AuthorizationEvent $e);
- public function onBeforeAuthorization(AuthorizationEvent $e);
- /**
- * @param AuthorizationEvent $e
- */
- public function onAfterAuthorization(AuthorizationEvent $e);
- /**
- * @param AuthorizationEvent $e
- */
- public function onForbidden(AuthorizationEvent $e);
- public function onAfterAuthorization(AuthorizationEvent $e);
- /**
- * @param AuthorizationEvent $e
- */
- public function onForbidden(AuthorizationEvent $e);
- }
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onBeforeAuthorization(AuthorizationEvent $e)
- {
- // no-op
- }
- /**
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onBeforeAuthorization(AuthorizationEvent $e)
- {
- // no-op
- }
- /**
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onBeforeAuthorization(AuthorizationEvent $e)
- {
- // no-op
- }
- /**
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onAfterAuthorization(AuthorizationEvent $e)
- {
- // no-op
- }
- /**
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onAfterAuthorization(AuthorizationEvent $e)
- {
- // no-op
- }
- /**
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onAfterAuthorization(AuthorizationEvent $e)
- {
- // no-op
- }
- /**
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onForbidden(AuthorizationEvent $e)
- {
- // no-op
- }
- }
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onForbidden(AuthorizationEvent $e)
- {
- // no-op
- }
- }
- }
- /**
- * @param AuthorizationEvent $e
- */
- public function onForbidden(AuthorizationEvent $e)
- {
- // no-op
- }
- }
- {
- /**
- * @param ContainerInterface $container
- * @param EventManagerInterface $eventManager
- */
- protected function attachListeners(ContainerInterface $container, EventManagerInterface $eventManager)
- {
- /** @var RbacGuardOptions $options */
- $options = $container->get(RbacGuardOptions::class);
- if (!empty($options->getEventListeners())
- {
- /**
- * @param ContainerInterface $container
- * @param EventManagerInterface $eventManager
- */
- protected function attachListeners(ContainerInterface $container, EventManagerInterface $eventManager)
- {
- /** @var RbacGuardOptions $options */
- $options = $container->get(RbacGuardOptions::class);
- if (!empty($options->getEventListeners())
- }
- /**
- * @param array $rules
- */
- abstract public function setRules(array $rules);
- /**
- * @return int
- */
- public function getPriority(): int
- }
- /**
- * @param array $rules
- */
- public function setRules(array $rules)
- {
- $this->rules = [];
- foreach ($rules as $rule) {
- $route = strtolower($rule['route']);
- }
- /**
- * @param RoleServiceInterface $roleService
- */
- public function setRoleService(RoleServiceInterface $roleService)
- {
- $this->roleService = $roleService;
- }
- /**
- }
- /**
- * @param array $rules
- */
- public function setRules(array $rules)
- {
- $this->rules = [];
- foreach ($rules as $rule) {
- $route = strtolower($rule['route']);
- }
- /**
- * @param AuthorizationInterface $authorizationService
- */
- public function setAuthorizationService(AuthorizationInterface $authorizationService)
- {
- $this->authorizationService = $authorizationService;
- }
- }
- }
- /**
- * @param array $rules
- */
- public function setRules(array $rules)
- {
- $this->rules = [];
- foreach ($rules as $key => $value) {
- if (is_int($key)) {
- }
- /**
- * @param RoleServiceInterface $roleService
- */
- public function setRoleService(RoleServiceInterface $roleService)
- {
- $this->roleService = $roleService;
- }
- /**
- }
- /**
- * @param array $rules
- */
- public function setRules(array $rules)
- {
- $this->rules = [];
- foreach ($rules as $key => $value) {
- if (is_int($key)) {
- $routeName = strtolower($value);
- }
- /**
- * @param AuthorizationInterface $authorizationService
- */
- public function setAuthorizationService(AuthorizationInterface $authorizationService)
- {
- $this->authorizationService = $authorizationService;
- }
- }
- }
- /**
- * @param $messages
- */
- public function setMessages(array $messages)
- {
- $this->messages = ArrayUtils::merge($this->messages, $messages, true);
- }
- /**
- }
- /**
- * @param string $protectionPolicy
- */
- public function setProtectionPolicy(string $protectionPolicy)
- {
- $this->protectionPolicy = $protectionPolicy;
- }
- /**
- }
- /**
- * @param array $guardsProvider
- */
- public function setGuardsProvider(array $guardsProvider)
- {
- $this->guardsProvider = $guardsProvider;
- }
- /**
- }
- /**
- * @param array $messagesOptions
- */
- public function setMessagesOptions(array $messagesOptions)
- {
- $this->messagesOptions = new MessagesOptions($messagesOptions);
- }
- /**
- }
- /**
- * @param array $eventListeners
- */
- public function setEventListeners(array $eventListeners)
- {
- $this->eventListeners = $eventListeners;
- }
- }
- }
- /**
- * @param $protectionPolicy
- */
- public function setProtectionPolicy(string $protectionPolicy)
- {
- $this->protectionPolicy = $protectionPolicy;
- }
- }
- }
- /**
- * @param Factory $guardFactory
- */
- public function setGuardFactory(Factory $guardFactory)
- {
- $this->guardFactory = $guardFactory;
- }
- }
- }
- /**
- * @param array $guardsConfig
- */
- public function setGuardsConfig(array $guardsConfig)
- {
- $this->guardsConfig = $guardsConfig;
- }
- }
Your project should not contain duplicated code
- Read doc
- Productivity
- Minor
More information: https://insight.symfony.com/what-we-analyse/php.duplicated_code
- $allowedPermissions = $this->rules[$route][0];
- } else {
- return $this->protectionPolicy === self::POLICY_ALLOW;
- }
- if (empty($allowedPermissions)) {
- return $this->protectionPolicy === self::POLICY_ALLOW;
- }
- if (in_array('*', $allowedPermissions)) {
- return true;