apply rules rector

This commit is contained in:
2023-07-19 22:48:26 +02:00
parent 6e6f19c499
commit 74ed34ba97
40 changed files with 250 additions and 697 deletions

View File

@@ -43,10 +43,6 @@ class ExportManager
*/
private array $aggregators = [];
private AuthorizationCheckerInterface $authorizationChecker;
private AuthorizationHelperInterface $authorizationHelper;
/**
* Collected Exports, injected by DI.
*
@@ -68,17 +64,15 @@ class ExportManager
*/
private array $formatters = [];
private LoggerInterface $logger;
/**
* @var \Symfony\Component\Security\Core\User\UserInterface
*/
private $user;
public function __construct(
LoggerInterface $logger,
AuthorizationCheckerInterface $authorizationChecker,
AuthorizationHelperInterface $authorizationHelper,
private LoggerInterface $logger,
private AuthorizationCheckerInterface $authorizationChecker,
private AuthorizationHelperInterface $authorizationHelper,
TokenStorageInterface $tokenStorage,
iterable $exports,
iterable $aggregators,
@@ -86,9 +80,6 @@ class ExportManager
//iterable $formatters,
//iterable $exportElementProvider
) {
$this->logger = $logger;
$this->authorizationChecker = $authorizationChecker;
$this->authorizationHelper = $authorizationHelper;
$this->user = $tokenStorage->getToken()->getUser();
$this->exports = iterator_to_array($exports);
$this->aggregators = iterator_to_array($aggregators);
@@ -166,7 +157,7 @@ class ExportManager
} elseif ($element instanceof FormatterInterface) {
$this->addFormatter($element, $alias);
} else {
throw new LogicException('This element ' . get_class($element) . ' '
throw new LogicException('This element ' . $element::class . ' '
. 'is not an instance of export element');
}
}
@@ -285,7 +276,6 @@ class ExportManager
}
/**
* @param array $aliases
* @return iterable<string, AggregatorInterface>
*/
public function getAggregators(array $aliases): iterable
@@ -352,7 +342,6 @@ class ExportManager
/**
* Get all exports grouped in an array.
*
* @param bool $whereUserIsGranted
*
* @return array<string, array<string, ExportInterface|DirectExportInterface>> where keys are the groups's name and value is an array of exports
*/
@@ -372,8 +361,6 @@ class ExportManager
}
/**
* @param string $alias
*
* @throws RuntimeException if the filter is not known
*/
public function getFilter(string $alias): FilterInterface
@@ -467,11 +454,9 @@ class ExportManager
* Return true if the current user has access to the ExportElement for every
* center, false if the user hasn't access to element for at least one center.
*
* @param \Chill\MainBundle\Export\ExportElementInterface $element
* @param DirectExportInterface|ExportInterface $export
*
*/
public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null): bool
public function isGrantedForElement(ExportElementInterface $element, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export = null, ?array $centers = null): bool
{
if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) {
$role = $element->requiredRole();
@@ -504,7 +489,7 @@ class ExportManager
//debugging
$this->logger->debug('user has no access to element', [
'method' => __METHOD__,
'type' => get_class($element),
'type' => $element::class,
'center' => $center->getName(),
'role' => $role,
]);
@@ -574,7 +559,7 @@ class ExportManager
private function handleFilters(
ExportInterface $export,
QueryBuilder $qb,
$data,
mixed $data,
array $centers
) {
$filters = $this->retrieveUsedFilters($data);
@@ -595,11 +580,9 @@ class ExportManager
}
/**
* @param mixed $data
*
* @return iterable<string, AggregatorInterface>
*/
private function retrieveUsedAggregators($data): iterable
private function retrieveUsedAggregators(mixed $data): iterable
{
if (null === $data) {
return [];
@@ -613,11 +596,9 @@ class ExportManager
}
/**
* @param mixed $data
*
* @return string[]
*/
private function retrieveUsedAggregatorsType($data)
private function retrieveUsedAggregatorsType(mixed $data)
{
if (null === $data) {
return [];
@@ -657,7 +638,7 @@ class ExportManager
*
* @return array an array with types
*/
private function retrieveUsedFiltersType($data)
private function retrieveUsedFiltersType(mixed $data)
{
if (null === $data) {
return [];
@@ -681,11 +662,10 @@ class ExportManager
/**
* parse the data to retrieve the used filters and aggregators.
*
* @param mixed $data
*
* @return string[]
*/
private function retrieveUsedModifiers($data)
private function retrieveUsedModifiers(mixed $data)
{
if (null === $data) {
return [];