Skip to content

Commit

Permalink
Drop old versions of PHP and Symfony (#8225)
Browse files Browse the repository at this point in the history
* Drop old versions

* Bump

* Fix

* Revert

* Rector
  • Loading branch information
VincentLanglet authored Dec 7, 2024
1 parent fea2a75 commit 709fba6
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 52 deletions.
62 changes: 31 additions & 31 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
],
"homepage": "https://docs.sonata-project.org/projects/SonataAdminBundle",
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"doctrine/collections": "^1.6 || ^2.0",
"doctrine/common": "^3.0",
"knplabs/knp-menu": "^3.1",
"knplabs/knp-menu": "^3.2",
"knplabs/knp-menu-bundle": "^3.0",
"psr/container": "^1.0 || ^2.0",
"psr/log": "^2.0 || ^3.0",
Expand All @@ -37,32 +37,32 @@
"sonata-project/exporter": "^2.14 || ^3.1.1",
"sonata-project/form-extensions": "^1.15 || ^2.0",
"sonata-project/twig-extensions": "^1.4.1 || ^2.0",
"symfony/asset": "^5.4 || ^6.2 || ^7.0",
"symfony/config": "^5.4 || ^6.2 || ^7.0",
"symfony/console": "^5.4 || ^6.2 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.2 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.2 || ^7.0",
"symfony/asset": "^6.4 || ^7.1",
"symfony/config": "^6.4 || ^7.1",
"symfony/console": "^6.4 || ^7.1",
"symfony/dependency-injection": "^6.4 || ^7.1",
"symfony/doctrine-bridge": "^6.4 || ^7.1",
"symfony/event-dispatcher": "^6.4 || ^7.1",
"symfony/event-dispatcher-contracts": "^2.0 || ^3.0",
"symfony/expression-language": "^5.4 || ^6.2 || ^7.0",
"symfony/form": "^5.4 || ^6.2 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.2 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.2 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.2 || ^7.0",
"symfony/property-access": "^5.4 || ^6.2 || ^7.0",
"symfony/routing": "^5.4 || ^6.2 || ^7.0",
"symfony/expression-language": "^6.4 || ^7.1",
"symfony/form": "^6.4 || ^7.1",
"symfony/framework-bundle": "^6.4 || ^7.1",
"symfony/http-foundation": "^6.4 || ^7.1",
"symfony/http-kernel": "^6.4 || ^7.1",
"symfony/options-resolver": "^6.4 || ^7.1",
"symfony/property-access": "^6.4 || ^7.1",
"symfony/routing": "^6.4 || ^7.1",
"symfony/security-acl": "^3.1",
"symfony/security-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/security-core": "^5.4 || ^6.2 || ^7.0",
"symfony/security-csrf": "^5.4 || ^6.2 || ^7.0",
"symfony/serializer": "^5.4 || ^6.2 || ^7.0",
"symfony/string": "^5.4 || ^6.2 || ^7.0",
"symfony/translation": "^5.4 || ^6.2 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.1",
"symfony/security-core": "^6.4 || ^7.1",
"symfony/security-csrf": "^6.4 || ^7.1",
"symfony/serializer": "^6.4 || ^7.1",
"symfony/string": "^6.4 || ^7.1",
"symfony/translation": "^6.4 || ^7.1",
"symfony/translation-contracts": "^2.3 || ^3.0",
"symfony/twig-bridge": "^5.4 || ^6.2 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/validator": "^5.4 || ^6.2 || ^7.0",
"symfony/twig-bridge": "^6.4 || ^7.1",
"symfony/twig-bundle": "^6.4 || ^7.1",
"symfony/validator": "^6.4 || ^7.1",
"twig/string-extra": "^3.0",
"twig/twig": "^3.0"
},
Expand All @@ -76,17 +76,17 @@
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^5.0",
"psr/event-dispatcher": "^1.0",
"rector/rector": "^1.1",
"symfony/browser-kit": "^5.4 || ^6.2 || ^7.0",
"symfony/css-selector": "^5.4 || ^6.2 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.2 || ^7.0",
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/css-selector": "^6.4 || ^7.1",
"symfony/filesystem": "^6.4 || ^7.1",
"symfony/maker-bundle": "^1.25",
"symfony/phpunit-bridge": "^6.2 || ^7.0",
"symfony/yaml": "^5.4 || ^6.2 || ^7.0",
"symfony/phpunit-bridge": "^6.4 || ^7.1",
"symfony/yaml": "^6.4 || ^7.1",
"vimeo/psalm": "^5.8.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/GenerateObjectAclCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function execute(InputInterface $input, OutputInterface $output): int

$securityIdentity = null;
if ($input->getOption('step') && $this->askConfirmation($input, $output, "<question>Set an object owner?</question>\n", 'no')) {
$username = $this->askAndValidate($input, $output, 'Please enter the username: ', '', [Validators::class, 'validateUsername']);
$username = $this->askAndValidate($input, $output, 'Please enter the username: ', '', Validators::validateUsername(...));

$securityIdentity = new UserSecurityIdentity($username, $this->getUserModelClass($input, $output));
}
Expand Down
7 changes: 7 additions & 0 deletions src/EventListener/ConfigureCRUDControllerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public function onKernelController(ControllerEvent $event): void

if (\is_array($controller)) {
$controller = $controller[0];
} else {
try {
$reflection = new \ReflectionFunction($controller(...));
$controller = $reflection->getClosureThis();
} catch (\ReflectionException) {
return;
}
}

if (!$controller instanceof CRUDController) {
Expand Down
12 changes: 6 additions & 6 deletions src/Maker/AdminMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
$this->modelClass = $io->ask(
'The fully qualified model class',
$input->getArgument('model'),
[Validators::class, 'validateClass']
Validators::validateClass(...)
);
$this->modelClassBasename = \array_slice(explode('\\', $this->modelClass), -1)[0];
$this->modelClassBasename = \array_slice(explode('\\', (string) $this->modelClass), -1)[0];

$this->adminClassBasename = $io->ask(
'The admin class basename',
$input->getOption('admin') ?? \sprintf('%sAdmin', $this->modelClassBasename),
[Validators::class, 'validateAdminClassBasename']
Validators::validateAdminClassBasename(...)
);
if (\count($this->availableModelManagers) > 1) {
$managerTypes = array_keys($this->availableModelManagers);
Expand All @@ -141,7 +141,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
$this->controllerClassBasename = $io->ask(
'The controller class basename',
$input->getOption('controller') ?? \sprintf('%sAdminController', $this->modelClassBasename),
[Validators::class, 'validateControllerClassBasename']
Validators::validateControllerClassBasename(...)
);
$input->setOption('controller', $this->controllerClassBasename);
}
Expand All @@ -150,12 +150,12 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
$servicesFile = $io->ask(
'The services YAML configuration file',
$input->getOption('services') ?? (is_file($path.'admin.yaml') ? 'admin.yaml' : 'services.yaml'),
[Validators::class, 'validateServicesFile']
Validators::validateServicesFile(...)
);
$id = $io->ask(
'The admin service ID',
$this->getAdminServiceId($this->adminClassBasename),
[Validators::class, 'validateServiceId']
Validators::validateServiceId(...)
);
$input->setOption('services', $servicesFile);
$input->setOption('id', $id);
Expand Down
10 changes: 2 additions & 8 deletions src/Util/AdminObjectAclData.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ final class AdminObjectAclData
*/
private static array $ownerPermissions = ['MASTER', 'OWNER'];

/**
* @var \Traversable<string> Roles to set ACL for
*/
private \Traversable $aclRoles;

/**
* @var array<string, mixed> Cache of masks
*/
Expand All @@ -50,7 +45,7 @@ final class AdminObjectAclData
/**
* @param AdminInterface<object> $admin
* @param \Traversable<UserInterface|string> $aclUsers
* @param \Traversable<string>|null $aclRoles
* @param \Traversable<string> $aclRoles
*
* @phpstan-param class-string $maskBuilderClass
*/
Expand All @@ -59,9 +54,8 @@ public function __construct(
private object $object,
private \Traversable $aclUsers,
private string $maskBuilderClass,
?\Traversable $aclRoles = null,
private \Traversable $aclRoles = new \ArrayIterator(),
) {
$this->aclRoles = $aclRoles ?? new \ArrayIterator();
if (!$admin->isAclEnabled()) {
throw new \InvalidArgumentException('The admin must have ACL enabled.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testItConfiguresCRUDController(): void

$controllerEvent = new ControllerEvent(
$this->createStub(HttpKernelInterface::class),
[$controller, 'listAction'],
$controller->listAction(...),
$request,
HttpKernelInterface::MAIN_REQUEST
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/FieldDescription/FieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function isIdentifier(): bool
throw new \BadMethodCallException(\sprintf('Implement %s() method.', __METHOD__));
}

public function getValue(object $object): void
public function getValue(object $object): never
{
throw new \BadMethodCallException(\sprintf('Implement %s() method.', __METHOD__));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Menu/Provider/GroupMenuProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function testGetMenuProviderWithCheckerGrantedMultipleGroupRoles(
): void {
$this->checker
->method('isGranted')
->willReturnCallback([$this, 'unanimousGrantCheckerMock']);
->willReturnCallback($this->unanimousGrantCheckerMock(...));

$menu = $this->provider->get(
'providerFoo',
Expand All @@ -162,7 +162,7 @@ public function testGetMenuProviderWithCheckerGrantedGroupAndItemRoles(
): void {
$this->checker
->method('isGranted')
->willReturnCallback([$this, 'unanimousGrantCheckerNoBazMock']);
->willReturnCallback($this->unanimousGrantCheckerNoBazMock(...));

$menu = $this->provider->get(
'providerFoo',
Expand Down Expand Up @@ -190,7 +190,7 @@ public function testGetMenuProviderWithCheckerGrantedMultipleGroupRolesOnTop(
): void {
$this->checker
->method('isGranted')
->willReturnCallback([$this, 'unanimousGrantCheckerMock']);
->willReturnCallback($this->unanimousGrantCheckerMock(...));

$menu = $this->provider->get(
'providerFoo',
Expand Down
2 changes: 1 addition & 1 deletion tests/Twig/Extension/FakeTemplateRegistryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class FakeTemplateRegistryExtension extends AbstractExtension
public function getFunctions(): array
{
return [
new TwigFunction('get_admin_template', [$this, 'getAdminTemplate']),
new TwigFunction('get_admin_template', $this->getAdminTemplate(...)),
];
}

Expand Down

0 comments on commit 709fba6

Please sign in to comment.