Skip to content

Commit b42880d

Browse files
committed
🔧 convert configuration to PHP
1 parent 0b83dd9 commit b42880d

9 files changed

Lines changed: 53 additions & 60 deletions

File tree

‎.github/workflows/build.yaml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,25 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
include:
38-
- description: 'Symfony 6.0'
38+
- description: 'Symfony 6.4'
3939
php: '8.1'
4040
composer_option: '--prefer-lowest'
4141
max_deprecations: 0
4242
- description: 'Symfony 6.4'
4343
php: '8.2'
4444
symfony: 6.4.*
4545
max_deprecations: 0
46-
- description: 'Symfony 7.3'
46+
- description: 'Symfony 7.4'
4747
php: '8.3'
48-
symfony: 7.3.*
48+
symfony: 7.4.*
4949
max_deprecations: 0
5050
- description: 'Symfony 8.0'
5151
php: '8.4'
52-
symfony: 8.0.*@dev
52+
symfony: 8.0.*
53+
max_deprecations: 0
54+
- description: 'Symfony 8.1'
55+
php: '8.5'
56+
symfony: 8.1.*@dev
5357
max_deprecations: 0
5458
name: PHP ${{ matrix.php }} tests (${{ matrix.description }})
5559
steps:

‎.php-cs-fixer.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
// see https://github.com/FriendsOfPHP/PHP-CS-Fixer
33

44
$finder = PhpCsFixer\Finder::create()
5-
->in([__DIR__.'/src', __DIR__.'/tests'])
5+
->in([__DIR__.'/config', __DIR__.'/src', __DIR__.'/tests'])
66
;
77

88
return (new PhpCsFixer\Config())
99
->setRiskyAllowed(true)
1010
->setRules([
1111
'@Symfony' => true,
1212
'@Symfony:risky' => true,
13-
'@PHP80Migration:risky' => true,
14-
'@PHPUnit84Migration:risky' => true,
13+
'@PHP8x0Migration:risky' => true,
14+
'@PHPUnit8x4Migration:risky' => true,
1515
'declare_strict_types' => false,
16-
'native_function_invocation' => ['include' => ['@all']],
16+
'native_function_invocation' => ['include' => ['@internal']],
1717
])
1818
->setFinder($finder)
1919
;

‎composer.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
"require": {
1919
"php": "^8.1",
2020
"google/recaptcha": "^1.3",
21-
"symfony/config": "^6.0 || ^7.0 || ^8.0",
22-
"symfony/dependency-injection": "^6.0 || ^7.0 || ^8.0",
23-
"symfony/form": "^6.0 || ^7.0 || ^8.0",
24-
"symfony/http-kernel": "^6.0 || ^7.0 || ^8.0",
25-
"symfony/validator": "^6.0 || ^7.0 || ^8.0"
21+
"symfony/config": "^6.4 || ^7.4 || ^8.0",
22+
"symfony/dependency-injection": "^6.4 || ^7.4 || ^8.0",
23+
"symfony/form": "^6.4 || ^7.4 || ^8.0",
24+
"symfony/http-kernel": "^6.4 || ^7.4 || ^8.0",
25+
"symfony/validator": "^6.4 || ^7.4 || ^8.0"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "^9.6",
2929
"symfony/http-client-contracts": "^3.5",
30-
"symfony/phpunit-bridge": "^7.3"
30+
"symfony/phpunit-bridge": "^7.4"
3131
},
3232
"suggest": {
3333
"symfony/twig-bundle": "To render widget. Minimum supported Twig version is 2.4"

‎config/services.php‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Beelab\Recaptcha2Bundle\Form\Type\RecaptchaType;
4+
use Beelab\Recaptcha2Bundle\Recaptcha\RecaptchaVerifier;
5+
use Beelab\Recaptcha2Bundle\Validator\Constraints\Recaptcha2Validator;
6+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
7+
8+
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
9+
10+
return static function (ContainerConfigurator $configurator): void {
11+
$services = $configurator->services();
12+
13+
$services
14+
->set('beelab_recaptcha2.google_recaptcha', RecaptchaVerifier::class)
15+
->args([
16+
'%beelab_recaptcha2.secret%',
17+
null, // placeholder is replaced by RequestMethodPass
18+
])
19+
;
20+
21+
$services
22+
->set('recaptcha2', Recaptcha2Validator::class)
23+
->args([service('beelab_recaptcha2.google_recaptcha')])
24+
->tag('validator.constraint_validator')
25+
;
26+
27+
$services
28+
->set(RecaptchaType::class)
29+
->tag('form.type')
30+
;
31+
};

‎config/services.xml‎

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

‎phpstan-baseline.neon‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
parameters:
2-
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-

‎phpstan.neon‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
parameters:
22
level: 6
33
paths:
4+
- config
45
- src
56
- tests
67
includes:

‎src/DependencyInjection/BeelabRecaptcha2Extension.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function load(array $configs, ContainerBuilder $container): void
2323
$requestMethodClass = $this->getRequestMethod($config['request_method']);
2424
$container->setParameter('beelab_recaptcha2.request_method', $requestMethodClass);
2525

26-
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
27-
$loader->load('services.xml');
26+
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../../config'));
27+
$loader->load('services.php');
2828
}
2929

3030
private function getRequestMethod(string $requestMethod): string

‎src/DependencyInjection/Configuration.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function getConfigTreeBuilder(): TreeBuilder
1111
{
1212
$treeBuilder = new TreeBuilder('beelab_recaptcha2');
1313
$rootNode = $treeBuilder->getRootNode();
14-
$rootNode
14+
$rootNode // @phpstan-ignore-line method.notFound
1515
->children()
1616
->enumNode('request_method')
1717
->values(['curl_post', 'post', 'http_client'])

0 commit comments

Comments
 (0)