cs: Enable more risky rules.

This commit is contained in:
Pol Dellaiera
2021-11-30 11:37:57 +01:00
parent c8195e6df5
commit a9188355c5
193 changed files with 306 additions and 63 deletions

View File

@@ -40,6 +40,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_key_exists;
use function array_keys;
use function array_merge;
use function count;
use function in_array;
use function strlen;
use function strtolower;
use function ucfirst;
@@ -107,13 +109,13 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
return [];
},
'choice_label' => function (string $key, string $label): string {
switch (\substr($key, 0, 7)) {
switch (substr($key, 0, 7)) {
case 'person_':
return $this->translator->trans(\substr($key, 7, strlen($key) - 7)) .
return $this->translator->trans(substr($key, 7, strlen($key) - 7)) .
' (' . $this->translator->trans('Person') . ')';
case 'report_':
return $this->translator->trans(ucfirst(\substr($key, 7, strlen($key) - 7))) .
return $this->translator->trans(ucfirst(substr($key, 7, strlen($key) - 7))) .
' (' . $this->translator->trans('Report') . ')';
default:
@@ -342,7 +344,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
// process fields which are not custom fields
foreach ($this->fields as $f) {
// do not add fields which are not selected
if (!\in_array($f, $data['fields'])) {
if (!in_array($f, $data['fields'])) {
continue;
}
@@ -350,7 +352,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
switch ($f) {
case 'person_countryOfBirth':
case 'person_nationality':
$suffix = \substr($f, 7);
$suffix = substr($f, 7);
$qb->addSelect(sprintf('IDENTITY(person.%s) as %s', $suffix, $f));
break;
@@ -363,7 +365,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
case 'person_address_country_name':
case 'person_address_country_code':
// remove 'person_'
$suffix = \substr($f, 7);
$suffix = substr($f, 7);
$qb->addSelect(sprintf(
'GET_PERSON_ADDRESS_%s(person.id, :address_date) AS %s',
@@ -386,8 +388,8 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
break;
default:
$prefix = \substr($f, 0, 7);
$suffix = \substr($f, 7);
$prefix = substr($f, 0, 7);
$suffix = substr($f, 7);
switch ($prefix) {
case 'person_':
@@ -410,7 +412,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
// process fields which are custom fields
foreach ($this->getCustomFields() as $cf) {
// do not add custom fields which are not selected
if (!\in_array($cf->getSlug(), $data['fields'])) {
if (!in_array($cf->getSlug(), $data['fields'])) {
continue;
}
@@ -500,7 +502,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
*/
private function getCustomFields()
{
return \array_filter($this->customfieldsGroup
return array_filter($this->customfieldsGroup
->getCustomFields()->toArray(), function (CustomField $cf) {
return $cf->getType() !== 'title';
});
@@ -528,7 +530,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) {
return function ($value) use ($cf, $cfType, $key) {
$slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug'];
$decoded = \json_decode($value, true);
$decoded = json_decode($value, true);
if ('_header' === $value) {
$label = $cfType->getChoices($cf)[$slugChoice];