Skip to content
Merged
Show file tree
Hide file tree
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/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ jobs:
fail-fast: false
matrix:
include:
- description: 'Symfony 6.0'
- description: 'Symfony 6.4'
php: '8.1'
composer_option: '--prefer-lowest'
max_deprecations: 0
- description: 'Symfony 6.4'
php: '8.2'
symfony: 6.4.*
max_deprecations: 0
- description: 'Symfony 7.3'
- description: 'Symfony 7.4'
php: '8.3'
symfony: 7.3.*
symfony: 7.4.*
max_deprecations: 0
- description: 'Symfony 8.0'
php: '8.4'
symfony: 8.0.*@dev
symfony: 8.0.*
max_deprecations: 0
- description: 'Symfony 8.1'
php: '8.5'
symfony: 8.1.*@dev
max_deprecations: 0
name: PHP ${{ matrix.php }} tests (${{ matrix.description }})
steps:
Expand Down
8 changes: 4 additions & 4 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// see https://github.com/FriendsOfPHP/PHP-CS-Fixer

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

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'@PHP8x0Migration:risky' => true,
'@PHPUnit8x4Migration:risky' => true,
'declare_strict_types' => false,
'native_function_invocation' => ['include' => ['@all']],
'native_function_invocation' => ['include' => ['@internal']],
])
->setFinder($finder)
;
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
"require": {
"php": "^8.1",
"google/recaptcha": "^1.3",
"symfony/config": "^6.0 || ^7.0 || ^8.0",
"symfony/dependency-injection": "^6.0 || ^7.0 || ^8.0",
"symfony/form": "^6.0 || ^7.0 || ^8.0",
"symfony/http-kernel": "^6.0 || ^7.0 || ^8.0",
"symfony/validator": "^6.0 || ^7.0 || ^8.0"
"symfony/config": "^6.4 || ^7.4 || ^8.0",
"symfony/dependency-injection": "^6.4 || ^7.4 || ^8.0",
"symfony/form": "^6.4 || ^7.4 || ^8.0",
"symfony/http-kernel": "^6.4 || ^7.4 || ^8.0",
"symfony/validator": "^6.4 || ^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"symfony/http-client-contracts": "^3.5",
"symfony/phpunit-bridge": "^7.3"
"symfony/phpunit-bridge": "^7.4"
},
"suggest": {
"symfony/twig-bundle": "To render widget. Minimum supported Twig version is 2.4"
Expand Down
59 changes: 59 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

use Beelab\Recaptcha2Bundle\Form\Type\RecaptchaSubmitType;
use Beelab\Recaptcha2Bundle\Form\Type\RecaptchaType;
use Beelab\Recaptcha2Bundle\Recaptcha\RecaptchaVerifier;
use Beelab\Recaptcha2Bundle\Recaptcha\SymfonyClientRequestMethod;
use Beelab\Recaptcha2Bundle\Validator\Constraints\Recaptcha2Validator;
use ReCaptcha\ReCaptcha;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Contracts\HttpClient\HttpClientInterface;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $configurator): void {
$services = $configurator->services();

$services
->set('beelab_recaptcha2.google_recaptcha', ReCaptcha::class)
->args([
'%beelab_recaptcha2.secret%',
null, // placeholder is replaced by RequestMethodPass
])
;

$services
->set(SymfonyClientRequestMethod::class)
->call('setClient', [service(HttpClientInterface::class)->nullOnInvalid()])
;

$services
->set('beelab_recaptcha2.type', RecaptchaType::class)
->public()
->args(['%beelab_recaptcha2.site_key%'])
->tag('form.type', ['alias' => 'beelab_recaptcha2'])
;

$services
->set('beelab_recaptcha2.submit_type', RecaptchaSubmitType::class)
->public()
->args(['%beelab_recaptcha2.site_key%'])
->tag('form.type', ['alias' => 'beelab_recaptcha2_submit'])
;

$services
->set('beelab_recaptcha2.verifier', RecaptchaVerifier::class)
->args([
service('beelab_recaptcha2.google_recaptcha'),
service('request_stack'),
'%beelab_recaptcha2.enabled%',
])
;

$services
->set('beelab_recaptcha2.validator', Recaptcha2Validator::class)
->public()
->args([service('beelab_recaptcha2.verifier')])
->tag('validator.constraint_validator', ['alias' => 'recaptcha2'])
;
};
36 changes: 0 additions & 36 deletions config/services.xml

This file was deleted.

7 changes: 0 additions & 7 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php

1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
level: 6
paths:
- config
- src
- tests
includes:
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/BeelabRecaptcha2Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public function load(array $configs, ContainerBuilder $container): void
$requestMethodClass = $this->getRequestMethod($config['request_method']);
$container->setParameter('beelab_recaptcha2.request_method', $requestMethodClass);

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

private function getRequestMethod(string $requestMethod): string
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('beelab_recaptcha2');
$rootNode = $treeBuilder->getRootNode();
$rootNode
$rootNode // @phpstan-ignore-line method.notFound
->children()
->enumNode('request_method')
->values(['curl_post', 'post', 'http_client'])
Expand Down