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
119 changes: 119 additions & 0 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Quality and Assurance

on:
push:
pull_request:

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php-versions: ['7.1', '8.1']

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, iconv, json, mbstring, pdo
env:
update: true

- name: Validate composer.json
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Install Lowest Composer dependencies
if: "matrix.php-versions < '8.1'"
run: composer update --prefer-lowest --no-progress --prefer-dist --optimize-autoloader

- name: Install PHPUnit
run: vendor/bin/simple-phpunit install

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
php-version: ${{ matrix.php-versions }}

qa:
name: Quality
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php-versions: ['8.1']

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, intl, dom, filter
tools: symfony
env:
update: true

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: PHP-CS-Fixer
run: symfony php ./vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --verbose --diff

test:
name: Tests
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php-versions: ['7.1', '8.1']

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, intl, dom, filter
tools: symfony
env:
update: true

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Install Lowest Composer dependencies
if: "matrix.php-versions < '8.1'"
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Execute unit tests
run: symfony php ./vendor/bin/simple-phpunit
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
phpunit.xml
composer.lock
Expand Down
4 changes: 2 additions & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder())
->exclude('Resources')
->in(__DIR__)
;

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
])
Expand Down
68 changes: 0 additions & 68 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 4.0 (04/2022)

* [BC Break] Drop support for Symfony < 4.4
* add support for Symfony 6.x
* add support for PHPUnit 10.x

## Version 3.0 (12/2019)

* [BC break] Dropped support for PHP 5.x. PHP 7.1 minimum required.
Expand Down
37 changes: 3 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,13 @@ This bundle integrates [HTMLPurifier][] into Symfony.

## Installation

## Symfony 3.4 and above (using Composer)

Require the bundle in your composer.json file:

```json
{
"require": {
"exercise/htmlpurifier-bundle": "*"
}
}
```

Install the bundle:

```bash
$ composer require exercise/htmlpurifier-bundle
```

Register the bundle in Symfony 3:

```php
// app/AppKernel.php

public function registerBundles()
{
return [
// ...
new Exercise\HTMLPurifierBundle\ExerciseHTMLPurifierBundle(),
];
}
```

## Configuration in Symfony 3

The configuration is the same as the following section, but the path should be
`app/config.yml` instead.

## Configuration in Symfony 4 and up
## Configuration

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

### Argument binding (Symfony >= 4.4)
### Argument binding

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

## Contributing

PRs are welcomed :). Please target the `2.0` branch for bug fixes and `master`
PRs are welcomed :). Please target the `3.x` branch for bug fixes and `master`
for new features.
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
],
"require": {
"php": "^7.1.3 || ^8.0.0",
"ezyang/htmlpurifier": "~4.0",
"symfony/config": "~3.4 || ~4.0 || ^5.0",
"symfony/dependency-injection": "~3.4.1 || ^4.0.1 || ^5.0",
"symfony/http-kernel": "~3.4.1 || ^4.0.1 || ^5.0"
"ezyang/htmlpurifier": "~4.14",
"symfony/config": "~4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"symfony/form": "~3.4.1 || ^4.0.1 || ^5.0",
"symfony/phpunit-bridge": "4.4.*",
"friendsofphp/php-cs-fixer": "^3.0",
"symfony/form": "^4.4 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^6.0",
"twig/twig": "^1.35.0 || ^2.4.4 || ^3.0"
},
"autoload": {
Expand All @@ -35,7 +35,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
"dev-master": "4.x-dev"
}
}
}
11 changes: 6 additions & 5 deletions src/CacheWarmer/SerializerCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class SerializerCacheWarmer implements CacheWarmerInterface
private $filesystem;

/**
* @param string[] $paths
* @param string[] $profiles
* @param HTMLPurifiersRegistryInterface $registry Used to build cache within bundle runtime
* @param string[] $paths
* @param string[] $profiles
*/
public function __construct(array $paths, array $profiles, HTMLPurifiersRegistryInterface $registry, Filesystem $filesystem)
{
Expand All @@ -41,7 +40,7 @@ public function __construct(array $paths, array $profiles, HTMLPurifiersRegistry
/**
* {@inheritdoc}
*/
public function warmUp($cacheDir)
public function warmUp($cacheDir): array
{
foreach ($this->paths as $path) {
$this->filesystem->remove($path); // clean previous cache
Expand All @@ -52,12 +51,14 @@ public function warmUp($cacheDir)
// Will build the configuration
$this->registry->get($profile)->purify("<div style=\"background:url('http://www.example.com/x.gif');\">");
}

return [];
}

/**
* {@inheritdoc}
*/
public function isOptional()
public function isOptional(): bool
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/HTMLPurifierPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

class HTMLPurifierPass implements CompilerPassInterface
{
const PURIFIER_TAG = 'exercise.html_purifier';
public const PURIFIER_TAG = 'exercise.html_purifier';

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasAlias(HTMLPurifiersRegistryInterface::class)) {
return;
Expand Down
10 changes: 2 additions & 8 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('exercise_html_purifier');

if (method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$rootNode = $treeBuilder->root('exercise_html_purifier');
}
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand Down
Loading