Skip to content

Commit

Permalink
Bump symfony 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 4, 2021
1 parent 9c7dc2a commit 2271797
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 60 deletions.
12 changes: 4 additions & 8 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ branches:
contexts:
- "Coding Standards (8)"
- "Static Code Analysis (8.1)"
- "Test (PHP 8, symfony 4.4, lowest)"
- "Test (PHP 8, symfony 4.4, highest)"
- "Test (PHP 8, symfony 5.3, lowest)"
- "Test (PHP 8, symfony 5.3, highest)"
- "Test (PHP 8.1, symfony 4.4, lowest)"
- "Test (PHP 8.1, symfony 4.4, highest)"
- "Test (PHP 8.1, symfony 5.3, lowest)"
- "Test (PHP 8.1, symfony 5.3, highest)"
- "Test (PHP 8, symfony 5.4, lowest)"
- "Test (PHP 8, symfony 5.4, highest)"
- "Test (PHP 8.1, symfony 5.4, lowest)"
- "Test (PHP 8.1, symfony 5.4, highest)"
- "Code Coverage (8.1)"
- "Mutation Tests (8.1)"
strict: true
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ jobs:
- highest

symfony:
- 4.4
- 5.3
- 5.4

steps:
- name: "Checkout"
Expand Down
40 changes: 20 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@
"psr/log": "^1.0 || ^2.0 || ^3.0",
"sonata-project/admin-bundle": "^3.90 || ^4.0",
"sonata-project/doctrine-extensions": "^1.5.1",
"symfony/asset": "^4.4 || ^5.3",
"symfony/config": "^4.4 || ^5.3",
"symfony/dependency-injection": "^4.4 || ^5.3",
"symfony/event-dispatcher": "^4.4 || ^5.3",
"symfony/asset": "^5.4",
"symfony/config": "^5.4",
"symfony/dependency-injection": "^5.4",
"symfony/event-dispatcher": "^5.4",
"symfony/event-dispatcher-contracts": "^1.0 || ^2.0",
"symfony/form": "^4.4 || ^5.3",
"symfony/framework-bundle": "^4.4 || ^5.3",
"symfony/http-foundation": "^4.4 || ^5.3",
"symfony/http-kernel": "^4.4 || ^5.3",
"symfony/options-resolver": "^4.4 || ^5.3",
"symfony/routing": "^4.4 || ^5.3",
"symfony/form": "^5.4",
"symfony/framework-bundle": "^5.4",
"symfony/http-foundation": "^5.4",
"symfony/http-kernel": "^5.4",
"symfony/options-resolver": "^5.4",
"symfony/routing": "^5.4",
"symfony/security-acl": "^3.0",
"symfony/security-core": "^4.4 || ^5.3",
"symfony/security-csrf": "^4.4 || ^5.3",
"symfony/security-http": "^4.4 || ^5.3",
"symfony/translation": "^4.4 || ^5.3",
"symfony/security-core": "^5.4",
"symfony/security-csrf": "^5.4",
"symfony/security-http": "^5.4",
"symfony/translation": "^5.4",
"symfony/translation-contracts": "^1.0 || ^2.0",
"symfony/twig-bridge": "^4.4 || ^5.3",
"symfony/twig-bundle": "^4.4 || ^5.3",
"symfony/twig-bridge": "^5.4",
"symfony/twig-bundle": "^5.4",
"twig/extra-bundle": "^3.0",
"twig/twig": "^2.14 || ^3.1"
},
"conflict": {
"doctrine/doctrine-bundle": "<1.12",
"doctrine/orm": "<2.7",
"symfony/doctrine-bridge": "<4.4"
"symfony/doctrine-bridge": "<5.4"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3",
Expand All @@ -58,9 +58,9 @@
"ergebnis/composer-normalize": "^2.0.1",
"knplabs/knp-menu": "^2.3 || ^3.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.13 || ^4.0",
"symfony/browser-kit": "^4.4 || ^5.3",
"symfony/doctrine-bridge": "^4.4 || ^5.3",
"symfony/intl": "^4.4 || ^5.3"
"symfony/browser-kit": "^5.4",
"symfony/doctrine-bridge": "^5.4",
"symfony/intl": "^5.3"
},
"config": {
"sort-packages": true
Expand Down
33 changes: 19 additions & 14 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ parameters:
count: 1
path: src/DependencyInjection/NucleosUserAdminExtension.php

-
message: "#^Method Nucleos\\\\UserAdminBundle\\\\Form\\\\Transformer\\\\RestoreRolesTransformer\\:\\:setOriginalRoles\\(\\) has parameter \\$originalRoles with no value type specified in iterable type array\\.$#"
count: 1
path: src/Form/Transformer/RestoreRolesTransformer.php

-
message: "#^Property Nucleos\\\\UserAdminBundle\\\\Form\\\\Transformer\\\\RestoreRolesTransformer\\:\\:\\$originalRoles type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Form/Transformer/RestoreRolesTransformer.php

-
message: "#^Strict comparison using \\=\\=\\= between false and array\\<\\(int\\|string\\)\\> will always evaluate to false\\.$#"
count: 1
Expand All @@ -81,7 +71,7 @@ parameters:
path: src/Security/EditableRolesBuilder.php

-
message: "#^Call to function is_array\\(\\) with array\\<array\\(\\?'admin' \\=\\> string, 'label' \\=\\> string, 'roles' \\=\\> array\\<int, string\\>, 'route' \\=\\> string, 'route_absolute' \\=\\> bool, 'route_params' \\=\\> array\\<string, string\\>\\)\\> will always evaluate to true\\.$#"
message: "#^Call to function is_array\\(\\) with array\\<array\\{admin\\?\\: string, label\\: string, roles\\: array\\<int, string\\>, route\\: string, route_absolute\\: bool, route_params\\: array\\<string, string\\>\\}\\> will always evaluate to true\\.$#"
count: 1
path: src/Security/RolesBuilder/AdminRolesBuilder.php

Expand Down Expand Up @@ -141,17 +131,32 @@ parameters:
path: tests/Resources/XliffTest.php

-
message: "#^Parameter \\#3 \\$options of class Sonata\\\\AdminBundle\\\\SonataConfiguration constructor expects array\\('confirm_exit' \\=\\> bool, 'default_group' \\=\\> string, 'default_icon' \\=\\> string, 'default_label_catalogue' \\=\\> string, 'dropdown_number_groups_per_colums' \\=\\> int, 'form_type' \\=\\> string, 'html5_validate' \\=\\> bool, 'javascripts' \\=\\> array\\<int, string\\>, \\.\\.\\.\\), array\\(\\) given\\.$#"
message: "#^Parameter \\#3 \\$options of class Sonata\\\\AdminBundle\\\\SonataConfiguration constructor expects array\\{confirm_exit\\: bool, default_group\\: string, default_icon\\: string, default_label_catalogue\\: string, dropdown_number_groups_per_colums\\: int, form_type\\: string, html5_validate\\: bool, javascripts\\: array\\<int, string\\>, \\.\\.\\.\\}, array\\{\\} given\\.$#"
count: 3
path: tests/Security/Authorization/Voter/EditableRolesBuilderTest.php

-
message: "#^Parameter \\#3 \\$options of class Sonata\\\\AdminBundle\\\\SonataConfiguration constructor expects array\\('confirm_exit' \\=\\> bool, 'default_group' \\=\\> string, 'default_icon' \\=\\> string, 'default_label_catalogue' \\=\\> string, 'dropdown_number_groups_per_colums' \\=\\> int, 'form_type' \\=\\> string, 'html5_validate' \\=\\> bool, 'javascripts' \\=\\> array\\<int, string\\>, \\.\\.\\.\\), array\\(\\) given\\.$#"
message: "#^Parameter \\#3 \\$options of class Sonata\\\\AdminBundle\\\\SonataConfiguration constructor expects array\\{confirm_exit\\: bool, default_group\\: string, default_icon\\: string, default_label_catalogue\\: string, dropdown_number_groups_per_colums\\: int, form_type\\: string, html5_validate\\: bool, javascripts\\: array\\<int, string\\>, \\.\\.\\.\\}, array\\{\\} given\\.$#"
count: 1
path: tests/Security/RolesBuilder/AdminRolesBuilderTest.php

-
message: "#^Property Nucleos\\\\UserAdminBundle\\\\Tests\\\\Security\\\\RolesBuilder\\\\AdminRolesBuilderTest\\:\\:\\$token is never read, only written\\.$#"
count: 1
path: tests/Security/RolesBuilder/AdminRolesBuilderTest.php

-
message: "#^Property Nucleos\\\\UserAdminBundle\\\\Tests\\\\Security\\\\RolesBuilder\\\\AdminRolesBuilderTest\\:\\:\\$tokenStorage is never read, only written\\.$#"
count: 1
path: tests/Security/RolesBuilder/AdminRolesBuilderTest.php

-
message: "#^Parameter \\#3 \\$options of class Sonata\\\\AdminBundle\\\\SonataConfiguration constructor expects array\\('confirm_exit' \\=\\> bool, 'default_group' \\=\\> string, 'default_icon' \\=\\> string, 'default_label_catalogue' \\=\\> string, 'dropdown_number_groups_per_colums' \\=\\> int, 'form_type' \\=\\> string, 'html5_validate' \\=\\> bool, 'javascripts' \\=\\> array\\<int, string\\>, \\.\\.\\.\\), array\\('role_super_admin' \\=\\> 'ROLE_SUPER_ADMIN', 'role_admin' \\=\\> 'ROLE_SONATA_ADMIN'\\) given\\.$#"
message: "#^Parameter \\#3 \\$options of class Sonata\\\\AdminBundle\\\\SonataConfiguration constructor expects array\\{confirm_exit\\: bool, default_group\\: string, default_icon\\: string, default_label_catalogue\\: string, dropdown_number_groups_per_colums\\: int, form_type\\: string, html5_validate\\: bool, javascripts\\: array\\<int, string\\>, \\.\\.\\.\\}, array\\{role_super_admin\\: 'ROLE_SUPER_ADMIN', role_admin\\: 'ROLE_SONATA_ADMIN'\\} given\\.$#"
count: 1
path: tests/Security/RolesBuilder/SecurityRolesBuilderTest.php

-
message: "#^Property Nucleos\\\\UserAdminBundle\\\\Tests\\\\Security\\\\RolesBuilder\\\\SecurityRolesBuilderTest\\:\\:\\$admin is never read, only written\\.$#"
count: 1
path: tests/Security/RolesBuilder/SecurityRolesBuilderTest.php

7 changes: 6 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.10.0@916b098b008f6de4543892b1e0651c1c3b92cbfa">
<files psalm-version="4.13.1@5cf660f63b548ccd4a56f62d916ee4d6028e01a3">
<file src="src/Action/CheckEmailAction.php">
<InvalidArgument occurrences="1">
<code>$username</code>
Expand All @@ -13,6 +13,11 @@
<code>children</code>
</UndefinedMethod>
</file>
<file src="src/Form/Transformer/RestoreRolesTransformer.php">
<TooManyTemplateParams occurrences="1">
<code>DataTransformerInterface</code>
</TooManyTemplateParams>
</file>
<file src="src/Security/EditableRolesBuilder.php">
<LessSpecificImplementedReturnType occurrences="1">
<code>array</code>
Expand Down
27 changes: 15 additions & 12 deletions src/Form/Transformer/RestoreRolesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
use RuntimeException;
use Symfony\Component\Form\DataTransformerInterface;

/**
* @phpstan-implements DataTransformerInterface<string[], string[]>
*/
final class RestoreRolesTransformer implements DataTransformerInterface
{
/**
* @var string[]|null
*/
private ?array $originalRoles = null;

private EditableRolesBuilderInterface $rolesBuilder;
Expand All @@ -28,6 +34,9 @@ public function __construct(EditableRolesBuilderInterface $rolesBuilder)
$this->rolesBuilder = $rolesBuilder;
}

/**
* @param string[]|null $originalRoles
*/
public function setOriginalRoles(?array $originalRoles = []): void
{
if (null === $originalRoles) {
Expand All @@ -37,12 +46,7 @@ public function setOriginalRoles(?array $originalRoles = []): void
$this->originalRoles = $originalRoles;
}

/**
* @param mixed $value
*
* @return mixed|null
*/
public function transform($value)
public function transform($value): mixed
{
if (null === $value) {
return null;
Expand All @@ -55,13 +59,12 @@ public function transform($value)
return $value;
}

/**
* @param mixed $value
*
* @return mixed[]
*/
public function reverseTransform($value): array
public function reverseTransform($value): mixed
{
if (null === $value) {
$value = [];
}

if (null === $this->originalRoles) {
throw new RuntimeException('Invalid state, originalRoles array is not set');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Action/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function tearDown(): void

protected function getEntityManager(): EntityManagerInterface
{
$manager = self::$container->get('doctrine.orm.entity_manager');
$manager = self::getContainer()->get('doctrine.orm.entity_manager');

\assert($manager instanceof EntityManagerInterface);

Expand Down
3 changes: 3 additions & 0 deletions tests/Action/LoginActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ protected function setUp(): void
$this->formFactory = $this->createMock(FormFactoryInterface::class);
}

/**
* @runInSeparateProcess
*/
public function testAlreadyAuthenticated(): void
{
$user = $this->createMock(UserInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()
parent::__construct('test', false);
}

public function registerBundles()
public function registerBundles(): iterable
{
yield new FrameworkBundle();
yield new TwigBundle();
Expand Down
46 changes: 46 additions & 0 deletions tests/App/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,52 @@ public function __construct()
$this->groups = new ArrayCollection();
}

/**
* @return array<mixed>
*/
public function __serialize(): array
{
return [
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->enabled,
$this->id,
$this->email,
$this->emailCanonical,
];
}

/**
* @param mixed $serialized
*/
public function __unserialize($serialized): void
{
$data = unserialize($serialized);

if (13 === \count($data)) {
// Unserializing a User object from 1.3.x
unset($data[4], $data[5], $data[6], $data[9], $data[10]);
$data = array_values($data);
} elseif (11 === \count($data)) {
// Unserializing a User from a dev version somewhere between 2.0-alpha3 and 2.0-beta1
unset($data[4], $data[7], $data[8]);
$data = array_values($data);
}

[
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->enabled,
$this->id,
$this->email,
$this->emailCanonical
] = $data;
}

public function toString(): string
{
return $this->getUsername();
Expand Down
2 changes: 1 addition & 1 deletion tests/App/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

$containerConfigurator->extension('framework', ['test' => true]);

$containerConfigurator->extension('framework', ['session' => ['storage_id' => 'session.storage.mock_file']]);
$containerConfigurator->extension('framework', ['session' => ['storage_factory_id' => 'session.storage.factory.mock_file']]);

$containerConfigurator->extension('framework', ['cache' => ['pools' => ['avatar.preview.cache' => ['adapter' => 'cache.app', 'default_lifetime' => 60]]]]);

Expand Down
2 changes: 2 additions & 0 deletions tests/Form/Transformer/RestoreRolesTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function testReverseTransformRevokedHierarchicalRole(): void
$revokedRole = array_shift($userRoles);
$processedRoles = $transformer->reverseTransform($userRoles);

static::assertNotNull($processedRoles);
static::assertNotContains($revokedRole, $processedRoles);
}

Expand All @@ -138,6 +139,7 @@ public function testReverseTransformHiddenRole(): void
unset($userRoles[array_search('ROLE_SUPER_ADMIN', $userRoles, true)]);
$processedRoles = $transformer->reverseTransform($userRoles);

static::assertNotNull($processedRoles);
static::assertContains('ROLE_SUPER_ADMIN', $processedRoles);
}
}

0 comments on commit 2271797

Please sign in to comment.