Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow Symfony 7 + drop support for 6.2 #41

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@ jobs:
SYMFONY_REQUIRE: 5.4.*
- php: 8.0
- php: 8.1
SYMFONY_REQUIRE: 6.2.*
- php: 8.2
SYMFONY_REQUIRE: 6.3.*
- php: 8.2
SYMFONY_REQUIRE: 7.0.*
stability: dev

steps:
- uses: actions/checkout@v2
@@ -33,6 +34,9 @@ jobs:
- name: Configure Composer minimum stability
if: matrix.stability
run: composer config minimum-stability ${{ matrix.stability }}

- name: Remove cs fixer
run: composer remove --dev friendsofphp/php-cs-fixer --no-update

- name: Install symfony/flex
run: |
@@ -57,7 +61,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
php-version: "8.2"

- name: Install dependencies
run: composer update --prefer-dist
@@ -75,7 +79,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
php-version: "8.2"

- name: Install dependencies
run: composer update --prefer-dist
17 changes: 9 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -13,21 +13,22 @@
],
"require": {
"php": "^7.2 || ^8.0",
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/twig-bundle": "^5.4 || ^6.2",
"symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.3 || ^7.0",
"twig/twig": "^1.35 || ^2.4.4 || ^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.27",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^8.5 || ^9.5",
"symfony/browser-kit": "^5.4 || ^6.2",
"symfony/css-selector": "^5.4 || ^6.2",
"symfony/expression-language": "^5.4 || ^6.2",
"symfony/phpunit-bridge": "^5.4 || ^6.2",
"symfony/security-bundle": "^5.4 || ^6.2",
"symfony/yaml": "5.4 || ^6.2"
"symfony/browser-kit": "^5.4 || ^6.3 || ^7.0",
"symfony/css-selector": "^5.4 || ^6.3 || ^7.0",
"symfony/expression-language": "^5.4 || ^6.3 || ^7.0",
"symfony/phpunit-bridge": "^6.3",
"symfony/security-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/yaml": "5.4 || ^6.3 || ^7.0"
},
"autoload": {
"psr-4": {
12 changes: 4 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
@@ -4,16 +4,12 @@ clear_cache:

test: clear_cache
vendor/bin/phpunit -c tests tests
make phpstan

phpstan:
vendor/bin/phpstan analyse -c phpstan.neon -l max src/

php_cs_fixer_fix: php-cs-fixer.phar
./php-cs-fixer.phar fix --config .php-cs-fixer.php src tests
php_cs_fixer_fix:
vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php src tests

php_cs_fixer_check: php-cs-fixer.phar
./php-cs-fixer.phar fix --config .php-cs-fixer.php src tests --dry-run --diff

php-cs-fixer.phar:
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.1.0/php-cs-fixer.phar && chmod 777 php-cs-fixer.phar
php_cs_fixer_check:
vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php src tests --dry-run --diff
4 changes: 2 additions & 2 deletions src/MenuConfig/MenuConfigProvider.php
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@ public function addMenuConfig(string $name, array $config): void
}

/**
* @throws \InvalidArgumentException
*
* @return array<string, mixed>
*
* @throws \InvalidArgumentException
*/
public function getMenuConfig(string $name): array
{
12 changes: 6 additions & 6 deletions src/Node/Node.php
Original file line number Diff line number Diff line change
@@ -74,14 +74,14 @@ class Node
/**
* @var bool|null
*/
protected $ifTrue = null;
protected $ifTrue;

/**
* @var bool
*/
protected $removeIfNoChildren = false;

public function __construct(?string $label = null)
public function __construct(string $label = null)
{
$this->label = $label;
$this->id = self::$counter++;
@@ -134,7 +134,7 @@ public function endIf(): self
/**
* @throws \BadMethodCallException
*/
public function child(?string $label = null): self
public function child(string $label = null): self
{
if (!$this->nodeFactory) {
throw new \BadMethodCallException('nodeFactory needs to be set on this node to be able
@@ -183,7 +183,7 @@ public function getLayer(): int
return $this->parent->getLayer() + 1;
}

return 0; //root
return 0; // root
}

/**
@@ -247,9 +247,9 @@ public function getAdditionalActiveRoutes(): array
}

/**
* @param mixed $value
*
* @return $this
*
* @phpstan-ignore-next-line
*/
public function setAttr(string $key, $value): self
{
2 changes: 1 addition & 1 deletion src/Node/NodeFactory.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

final class NodeFactory implements NodeFactoryInterface
{
public function create(?string $label = null): Node
public function create(string $label = null): Node
{
$node = new Node($label);
$node->setNodeFactory($this);
2 changes: 1 addition & 1 deletion src/Node/NodeFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -4,5 +4,5 @@

interface NodeFactoryInterface
{
public function create(?string $label = null): Node;
public function create(string $label = null): Node;
}
3 changes: 0 additions & 3 deletions src/NodeVisitor/NodeActivator.php
Original file line number Diff line number Diff line change
@@ -20,9 +20,6 @@ public function __construct(RequestStack $requestStack)
$this->requestStack = $requestStack;
}

/**
* {@inheritdoc}
*/
public function visit(Node $node): void
{
if (!$request = $this->requestStack->getCurrentRequest()) {
3 changes: 0 additions & 3 deletions src/NodeVisitor/NodeFilter.php
Original file line number Diff line number Diff line change
@@ -30,9 +30,6 @@ public function __construct(
$this->authChecker = $authChecker;
}

/**
* {@inheritdoc}
*/
public function visit(Node $node)
{
foreach ($node->getRequiredPermissions() as $permission) {
3 changes: 0 additions & 3 deletions src/NodeVisitor/NodeRoutePropagator.php
Original file line number Diff line number Diff line change
@@ -9,9 +9,6 @@
*/
final class NodeRoutePropagator implements NodeVisitorInterface
{
/**
* {@inheritdoc}
*/
public function visit(Node $node): void
{
$parent = $node->getParent();
2 changes: 1 addition & 1 deletion tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ private function loginUser(KernelBrowser $client, string $username, string $pass
return;
}

//TODO: cleanup once Symfony 4.4 support is dropped
// TODO: cleanup once Symfony 4.4 support is dropped
$token = new UsernamePasswordToken($user, $user->getPassword(), 'main', $user->getRoles());

$container = self::$kernel->getContainer()->get('test.service_container');
27 changes: 10 additions & 17 deletions tests/Functional/config.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
<?php

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\User;

return function (ContainerConfigurator $container): void {
if (class_exists(InMemoryUser::class)) {
$sessionConfig = ['storage_factory_id' => 'session.storage.factory.mock_file'];
$securityConfig = [
'password_hashers' => [
InMemoryUser::class => 'plain',
],
'enable_authenticator_manager' => true,
];
} else {
$sessionConfig = ['storage_id' => 'session.storage.mock_file'];
$securityConfig = [
'encoders' => [
User::class => 'plain',
],
];
$securityConfig = [
'password_hashers' => [
InMemoryUser::class => 'plain',
],
];

if (Kernel::VERSION_ID < 70000) {
$securityConfig['enable_authenticator_manager'] = true;
}

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

$container->extension('security', $securityConfig);
2 changes: 0 additions & 2 deletions tests/NodeVisitor/NodeActivatorTest.php
Original file line number Diff line number Diff line change
@@ -22,8 +22,6 @@ public function setUp(): void
* @dataProvider getTestData
*
* @param string $route
* @param $requestRoute
* @param $expectedIsActive
*/
public function testVisit($route, array $routes, $requestRoute, $expectedIsActive): void
{
Loading