Skip to content

Commit

Permalink
Migrate to PHP 8.0 and Symfony 6.0
Browse files Browse the repository at this point in the history
Signed-off-by: Ingo Pfennigstorf <[email protected]>
  • Loading branch information
ipf committed Aug 31, 2022
1 parent 74eff18 commit aefed68
Show file tree
Hide file tree
Showing 73 changed files with 1,091 additions and 1,998 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI-coverage

on: [ push ]

jobs:
build-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- uses: php-actions/composer@v6
with:
php_version: "8.0"
php_extensions: fileinfo gd xml zip
version: 2

- name: PHPUnit Tests
uses: php-actions/phpunit@v3
with:
version: 9
php_version: 8.0
configuration: phpunit.xml.dist
php_extensions: fileinfo gd xml zip
args: -c phpunit.coverage.xml.dist --coverage-clover var/coverage/coverage.xml
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/var/
/vendor/
/.php_cs
/.php_cs.cache
/.php-cs-fixer.cache
/composer.lock
/phpunit.coverage.xml
/phpunit.xml
/.phpunit.result.cache
8 changes: 4 additions & 4 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
// one should use PHPUnit methods to set up expected exception instead of annotations
'general_phpdoc_annotation_remove' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'],
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']],
'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_short_echo_tag' => true,
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
'echo_tag_syntax' => ['format' => 'long'],
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
Expand Down
1 change: 1 addition & 0 deletions .php-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0
25 changes: 12 additions & 13 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
build:
environment:
php:
version: '7.0'
tests:
override:
-
command: vendor/bin/simple-phpunit -c phpunit.coverage.xml.dist
coverage:
file: var/coverage/coverage.xml
format: clover
environment:
php:
version: '8.0'
tests:
override:
- command: vendor/bin/phpunit -c phpunit.coverage.xml.dist
coverage:
file: var/coverage/coverage.xml
format: clover

checks:
php: true
php: true

filter:
excluded_paths:
- tests/*
excluded_paths:
- tests/*
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TwigSpreadsheetBundle
# TwigSpreadsheetBundle (PHP 8.0, Symfony 6.0 & Twig 3.0)

[![Teavis CI: Build Status](https://travis-ci.org/MewesK/TwigSpreadsheetBundle.png?branch=master)](https://travis-ci.org/MewesK/TwigSpreadsheetBundle)
[![Scrutinizer: Code Quality](https://scrutinizer-ci.com/g/MewesK/TwigSpreadsheetBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/MewesK/TwigSpreadsheetBundle/?branch=master)
Expand All @@ -7,6 +7,13 @@

This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.

This repository is a continuation of the original TwigSpreadsheetBundle.

A list of differences from the original TwigSpreadsheetBundle:
- added support for Symfony 6 and Twig 3
- removed RequestListener.php
- removed functional tests for controller functionality

## Features

* Easy to use Twig integration including ``macro`` and ``include`` support
Expand All @@ -29,8 +36,9 @@ The following software is required to use PhpSpreadsheet/TwigSpreadsheetBundle.

**Required by this bundle:**

* PHP 7.0 or newer
* Symfony 3.2 or newer
* PHP 8.0 or newer
* Symfony 6.0 or newer
* Twig 3.0 or newer

**Required by PhpSpreadsheet:**

Expand Down
33 changes: 19 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "technetium/twig-spreadsheet-bundle",
"name": "subugoe/twig-spreadsheet-bundle",
"type": "symfony-bundle",
"description": "This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig. Forked by technetium to get bugfixes in",
"keywords": ["excel","phpexcel","spreadsheet","phpspreadsheet","twig","symfony"],
"homepage": "https://github.com/technetium/TwigSpreadsheetBundle",
"description": "This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.",
"keywords": ["excel","phpexcel","spreadsheet","phpspreadsheet","twig","twig3","symfony","symfony6"],
"homepage": "https://github.com/subugoe/TwigSpreadsheetBundle",
"license": "MIT",
"authors": [
{
Expand All @@ -12,21 +12,26 @@
},
{
"name": "Community Contributors",
"homepage": "https://github.com/technetium/TwigSpreadsheetBundle/graphs/contributors"
"homepage": "https://github.com/MewesK/TwigSpreadsheetBundle/graphs/contributors"
}
],
"require": {
"php": ">=7.0",
"symfony/framework-bundle": "~3.2|~4.0",
"twig/twig": "~2.0",
"phpoffice/phpspreadsheet": "~1.8.0"
"php": "^8.0",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-xml": "*",
"ext-zip": "*",
"symfony/framework-bundle": "^6.0",
"twig/twig": "^3.0",
"phpoffice/phpspreadsheet": "^1.3"
},
"require-dev": {
"symfony/symfony": "~3.2|~4.0",
"sensio/framework-extra-bundle": "~3.2|~4.0",
"symfony/phpunit-bridge": "~4.0",
"phpunit/phpunit": "^6.5",
"mpdf/mpdf": "~7.0"
"sensio/framework-extra-bundle": "^6.0",
"phpunit/phpunit": "^9.5",
"mpdf/mpdf": "~8.0",
"friendsofphp/php-cs-fixer": "^3",
"rector/rector": "^0.14.0",
"symfony/twig-bridge": "^6.0"
},
"suggest": {
"mpdf/mpdf": "Add support for PDF rendering, requires ~7.0"
Expand Down
45 changes: 20 additions & 25 deletions phpunit.coverage.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.0/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./vendor/autoload.php"
>
<testsuites>
<testsuite name="MewesKTwigSpreadsheetBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src</directory>
<exclude>
<directory>./src/Resources</directory>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="./var/coverage/coverage.xml"/>
<log type="coverage-html" target="./var/coverage/report" lowUpperBound="35" highLowerBound="70"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php">
<coverage>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./src/Resources</directory>
<directory>./src/DependencyInjection</directory>
</exclude>
<report>
<clover outputFile="./var/coverage/coverage.xml"/>
<html outputDirectory="./var/coverage/report" lowUpperBound="35" highLowerBound="70"/>
</report>
</coverage>
<testsuites>
<testsuite name="MewesKTwigSpreadsheetBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>
41 changes: 17 additions & 24 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.0/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./vendor/autoload.php"
>
<php>
<env name="SYMFONY_PHPUNIT_VERSION" value="6.5"/>
</php>

<testsuites>
<testsuite name="MewesKTwigSpreadsheetBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src</directory>
<exclude>
<directory>./src/Resources</directory>
</exclude>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php">
<coverage>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./src/Resources</directory>
</exclude>
</coverage>
<php>
<env name="SYMFONY_PHPUNIT_VERSION" value="9.3"/>
</php>
<testsuites>
<testsuite name="MewesKTwigSpreadsheetBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
24 changes: 24 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->importShortClasses(false);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
SetList::CODING_STYLE,
SetList::CODE_QUALITY,
]);
};
36 changes: 30 additions & 6 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* Class Configuration.
*/
class Configuration implements ConfigurationInterface
{
/**
Expand All @@ -17,14 +14,14 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('mewes_k_twig_spreadsheet');
$treeBuilder = new TreeBuilder('mewes_k_twig_spreadsheet');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
->booleanNode('pre_calculate_formulas')
->defaultTrue()
->info('Disabling formula calculations can improve the performance but the resulting documents won\'t immediately show formula results in external programs.')
->info("Disabling formula calculations can improve the performance but the resulting documents won't immediately show formula results in external programs.")
->end()
->arrayNode('cache')
->addDefaultsIfNotSet()
Expand All @@ -41,6 +38,33 @@ public function getConfigTreeBuilder()
->end()
->end()
->end()
->arrayNode('csv_writer')
->addDefaultsIfNotSet()
->info('See PhpOffice\PhpSpreadsheet\Writer\Csv.php for more information.')
->children()
->scalarNode('delimiter')
->defaultValue(',')
->end()
->scalarNode('enclosure')
->defaultValue('"')
->end()
->booleanNode('excel_compatibility')
->defaultFalse()
->end()
->booleanNode('include_separator_line')
->defaultFalse()
->end()
->scalarNode('line_ending')
->defaultValue(\PHP_EOL)
->end()
->integerNode('sheet_index')
->defaultValue(0)
->end()
->booleanNode('use_bom')
->defaultFalse()
->end()
->end()
->end()
->end();

return $treeBuilder;
Expand Down
Loading

0 comments on commit aefed68

Please sign in to comment.