Skip to content

Commit

Permalink
Merge pull request #6 from timonf/symfony-upgrade
Browse files Browse the repository at this point in the history
Upgrade to Symfony 4 and higher
  • Loading branch information
jojoguru authored Oct 25, 2021
2 parents 1822233 + 2b99287 commit e0f8afc
Show file tree
Hide file tree
Showing 20 changed files with 185 additions and 106 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 0 additions & 6 deletions .scrutinizer.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 19 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -19,26 +19,35 @@
}
],
"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/" }
},
"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",
Expand Down
8 changes: 8 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<file extension="php">src/</file>
<file extension="php">tests/</file>
<arg name="basepath" value="." />
<arg name="colors" />
<rule ref="Brainbits" />
</ruleset>
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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
19 changes: 7 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
syntaxCheck="true">
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuite name="transcoder-bundle">
<directory>tests</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion src/BrainbitsTranscoderBundle.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

/*
* This file is part of the brainbits transcoder bundle package.
Expand Down
7 changes: 5 additions & 2 deletions src/DependencyInjection/BrainbitsTranscoderExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

/*
* This file is part of the brainbits transcoder bundle package.
Expand All @@ -23,9 +23,12 @@
*/
class BrainbitsTranscoderExtension extends Extension
{
/**
* @param array<int, mixed> $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');
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/Compiler/AddDecoderPass.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

/*
* This file is part of the brainbits transcoder bundle package.
Expand All @@ -24,11 +24,11 @@ class AddDecoderPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (false === $container->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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyInjection/Compiler/AddEncoderPass.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

/*
* This file is part of the brainbits transcoder bundle package.
Expand All @@ -13,8 +13,8 @@

namespace Brainbits\TranscoderBundle\DependencyInjection\Compiler;

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

/**
Expand All @@ -24,11 +24,11 @@ class AddEncoderPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (false === $container->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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

/*
* This file is part of the brainbits transcoder bundle package.
Expand All @@ -23,9 +23,10 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('brainbits_transcoder');
$treeBuilder = new TreeBuilder('brainbits_transcoder');
$rootNode = $treeBuilder->getRootNode();

// @phpstan-ignore-next-line
$rootNode
->children()
->arrayNode('decoder')
Expand Down
7 changes: 6 additions & 1 deletion tests/BrainbitsTranscoderBundleTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the brainbits transcoder bundle package.
*
Expand All @@ -16,14 +18,17 @@
use Brainbits\TranscoderBundle\DependencyInjection\Compiler\AddEncoderPass;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Transcoder bundle test.
*/
class BrainbitsTranscoderBundleTest extends TestCase
{
public function testBuild()
use ProphecyTrait;

public function testBuild(): void
{
$bundle = new BrainbitsTranscoderBundle();

Expand Down
16 changes: 10 additions & 6 deletions tests/DependencyInjection/BrainbitsTranscoderExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the brainbits transcoder bundle package.
*
Expand All @@ -18,22 +21,23 @@
*/
class BrainbitsTranscoderExtensionTest extends AbstractExtensionTestCase
{
protected function getContainerExtensions()
/**
* @inheritDoc
*/
protected function getContainerExtensions(): array
{
return [
new BrainbitsTranscoderExtension()
];
return [new BrainbitsTranscoderExtension()];
}

public function testContainerHasDefaultParameters()
public function testContainerHasDefaultParameters(): void
{
$this->load();

$this->assertContainerBuilderHasParameter('brainbits.transcoder.decoder.7z.executable', '7z');
$this->assertContainerBuilderHasParameter('brainbits.transcoder.encoder.7z.executable', '7z');
}

public function testContainerHasProvidedParameters()
public function testContainerHasProvidedParameters(): void
{
$this->load([
'encoder' => ['7z' => 'sevenZ'],
Expand Down
Loading

0 comments on commit e0f8afc

Please sign in to comment.