Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/drop support of php7 #48

Merged
merged 19 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fbed9ba
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format
Chris8934 Jan 4, 2023
db45a48
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
6f06ffd
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
1fb9fc7
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
13fc94a
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
a88424f
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
61d2ba4
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
d7ef3dc
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
1d860c7
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 4, 2023
fbb7198
Update Tests/bootstrap.php
Chris53897 Jan 5, 2023
c135ea2
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 5, 2023
01c9d4a
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 5, 2023
80e61fd
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 5, 2023
273cca7
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 5, 2023
1782570
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 5, 2023
c9ffb05
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 5, 2023
0698eb6
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 5, 2023
0aad17e
Update composer.json
Chris53897 Jan 6, 2023
19bbe87
feat: drop support of php 7, migrate phpunit.xml.dist to v. 9 format,…
Chris8934 Jan 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
maxbaldanza marked this conversation as resolved.
Show resolved Hide resolved
"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>