Skip to content

Commit

Permalink
Drop support of PHP7 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris53897 authored Jan 6, 2023
1 parent 887fa15 commit 2665bcb
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 145 deletions.
57 changes: 33 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ jobs:
run:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php-versions: 7.3
symfony-versions: 4.4.*
- php-versions: 7.4
symfony-versions: 5.4.*
- php-versions: 8.0
symfony-versions: 5.4.*
- php-versions: 8.0
symfony-versions: 6.0.*
- php-versions: 8.1
symfony-versions: 6.2.*
- php-versions: 8.2
symfony-versions: 6.2.*
- php-version: 8.0
symfony-version: 4.4.*
stability: prefer-lowest
- php-version: 8.0
symfony-version: 4.4.*
stability: prefer-stable
- php-version: 8.0
symfony-version: 5.4.*
stability: prefer-stable
- php-version: 8.0
symfony-version: 5.4.*
stability: prefer-stable
- php-version: 8.0
symfony-version: 6.0.*
stability: prefer-stable
- php-version: 8.1
symfony-version: 6.2.*
stability: prefer-stable
- php-version: 8.2
symfony-version: 6.2.*
stability: prefer-stable

name: PHP ${{ matrix.php-versions }} Test with Symfony ${{ matrix.symfony-versions }}
name: PHP ${{ matrix.php-version }} Test with Symfony ${{ matrix.symfony-version }} and ${{ matrix.stability }}
steps:
# —— Setup Github actions 🐙 —————————————————————————————————————————————
- name: Checkout
Expand All @@ -31,7 +41,7 @@ jobs:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, ctype, iconv, intl
coverage: xdebug #optional

Expand All @@ -54,20 +64,19 @@ jobs:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ matrix.symfony-versions }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ matrix.symfony-versions }}-
key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ matrix.symfony-version }}--${{ matrix.stability }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ matrix.symfony-version }}--${{ matrix.stability }}-

- name: Validate Composer.json
run: composer validate

- name: Fix symfony version for symfony/framework
run: composer require --no-update symfony/framework-bundle:"${{ matrix.symfony-versions }}";

- name: Fix symfony version for symfony/console
run: composer require --no-update symfony/console:"${{ matrix.symfony-versions }}";

- name: Install Composer dependencies
run: composer update --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Install dependencies
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer update --no-interaction --prefer-dist --optimize-autoloader --${{ matrix.stability }}
## —— Test ✅ ———————————————————————————————————————————————————————————
- name: Run Tests
Expand Down
60 changes: 17 additions & 43 deletions Annotation/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,21 @@
*/
class Cron extends Annotation
{
/** @var string */
public $minute;

/** @var string */
public $hour;

/** @var string */
public $dayOfMonth;

/** @var string */
public $month;

/** @var string */
public $dayOfWeek;

/** @var string */
public $comment;

/** @var string */
public $logFile;

/** @var string */
public $errorFile;

/**
* If true add /dev/null.
*
* @var boolean
*/
public $noLogs;

/**
* Which server should this cron job run on.
*
* @var string
*/
public $server;

/** @var string */
public $params;

/** @var string */
public $executor;
public string $minute;
public string $hour;
public ?string $dayOfMonth = null;
public ?string $month = null;
public ?string $dayOfWeek = null;
public ?string $comment = null;
public ?string $logFile = null;
public ?string $errorFile = null;

// If true add /dev/null.
public ?bool $noLogs = null;

// Which server should this cron job run on.
public string $server;

public ?string $params = null;
public ?string $executor = null;
}
1 change: 0 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\HttpKernel\Kernel;

class Configuration implements ConfigurationInterface
{
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/MyBuilderCronosExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class MyBuilderCronosExtension extends Extension
{
/** @noinspection PhpUnhandledExceptionInspection */
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration(new Configuration(), $configs);
Expand Down
12 changes: 4 additions & 8 deletions Exporter/AnnotationCronExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ class AnnotationCronExporter
{
public const ALL_SERVERS = 'all';

/** @var Reader */
private $annotationsReader;

/** @var array */
private $config = [];
private array $config = [];

public function __construct(Reader $annotationsReader)
{
$this->annotationsReader = $annotationsReader;
}
public function __construct(private Reader $annotationsReader)
{}

public function setConfig(array $config): void
{
Expand All @@ -30,6 +25,7 @@ public function setConfig(array $config): void

/**
* Export the cron for the given commands and server
* @param Command[] $commands
*/
public function export(array $commands, array $options): CronFormatter
{
Expand Down
9 changes: 2 additions & 7 deletions Exporter/AnnotationLineConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@

class AnnotationLineConfigurator
{
/** @var Job */
private $line;

public function __construct(Job $line)
{
$this->line = $line;
}
public function __construct(private Job $line)
{}

public function configureFrom(CronAnnotation $annotation): Job
{
Expand Down
11 changes: 3 additions & 8 deletions Exporter/ArrayHeaderConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@
class ArrayHeaderConfigurator
{
/** @var string[] */
private $configFields = ['mailto', 'path', 'shell', 'encoding', 'contentType', 'timezone'];
private array $configFields = ['mailto', 'path', 'shell', 'encoding', 'contentType', 'timezone'];

/** @var Header */
private $header;

public function __construct(Header $header)
{
$this->header = $header;
}
public function __construct(private Header $header)
{}

public function configureFrom(array $config): Header
{
Expand Down
4 changes: 1 addition & 3 deletions Tests/Command/DumpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

class DumpCommandTest extends CronosTestCase
{
/** @var Command */
private $command;
private Command $command;

protected function setUp(): void
{
Expand All @@ -35,7 +34,6 @@ protected function tearDown(): void
}

/**
* @test
* @dataProvider environmentDumps
*/
public function test_dump_should_be_as_expected(string $expectedOutput, array $input): void
Expand Down
3 changes: 2 additions & 1 deletion Tests/CronosTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace MyBuilder\Bundle\CronosBundle\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use MyBuilder\Bundle\CronosBundle\Tests\Fixtures\app\AppKernel;

class CronosTestCase extends WebTestCase
{
protected static function getKernelClass(): string
{
require_once __DIR__ . '/Fixtures/app/AppKernel.php';

return 'MyBuilder\Bundle\CronosBundle\Tests\Fixtures\app\AppKernel';
return AppKernel::class;
}
}
13 changes: 3 additions & 10 deletions Tests/DependencyInjection/MyBuilderCronosExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@

class MyBuilderCronosExtensionTest extends TestCase
{
/** @var MyBuilderCronosExtension */
private $loader;

/** @var ContainerBuilder */
private $container;
private MyBuilderCronosExtension $loader;
private ContainerBuilder $container;

protected function setUp(): void
{
Expand Down Expand Up @@ -73,10 +70,6 @@ private function getConfig(string $fileName): array

$config = Yaml::parse(file_get_contents($file));

if (null === $config) {
return [];
}

return $config;
return $config ?? [];
}
}
1 change: 1 addition & 0 deletions Tests/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function registerBundles(): iterable

public function registerContainerConfiguration(LoaderInterface $loader): void
{
/** @noinspection PhpUnhandledExceptionInspection */
$loader->load(__DIR__ . '/config/' . $this->getEnvironment() . '.yml');
}
}
4 changes: 3 additions & 1 deletion Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
$loader = require __DIR__ . '/../vendor/autoload.php';

AnnotationRegistry::registerLoader('class_exists');
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}

return $loader;
}
Expand Down
23 changes: 11 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
}
],
"require": {
"php": ">=7.3",
"mybuilder/cronos": "~3.0",
"doctrine/annotations": "1.*",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
"symfony/property-access": "^4.4 || ^5.0 || ^6.0",
"symfony/yaml": "^4.4 || ^5.0 || ^6.0"
"php": ">=8.0.2",
"mybuilder/cronos": "^3.0 || ^4.0",
"doctrine/annotations": "^1.11",
"symfony/console": "^4.4.20 || ^5.4 || ^6.0",
"symfony/config": "^4.4.20 || ^5.4 || ^6.0",
"symfony/dependency-injection": "^4.4.20 || ^5.4 || ^6.0",
"symfony/framework-bundle": "^4.4.20 || ^5.4 || ^6.0",
"symfony/http-kernel": "^4.4.20 || ^5.4 || ^6.0",
"symfony/property-access": "^4.4.20 || ^5.4 || ^6.0",
"symfony/yaml": "^4.4.20 || ^5.4 || ^6.0"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"phpunit/phpunit": "~9.0"
"phpunit/phpunit": "^9.5.27"
},
"autoload": {
"psr-4": { "MyBuilder\\Bundle\\CronosBundle\\": "" }
Expand Down
52 changes: 25 additions & 27 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true"
bootstrap="Tests/bootstrap.php">

<testsuites>
<testsuite name="Project Test Suite">
<directory>Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true"
bootstrap="Tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<coverage>
<include>
<directory>./</directory>
</include>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Project Test Suite">
<directory>Tests</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit 2665bcb

Please sign in to comment.