diff --git a/.gitattributes b/.gitattributes index aa31462..2c1a0d6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,7 @@ /tests export-ignore /.gitattributes export-ignore +/.github export-ignore /.gitignore export-ignore -/.php_cs.dist export-ignore -/.styleci.yml export-ignore -/.travis.yml export-ignore +/.php-cs-fixer.dist.php export-ignore +/phpstan.neon export-ignore /phpunit.xml.dist export-ignore -/ruleset.xml export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..761809b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI + +on: + push: + branches: + - '*.x' + pull_request: + +jobs: + phpunit: + name: PHP ${{ matrix.php }} ${{ matrix.env.COMPOSER_FLAGS }} + runs-on: ubuntu-20.04 + env: + SYMFONY_DEPRECATIONS_HELPER: weak + PHPUNIT_FLAGS: "-v" + strategy: + fail-fast: false + matrix: + include: + - php: '7.2' + env: + SYMFONY_REQUIRE: "*" + - php: '7.3' + env: + SYMFONY_REQUIRE: "*" + - php: '7.4' + env: + SYMFONY_REQUIRE: "*" + - php: '8.0' + env: + SYMFONY_REQUIRE: "*" + - php: '8.1' + env: + SYMFONY_REQUIRE: "*" + - php: '8.2' + env: + SYMFONY_REQUIRE: "*" + - php: '7.2' + env: + COMPOSER_FLAGS: "--prefer-lowest" + - php: '8.0' + env: + COMPOSER_FLAGS: "--prefer-lowest" + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: none + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install composer dependencies + run: | + composer update --prefer-dist --no-interaction --no-progress --no-ansi ${COMPOSER_FLAGS} + vendor/bin/simple-phpunit install + + - name: Execute tests + run: | + composer validate --strict --no-check-lock + vendor/bin/simple-phpunit diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..9cefafb --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,40 @@ +name: Static analysis + +on: + push: + branches: + - '*.x' + pull_request: + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Downgrade composer and require extra extensions + # setting composer config version to be able to install with outdated composer version, see https://github.com/OskarStark/phpstan-ga/pull/50 + run: | + composer config version 1.3.3 + composer require --no-update phpstan/phpstan-symfony + + - name: PHPStan + uses: docker://oskarstark/phpstan-ga + with: + args: analyze --no-progress + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --dry-run --diff diff --git a/.gitignore b/.gitignore index 1e3fb97..125c554 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /composer.lock /.idea /.php_cs.cache +/.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..15389f9 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,37 @@ +notPath('src/AppBundle/Command/TestCommand.php') + ->exclude('tests/*/Fixtures') + ->exclude('var') + ->in(__DIR__); + +$config = new PhpCsFixer\Config(); + +return $config + ->setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + '@Symfony:risky' => true, + 'array_syntax' => ['syntax' => 'short'], + 'combine_consecutive_unsets' => true, + 'heredoc_to_nowdoc' => true, + 'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']], + 'no_unreachable_default_argument_value' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'non_printable_character' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => true, + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_order' => true, + 'random_api_migration' => true, + 'psr_autoloading' => true, + 'strict_param' => true, + 'native_function_invocation' => ['include' => ['@compiler_optimized']], + 'phpdoc_no_empty_return' => false, + 'no_superfluous_phpdoc_tags' => true, + ]) + ->setFinder( + $finder + ); diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 64fe8c7..0000000 --- a/.php_cs.dist +++ /dev/null @@ -1,26 +0,0 @@ -setRiskyAllowed(true) - ->setRules([ - 'array_syntax' => array('syntax' => 'short'), - 'combine_consecutive_unsets' => true, - 'heredoc_to_nowdoc' => true, - 'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'], - 'no_unreachable_default_argument_value' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'ordered_class_elements' => true, - 'ordered_imports' => true, - 'phpdoc_add_missing_param_annotation' => true, - 'phpdoc_order' => true, - 'psr4' => true, - '@Symfony' => true, - '@Symfony:risky' => true, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('vendor') - ->in(__DIR__) - ) -; diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 65fa522..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,5 +0,0 @@ -preset: symfony - -enabled: - - alpha_ordered_imports - - short_array_syntax diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 945d620..0000000 --- a/.travis.yml +++ /dev/null @@ -1,53 +0,0 @@ -language: php - -sudo: false - -cache: - directories: - - $HOME/.composer/cache - - $HOME/symfony-bridge/.phpunit - -env: - global: - - PHPUNIT_FLAGS="-v" - - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" - -branches: - only: - - master - - develop - - /^\d+\.\d+$/ - -matrix: - fast_finish: true - include: - # Minimum supported dependencies with min and max PHP version - - php: 7.1 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" - - php: 7.4 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" - - # Latest supported dependencies with each PHP version - - php: 7.1 - - php: 7.2 - - php: 7.3 - - php: 7.4 - env: COVERAGE=true XDEBUG_MODE="coverage" PHPUNIT_FLAGS="-v --coverage-text" - - - php: 7.4 - env: SYMFONY_REQUIRE=4.3.* - - php: 7.4 - env: SYMFONY_REQUIRE=4.4.* - - php: 7.4 - env: SYMFONY_REQUIRE=5.0.* - -before_install: - - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi - - composer global require --no-progress --no-scripts --no-plugins symfony/flex - -install: - - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction - - ./vendor/bin/simple-phpunit install - -script: - - SYMFONY_DEPRECATIONS_HELPER=weak ./vendor/bin/simple-phpunit ${PHPUNIT_FLAGS} diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b54ba..3d9d93e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Removed ### Security +## 1.4.0 - 2023-03-27 + +### Fixed + +* Compatibility with Symfony 6 + +### Removed + +* Support for PHP 7.1 + +## 1.3.3 - 2022-01-19 + +### Fixed + +* Deprecation notices + +### Removed + +* Support for Symfony < 5 ## 1.3.2 - 2022-01-19 diff --git a/README.md b/README.md index 0914b9a..c3bf6ba 100644 --- a/README.md +++ b/README.md @@ -8,24 +8,7 @@ A [Symfony](http://symfony.com/) bundle for the [Rokka](https://rokka.io/) image Free account plans are available. Just install the plugin, register and use it. -## Installation Symfony version <= 3 - -Require the bundle using composer: - -`composer require rokka/client-bundle` - -Add it to `app/AppKernel.php` - -``` - $bundles = array( - ... - new Rokka\RokkaClientBundle\RokkaClientBundle(), - ); -``` - -Configure the bundle with the parameters below. - -## Installation Symfony version >= 4 +## Installation The rokka Symfony bundle comes with a flex recipe. diff --git a/composer.json b/composer.json index 1cdb82e..cb2d75d 100644 --- a/composer.json +++ b/composer.json @@ -30,19 +30,14 @@ "psr-4": { "Rokka\\RokkaClientBundle\\Tests\\": "tests" } }, "require": { - "php": "^7.1 || ^8.0", + "php": "^7.2 || ^8.0", "rokka/client": "^1.10", - "rokka/client-cli": "^1.8", - "symfony/framework-bundle": "^3.4.26 || ^4.3 || ^5.0 || ^6.0 || ^7.0", + "rokka/client-cli": "^1.9", + "symfony/framework-bundle": "^5.2 || ^6.0 || ^7.0", "rokka/twig": "^1.0" }, "require-dev": { - "squizlabs/php_codesniffer": "^2.0", - "symfony/phpunit-bridge": "^5.0" - }, - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } + "friendsofphp/php-cs-fixer": "^3.0", + "symfony/phpunit-bridge": "^5.2 || ^6.0" } } diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..ca4d9fd --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 7 + paths: + - src/ + checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false diff --git a/ruleset.xml b/ruleset.xml deleted file mode 100644 index b67deaa..0000000 --- a/ruleset.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - The Rokka-specific coding standard (fully includes PSR-2). - - - - - */Tests/fixtures/* - *\Tests\fixtures\* - *.xml - *.yml - *.html - *.html.twig - vendor/* - - - - - - - - - - - - */Tests/* - *\Tests\* - - - - - */Tests/* - *\Tests\* - */DependencyInjection/* - *\DependencyInjection\* - - - */Tests/* - *\Tests\* - - - */Tests/* - *\Tests\* - - - */Tests/* - *\Tests\* - - - - - - * - - - * - - - * - - - - * - - - * - - - * - - - * - - - * - - - * - - - - diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index de1ce5d..989275d 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -7,15 +7,10 @@ class Configuration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('rokka_client'); - if (method_exists($treeBuilder, 'getRootNode')) { - $rootNode = $treeBuilder->getRootNode(); - } else { - // symfony < 4.2 support - $rootNode = $treeBuilder->root('rokka_client'); - } + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() @@ -47,7 +42,7 @@ public function getConfigTreeBuilder() ->defaultNull(); if (method_exists($secretNode, 'setDeprecated')) { - $secretNode->setDeprecated(); + $secretNode->setDeprecated('rokka/client-bundle', '1.1.0', 'This is not used anymore'); } return $treeBuilder; diff --git a/src/DependencyInjection/RokkaClientExtension.php b/src/DependencyInjection/RokkaClientExtension.php index 82ecb20..8320c97 100644 --- a/src/DependencyInjection/RokkaClientExtension.php +++ b/src/DependencyInjection/RokkaClientExtension.php @@ -2,6 +2,7 @@ namespace Rokka\RokkaClientBundle\DependencyInjection; +use RokkaCli\ConsoleApplication; use Symfony\Component\Config\FileLocator; use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -10,15 +11,19 @@ class RokkaClientExtension extends Extension { - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { - $reflection = new \ReflectionClass('\RokkaCli\ConsoleApplication'); + $reflection = new \ReflectionClass(ConsoleApplication::class); + $filename = $reflection->getFileName(); + if (false === $filename) { + throw new \RuntimeException('Could not determine the configuration folder for the CLI tools'); + } $loader = new XmlFileLoader( $container, new FileLocator([ __DIR__.'/../Resources/config', - \dirname($reflection->getFileName()).'/config', + \dirname($filename).'/config', ]) ); @@ -47,7 +52,7 @@ public function load(array $configs, ContainerBuilder $container) foreach ($container->getDefinitions() as $name => $definition) { if (0 === strpos($name, 'rokka.command.') && $definition->hasTag('console.command')) { $tagAttributes = $definition->getTag('console.command')[0]; - if (array_key_exists('command', $tagAttributes)) { + if (\array_key_exists('command', $tagAttributes)) { if (interface_exists(CommandLoaderInterface::class)) { // since symfony 3.4 // when we drop support for Symfony < 3.4, we can drop the interface check and the else clause // and remove the command name from the command classes to only have them in the tag diff --git a/tests/Functional/Fixtures/AppKernel.php b/tests/Functional/Fixtures/AppKernel.php index 5f71df7..30b5686 100644 --- a/tests/Functional/Fixtures/AppKernel.php +++ b/tests/Functional/Fixtures/AppKernel.php @@ -7,7 +7,7 @@ class AppKernel extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { return [ new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), @@ -20,12 +20,12 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(__DIR__.'/app/config/config.yml'); } - public function getCacheDir() + public function getCacheDir(): string { return sys_get_temp_dir().'/rokka-client-bundle/cache'; } - public function getLogDir() + public function getLogDir(): string { return sys_get_temp_dir().'/rokka-client-bundle/logs'; }