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

Drop PHP v7.4 support #38

Merged
merged 3 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 1 addition & 9 deletions .github/workflows/code_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
strategy:
matrix:
php:
- '7.4'
- '8.0'
- '8.1'
dependencies:
Expand All @@ -18,13 +17,6 @@ jobs:
- "~v4.4.30"
- "~v5.4.0"
- "~v6.0.0"
exclude:
- php: '7.4'
dependencies: 'low'
symfony_version: "~v6.0.0"
- php: '7.4'
dependencies: 'high'
symfony_version: "~v6.0.0"
include:
- php: '8.1'
dependencies: 'low'
Expand Down Expand Up @@ -63,7 +55,7 @@ jobs:
strategy:
matrix:
php:
- '7.4'
- '8.0'
vars:
- dependencies: "high"
composerExtraFlags: ''
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Make sure current working directory is "tests"
$filesystem = new \Crunz\Filesystem\Filesystem();
if (\strpos($filesystem->getCwd(), 'tests') !== false) {
if (\str_contains($filesystem->getCwd(), 'tests')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion composer-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
continue;
}

if (false === \mb_strpos($packageName, 'symfony/')) {
if (!\str_contains($packageName, 'symfony/')) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.0",
"composer-runtime-api": "^2.0",
"dragonmantank/cron-expression": "^3.1",
"laravel/serializable-closure": "^1.0",
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ parameters:
count: 1
path: src/EventRunner.php

-
message: "#^Only booleans are allowed in a ternary operator condition, string\\|null given\\.$#"
count: 2
path: src/EventRunner.php

-
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
count: 2
Expand Down
21 changes: 12 additions & 9 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

namespace Crunz;

use Crunz\Console\Command\ConfigGeneratorCommand;
use Crunz\Console\Command\ScheduleListCommand;
use Crunz\Console\Command\ScheduleRunCommand;
use Crunz\Console\Command\TaskGeneratorCommand;
use Crunz\EnvFlags\EnvFlags;
use Crunz\Path\Path;
use Crunz\UserInterface\Cli\DebugTaskCommand;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Console\Application as SymfonyApplication;
Expand All @@ -30,33 +35,31 @@ class Application extends SymfonyApplication
// It takes an optional argument which is the source directory for tasks
// If the argument is not provided, the default in the configuratrion file
// will be considered as the source path
\Crunz\Console\Command\ScheduleRunCommand::class,
ScheduleRunCommand::class,

// This command (vendor/bin/schedule:list) lists the scheduled events in different task files
// Just like schedule:run it gets the :source argument
\Crunz\Console\Command\ScheduleListCommand::class,
ScheduleListCommand::class,

// This command generates a task from the command-line
// This is often useful when you want to create a task file and start
// adding tasks to it.
\Crunz\Console\Command\TaskGeneratorCommand::class,
TaskGeneratorCommand::class,

// The modify the configuration, the user's own copy should be modified
// This command creates a configuration file in Crunz installation directory
\Crunz\Console\Command\ConfigGeneratorCommand::class,
ConfigGeneratorCommand::class,

// This command is used by Crunz itself for running serialized closures
// It accepts an argument which is the serialized form of the closure to run.
UserInterface\Cli\ClosureRunCommand::class,

// Debug task command
\Crunz\UserInterface\Cli\DebugTaskCommand::class,
DebugTaskCommand::class,
];

/** @var Container */
private $container;
/** @var EnvFlags */
private $envFlags;
private Container $container;
private EnvFlags $envFlags;

public function __construct(string $appName, string $appVersion)
{
Expand Down
6 changes: 1 addition & 5 deletions src/Application/Query/TaskInformation/TaskInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@

final class TaskInformation
{
/** @var TaskNumber */
private $taskNumber;

public function __construct(TaskNumber $taskNumber)
public function __construct(private TaskNumber $taskNumber)
{
$this->taskNumber = $taskNumber;
}

public function taskNumber(): TaskNumber
Expand Down
33 changes: 7 additions & 26 deletions src/Application/Query/TaskInformation/TaskInformationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,14 @@

final class TaskInformationHandler
{
/** @var Timezone */
private $timezone;
/** @var ConfigurationInterface */
private $configuration;
/** @var CollectionInterface */
private $taskCollection;
/** @var LoaderInterface */
private $taskLoader;
/** @var ScheduleFactory */
private $scheduleFactory;
/** @var CronExpressionFactoryInterface */
private $cronExpressionFactory;

public function __construct(
Timezone $timezone,
ConfigurationInterface $configuration,
CollectionInterface $taskCollection,
LoaderInterface $taskLoader,
ScheduleFactory $scheduleFactory,
CronExpressionFactoryInterface $cronExpressionFactory
private Timezone $timezone,
private ConfigurationInterface $configuration,
private CollectionInterface $taskCollection,
private LoaderInterface $taskLoader,
private ScheduleFactory $scheduleFactory,
private CronExpressionFactoryInterface $cronExpressionFactory
) {
$this->timezone = $timezone;
$this->configuration = $configuration;
$this->taskCollection = $taskCollection;
$this->taskLoader = $taskLoader;
$this->scheduleFactory = $scheduleFactory;
$this->cronExpressionFactory = $cronExpressionFactory;
}

public function handle(TaskInformation $taskInformation): TaskInformationView
Expand Down Expand Up @@ -104,7 +85,7 @@ private function getEventProperties(Event $event, array $properties): array
$values = [];
foreach ($properties as $property) {
if (!\property_exists($event, $property)) {
$class = \get_class($event);
$class = $event::class;

throw new \RuntimeException("Property '{$property}' doesn't exists in '{$class}' class.");
}
Expand Down
35 changes: 8 additions & 27 deletions src/Application/Query/TaskInformation/TaskInformationView.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,23 @@

final class TaskInformationView
{
/** @var string|object */
private $command;
/** @var string */
private $description;
/** @var string */
private $cronExpression;
/** @var \DateTimeZone|null */
private $timeZone;
/** @var \DateTimeZone */
private $configTimeZone;
/** @var \DateTimeImmutable[] */
private $nextRuns;
/** @var bool */
private $preventOverlapping;
private array $nextRuns;

/** @param string|object $command */
public function __construct(
$command,
string $description,
string $cronExpression,
bool $preventOverlapping,
?\DateTimeZone $timeZone,
\DateTimeZone $configTimeZone,
private string|object $command,
private string $description,
private string $cronExpression,
private bool $preventOverlapping,
private ?\DateTimeZone $timeZone,
private \DateTimeZone $configTimeZone,
\DateTimeImmutable ...$nextRuns
) {
$this->command = $command;
$this->description = $description;
$this->cronExpression = $cronExpression;
$this->timeZone = $timeZone;
$this->configTimeZone = $configTimeZone;
$this->nextRuns = $nextRuns;
$this->preventOverlapping = $preventOverlapping;
}

/** @return string|object */
public function command()
public function command(): string|object
{
return $this->command;
}
Expand Down
12 changes: 4 additions & 8 deletions src/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ final class Configuration implements ConfigurationInterface
{
/** @var array<string,mixed> */
private $config;
/** @var ConfigurationParserInterface */
private $configurationParser;
/** @var FilesystemInterface */
private $filesystem;

public function __construct(ConfigurationParserInterface $configurationParser, FilesystemInterface $filesystem)
{
$this->configurationParser = $configurationParser;
$this->filesystem = $filesystem;
public function __construct(
private ConfigurationParserInterface $configurationParser,
private FilesystemInterface $filesystem
) {
}

/**
Expand Down
27 changes: 6 additions & 21 deletions src/Configuration/ConfigurationParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,19 @@

final class ConfigurationParser implements ConfigurationParserInterface
{
/** @var ConfigurationInterface */
private $configurationDefinition;
/** @var Processor */
private $definitionProcessor;
/** @var ConsoleLoggerInterface */
private $consoleLogger;
/** @var FileParser */
private $fileParser;
/** @var FilesystemInterface */
private $filesystem;

public function __construct(
ConfigurationInterface $configurationDefinition,
Processor $definitionProcessor,
FileParser $fileParser,
ConsoleLoggerInterface $consoleLogger,
FilesystemInterface $filesystem
private ConfigurationInterface $configurationDefinition,
private Processor $definitionProcessor,
private FileParser $fileParser,
private ConsoleLoggerInterface $consoleLogger,
private FilesystemInterface $filesystem
) {
$this->consoleLogger = $consoleLogger;
$this->configurationDefinition = $configurationDefinition;
$this->definitionProcessor = $definitionProcessor;
$this->fileParser = $fileParser;
$this->filesystem = $filesystem;
}

/** {@inheritdoc} */
public function parseConfig(): array
{
$configFile = null;
$parsedConfig = [];
$configFileParsed = false;

Expand Down
6 changes: 1 addition & 5 deletions src/Configuration/FileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@

class FileParser
{
/** @var Yaml */
private $yamlParser;

public function __construct(Yaml $yamlParser)
public function __construct(private Yaml $yamlParser)
{
$this->yamlParser = $yamlParser;
}

/**
Expand Down
19 changes: 4 additions & 15 deletions src/Console/Command/ConfigGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,11 @@ final class ConfigGeneratorCommand extends Command
{
public const CONFIG_FILE_NAME = 'crunz.yml';

/** @var ProviderInterface */
private $timezoneProvider;
/** @var Filesystem */
private $symfonyFilesystem;
/** @var FilesystemInterface */
private $filesystem;

public function __construct(
ProviderInterface $timezoneProvider,
Filesystem $symfonyFilesystem,
FilesystemInterface $filesystem
private ProviderInterface $timezoneProvider,
private Filesystem $symfonyFilesystem,
private FilesystemInterface $filesystem
) {
$this->timezoneProvider = $timezoneProvider;
$this->symfonyFilesystem = $symfonyFilesystem;
$this->filesystem = $filesystem;

parent::__construct();
}

Expand Down Expand Up @@ -123,7 +112,7 @@ protected function askForTimezone(SymfonyStyle $symfonyStyleIo)
static function ($answer) {
try {
new \DateTimeZone($answer);
} catch (\Exception $exception) {
} catch (\Exception) {
throw new \Exception("Timezone '{$answer}' is not valid. Please provide valid timezone.");
}

Expand Down
17 changes: 3 additions & 14 deletions src/Console/Command/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,11 @@ class ScheduleListCommand extends \Symfony\Component\Console\Command\Command
self::FORMAT_JSON,
];

/** @var ConfigurationInterface */
private $configuration;
/** @var CollectionInterface */
private $taskCollection;
/** @var LoaderInterface */
private $taskLoader;

public function __construct(
ConfigurationInterface $configuration,
CollectionInterface $taskCollection,
LoaderInterface $taskLoader
private ConfigurationInterface $configuration,
private CollectionInterface $taskCollection,
private LoaderInterface $taskLoader
) {
$this->configuration = $configuration;
$this->taskCollection = $taskCollection;
$this->taskLoader = $taskLoader;

parent::__construct();
}

Expand Down
Loading