Skip to content

Commit 6e5b963

Browse files
authored
Bump requirements to currently supported Symfony versions, allow Symfony 8.x (#44)
(Case 204755)
1 parent 576e81f commit 6e5b963

File tree

13 files changed

+140
-119
lines changed

13 files changed

+140
-119
lines changed

.github/workflows/dependencies.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,31 @@ on:
1010
pull_request:
1111

1212
env:
13-
PHP_VERSION: 8.1
13+
PHP_VERSION: 8.4
1414

1515
jobs:
1616
composer-require-checker:
1717
name: Check missing composer requirements
18-
runs-on: ubuntu-22.04
18+
runs-on: ubuntu-latest
19+
if: github.actor != 'dependabot[bot]'
1920
steps:
2021
- uses: shivammathur/setup-php@v2
2122
with:
2223
php-version: ${{ env.PHP_VERSION }}
2324
coverage: none
24-
tools: composer:v2
25+
tools: composer:v2, flex
2526
- uses: actions/checkout@v4
2627
- uses: actions/cache@v4
2728
with:
2829
path: vendor
29-
key: composer-${{ runner.os }}-${{ env.PHP_VERSION }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }}
30+
key: composer-${{ runner.os }}-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json', 'composer.lock') }}
3031
restore-keys: |
31-
composer-${{ runner.os }}-${{ env.PHP_VERSION }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-
32-
- run: composer install --no-interaction --no-scripts --no-progress --prefer-dist
33-
- uses: docker://ghcr.io/webfactory/composer-require-checker:4.6.0
32+
composer-${{ runner.os }}-${{ env.PHP_VERSION }}-
33+
composer-${{ runner.os }}-
34+
- run: |
35+
composer install --no-interaction --no-progress --ansi --no-scripts
36+
composer show
37+
env:
38+
SYMFONY_REQUIRE: 7.*
39+
- name: ComposerRequireChecker
40+
uses: docker://ghcr.io/webfactory/composer-require-checker:4.18.0

.github/workflows/fix-cs-php.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Update this by running
2-
# curl https://gist.github.com/mpdude/ca93a185bcbf56eb7e341632ad4f8263/raw/fix-cs-php.yml > .github/workflows/fix-cs-php.yml
2+
# curl https://gist.githubusercontent.com/mpdude/804005e2bc7717bc36e4def876a5303d/raw/fix-php-cs.yml > .github/workflows/fix-cs-php.yml
3+
4+
name: Coding Standards
35

46
on:
57
push:
68
branches:
79
- master
810
pull_request:
911

10-
name: Coding Standards
11-
1212
jobs:
13-
fix-cs-issues:
14-
name: PHP-CS-Fixer
15-
runs-on: ubuntu-22.04
13+
fix-cs-violations:
14+
name: Apply PHP-CS-Fixer
15+
runs-on: ubuntu-latest
1616
if: github.actor != 'dependabot[bot]'
1717
steps:
1818
- name: Checkout code
@@ -21,7 +21,7 @@ jobs:
2121
ref: ${{ github.head_ref }}
2222

2323
- name: Run PHP-CS-Fixer
24-
uses: docker://ghcr.io/php-cs-fixer/php-cs-fixer:3.62.0-php8.3
24+
uses: docker://ghcr.io/php-cs-fixer/php-cs-fixer:3.89.2-php8.4
2525
with:
2626
args: "fix --show-progress=dots"
2727

.github/workflows/lock-symfony-version.sh

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

.github/workflows/tests.yml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,34 @@ on:
66
- master
77
pull_request:
88

9-
env:
10-
SYMFONY_DEPRECATIONS_HELPER: weak
11-
129
jobs:
1310
PHPUnit:
14-
15-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-latest
1612
strategy:
1713
fail-fast: false
1814
matrix:
1915
include:
20-
- { php-version: 8.1, symfony-locked-version: none, dependency-version: prefer-lowest }
21-
- { php-version: 8.1, symfony-locked-version: 5.4.*, dependency-version: prefer-stable }
22-
- { php-version: 8.2, symfony-locked-version: 6.4.*, dependency-version: prefer-stable }
23-
- { php-version: 8.3, symfony-locked-version: none, dependency-version: prefer-stable }
24-
name: PHPUnit (PHP ${{matrix.php-version}}, Symfony Version Lock ${{ matrix.symfony-locked-version }}, ${{ matrix.dependency-version }})
16+
- { php-version: 8.1, symfony-version: 6.4.*, dependency-version: prefer-lowest }
17+
- { php-version: 8.1, symfony-version: 6.4.*, dependency-version: prefer-stable }
18+
- { php-version: 8.3, symfony-version: 7.*, dependency-version: prefer-stable }
19+
- { php-version: 8.4, symfony-version: 8.*, dependency-version: prefer-stable }
20+
name: PHPUnit (PHP ${{ matrix.php-version }}, Symfony version lock ${{ matrix.symfony-version }}, ${{ matrix.dependency-version }})
2521
steps:
2622
- uses: actions/checkout@v4
2723
- uses: shivammathur/setup-php@v2
2824
with:
2925
php-version: ${{ matrix.php-version }}
3026
coverage: none
31-
tools: composer:v2
27+
tools: composer:v2, flex
3228
- uses: actions/cache@v4
3329
with:
3430
path: vendor
35-
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }}
31+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }}
3632
restore-keys: |
37-
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-
38-
- run: VERSION=${{ matrix.symfony-locked-version }} .github/workflows/lock-symfony-version.sh
39-
if: matrix.symfony-locked-version != 'none'
33+
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.dependency-version }}-
4034
- run: composer update --${{ matrix.dependency-version }} --no-interaction --no-scripts --no-progress --ansi
35+
env:
36+
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
37+
COMPOSER_NO_SECURITY_BLOCKING: 1
4138
- run: composer show
42-
- run: vendor/bin/phpunit
39+
- run: vendor/bin/phpunit --display-warnings --display-deprecations

CHANGELOG.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
## Version 2.0.0
1414

15-
### Removed
16-
1715
- The current request will no longer be passed to controllers generating the shortcode substitution (see #15). For shortcodes being handled `inline`, use the `RequestStack` directly in the substituting controller method to obtain the parent request. For `esi`-based renderers, there is no current solution provided by this bundle (see #14). Check your shortcode controllers for access to the request attribute named `request` to find affected places.
1816

19-
### Changed
20-
2117
- Logging will now by default be directed to the `shortcode` channel, instead of the `app` channel used previously.
18+
2219
- Slightly reduced the logging level in `EmbeddedShortcodeHandler`.

composer.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,26 @@
77
"php": ">=8.1",
88
"ext-json": "*",
99
"ext-mbstring": "*",
10-
"psr/log": "^1|^2|^3",
11-
"symfony/config": "^5.4|^6.0|^7.0",
12-
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
13-
"symfony/deprecation-contracts": "^2.5|^3.0",
14-
"symfony/form": "^5.4|^6.0|^7.0",
15-
"symfony/http-foundation": "^5.4|^6.0|^7.0",
16-
"symfony/http-kernel": "^5.4|^6.0|^7.0",
17-
"symfony/routing": "^5.4|^6.0|^7.0",
18-
"thunderer/shortcode": "^0.6.5|^0.7",
19-
"twig/twig": "^2.0|^3.0"
10+
"psr/log": "^2.0 || ^3.0",
11+
"symfony/config": "^6.4 || ^7.3 || ^8.0",
12+
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
13+
"symfony/deprecation-contracts": "^2.5 || ^3.0",
14+
"symfony/form": "^6.4 || ^7.3 || ^8.0",
15+
"symfony/http-foundation": "^6.4 || ^7.3 || ^8.0",
16+
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0",
17+
"symfony/routing": "^6.4 || ^7.3 || ^8.0",
18+
"thunderer/shortcode": "^0.6.5 || ^0.7",
19+
"twig/twig": "^2.0 || ^3.0"
2020
},
2121

2222
"require-dev": {
2323
"phpunit/phpunit": "^10.5",
24-
"symfony/browser-kit": "^5.4|^6.0|^7.0",
25-
"symfony/error-handler": "^5.4|^6.0|^7.1",
26-
"symfony/expression-language": "^5.4|^6.0|^7.0",
27-
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
28-
"symfony/phpunit-bridge": ">= 6.0",
29-
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
30-
"symfony/yaml": "^5.4|^6.0|^7.0"
24+
"symfony/browser-kit": "^6.4 || ^7.3 || ^8.0",
25+
"symfony/error-handler": "^6.4 || ^7.3 || ^8.0",
26+
"symfony/expression-language": "^6.4 || ^7.3 || ^8.0",
27+
"symfony/framework-bundle": "^6.4 || ^7.3 || ^8.0",
28+
"symfony/twig-bundle": "^6.4 || ^7.3 || ^8.0",
29+
"symfony/yaml": "^6.4 || ^7.3 || ^8.0"
3130
},
3231

3332
"autoload": {

phpunit.xml.dist

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="tests/bootstrap.php" cacheDirectory=".phpunit.cache">
3-
<php>
4-
<env name="SHELL_VERBOSITY" value="-1" />
5-
<server name="KERNEL_CLASS" value="\Webfactory\ShortcodeBundle\Tests\Fixtures\TestKernel" />
6-
<ini name="error_reporting" value="-1" />
7-
<server name="APP_ENV" value="test" force="true" />
8-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=9999" />
9-
</php>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
bootstrap="tests/bootstrap.php"
6+
colors="true">
7+
108
<testsuites>
119
<testsuite name="Project Test Suite">
1210
<directory>tests</directory>
1311
<exclude>tests/Functional/ShortcodeTest.php</exclude>
1412
</testsuite>
1513
</testsuites>
14+
15+
<source ignoreSuppressionOfDeprecations="true">
16+
<include>
17+
<directory>src</directory>
18+
</include>
19+
</source>
20+
21+
<php>
22+
<server name="KERNEL_CLASS" value="Webfactory\ShortcodeBundle\Tests\Fixtures\TestKernel" />
23+
<env name="SHELL_VERBOSITY" value="-1" />
24+
</php>
25+
1626
</phpunit>

src/Handler/EmbeddedShortcodeHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
string $controllerName,
4040
string $renderer,
4141
RequestStack $requestStack,
42-
?LoggerInterface $logger = null
42+
?LoggerInterface $logger = null,
4343
) {
4444
$this->validateControllerName($controllerName);
4545

tests/Fixtures/TestKernel.php

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
66
use Symfony\Bundle\TwigBundle\TwigBundle;
77
use Symfony\Component\Config\Loader\LoaderInterface;
8+
use Symfony\Component\DependencyInjection\ChildDefinition;
9+
use Symfony\Component\DependencyInjection\ContainerBuilder;
810
use Symfony\Component\HttpKernel\Kernel;
11+
use Thunder\Shortcode\Handler\PlaceholderHandler;
12+
use Webfactory\ShortcodeBundle\Tests\Fixtures\Controller\InvokableShortcodeTestController;
13+
use Webfactory\ShortcodeBundle\Tests\Fixtures\Controller\ShortcodeTestController;
914
use Webfactory\ShortcodeBundle\WebfactoryShortcodeBundle;
1015

1116
final class TestKernel extends Kernel
@@ -21,17 +26,68 @@ public function registerBundles(): array
2126

2227
public function registerContainerConfiguration(LoaderInterface $loader): void
2328
{
24-
$loader->load(__DIR__.'/config/config.yml');
25-
$loader->load(__DIR__.'/config/test_shortcodes.xml');
29+
$loader->load(static function (ContainerBuilder $container): void {
30+
$container->loadFromExtension('framework', [
31+
'secret' => 'top-secret',
32+
'test' => true,
33+
'esi' => ['enabled' => true],
34+
'fragments' => ['enabled' => true],
35+
'router' => ['resource' => '%kernel.project_dir%/src/Resources/config/guide-routing.php'],
36+
] + (Kernel::VERSION_ID < 70000 ? ['annotations' => ['enabled' => false]] : []));
37+
38+
$container->loadFromExtension('twig', [
39+
'strict_variables' => true,
40+
]);
41+
42+
$testControllerAction = ShortcodeTestController::class.'::test';
43+
44+
$container->loadFromExtension('webfactory_shortcode', [
45+
'shortcodes' => [
46+
'test-config-inline' => $testControllerAction,
47+
'test-config-esi' => [
48+
'controller' => $testControllerAction,
49+
'method' => 'esi',
50+
],
51+
'test-config-invokable' => InvokableShortcodeTestController::class,
52+
'test-shortcode-guide' => [
53+
'controller' => $testControllerAction,
54+
'description' => "Description for the 'test-shortcode-guide' shortcode",
55+
'example' => 'test-shortcode-guide test=true',
56+
],
57+
],
58+
]);
59+
60+
$container->register(ShortcodeTestController::class)
61+
->setAutoconfigured(true)
62+
->setAutowired(true)
63+
->addTag('controller.service_arguments');
64+
65+
$container->register(InvokableShortcodeTestController::class)
66+
->setAutoconfigured(true)
67+
->setAutowired(true)
68+
->addTag('controller.service_arguments');
69+
70+
// Service definitions from test_shortcodes.xml
71+
$container->setDefinition('test_esi', new ChildDefinition('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi'))
72+
->replaceArgument(1, $testControllerAction)
73+
->addTag('webfactory.shortcode', ['shortcode' => 'test-service-esi']);
74+
75+
$container->setDefinition('test_inline', new ChildDefinition('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline'))
76+
->replaceArgument(1, $testControllerAction)
77+
->addTag('webfactory.shortcode', ['shortcode' => 'test-service-inline']);
78+
79+
$container->register(PlaceholderHandler::class)
80+
->addTag('webfactory.shortcode', ['shortcode' => 'placeholder']);
81+
});
2682
}
2783

2884
public function getCacheDir(): string
2985
{
30-
return __DIR__.'/cache/'.$this->environment;
86+
return __DIR__.'/var/cache/'.$this->environment;
3187
}
3288

3389
public function getLogDir(): string
3490
{
35-
return __DIR__.'/logs';
91+
return __DIR__.'/var/log';
3692
}
3793
}

tests/Fixtures/config/config.yml

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

0 commit comments

Comments
 (0)