Skip to content

Commit

Permalink
Merge pull request #33 from Chris53897/feature/drop-sopport-of-symfony-3
Browse files Browse the repository at this point in the history
feat: drop support of symfony < 4.4, drop support of php 7
  • Loading branch information
maxbaldanza authored Jan 3, 2023
2 parents 069e0ae + 1ebda69 commit 1019a39
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 148 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ jobs:
strategy:
matrix:
include:
- php-versions: 7.3
symfony-versions: 3.4.*
- php-versions: 7.4
- php-versions: 8.0
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: 4.4.*
- php-versions: 8.1
symfony-versions: 5.4.*
- php-versions: 8.1
symfony-versions: 6.2.*
- php-versions: 8.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Easily configure cron through PHP.

If you use Symfony 3/4/5/6, you could use our [cool bundle](https://github.com/mybuilder/cronos-bundle) in order to configure your app jobs through fancy annotations!
If you use Symfony 4/5/6, you could use our [cool bundle](https://github.com/mybuilder/cronos-bundle) in order to configure your app jobs through fancy annotations!

## Setup and Configuration

Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
}
],
"require": {
"php": ">=7.3",
"symfony/process": "^3.4|^4.4|^5.4|^6.0"
"php": ">=8.0.2",
"symfony/process": "^4.4|^5.4|^6.0"
},
"suggest": {
"symfony/filesystem": "Allows using Symfony Filesystem"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"symfony/filesystem": "^3.4|^4.4|^5.4|^6.0",
"symfony/filesystem": "^4.4|^5.4|^6.0",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": { "MyBuilder\\Cronos\\": "src" }
},
"autoload-dev": {
"psr-4": { "MyBuilder\\Cronos\\Tests\\": "tests/" }
},
"config": {
"bin-dir": "bin"
},
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="./vendor/autoload.php">

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

<filter>
<whitelist>
<directory>./src</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="./vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
9 changes: 2 additions & 7 deletions src/Formatter/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

class Comment
{
/** @var string */
private $comment;

public function __construct(string $comment)
{
$this->comment = $comment;
}
public function __construct(private string $comment)
{}

public function format(): string
{
Expand Down
5 changes: 2 additions & 3 deletions src/Formatter/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

class Cron
{
/** @var Header */
private $header;
private ?Header $header = null;

/** @var mixed[] */
private $lines = [];
private array $lines = [];

public function header(): Header
{
Expand Down
38 changes: 10 additions & 28 deletions src/Formatter/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,16 @@

class Header
{
/** @var Cron */
private $cron;

/** @var string */
private $path;

/** @var string */
private $mailTo;

/** @var string */
private $home;

/** @var string */
private $shell;

/** @var string */
private $contentType;

/** @var string */
private $encoding;

/** @var string */
private $timezone;

public function __construct(Cron $cron)
{
$this->cron = $cron;
}
private ?string $path = null;
private ?string $mailTo = null;
private ?string $home = null;
private ?string $shell = null;
private ?string $contentType = null;
private ?string $encoding = null;
private ?string $timezone = null;

public function __construct(private Cron $cron)
{}

/**
* Works just like the shell PATH, but it does not inherit from your environment.
Expand Down
17 changes: 3 additions & 14 deletions src/Formatter/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,12 @@

class Job
{
/** @var Cron */
private $cron;
private Time $time;
private Output $output;

/** @var Time */
private $time;

/** @var string */
private $command;

/** @var Output */
private $output;

public function __construct(string $command, Cron $cron)
public function __construct(private string $command, private Cron $cron)
{
$this->cron = $cron;
$this->time = new Time;
$this->command = $command;
$this->output = new Output;
}

Expand Down
20 changes: 5 additions & 15 deletions src/Formatter/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,11 @@
class Output
{
public const NO_FILE = '/dev/null';

/** @var bool */
private $noOutput = false;

/** @var string */
private $stdOutFile;

/** @var bool */
private $stdOutAppend;

/** @var string */
private $stdErrFile;

/** @var bool */
private $stdErrAppend;
private bool $noOutput = false;
private ?string $stdOutFile = null;
private bool $stdOutAppend = false;
private ?string $stdErrFile = null;
private bool $stdErrAppend = false;

public function suppressOutput(): self
{
Expand Down
21 changes: 6 additions & 15 deletions src/Formatter/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,11 @@ class Time
public const FORMAT = '%-4s %-4s %-4s %-4s %-4s ';
public const WILDCARD_TIME = '*';

/** @var string */
private $minute = self::WILDCARD_TIME;

/** @var string */
private $hour = self::WILDCARD_TIME;

/** @var string */
private $dayOfMonth = self::WILDCARD_TIME;

/** @var string */
private $month = self::WILDCARD_TIME;

/** @var string */
private $dayOfWeek = self::WILDCARD_TIME;
private string $minute = self::WILDCARD_TIME;
private string $hour = self::WILDCARD_TIME;
private string $dayOfMonth = self::WILDCARD_TIME;
private string $month = self::WILDCARD_TIME;
private string $dayOfWeek = self::WILDCARD_TIME;

/**
* @param string $value 0-59 or a list or range
Expand Down Expand Up @@ -98,7 +89,7 @@ public function format(): string

private function parse(string $value): string
{
if (0 === \strpos($value, '/')) {
if (\str_starts_with($value, '/')) {
return self::WILDCARD_TIME . $value;
}

Expand Down
19 changes: 4 additions & 15 deletions src/Updater/CommandCronManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@

class CommandCronManipulator implements CronManipulator
{
/** @var ProcessRunner */
private $processRunner;

/** @var FileSystem */
private $fileSystem;

/** @var string */
private $cronCommand;

public function __construct(ProcessRunner $processRunner, FileSystem $fileSystem, string $cronCommand = 'crontab')
{
$this->processRunner = $processRunner;
$this->fileSystem = $fileSystem;
$this->cronCommand = $cronCommand;
}
public function __construct(private ProcessRunner $processRunner,
private FileSystem $fileSystem,
private string $cronCommand = 'crontab')
{}

public function replace(string $contents): void
{
Expand Down
9 changes: 2 additions & 7 deletions src/Updater/CronUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ class CronUpdater
public const KEY_BEGIN = '# KEY %key%';
public const KEY_END = '# END';

/** @var CronManipulator */
private $cronManipulator;

public function __construct(CronManipulator $cronManipulator)
{
$this->cronManipulator = $cronManipulator;
}
public function __construct(private CronManipulator $cronManipulator)
{}

public static function createDefault(): self
{
Expand Down
3 changes: 1 addition & 2 deletions src/Updater/SymfonyFileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

class SymfonyFileSystem implements FileSystem
{
/** @var FileSystemHelper; */
private $filesystem;
private FileSystemHelper $filesystem;

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Formatter/CronTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class CronTest extends TestCase
{
private $cron;
private Cron $cron;

protected function setUp(): void
{
Expand Down
7 changes: 3 additions & 4 deletions tests/Updater/CronUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

class CronUpdaterTest extends TestCase
{
private $manipulatorStub;
private $updater;
private CronManipulatorStub $manipulatorStub;
private CronUpdater $updater;

protected function setUp(): void
{
Expand Down Expand Up @@ -109,8 +109,7 @@ public function shouldReplaceKeyIfExist(): void

class CronManipulatorStub implements CronManipulator
{
/** @var string */
public $contents;
public string $contents;

public function replace(string $contents): void
{
Expand Down

0 comments on commit 1019a39

Please sign in to comment.