DX: apply rector rulesets up to PHP 73

This commit is contained in:
2023-03-29 22:39:11 +02:00
parent b9a7530f7a
commit 4c5dae60a8
37 changed files with 129 additions and 131 deletions

View File

@@ -665,7 +665,7 @@ class ExportController extends AbstractController
$this->logger->notice('[export] choices for an export unserialized', [
'key' => $key,
'rawData' => json_encode($rawData),
'rawData' => json_encode($rawData, JSON_THROW_ON_ERROR),
]);
return $rawData;

View File

@@ -109,10 +109,8 @@ class SearchController extends AbstractController
->getHasAdvancedFormSearchServices();
if (count($advancedSearchProviders) === 1) {
reset($advancedSearchProviders);
return $this->redirectToRoute('chill_main_advanced_search', [
'name' => key($advancedSearchProviders),
'name' => array_key_first($advancedSearchProviders),
]);
}

View File

@@ -41,7 +41,7 @@ class Point implements JsonSerializable
public static function fromGeoJson(string $geojson): self
{
$a = json_decode($geojson);
$a = json_decode($geojson, null, 512, JSON_THROW_ON_ERROR);
if (null === $a) {
throw PointException::badJsonString($geojson);
@@ -96,7 +96,7 @@ class Point implements JsonSerializable
{
$array = $this->toArrayGeoJson();
return json_encode($array);
return json_encode($array, JSON_THROW_ON_ERROR);
}
public function toWKT(): string

View File

@@ -29,7 +29,7 @@ class AggregateStringHelper
return implode(
'|',
json_decode($value, true)
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
);
};
}

View File

@@ -310,7 +310,7 @@ class ExportAddressHelper
return '';
}
return $this->translatableStringHelper->localize(json_decode($value, true));
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
};
case 'isNoAddress':
@@ -369,7 +369,7 @@ class ExportAddressHelper
return '';
}
$decodedValues = json_decode($value, true);
$decodedValues = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
switch (count($decodedValues)) {
case 0:

View File

@@ -39,7 +39,7 @@ class TranslatableStringExportLabelHelper
return '';
}
return $this->translatableStringHelper->localize(json_decode($value, true));
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
};
}
@@ -54,7 +54,7 @@ class TranslatableStringExportLabelHelper
return '';
}
$decoded = json_decode($value, true);
$decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
return implode(
'|',

View File

@@ -54,7 +54,7 @@ class UserHelper
return '';
}
$decoded = json_decode($value);
$decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
if (0 === count($decoded)) {
return '';

View File

@@ -43,7 +43,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
public function reverseTransform($value)
{
$denormalized = json_decode($value, true);
$denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
if ($this->multiple) {
if (null === $denormalized) {

View File

@@ -224,7 +224,7 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface
return null;
}
$validation = json_decode($response->getBody()->getContents())->carrier->type;
$validation = json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR)->carrier->type;
$item
->set($validation)

View File

@@ -44,7 +44,7 @@ final class PermissionApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true);
$data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertFalse($data['roles']['FOO_ROLE']);
}
@@ -67,7 +67,7 @@ final class PermissionApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true);
$data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertTrue($data['roles']['ROLE_USER']);
$this->assertFalse($data['roles']['ROLE_ADMIN']);
}

View File

@@ -35,7 +35,7 @@ final class PostalCodeApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true);
$data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertEquals('Fontenay Le Comte', $data['results'][0]['name']);

View File

@@ -47,7 +47,7 @@ final class UserApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true);
$data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertTrue(array_key_exists('count', $data));
$this->assertGreaterThan(0, $data['count']);
$this->assertTrue(array_key_exists('results', $data));

View File

@@ -64,7 +64,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase
$this->assertEquals($results['unitrefid'], 'layer_one');
$this->assertEquals($results['unitname'], 'Layer one');
$this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer']);
$this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer']);
$this->assertEquals($results['layerrefid'], 'test');
$this->assertEquals($results['geom'], 'MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))');
@@ -93,7 +93,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase
$this->assertEquals($results['unitrefid'], 'layer_one');
$this->assertEquals($results['unitname'], 'Layer one fixed');
$this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer fixed']);
$this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer fixed']);
$this->assertEquals($results['layerrefid'], 'test');
$this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))');
}

View File

@@ -49,18 +49,18 @@ final class Version20180709181423 extends AbstractMigration
$this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9885281E ON users (emailCanonical)');
$this->addSql(
<<<'SQL'
CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS
$BODY$
BEGIN
IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
END IF;
<<<'SQL_WRAP'
CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS
$BODY$
BEGIN
IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
END IF;
RETURN NEW;
END;
$BODY$ LANGUAGE PLPGSQL
SQL
RETURN NEW;
END;
$BODY$ LANGUAGE PLPGSQL
SQL_WRAP
);
$this->addSql(
@@ -74,16 +74,16 @@ final class Version20180709181423 extends AbstractMigration
);
$this->addSql(
<<<'SQL'
CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS
$BODY$
BEGIN
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
<<<'SQL_WRAP'
CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS
$BODY$
BEGIN
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
RETURN NEW;
END;
$BODY$ LANGUAGE PLPGSQL;
SQL
RETURN NEW;
END;
$BODY$ LANGUAGE PLPGSQL;
SQL_WRAP
);
$this->addSql(