Skip to content

Commit

Permalink
Fix deprecations and drop support for < Symfony 6 (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
trsteel88 authored Jan 24, 2023
1 parent 9477eab commit 2a7338e
Show file tree
Hide file tree
Showing 18 changed files with 619 additions and 582 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/phpunit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: PHPUnit

on: [ push, pull_request ]

jobs:
phpunit:
name: "PHP ${{ matrix.php }} + ${{ matrix.dependencies }} dependencies + Symfony ${{ matrix.symfony }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.1' ]
dependencies: [ highest ]
symfony: [ '*' ]
stability: [ 'stable' ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ steps.coverage.outputs.driver }}
# extensions: gd, imagick

- name: Require Symfony version
if: matrix.symfony != '*'
run: |
composer global require --no-interaction --no-progress symfony/flex:^1.11
composer config extra.symfony.require ${{ matrix.symfony }}
- name: Set minimum-stability
run: composer config minimum-stability ${{ matrix.stability }}

- name: Update project dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}

- name: Cache PHPUnit
uses: actions/cache@v2
with:
path: vendor/bin/.phpunit
key: ${{ runner.os }}-phpunit-${{ matrix.php }}

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

- name: Run PHPUnit tests
env:
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
run: vendor/bin/simple-phpunit -v
28 changes: 28 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on: [ push, pull_request ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none

- name: Update project dependencies
uses: ramsey/composer-install@v2

- name: Run PHP CS Fixer
run: vendor/bin/php-cs-fixer fix -v --dry-run

- name: Run PHPStan
run: vendor/bin/phpstan analyse --ansi

- name: Run Rector
run: vendor/bin/rector process --dry-run --no-progress-bar
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
/vendor
/Tests/Resources/cache
/Tests/Resources/logs
/.idea
/var
.phpunit.result.cache
.php-cs-fixer.cache
37 changes: 37 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

$finder = PhpCsFixer\Finder::create()
//->exclude('tests/Fixtures')
->in(__DIR__);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_superfluous_phpdoc_tags' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
'semicolon_after_instruction' => true,
'strict_comparison' => true,
'strict_param' => true,
'ordered_class_elements' => true,
'phpdoc_add_missing_param_annotation' => true,
'psr_autoloading' => true,
'heredoc_to_nowdoc' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']],
'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one', 'trait_import' => 'none']],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'blank_line_before_statement' => ['statements' => ['if', 'switch', 'case', 'default', 'declare', 'return', 'throw', 'try', 'foreach', 'while']],
))
->setFinder($finder)
;
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions DependencyInjection/Compiler/TransformerCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Trsteel\CkeditorBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class TransformerCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (false === $container->hasDefinition('trsteel_ckeditor.form.type')) {
return;
Expand All @@ -18,7 +18,7 @@ public function process(ContainerBuilder $container)

foreach ($container->findTaggedServiceIds('trsteel_ckeditor.transformer') as $id => $tags) {
foreach ($tags as $tag) {
$definition->addMethodCall('addTransformer', array(new Reference($id), $tag['alias']));
$definition->addMethodCall('addTransformer', [new Reference($id), $tag['alias']]);
}
}
}
Expand Down
57 changes: 26 additions & 31 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Trsteel\CkeditorBundle\Form\Type\CkeditorType;

/**
* This is the class that validates and merges configuration from your app/config files.
Expand All @@ -12,42 +13,37 @@
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('trsteel_ckeditor');
$rootNode = method_exists(TreeBuilder::class, 'getRootNode')
? $treeBuilder->getRootNode()
: $treeBuilder->root('trsteel_ckeditor');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
->scalarNode('class')->defaultValue('Trsteel\CkeditorBundle\Form\Type\CkeditorType')->end()
->scalarNode('class')->defaultValue(CkeditorType::class)->end()
->arrayNode('html_purifier')
->addDefaultsIfNotSet()
->children()
->variableNode('config')
->defaultValue(array())
->defaultValue([])
->info('The default html purifer config. See http://htmlpurifier.org/live/configdoc/plain.html for more information.')
->end()
->end()
->end()
->variableNode('transformers')
->defaultValue(array('html_purifier'))
->defaultValue(['html_purifier'])
->info('Default data transformers for the submitted html.')
->end()
->variableNode('toolbar')
->defaultValue(array(
->defaultValue([
'document', 'clipboard', 'editing', '/',
'basicstyles', 'paragraph', 'links', '/',
'insert', 'styles', 'tools',
))
])
->info('The default toolbar displayed on the editor.')
->end()
->variableNode('toolbar_groups')
->defaultValue(array())
->defaultValue([])
->info('Groups of icons in the editor.')
->end()
->booleanNode('startup_outline_blocks')
Expand Down Expand Up @@ -82,77 +78,77 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('url' => $v); })
->then(function ($v) { return ['url' => $v]; })
->end()
->children()
->scalarNode('url')->defaultNull()->end()
->scalarNode('route')->defaultNull()->end()
->variableNode('route_parameters')->defaultValue(array())->end()
->variableNode('route_parameters')->defaultValue([])->end()
->end()
->info('The location of an external file browser that should be launched when the Browse Server button is pressed.')
->end()
->arrayNode('filebrowser_upload_url')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('url' => $v); })
->then(function ($v) { return ['url' => $v]; })
->end()
->children()
->scalarNode('url')->defaultNull()->end()
->scalarNode('route')->defaultNull()->end()
->variableNode('route_parameters')->defaultValue(array())->end()
->variableNode('route_parameters')->defaultValue([])->end()
->end()
->info('The location of the script that handles file uploads.')
->end()
->arrayNode('filebrowser_image_browse_url')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('url' => $v); })
->then(function ($v) { return ['url' => $v]; })
->end()
->children()
->scalarNode('url')->defaultNull()->end()
->scalarNode('route')->defaultNull()->end()
->variableNode('route_parameters')->defaultValue(array())->end()
->variableNode('route_parameters')->defaultValue([])->end()
->end()
->info('The location of an external file browser that should be launched when the Browse Server button is pressed in the Image dialog window.')
->end()
->arrayNode('filebrowser_image_upload_url')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('url' => $v); })
->then(function ($v) { return ['url' => $v]; })
->end()
->children()
->scalarNode('url')->defaultNull()->end()
->scalarNode('route')->defaultNull()->end()
->variableNode('route_parameters')->defaultValue(array())->end()
->variableNode('route_parameters')->defaultValue([])->end()
->end()
->info('The location of the script that handles file uploads in the Image dialog window.')
->end()
->arrayNode('filebrowser_flash_browse_url')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('url' => $v); })
->then(function ($v) { return ['url' => $v]; })
->end()
->children()
->scalarNode('url')->defaultNull()->end()
->scalarNode('route')->defaultNull()->end()
->variableNode('route_parameters')->defaultValue(array())->end()
->variableNode('route_parameters')->defaultValue([])->end()
->end()
->info('The location of an external file browser that should be launched when the Browse Server button is pressed in the Flash dialog window.')
->end()
->arrayNode('filebrowser_flash_upload_url')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function ($v) { return array('url' => $v); })
->then(function ($v) { return ['url' => $v]; })
->end()
->children()
->scalarNode('url')->defaultNull()->end()
->scalarNode('route')->defaultNull()->end()
->variableNode('route_parameters')->defaultValue(array())->end()
->variableNode('route_parameters')->defaultValue([])->end()
->end()
->info('The location of the script that handles file uploads in the Flash dialog window.')
->end()
Expand All @@ -165,7 +161,7 @@ public function getConfigTreeBuilder()
->info('Disables the built-in spell checker if the browser provides one.')
->end()
->variableNode('format_tags')
->defaultValue(array())
->defaultValue([])
->info('An array of style names (by default tags) representing the style definition for each entry to be displayed in the Format combo in the toolbar.')
->example('[\'p\',\'h2\',\'h3\',\'pre\']')
->end()
Expand All @@ -184,7 +180,7 @@ public function getConfigTreeBuilder()
->arrayNode('contents_css')
->beforeNormalization()
->ifString()
->then(function ($v) { return array($v); })
->then(function ($v) { return [$v]; })
->end()
->prototype('scalar')->end()
->info('The CSS file(s) to be used to apply style to editor contents.')
Expand Down Expand Up @@ -214,11 +210,10 @@ public function getConfigTreeBuilder()
->info('The path of the custom config.js to use for the editor setup.')
->end()
->arrayNode('external_plugins')
->useAttributeAsKey(true)
->prototype('array')
->beforeNormalization()
->ifString()
->then(function ($v) { return array('path' => $v); })
->then(function ($v) { return ['path' => $v]; })
->end()
->children()
->scalarNode('path')->isRequired()->end()
Expand All @@ -227,7 +222,7 @@ public function getConfigTreeBuilder()
->end()
->end()
->variableNode('templates_files')
->defaultValue(array())
->defaultValue([])
->info('The list of templates definition files to load.')
->end()
->scalarNode('allowed_content')
Expand Down
Loading

0 comments on commit 2a7338e

Please sign in to comment.