Skip to content

Commit 15721f4

Browse files
authored
Merge pull request #91 from Exercise/update-compat
Update compatibility support for Symfony 6.x and drop support for Symfony < 4.4
2 parents 32f4709 + 6c3ab43 commit 15721f4

24 files changed

+212
-193
lines changed

.github/workflows/qa.yaml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Quality and Assurance
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: true
13+
matrix:
14+
php-versions: ['7.1', '8.1']
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Setup PHP, extensions and composer with shivammathur/setup-php
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-versions }}
24+
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, iconv, json, mbstring, pdo
25+
env:
26+
update: true
27+
28+
- name: Validate composer.json
29+
run: composer validate --strict
30+
31+
- name: Get composer cache directory
32+
id: composer-cache
33+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
34+
35+
- name: Install Composer dependencies
36+
run: composer install --no-progress --prefer-dist --optimize-autoloader
37+
38+
- name: Install Lowest Composer dependencies
39+
if: "matrix.php-versions < '8.1'"
40+
run: composer update --prefer-lowest --no-progress --prefer-dist --optimize-autoloader
41+
42+
- name: Install PHPUnit
43+
run: vendor/bin/simple-phpunit install
44+
45+
- name: Cache composer dependencies
46+
uses: actions/cache@v1
47+
with:
48+
path: ${{ steps.composer-cache.outputs.dir }}
49+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
50+
restore-keys: ${{ runner.os }}-composer-
51+
php-version: ${{ matrix.php-versions }}
52+
53+
qa:
54+
name: Quality
55+
needs: build
56+
runs-on: ubuntu-latest
57+
strategy:
58+
fail-fast: true
59+
matrix:
60+
php-versions: ['8.1']
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v2
65+
66+
- name: Setup PHP, extensions and composer with shivammathur/setup-php
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: ${{ matrix.php-versions }}
70+
extensions: mbstring, xml, ctype, intl, dom, filter
71+
tools: symfony
72+
env:
73+
update: true
74+
75+
- name: Get composer cache directory
76+
id: composer-cache
77+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
78+
79+
- name: Install Composer dependencies
80+
run: composer install --no-progress --prefer-dist --optimize-autoloader
81+
82+
- name: PHP-CS-Fixer
83+
run: symfony php ./vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --verbose --diff
84+
85+
test:
86+
name: Tests
87+
needs: build
88+
runs-on: ubuntu-latest
89+
strategy:
90+
fail-fast: true
91+
matrix:
92+
php-versions: ['7.1', '8.1']
93+
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v2
97+
98+
- name: Setup PHP, extensions and composer with shivammathur/setup-php
99+
uses: shivammathur/setup-php@v2
100+
with:
101+
php-version: ${{ matrix.php-versions }}
102+
extensions: mbstring, xml, ctype, intl, dom, filter
103+
tools: symfony
104+
env:
105+
update: true
106+
107+
- name: Get composer cache directory
108+
id: composer-cache
109+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
110+
111+
- name: Install Composer dependencies
112+
run: composer install --no-progress --prefer-dist --optimize-autoloader
113+
114+
- name: Install Lowest Composer dependencies
115+
if: "matrix.php-versions < '8.1'"
116+
run: composer install --no-progress --prefer-dist --optimize-autoloader
117+
118+
- name: Execute unit tests
119+
run: symfony php ./vendor/bin/simple-phpunit

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.php_cs.cache
1+
.php-cs-fixer.cache
22
.phpunit.result.cache
33
phpunit.xml
44
composer.lock

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
$finder = PhpCsFixer\Finder::create()
3+
$finder = (new PhpCsFixer\Finder())
44
->exclude('Resources')
55
->in(__DIR__)
66
;
77

8-
return PhpCsFixer\Config::create()
8+
return (new PhpCsFixer\Config())
99
->setRules([
1010
'@Symfony' => true,
1111
])

.travis.yml

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

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Version 4.0 (04/2022)
2+
3+
* [BC Break] Drop support for Symfony < 4.4
4+
* add support for Symfony 6.x
5+
* add support for PHPUnit 10.x
6+
17
## Version 3.0 (12/2019)
28

39
* [BC break] Dropped support for PHP 5.x. PHP 7.1 minimum required.

README.md

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,13 @@ This bundle integrates [HTMLPurifier][] into Symfony.
1111

1212
## Installation
1313

14-
## Symfony 3.4 and above (using Composer)
15-
16-
Require the bundle in your composer.json file:
17-
18-
```json
19-
{
20-
"require": {
21-
"exercise/htmlpurifier-bundle": "*"
22-
}
23-
}
24-
```
25-
2614
Install the bundle:
2715

2816
```bash
2917
$ composer require exercise/htmlpurifier-bundle
3018
```
3119

32-
Register the bundle in Symfony 3:
33-
34-
```php
35-
// app/AppKernel.php
36-
37-
public function registerBundles()
38-
{
39-
return [
40-
// ...
41-
new Exercise\HTMLPurifierBundle\ExerciseHTMLPurifierBundle(),
42-
];
43-
}
44-
```
45-
46-
## Configuration in Symfony 3
47-
48-
The configuration is the same as the following section, but the path should be
49-
`app/config.yml` instead.
50-
51-
## Configuration in Symfony 4 and up
20+
## Configuration
5221

5322
If you do not explicitly configure this bundle, an HTMLPurifier service will be
5423
defined as `exercise_html_purifier.default`. This behavior is the same as if you
@@ -117,7 +86,7 @@ services:
11786
exercise_html_purifier.default: '@App\Html\CustomHtmlPurifier'
11887
```
11988

120-
### Argument binding (Symfony >= 4.4)
89+
### Argument binding
12190

12291
The bundle also leverages the alias argument binding for each profile. So the
12392
following config:
@@ -353,5 +322,5 @@ previous, and "all" could define its own rules too.
353322

354323
## Contributing
355324

356-
PRs are welcomed :). Please target the `2.0` branch for bug fixes and `master`
325+
PRs are welcomed :). Please target the `3.x` branch for bug fixes and `master`
357326
for new features.

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
],
1414
"require": {
1515
"php": "^7.1.3 || ^8.0.0",
16-
"ezyang/htmlpurifier": "~4.0",
17-
"symfony/config": "~3.4 || ~4.0 || ^5.0",
18-
"symfony/dependency-injection": "~3.4.1 || ^4.0.1 || ^5.0",
19-
"symfony/http-kernel": "~3.4.1 || ^4.0.1 || ^5.0"
16+
"ezyang/htmlpurifier": "~4.14",
17+
"symfony/config": "~4.4 || ^5.0 || ^6.0",
18+
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
19+
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0"
2020
},
2121
"require-dev": {
22-
"friendsofphp/php-cs-fixer": "^2.0",
23-
"symfony/form": "~3.4.1 || ^4.0.1 || ^5.0",
24-
"symfony/phpunit-bridge": "4.4.*",
22+
"friendsofphp/php-cs-fixer": "^3.0",
23+
"symfony/form": "^4.4 || ^5.0 || ^6.0",
24+
"symfony/phpunit-bridge": "^6.0",
2525
"twig/twig": "^1.35.0 || ^2.4.4 || ^3.0"
2626
},
2727
"autoload": {
@@ -35,7 +35,7 @@
3535
},
3636
"extra": {
3737
"branch-alias": {
38-
"dev-master": "3.0.x-dev"
38+
"dev-master": "4.x-dev"
3939
}
4040
}
4141
}

src/CacheWarmer/SerializerCacheWarmer.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ class SerializerCacheWarmer implements CacheWarmerInterface
2626
private $filesystem;
2727

2828
/**
29-
* @param string[] $paths
30-
* @param string[] $profiles
31-
* @param HTMLPurifiersRegistryInterface $registry Used to build cache within bundle runtime
29+
* @param string[] $paths
30+
* @param string[] $profiles
3231
*/
3332
public function __construct(array $paths, array $profiles, HTMLPurifiersRegistryInterface $registry, Filesystem $filesystem)
3433
{
@@ -41,7 +40,7 @@ public function __construct(array $paths, array $profiles, HTMLPurifiersRegistry
4140
/**
4241
* {@inheritdoc}
4342
*/
44-
public function warmUp($cacheDir)
43+
public function warmUp($cacheDir): array
4544
{
4645
foreach ($this->paths as $path) {
4746
$this->filesystem->remove($path); // clean previous cache
@@ -52,12 +51,14 @@ public function warmUp($cacheDir)
5251
// Will build the configuration
5352
$this->registry->get($profile)->purify("<div style=\"background:url('http://www.example.com/x.gif');\">");
5453
}
54+
55+
return [];
5556
}
5657

5758
/**
5859
* {@inheritdoc}
5960
*/
60-
public function isOptional()
61+
public function isOptional(): bool
6162
{
6263
return false;
6364
}

src/DependencyInjection/Compiler/HTMLPurifierPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
class HTMLPurifierPass implements CompilerPassInterface
1414
{
15-
const PURIFIER_TAG = 'exercise.html_purifier';
15+
public const PURIFIER_TAG = 'exercise.html_purifier';
1616

1717
/**
1818
* {@inheritdoc}
1919
*/
20-
public function process(ContainerBuilder $container)
20+
public function process(ContainerBuilder $container): void
2121
{
2222
if (!$container->hasAlias(HTMLPurifiersRegistryInterface::class)) {
2323
return;

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ class Configuration implements ConfigurationInterface
1111
/**
1212
* {@inheritdoc}
1313
*/
14-
public function getConfigTreeBuilder()
14+
public function getConfigTreeBuilder(): TreeBuilder
1515
{
1616
$treeBuilder = new TreeBuilder('exercise_html_purifier');
17-
18-
if (method_exists($treeBuilder, 'getRootNode')) {
19-
$rootNode = $treeBuilder->getRootNode();
20-
} else {
21-
// BC layer for symfony/config 4.1 and older
22-
$rootNode = $treeBuilder->root('exercise_html_purifier');
23-
}
17+
$rootNode = $treeBuilder->getRootNode();
2418

2519
$rootNode
2620
->children()

0 commit comments

Comments
 (0)