From 2b99287737f8137fe12a8b4c56280dc049730a65 Mon Sep 17 00:00:00 2001
From: timonf <546813+timonf@users.noreply.github.com>
Date: Wed, 20 Oct 2021 14:02:39 +0200
Subject: [PATCH] build!: Upgrade to Symfony 4 and higher
- Introduce GitHub actions
- Add codestyle and static analysis checks
---
.editorconfig | 11 ++++
.github/workflows/test.yml | 56 +++++++++++++++++++
.scrutinizer.yml | 6 --
.travis.yml | 17 ------
LICENSE | 2 +-
README.md | 6 +-
composer.json | 29 ++++++----
phpcs.xml | 8 +++
phpstan.neon | 10 ++++
phpunit.xml.dist | 19 +++----
src/BrainbitsTranscoderBundle.php | 2 +-
.../BrainbitsTranscoderExtension.php | 7 ++-
.../Compiler/AddDecoderPass.php | 6 +-
.../Compiler/AddEncoderPass.php | 8 +--
src/DependencyInjection/Configuration.php | 7 ++-
tests/BrainbitsTranscoderBundleTest.php | 7 ++-
.../BrainbitsTranscoderExtensionTest.php | 16 ++++--
.../Compiler/AddDecoderPassTest.php | 18 ++++--
.../Compiler/AddEncoderPassTest.php | 18 ++++--
.../DependencyInjection/ConfigurationTest.php | 38 +++++--------
20 files changed, 185 insertions(+), 106 deletions(-)
create mode 100644 .editorconfig
create mode 100644 .github/workflows/test.yml
delete mode 100644 .scrutinizer.yml
delete mode 100644 .travis.yml
create mode 100644 phpcs.xml
create mode 100644 phpstan.neon
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..c79ce95
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,11 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = LF
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{dist,json,lock,neon,php,xml,yml}]
+indent_style = space
+indent_size = 4
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..fec588f
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,56 @@
+name: "Test"
+
+on:
+ push:
+ pull_request:
+ schedule:
+ - cron: '0 04 * * 1' # At 04:00 on Monday.
+
+jobs:
+ tests:
+ name: "Tests"
+
+ runs-on: ${{ matrix.operating-system }}
+
+ strategy:
+ matrix:
+ dependencies: ["lowest", "highest"]
+ php-version:
+ - "7.4"
+ - "8.0"
+ - "8.1"
+ operating-system: ["ubuntu-latest"]
+
+ steps:
+ - name: "Checkout"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
+ with:
+ coverage: "none"
+ php-version: "${{ matrix.php-version }}"
+
+ - name: "Cache dependencies"
+ uses: "actions/cache@v2"
+ with:
+ path: "~/.composer/cache"
+ key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}"
+ restore-keys: "php-${{ matrix.php-version }}-composer-"
+
+ - name: "Install lowest dependencies"
+ if: ${{ matrix.dependencies == 'lowest' }}
+ run: "composer update --prefer-lowest --prefer-dist --no-interaction --no-progress --no-suggest"
+
+ - name: "Install highest dependencies"
+ if: ${{ matrix.dependencies == 'highest' }}
+ run: "composer update --prefer-dist --no-interaction --no-progress --no-suggest"
+
+ - name: "Unit tests"
+ run: "vendor/bin/phpunit --colors"
+
+ - name: "Coding style"
+ run: "vendor/bin/phpcs --report=summary"
+
+ - name: "Static analysis"
+ run: "vendor/bin/phpstan --configuration=phpstan.neon --no-progress"
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
deleted file mode 100644
index da18520..0000000
--- a/.scrutinizer.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-inherit: true
-imports:
- - php
-tools:
- external_code_coverage:
- timeout: 600 # Timeout in seconds.
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 43fd3e9..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-language: php
-
-php:
- - 7.1
- - nightly
-
-matrix:
- allow_failures:
- - php:
- - nightly
-
-before_script: composer install
-
-script: vendor/bin/phpunit --coverage-clover=coverage.clover
-
-after_script:
- - sh -c 'if [ $(phpenv version-name) = "7.1" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;'
diff --git a/LICENSE b/LICENSE
index c75eb44..8bb93f2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2012-2016 brainbits GmbH (http://www.brainbits.net)
+Copyright (c) 2012-2021 brainbits GmbH (https://www.brainbits.net)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 1e09b76..3102f6d 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,8 @@
Transcoder Bundle
=================
-[![SensioLabsInsight](https://insight.sensiolabs.com/projects/c4ed9ba2-820a-4e27-8439-40133427ffdc/mini.png)](https://insight.sensiolabs.com/projects/c4ed9ba2-820a-4e27-8439-40133427ffdc)
-[![Build Status](https://travis-ci.org/brainbits/transcoder-bundle.svg?branch=master)](https://travis-ci.org/brainbits/transcoder-bundle)
-[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/brainbits/transcoder-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/brainbits/transcoder-bundle/?branch=master)
-[![Scrutinizer Code Coverage](https://scrutinizer-ci.com/g/brainbits/transcoder-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/brainbits/transcoder-bundle/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/brainbits/transcoder-bundle/v/stable.svg)](https://packagist.org/packages/brainbits/transcoder-bundle)
[![Total Downloads](https://poser.pugx.org/brainbits/transcoder-bundle/downloads.svg)](https://packagist.org/packages/brainbits/transcoder-bundle)
-[![Dependency Status](https://www.versioneye.com/php/brainbits:transcoder-bundle/master/badge.svg)](https://www.versioneye.com/php/brainbits:transcoder-bundle/master)
+[![Tests](https://github.com/brainbits/transcoder-bundle/actions/workflows/test.yml/badge.svg)](https://github.com/brainbits/transcoder-bundle/actions)
The Transcoder Bundle provides methods to transcode data.
diff --git a/composer.json b/composer.json
index b3d005b..5be0015 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "brainbits/transcoder-bundle",
"description": "Bundle for encoding, decoding transcoding data.",
"keywords": ["symfony", "encoder", "decoder"],
- "homepage": "http://brainbits.net",
+ "homepage": "https://www.brainbits.net",
"license": "MIT",
"authors": [
{
@@ -19,16 +19,22 @@
}
],
"require": {
- "php": "^7.1",
- "brainbits/transcoder": "^3.0"
+ "php": "^7.4|^8.0",
+ "brainbits/transcoder": "^4.0",
+ "symfony/config": ">=4.4.12",
+ "symfony/dependency-injection": ">=4.4.12",
+ "symfony/http-kernel": ">=4.4"
},
"require-dev": {
- "phpunit/phpunit": "^6.0",
- "symfony/config": "^2.8|^3.0",
- "symfony/dependency-injection": "^2.8|^3.0",
- "symfony/http-kernel": "^2.8|^3.0",
- "matthiasnoback/symfony-config-test": "^3.0",
- "matthiasnoback/symfony-dependency-injection-test": "^2.0"
+ "brainbits/phpcs-standard": "^5.0",
+ "brainbits/phpstan-rules": "^2.0",
+ "jangregor/phpstan-prophecy": "^0.8.1",
+ "matthiasnoback/symfony-config-test": "^4.3",
+ "matthiasnoback/symfony-dependency-injection-test": "^4.3",
+ "phpspec/prophecy-phpunit": "^2.0",
+ "phpstan/phpstan": "^0.12.99",
+ "phpunit/phpunit": "^9.5",
+ "squizlabs/php_codesniffer": "^3.6"
},
"autoload": {
"psr-4": { "Brainbits\\TranscoderBundle\\": "src/" }
@@ -36,9 +42,12 @@
"autoload-dev": {
"psr-4": { "Brainbits\\TranscoderBundle\\Tests\\": "tests/" }
},
+ "config": {
+ "sort-packages": true
+ },
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "4.0-dev"
}
},
"minimum-stability": "dev",
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..53da810
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+
+
+ src/
+ tests/
+
+
+
+
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..d5d090a
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,10 @@
+parameters:
+ level: max
+ paths:
+ - src
+ - tests
+ bootstrapFiles:
+ - vendor/autoload.php
+includes:
+ - vendor/jangregor/phpstan-prophecy/extension.neon
+ - vendor/brainbits/phpstan-rules/rules.neon
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 777126e..a02dd01 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,16 +1,11 @@
-
+
+
+
+
+ src
+
+
tests
-
-
- src
-
-
diff --git a/src/BrainbitsTranscoderBundle.php b/src/BrainbitsTranscoderBundle.php
index 957e939..e72c621 100644
--- a/src/BrainbitsTranscoderBundle.php
+++ b/src/BrainbitsTranscoderBundle.php
@@ -1,6 +1,6 @@
$configs
+ */
public function load(array $configs, ContainerBuilder $container): void
{
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('decoders.xml');
$loader->load('encoders.xml');
diff --git a/src/DependencyInjection/Compiler/AddDecoderPass.php b/src/DependencyInjection/Compiler/AddDecoderPass.php
index f11ffd4..9212b97 100644
--- a/src/DependencyInjection/Compiler/AddDecoderPass.php
+++ b/src/DependencyInjection/Compiler/AddDecoderPass.php
@@ -1,6 +1,6 @@
hasDefinition('brainbits.transcoder.decoder.resolver')) {
+ if ($container->hasDefinition('brainbits.transcoder.decoder.resolver') === false) {
return;
}
- $decoders = array();
+ $decoders = [];
foreach ($container->findTaggedServiceIds('transcoder.decoder') as $id => $attributes) {
$decoders[] = new Reference($id);
}
diff --git a/src/DependencyInjection/Compiler/AddEncoderPass.php b/src/DependencyInjection/Compiler/AddEncoderPass.php
index 2a3c969..1afcf66 100644
--- a/src/DependencyInjection/Compiler/AddEncoderPass.php
+++ b/src/DependencyInjection/Compiler/AddEncoderPass.php
@@ -1,6 +1,6 @@
hasDefinition('brainbits.transcoder.encoder.resolver')) {
+ if ($container->hasDefinition('brainbits.transcoder.encoder.resolver') === false) {
return;
}
- $encoders = array();
+ $encoders = [];
foreach ($container->findTaggedServiceIds('transcoder.encoder') as $id => $attributes) {
$encoders[] = new Reference($id);
}
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 246ad49..760e22d 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -1,6 +1,6 @@
root('brainbits_transcoder');
+ $treeBuilder = new TreeBuilder('brainbits_transcoder');
+ $rootNode = $treeBuilder->getRootNode();
+ // @phpstan-ignore-next-line
$rootNode
->children()
->arrayNode('decoder')
diff --git a/tests/BrainbitsTranscoderBundleTest.php b/tests/BrainbitsTranscoderBundleTest.php
index 13da34d..066bbe5 100644
--- a/tests/BrainbitsTranscoderBundleTest.php
+++ b/tests/BrainbitsTranscoderBundleTest.php
@@ -1,5 +1,7 @@
load();
@@ -33,7 +37,7 @@ public function testContainerHasDefaultParameters()
$this->assertContainerBuilderHasParameter('brainbits.transcoder.encoder.7z.executable', '7z');
}
- public function testContainerHasProvidedParameters()
+ public function testContainerHasProvidedParameters(): void
{
$this->load([
'encoder' => ['7z' => 'sevenZ'],
diff --git a/tests/DependencyInjection/Compiler/AddDecoderPassTest.php b/tests/DependencyInjection/Compiler/AddDecoderPassTest.php
index 902dd32..c8e5a8d 100644
--- a/tests/DependencyInjection/Compiler/AddDecoderPassTest.php
+++ b/tests/DependencyInjection/Compiler/AddDecoderPassTest.php
@@ -1,4 +1,7 @@
prophesize(ContainerBuilder::class);
$container->hasDefinition('brainbits.transcoder.decoder.resolver')->willReturn(false);
@@ -34,18 +40,18 @@ public function testProcessWithoutDefinition()
$pass->process($container->reveal());
- $this->assertNull($definition->getArgument(0)[0]);
+ $this->assertNull($definition->getArguments()[0]);
}
- public function testProcess()
+ public function testProcess(): void
{
$pass = new AddDecoderPass();
- $definition = new Definition(null, array(null));
+ $definition = new Definition(null, [null]);
$container = $this->prophesize(ContainerBuilder::class);
$container->hasDefinition('brainbits.transcoder.decoder.resolver')->willReturn(true);
- $container->findTaggedServiceIds('transcoder.decoder')->willReturn(array('test_id' => 'arg'));
+ $container->findTaggedServiceIds('transcoder.decoder')->willReturn(['test_id' => 'arg']);
$container->getDefinition('brainbits.transcoder.decoder.resolver')->willReturn($definition);
$pass->process($container->reveal());
diff --git a/tests/DependencyInjection/Compiler/AddEncoderPassTest.php b/tests/DependencyInjection/Compiler/AddEncoderPassTest.php
index b2e16e9..223d3b5 100644
--- a/tests/DependencyInjection/Compiler/AddEncoderPassTest.php
+++ b/tests/DependencyInjection/Compiler/AddEncoderPassTest.php
@@ -1,4 +1,7 @@
prophesize(ContainerBuilder::class);
$container->hasDefinition('brainbits.transcoder.encoder.resolver')->willReturn(false);
@@ -34,18 +40,18 @@ public function testProcessWithoutDefinition()
$pass->process($container->reveal());
- $this->assertNull($definition->getArgument(0)[0]);
+ $this->assertNull($definition->getArguments()[0]);
}
- public function testProcess()
+ public function testProcess(): void
{
$pass = new AddEncoderPass();
- $definition = new Definition(null, array(null));
+ $definition = new Definition(null, [null]);
$container = $this->prophesize(ContainerBuilder::class);
$container->hasDefinition('brainbits.transcoder.encoder.resolver')->willReturn(true);
- $container->findTaggedServiceIds('transcoder.encoder')->willReturn(array('test_id' => 'arg'));
+ $container->findTaggedServiceIds('transcoder.encoder')->willReturn(['test_id' => 'arg']);
$container->getDefinition('brainbits.transcoder.encoder.resolver')->willReturn($definition);
$pass->process($container->reveal());
diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php
index 85b0029..bd56047 100644
--- a/tests/DependencyInjection/ConfigurationTest.php
+++ b/tests/DependencyInjection/ConfigurationTest.php
@@ -1,4 +1,7 @@
assertConfigurationIsValid(
[
- [] // no values at all
+ [], // no values at all
]
);
}
- public function testDefaultValues()
+ public function testDefaultValues(): void
{
$this->assertProcessedConfigurationEquals(
[
[], // no values at all
],
[
- 'decoder' => [
- '7z' => '7z',
- ],
- 'encoder' => [
- '7z' => '7z',
- ],
+ 'decoder' => ['7z' => '7z'],
+ 'encoder' => ['7z' => '7z'],
]
);
}
- public function testProvidedValues()
+ public function testProvidedValues(): void
{
$this->assertProcessedConfigurationEquals(
[
[
- 'decoder' => [
- '7z' => 'sevenZ',
- ],
- 'encoder' => [
- '7z' => 'sevenZ',
- ],
+ 'decoder' => ['7z' => 'sevenZ'],
+ 'encoder' => ['7z' => 'sevenZ'],
],
],
[
- 'decoder' => [
- '7z' => 'sevenZ',
- ],
- 'encoder' => [
- '7z' => 'sevenZ',
- ],
+ 'decoder' => ['7z' => 'sevenZ'],
+ 'encoder' => ['7z' => 'sevenZ'],
]
);
}