cs: Enable risky rule static_lambda.

This commit is contained in:
Pol Dellaiera
2021-11-30 11:43:34 +01:00
parent a9188355c5
commit 91d12c4a96
111 changed files with 212 additions and 212 deletions

View File

@@ -100,7 +100,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
'expanded' => true,
'choices' => $choices,
'label' => 'Fields to include in export',
'choice_attr' => function ($val, $key, $index) {
'choice_attr' => static function ($val, $key, $index) {
// add a 'data-display-target' for address fields
if (substr($val, 0, 8) === 'address_') {
return ['data-display-target' => 'address_date'];
@@ -124,7 +124,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
}
},
'constraints' => [new Callback([
'callback' => function ($selected, ExecutionContextInterface $context) {
'callback' => static function ($selected, ExecutionContextInterface $context) {
if (count($selected) === 0) {
$context->buildViolation('You must select at least one element')
->atPath('fields')
@@ -165,7 +165,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
case 'report_date':
// for birthdate or report date, we have to transform the string into a date
// to format the date correctly.
return function ($value) use ($key) {
return static function ($value) use ($key) {
if ('_header' === $value) {
return 'person_birthdate' === $key ? 'birthdate' : 'report_date';
}
@@ -202,7 +202,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
$scopes[$row['id']] = $this->translatableStringHelper->localize($row['name']);
}
return function ($value) use ($scopes): string {
return static function ($value) use ($scopes): string {
if ('_header' === $value) {
return 'circle';
}
@@ -224,7 +224,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
$users[$row['id']] = $row['username'];
}
return function ($value) use ($users): string {
return static function ($value) use ($users): string {
if ('_header' === $value) {
return 'user';
}
@@ -282,7 +282,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
default:
// for fields which are associated with person
if (in_array($key, $this->fields)) {
return function ($value) use ($key) {
return static function ($value) use ($key) {
if ('_header' === $value) {
return strtolower($key);
}
@@ -331,7 +331,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(function ($el) { return $el['center']; }, $acl);
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
// throw an error if any fields are present
if (!array_key_exists('fields', $data)) {
@@ -503,7 +503,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
private function getCustomFields()
{
return array_filter($this->customfieldsGroup
->getCustomFields()->toArray(), function (CustomField $cf) {
->getCustomFields()->toArray(), static function (CustomField $cf) {
return $cf->getType() !== 'title';
});
}

View File

@@ -94,7 +94,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface
foreach ($reachableCenters as $center) {
$reachableScopesId = array_map(
function (Scope $scope) { return $scope->getId(); },
static function (Scope $scope) { return $scope->getId(); },
$this->helper->getReachableScopes($this->user, $role, $center)
);
$whereElement->add(

View File

@@ -66,7 +66,7 @@ class ReportControllerNextTest extends WebTestCase
//filter customFieldsGroup to get only "situation de logement"
$filteredCustomFieldsGroupHouse = array_filter(
$customFieldsGroups,
function (CustomFieldsGroup $group) {
static function (CustomFieldsGroup $group) {
return in_array('Situation de logement', $group->getName());
}
);

View File

@@ -84,7 +84,7 @@ class ReportControllerTest extends WebTestCase
//filter customFieldsGroup to get only "situation de logement"
$filteredCustomFieldsGroupHouse = array_filter(
$customFieldsGroups,
function (CustomFieldsGroup $group) {
static function (CustomFieldsGroup $group) {
return in_array('Situation de logement', $group->getName());
}
);

View File

@@ -65,7 +65,7 @@ class TimelineProviderTest extends WebTestCase
static::$em
->getRepository('ChillMainBundle:Scope')
->findAll(),
function (Scope $scope) { return $scope->getName()['en'] === 'social'; }
static function (Scope $scope) { return $scope->getName()['en'] === 'social'; }
);
$report = (new Report())