Skip to content

Commit ae0e622

Browse files
authored
Allow Symfony 8 (#210)
* Allow Symfony 8 * Convert XML config into PHP * Enable package sorting * Remove ignored PHPstan error * Suppress PHPstan error about TreeBuilder does not specify its types
1 parent e20c7a0 commit ae0e622

File tree

6 files changed

+66
-48
lines changed

6 files changed

+66
-48
lines changed

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
"minimum-stability": "dev",
77
"require": {
88
"php": ">=8.1",
9-
"symfony/config": "^5.4 | ^6.0 | ^7.0",
10-
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0",
11-
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0",
12-
"symfony/routing": "^5.4 | ^6.0 | ^7.0",
13-
"symfony/deprecation-contracts": "^2.2 | ^3.0"
9+
"symfony/config": "^5.4 | ^6.0 | ^7.0 | ^8.0",
10+
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0 | ^8.0",
11+
"symfony/deprecation-contracts": "^2.2 | ^3.0",
12+
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0 | ^8.0",
13+
"symfony/routing": "^5.4 | ^6.0 | ^7.0 | ^8.0"
1414
},
1515
"require-dev": {
1616
"doctrine/orm": "^2.7",
1717
"doctrine/persistence": "^2.0",
18-
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0",
19-
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0"
18+
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0 | ^8.0",
19+
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0 | ^8.0"
2020
},
2121
"autoload": {
2222
"psr-4": {
@@ -41,5 +41,8 @@
4141
],
4242
"tools:run:php-cs-fixer": "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix",
4343
"tools:run:phpstan": "tools/phpstan/vendor/bin/phpstan --memory-limit=1G"
44+
},
45+
"config": {
46+
"sort-packages": true
4447
}
4548
}

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
5-
count: 1
6-
path: src/DependencyInjection/Configuration.php
7-
83
-
94
message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\UriSigner not found\\.$#"
105
count: 1

phpstan.dist.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ parameters:
77
paths:
88
- src
99
- tests
10+
ignoreErrors:
11+
- '#Method .+::getConfigTreeBuilder\(\) return type with generic class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder does not specify its types: T#'

src/DependencyInjection/SymfonyCastsVerifyEmailExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Symfony\Component\Config\FileLocator;
1313
use Symfony\Component\DependencyInjection\ContainerBuilder;
1414
use Symfony\Component\DependencyInjection\Extension\Extension;
15-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
15+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
1616

1717
/**
1818
* @author Jesse Rushlow <jr@rushlow.dev>
@@ -22,8 +22,8 @@ final class SymfonyCastsVerifyEmailExtension extends Extension
2222
{
2323
public function load(array $configs, ContainerBuilder $container): void
2424
{
25-
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
26-
$loader->load('verify_email_services.xml');
25+
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
26+
$loader->load('verify_email_services.php');
2727

2828
$configuration = $this->getConfiguration($configs, $container);
2929
if (!$configuration) {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the SymfonyCasts VerifyEmailBundle package.
5+
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
11+
12+
use Symfony\Component\HttpFoundation\UriSigner;
13+
use SymfonyCasts\Bundle\VerifyEmail\Factory\UriSignerFactory;
14+
use SymfonyCasts\Bundle\VerifyEmail\Generator\VerifyEmailTokenGenerator;
15+
use SymfonyCasts\Bundle\VerifyEmail\Util\VerifyEmailQueryUtility;
16+
use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelper;
17+
use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface;
18+
19+
return static function (ContainerConfigurator $container): void {
20+
$services = $container->services();
21+
$services->set('symfonycasts.verify_email.token_generator', VerifyEmailTokenGenerator::class)
22+
->args(['%kernel.secret%'])
23+
->private();
24+
25+
$services->set('symfonycasts.verify_email.query_utility', VerifyEmailQueryUtility::class)
26+
->private();
27+
28+
$services->set('symfonycasts.verify_email.uri_signer_factory', UriSignerFactory::class)
29+
->args([
30+
'%kernel.secret%',
31+
'signature',
32+
])
33+
->private();
34+
35+
$services->set('symfonycasts.verify_email.uri_signer', UriSigner::class)
36+
->factory([
37+
service('symfonycasts.verify_email.uri_signer_factory'),
38+
'createUriSigner',
39+
]);
40+
41+
$services->alias(VerifyEmailHelperInterface::class, 'symfonycasts.verify_email.helper');
42+
43+
$services->set('symfonycasts.verify_email.helper', VerifyEmailHelper::class)
44+
->args([
45+
service('router'),
46+
service('symfonycasts.verify_email.uri_signer'),
47+
service('symfonycasts.verify_email.query_utility'),
48+
service('symfonycasts.verify_email.token_generator'),
49+
null, // verify user signature lifetime
50+
]);
51+
};

src/Resources/config/verify_email_services.xml

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)