apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -18,17 +18,7 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery;
use Chill\PersonBundle\Entity\Person;
use Chill\ReportBundle\Entity\Report;
use Doctrine\ORM\EntityManager;
use LogicException;
use Symfony\Component\Security\Core\Security;
use UnexpectedValueException;
use function array_fill;
use function array_key_exists;
use function array_merge;
use function count;
use function implode;
use function in_array;
use function strtr;
/**
* Provide report for inclusion in timeline.
@@ -46,10 +36,10 @@ class TimelineReportProvider implements TimelineProviderInterface
return TimelineSingleQuery::fromArray([
'id' => $report->getTableName()
. '.' . $report->getColumnName('id'),
.'.'.$report->getColumnName('id'),
'type' => 'report',
'date' => $report->getTableName()
. '.' . $report->getColumnName('date'),
.'.'.$report->getColumnName('date'),
'FROM' => $this->getFromClause($context),
'WHERE' => $where,
'parameters' => $parameters,
@@ -91,17 +81,17 @@ class TimelineReportProvider implements TimelineProviderInterface
protected function getFieldsToRender(Report $entity, $context, array $args = [])
{
//gather all custom fields which should appears in summary
// gather all custom fields which should appears in summary
$gatheredFields = [];
if (array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) {
if (\array_key_exists('summary_fields', $entity->getCFGroup()->getOptions())) {
// keep in memory title
$title = null;
$subtitle = null;
foreach ($entity->getCFGroup()->getCustomFields() as $customField) {
if (
in_array(
\in_array(
$customField->getSlug(),
$entity->getCFGroup()->getOptions()['summary_fields'],
true
@@ -109,7 +99,7 @@ class TimelineReportProvider implements TimelineProviderInterface
) {
// if we do not want to show empty values
if (false === $this->showEmptyValues) {
if ($customField->getType() === 'title') {
if ('title' === $customField->getType()) {
$options = $customField->getOptions();
switch ($options['type']) {
@@ -125,8 +115,8 @@ class TimelineReportProvider implements TimelineProviderInterface
}
} else {
if (
$this->customFieldsHelper->isEmptyValue($entity->getCFData(), $customField)
=== false
false
=== $this->customFieldsHelper->isEmptyValue($entity->getCFData(), $customField)
) {
if (null !== $title) {
$gatheredFields[] = $title;
@@ -155,13 +145,12 @@ class TimelineReportProvider implements TimelineProviderInterface
*
* @param string $context
*
* @throws LogicException if the context is not supported
* @throws \LogicException if the context is not supported
*/
private function checkContext($context)
{
if ('person' !== $context && 'center' !== $context) {
throw new LogicException("The context '{$context}' is not "
. "supported. Currently only 'person' and 'center' is supported");
throw new \LogicException("The context '{$context}' is not supported. Currently only 'person' and 'center' is supported");
}
}
@@ -174,10 +163,10 @@ class TimelineReportProvider implements TimelineProviderInterface
$personId = $report
->getAssociationMapping('person')['joinColumns'][0]['referencedColumnName'];
$clause = '{report} ' .
$clause = '{report} '.
'JOIN {person} ON {report}.{person_id} = {person}.{id_person} ';
return strtr(
return \strtr(
$clause,
[
'{report}' => $report->getTableName(),
@@ -193,7 +182,7 @@ class TimelineReportProvider implements TimelineProviderInterface
return match ($context) {
'person' => $this->getWhereClauseForPerson($context, $args),
'center' => $this->getWhereClauseForCenter($context, $args),
default => throw new UnexpectedValueException("This context {$context} is not implemented"),
default => throw new \UnexpectedValueException("This context {$context} is not implemented"),
};
}
@@ -212,7 +201,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$parameters = [];
// the clause, that will be joined with an "OR"
$centerScopesClause = '({person}.{center_id} = ? ' .
$centerScopesClause = '({person}.{center_id} = ? '.
'AND {report}.{scopes_id} IN ({scopes_ids}))';
// container for formatted clauses
$formattedClauses = [];
@@ -220,7 +209,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$askedCenters = $args['centers'];
foreach ($reachableCenters as $center) {
if (false === in_array($center, $askedCenters, true)) {
if (false === \in_array($center, $askedCenters, true)) {
continue;
}
@@ -230,26 +219,26 @@ class TimelineReportProvider implements TimelineProviderInterface
$scopeIds = [];
foreach ($this->helper->getReachableScopes($this->security->getUser(), $role, $center) as $scope) {
if (in_array($scope->getId(), $scopeIds, true)) {
if (\in_array($scope->getId(), $scopeIds, true)) {
continue;
}
$scopeIds[] = $scope->getId();
}
$formattedClauses[] = strtr($centerScopesClause, [
'{scopes_ids}' => implode(', ', array_fill(0, count($scopeIds), '?')),
$formattedClauses[] = \strtr($centerScopesClause, [
'{scopes_ids}' => \implode(', ', \array_fill(0, \count($scopeIds), '?')),
]);
// append $scopeIds to parameters
$parameters = [...$parameters, ...$scopeIds];
}
if (0 === count($formattedClauses)) {
if (0 === \count($formattedClauses)) {
return ['FALSE = TRUE', []];
}
return [
strtr(
implode(' OR ', $formattedClauses),
\strtr(
\implode(' OR ', $formattedClauses),
[
'{person}' => $person->getTableName(),
'{center_id}' => $personCenterId,
@@ -278,28 +267,28 @@ class TimelineReportProvider implements TimelineProviderInterface
$scopes = $this->helper->getReachableScopes($this->security->getUser(), $role, $args['person']->getCenter());
foreach ($scopes as $scope) {
if (in_array($scope->getId(), $parameters, true)) {
if (\in_array($scope->getId(), $parameters, true)) {
continue;
}
$parameters[] = $scope->getId();
}
if (1 === count($parameters)) {
if (1 === \count($parameters)) {
// nothing change, we simplify the clause
$clause = '{report}.{person_id} = ? AND FALSE = TRUE';
}
return [
strtr(
\strtr(
$clause,
[
'{report}' => $report->getTableName(),
'{person_id}' => $reportPersonId,
'{scopes_id}' => $reportScopeId,
'{scopes_ids}' => implode(
'{scopes_ids}' => \implode(
', ',
array_fill(0, count($parameters) - 1, '?')
\array_fill(0, \count($parameters) - 1, '?')
),
]
),