From ff3d71bb9fcccb726a4bf468e00d25f6205b1a5f Mon Sep 17 00:00:00 2001 From: Dimitri Sitchet Tomkeu Date: Wed, 14 Oct 2026 22:09:46 +0100 Subject: [PATCH 1/4] chore: passage a blitz-php 1.0.13 --- composer.json | 12 ++++---- spec/_support/Commands/TasksTest.php | 8 +++--- spec/_support/Config/app.php | 2 +- spec/bootstrap.php | 41 ++++++++++++++++++++-------- src/Commands/Disable.php | 6 ++-- src/Commands/Enable.php | 6 ++-- src/Commands/Lister.php | 8 +++--- src/Commands/Run.php | 8 +++--- src/Commands/TaskCommand.php | 2 +- src/Commands/Work.php | 12 ++++---- src/Config/Registrar.php | 23 ++++++++++++++++ src/Config/Services.php | 12 ++++---- src/CronExpression.php | 2 +- src/FrequenciesTrait.php | 2 +- src/Publishers/TasksPublisher.php | 35 ------------------------ src/RunResolver.php | 2 +- src/Task.php | 2 +- src/TaskLog.php | 2 +- src/TaskRunner.php | 2 +- 19 files changed, 96 insertions(+), 91 deletions(-) create mode 100644 src/Config/Registrar.php delete mode 100644 src/Publishers/TasksPublisher.php diff --git a/composer.json b/composer.json index 70c2deb..c3a5e5f 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,17 @@ } ], "require": { - "php": "^8.1", + "php": "^8.2", "ext-json": "*", - "blitz-php/parametres": "^1.0" + "blitz-php/parametres": "^1.4.0-rc" }, "require-dev": { - "blitz-php/coding-standard": "^1.4", - "blitz-php/framework": "^0.12", + "blitz-php/coding-standard": "^1.6", + "blitz-php/framework": "^1.0.13-rc", "blitz-php/http-client": "^0.0.2", "blitz-php/queue": "^0.2.0", - "kahlan/kahlan": "^6.0", - "phpstan/phpstan": "^2.1" + "kahlan/kahlan": "^6.1", + "phpstan/phpstan": "^2.3" }, "autoload": { "psr-4": { diff --git a/spec/_support/Commands/TasksTest.php b/spec/_support/Commands/TasksTest.php index 8b64867..7ac7872 100644 --- a/spec/_support/Commands/TasksTest.php +++ b/spec/_support/Commands/TasksTest.php @@ -18,11 +18,11 @@ */ final class TasksTest extends Command { - protected $group = 'Testing'; - protected $name = 'tasks:test'; - protected $description = 'Tests Tasks'; + protected string $group = 'Testing'; + protected string $name = 'tasks:test'; + protected string $description = 'Tests Tasks'; - public function execute(array $params) + public function handle() { $this->write('La commande peut produire du texte.'); } diff --git a/spec/_support/Config/app.php b/spec/_support/Config/app.php index a827cd2..f46f18c 100644 --- a/spec/_support/Config/app.php +++ b/spec/_support/Config/app.php @@ -17,6 +17,6 @@ return [ 'base_url' => 'http://localhost', 'environment' => 'testing', - 'language' => 'en', + 'locale' => 'en', 'show_debugbar' => false, ]; diff --git a/spec/bootstrap.php b/spec/bootstrap.php index 2b5687f..1edb085 100644 --- a/spec/bootstrap.php +++ b/spec/bootstrap.php @@ -9,23 +9,40 @@ * the LICENSE file that was distributed with this source code. */ -use BlitzPHP\Tasks\Config\Services; +use BlitzPHP\Initializer\Boot; -defined('HOME_PATH') || define('HOME_PATH', realpath(rtrim(getcwd(), '\\/ ')) . DIRECTORY_SEPARATOR); -defined('VENDOR_PATH') || define('VENDOR_PATH', realpath(HOME_PATH . 'vendor') . DIRECTORY_SEPARATOR); +error_reporting(E_ALL); +ini_set('display_errors', '1'); +ini_set('display_startup_errors', '1'); + +// S'assure qu'il reconnaît que nous testons. +$_SERVER['ENVIRONMENT'] = 'testing'; +define('ENVIRONMENT', 'testing'); +define('BLITZ_DEBUG', true); + +// Souvent, ces constantes sont prédéfinies, mais interroger la structure actuelle du répertoire comme un repli +defined('HOME_PATH') || define('HOME_PATH', realpath(rtrim(getcwd(), '\\/ ')) . DIRECTORY_SEPARATOR); +defined('VENDOR_PATH') || define('VENDOR_PATH', realpath(HOME_PATH . 'vendor') . DIRECTORY_SEPARATOR); + +if (! is_file($autoload_file = realpath(VENDOR_PATH . 'autoload.php')) ?: '') { + echo 'Votre fichier autoload de Composer ne semble pas être défini correctement. '; + echo 'Veuillez ouvrir le fichier suivant et pour corriger: "' . __FILE__ . '"'; + + exit(3); // EXIT_CONFIG +} -define('APP_NAMESPACE', 'App'); -define('APP_PATH', __DIR__ . '/_support/'); -define('WEBROOT', APP_PATH); -define('STORAGE_PATH', APP_PATH); define('SYST_PATH', VENDOR_PATH . 'blitz-php/framework/src/'); +define('APPLICATION_PATH', __DIR__ . '/_support/'); +define('TEST_PATH', __DIR__ . '/'); +define('WEBROOT', APPLICATION_PATH); + +require_once $autoload_file; +require_once SYST_PATH . 'Initializer' . DIRECTORY_SEPARATOR. 'Boot.php'; -require_once SYST_PATH . 'Constants/constants.php'; -require_once SYST_PATH . 'Helpers/common.php'; -require_once SYST_PATH . 'Helpers/path.php'; +$paths = ['app' => APPLICATION_PATH, 'storage' => APPLICATION_PATH, 'test' => TEST_PATH, 'composer' => VENDOR_PATH]; +Boot::test($paths, __FILE__); -Services::autoloader()->initialize()->register(); -Services::container()->initialize(); +helper('path'); config()->load('parametres', VENDOR_PATH . 'blitz-php/parametres/src/Config/parametres.php'); config()->set('parametres.file.path', storage_path('.parametres.json')); diff --git a/src/Commands/Disable.php b/src/Commands/Disable.php index 455812a..e4b7bdc 100644 --- a/src/Commands/Disable.php +++ b/src/Commands/Disable.php @@ -21,19 +21,19 @@ class Disable extends TaskCommand /** * {@inheritDoc} */ - protected $name = 'tasks:disable'; + protected string $name = 'tasks:disable'; /** * {@inheritDoc} */ - protected $description = 'Désactive l\'exécuteur de tâches.'; + protected string $description = 'Désactive l\'exécuteur de tâches.'; /** * {@inheritDoc} * * @return void */ - public function execute(array $params) + public function handle() { parametre('tasks.enabled', false); diff --git a/src/Commands/Enable.php b/src/Commands/Enable.php index 5ba2176..28b985e 100644 --- a/src/Commands/Enable.php +++ b/src/Commands/Enable.php @@ -21,19 +21,19 @@ class Enable extends TaskCommand /** * {@inheritDoc} */ - protected $name = 'tasks:enable'; + protected string $name = 'tasks:enable'; /** * {@inheritDoc} */ - protected $description = 'Active l\'exécuteur de tâches.'; + protected string $description = 'Active l\'exécuteur de tâches.'; /** * {@inheritDoc} * * @return void */ - public function execute(array $params) + public function handle() { parametre('tasks.enabled', true); diff --git a/src/Commands/Lister.php b/src/Commands/Lister.php index 98820ed..5bf7bff 100644 --- a/src/Commands/Lister.php +++ b/src/Commands/Lister.php @@ -15,7 +15,7 @@ use BlitzPHP\Tasks\CronExpression; use BlitzPHP\Tasks\Scheduler; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; /** * Répertorie les tâches actuellement planifiées. @@ -25,19 +25,19 @@ class Lister extends TaskCommand /** * {@inheritDoc} */ - protected $name = 'tasks:list'; + protected string $name = 'tasks:list'; /** * {@inheritDoc} */ - protected $description = 'Répertorie les tâches actuellement configurées pour être exécutées.'; + protected string $description = 'Répertorie les tâches actuellement configurées pour être exécutées.'; /** * {@inheritDoc} * * @return void */ - public function execute(array $params) + public function handle() { if (parametre('tasks.enabled') === false) { $this->writer->error('WARNING: L\'exécution de la tâche est actuellement désactivée.', true); diff --git a/src/Commands/Run.php b/src/Commands/Run.php index 0f05327..f2a50dd 100644 --- a/src/Commands/Run.php +++ b/src/Commands/Run.php @@ -24,26 +24,26 @@ class Run extends TaskCommand /** * {@inheritDoc} */ - protected $name = 'tasks:run'; + protected string $name = 'tasks:run'; /** * {@inheritDoc} */ - protected $options = [ + protected array $options = [ '--task' => 'Exécuter une tâche spécifique par son alias.', ]; /** * {@inheritDoc} */ - protected $description = 'Exécute des tâches en fonction de la planification, doit être configuré comme une tâche cron pour s\'exécuter toutes les minutes.'; + protected string $description = 'Exécute des tâches en fonction de la planification, doit être configuré comme une tâche cron pour s\'exécuter toutes les minutes.'; /** * {@inheritDoc} * * @return int */ - public function execute(array $params) + public function handle() { if (parametre('tasks.enabled') === false) { $this->writer->error('WARNING: L\'exécution de la tâche est actuellement désactivée.', true); diff --git a/src/Commands/TaskCommand.php b/src/Commands/TaskCommand.php index e3bb133..44a804e 100644 --- a/src/Commands/TaskCommand.php +++ b/src/Commands/TaskCommand.php @@ -23,7 +23,7 @@ abstract class TaskCommand extends Command /** * {@inheritDoc} */ - protected $group = 'Tasks'; + protected string $group = 'Tasks'; /** * emplacement pour sauvegarder. diff --git a/src/Commands/Work.php b/src/Commands/Work.php index a5e883c..403df1f 100644 --- a/src/Commands/Work.php +++ b/src/Commands/Work.php @@ -11,7 +11,7 @@ namespace BlitzPHP\Tasks\Commands; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use Symfony\Component\Process\Process; class Work extends TaskCommand @@ -19,24 +19,24 @@ class Work extends TaskCommand /** * {@inheritDoc} */ - protected $name = 'tasks:work'; + protected string $name = 'tasks:work'; /** * {@inheritDoc} */ - protected $options = [ + protected array $options = [ '--run-output-file' => 'Le fichier vers lequel diriger la sortie de `tasks:run`.', ]; /** * {@inheritDoc} */ - protected $description = 'Démarre le planificateur de tâche et l\'exécute localement.'; + protected string $description = 'Démarre le planificateur de tâche et l\'exécute localement.'; /** * @var list */ - protected $required = [ + protected array $required = [ 'symfony/process:^7.2', ]; @@ -45,7 +45,7 @@ class Work extends TaskCommand * * @return void */ - public function execute(array $params) + public function handle() { $this->info('Exéctutions des tâches programmées.'); diff --git a/src/Config/Registrar.php b/src/Config/Registrar.php new file mode 100644 index 0000000..04e054a --- /dev/null +++ b/src/Config/Registrar.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace BlitzPHP\Tasks\Config; + +class Registrar +{ + /** + * Enregistre les fichiers de configurations publiable + */ + public static function config(): array + { + return ['tasks']; + } +} diff --git a/src/Config/Services.php b/src/Config/Services.php index 96699c9..ae69af0 100644 --- a/src/Config/Services.php +++ b/src/Config/Services.php @@ -24,11 +24,11 @@ class Services extends BaseServices */ public static function scheduler(bool $shared = true): Scheduler { - if (true === $shared && isset(static::$instances[Scheduler::class])) { - return static::$instances[Scheduler::class]; + if ($shared) { + return static::sharedInstance('scheduler'); } - return static::$instances[Scheduler::class] = new Scheduler(); + return new Scheduler(); } /** @@ -36,10 +36,10 @@ public static function scheduler(bool $shared = true): Scheduler */ public static function cronExpression(bool $shared = true): CronExpression { - if (true === $shared && isset(static::$instances[CronExpression::class])) { - return static::$instances[CronExpression::class]; + if ($shared) { + return static::sharedInstance('cronExpression'); } - return static::$instances[CronExpression::class] = new CronExpression(); + return new CronExpression(); } } diff --git a/src/CronExpression.php b/src/CronExpression.php index 2e23d50..476ba23 100644 --- a/src/CronExpression.php +++ b/src/CronExpression.php @@ -14,7 +14,7 @@ namespace BlitzPHP\Tasks; use BlitzPHP\Tasks\Exceptions\TasksException; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use Exception; /** diff --git a/src/FrequenciesTrait.php b/src/FrequenciesTrait.php index ba9042d..71a8a80 100644 --- a/src/FrequenciesTrait.php +++ b/src/FrequenciesTrait.php @@ -13,7 +13,7 @@ namespace BlitzPHP\Tasks; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; /** * Fournit les méthodes permettant d'attribuer des fréquences à des tâches individuelles. diff --git a/src/Publishers/TasksPublisher.php b/src/Publishers/TasksPublisher.php deleted file mode 100644 index 96fbbac..0000000 --- a/src/Publishers/TasksPublisher.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace BlitzPHP\Tasks\Publishers; - -use BlitzPHP\Publisher\Publisher; - -class TasksPublisher extends Publisher -{ - /** - * {@inheritDoc} - */ - protected string $source = __DIR__ . '/../Config/'; - - /** - * {@inheritDoc} - */ - protected string $destination = CONFIG_PATH; - - /** - * {@inheritDoc} - */ - public function publish(): bool - { - return $this->addPaths(['tasks.php'])->merge(false); - } -} diff --git a/src/RunResolver.php b/src/RunResolver.php index 28a7658..94f3121 100644 --- a/src/RunResolver.php +++ b/src/RunResolver.php @@ -13,7 +13,7 @@ namespace BlitzPHP\Tasks; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; /** * @credit CodeIgniter4 - CodeIgniter\Tasks\RunResolver diff --git a/src/Task.php b/src/Task.php index c516e3b..b89d8a9 100644 --- a/src/Task.php +++ b/src/Task.php @@ -15,7 +15,7 @@ use BlitzPHP\Contracts\Container\ContainerInterface; use BlitzPHP\Tasks\Exceptions\TasksException; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use InvalidArgumentException; use ReflectionException; use ReflectionFunction; diff --git a/src/TaskLog.php b/src/TaskLog.php index 36cd884..e5bc3f0 100644 --- a/src/TaskLog.php +++ b/src/TaskLog.php @@ -13,7 +13,7 @@ namespace BlitzPHP\Tasks; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use Exception; use Throwable; diff --git a/src/TaskRunner.php b/src/TaskRunner.php index a14e789..4dd459e 100644 --- a/src/TaskRunner.php +++ b/src/TaskRunner.php @@ -15,7 +15,7 @@ use Ahc\Cli\Output\Color; use Ahc\Cli\Output\Writer; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use Throwable; /** From 484d476c10dca849804913682e77993ae875ba0e Mon Sep 17 00:00:00 2001 From: Dimitri Sitchet Tomkeu Date: Thu, 15 Oct 2026 10:19:44 +0100 Subject: [PATCH 2/4] test: corrections des tests unitaires --- composer.json | 1 - spec/Command.spec.php | 5 +---- spec/CronExpression.spec.php | 2 +- spec/FrequenciesTrait.spec.php | 2 +- spec/Task.spec.php | 7 ++++--- spec/TaskLog.spec.php | 2 +- spec/bootstrap.php | 3 ++- src/CronExpression.php | 2 +- src/RunResolver.php | 18 ++++++++---------- src/Scheduler.php | 5 ++--- 10 files changed, 21 insertions(+), 26 deletions(-) diff --git a/composer.json b/composer.json index c3a5e5f..ff00eb0 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,6 @@ "blitz-php/coding-standard": "^1.6", "blitz-php/framework": "^1.0.13-rc", "blitz-php/http-client": "^0.0.2", - "blitz-php/queue": "^0.2.0", "kahlan/kahlan": "^6.1", "phpstan/phpstan": "^2.3" }, diff --git a/spec/Command.spec.php b/spec/Command.spec.php index 1e7c41a..a7f9aa6 100644 --- a/spec/Command.spec.php +++ b/spec/Command.spec.php @@ -23,8 +23,6 @@ }); it('Publisher', function () { - config()->ghost('publisher')->set('publisher.restrictions', [ROOTPATH => '*']); - $path = CONFIG_PATH . 'tasks.php'; expect(file_exists($path))->toBeFalsy(); @@ -32,8 +30,7 @@ // conserver les fichiers originaux car a la fin, on suppimera tous les fichiers publiés $original_files = array_map(fn ($f) => $f->getRelativePathname(), service('fs')->files(CONFIG_PATH)); - command('publish'); - // command('publish --namespace=BlitzPHP\\\\Tasks'); + command('config:publish tasks'); expect(file_exists($path))->toBeTruthy(); diff --git a/spec/CronExpression.spec.php b/spec/CronExpression.spec.php index 6c37386..ff2d2d5 100644 --- a/spec/CronExpression.spec.php +++ b/spec/CronExpression.spec.php @@ -11,7 +11,7 @@ use BlitzPHP\Tasks\CronExpression; use BlitzPHP\Tasks\Exceptions\TasksException; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use function Kahlan\expect; diff --git a/spec/FrequenciesTrait.spec.php b/spec/FrequenciesTrait.spec.php index 0d89870..7e5b1ac 100644 --- a/spec/FrequenciesTrait.spec.php +++ b/spec/FrequenciesTrait.spec.php @@ -10,7 +10,7 @@ */ use BlitzPHP\Tasks\FrequenciesTrait; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use function Kahlan\expect; diff --git a/spec/Task.spec.php b/spec/Task.spec.php index f608c58..cd9e978 100644 --- a/spec/Task.spec.php +++ b/spec/Task.spec.php @@ -13,7 +13,7 @@ use BlitzPHP\Spec\ReflectionHelper; use BlitzPHP\Tasks\Exceptions\TasksException; use BlitzPHP\Tasks\Task; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use BlitzPHP\Utilities\Helpers; use function Kahlan\expect; @@ -134,8 +134,9 @@ ]]); // Doit renvoyer l'heure actuelle - expect($task->lastRun())->toBeAnInstanceOf(Date::class); // @phpstan-ignore-line - expect($task->lastRun()->format('Y-m-d H:i:s'))->toBe($date); + $lastRun = $task->lastRun(); + expect($lastRun)->toBeAnInstanceOf(Date::class); // @phpstan-ignore-line + expect($lastRun->format('Y-m-d H:i:s'))->toBe($date); }); it('Execute une tache unique', function () { diff --git a/spec/TaskLog.spec.php b/spec/TaskLog.spec.php index d95bf8d..4dd74d7 100644 --- a/spec/TaskLog.spec.php +++ b/spec/TaskLog.spec.php @@ -11,7 +11,7 @@ use BlitzPHP\Tasks\Task; use BlitzPHP\Tasks\TaskLog; -use BlitzPHP\Utilities\Date; +use BlitzPHP\Utilities\DateTime\Date; use function Kahlan\expect; diff --git a/spec/bootstrap.php b/spec/bootstrap.php index 1edb085..8317149 100644 --- a/spec/bootstrap.php +++ b/spec/bootstrap.php @@ -45,6 +45,7 @@ helper('path'); config()->load('parametres', VENDOR_PATH . 'blitz-php/parametres/src/Config/parametres.php'); -config()->set('parametres.file.path', storage_path('.parametres.json')); +config()->set('parametres.json.file', storage_path('.parametres.json')); +config()->set('parametres.handlers', ['json']); config()->load('tasks', __DIR__ . '/../src/Config/tasks.php'); config()->ghost('cache', ['handler' => 'file']); diff --git a/src/CronExpression.php b/src/CronExpression.php index 476ba23..91505e3 100644 --- a/src/CronExpression.php +++ b/src/CronExpression.php @@ -112,7 +112,7 @@ public function nextRun(string $expression): Date */ public function lastRun(string $expression): Date { - return new Date(); + return new Date(timezone: $this->timezone); } /** diff --git a/src/RunResolver.php b/src/RunResolver.php index 94f3121..9eeaa8d 100644 --- a/src/RunResolver.php +++ b/src/RunResolver.php @@ -61,19 +61,17 @@ public function nextRun(string $expression, Date $next): Date foreach ($cron as $position => $value) { $satisfied = false; - // La méthode à utiliser sur l'instance Date - $method = 'get' . ucfirst($position); - - // monthDay et weekDay nécessitent des méthodes personnalisées - if ($position === 'monthDay') { - $method = 'getDay'; - } + $format = match($position) { + 'monthDay' => 'd', + 'weekDay' => 'c', + 'minute' => 'm', + 'hour' => 'H', + 'month' => 'M' + }; if ($position === 'weekDay') { - $method = 'getDayOfWeek'; - $value = $this->convertDOWToNumbers($value); } - $nextValue = $next->{$method}(); + $nextValue = $next->formatLocalized($format); // S'il s'agit d'une valeur unique if ($nextValue === $value) { diff --git a/src/Scheduler.php b/src/Scheduler.php index fe1928d..a9afac1 100644 --- a/src/Scheduler.php +++ b/src/Scheduler.php @@ -14,7 +14,6 @@ namespace BlitzPHP\Tasks; use BlitzPHP\Contracts\Queue\ShouldQueue; -use BlitzPHP\Queue\Job; /** * @credit CodeIgniter4 - CodeIgniter\Tasks\Scheduler @@ -91,12 +90,12 @@ public function url(string $url): Task /** * Planifie l'execution d'un job dans la file d'attente. * - * @param class-string|Job $job + * @param class-string<\BlitzPHP\Queue\Job>|\BlitzPHP\Queue\Job $job */ public function job(object|string $job, ?string $queue = null, ?string $driver = null) { return $this->call(function () use ($job, $queue, $driver) { - /** @var Job $job */ + /** @var \BlitzPHP\Queue\Job $job */ $job = is_string($job) ? service('container')->make($job) : $job; if ($job instanceof ShouldQueue) { From ed4f6ac1387d6662c22f47e5ebd100b3ac24ec2e Mon Sep 17 00:00:00 2001 From: Dimitri Sitchet Tomkeu Date: Thu, 15 Oct 2026 10:20:12 +0100 Subject: [PATCH 3/4] chore: mise a jour de la version de php sur github actions --- .github/workflows/run-tests.yml | 2 +- .github/workflows/test-coding-standards.yml | 2 +- .github/workflows/test-phpstan.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3b0d547..fb6abef 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: ['8.1', '8.2'] + php-versions: ['8.2', '8.3'] name: Test with PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }} steps: - name: Checkout diff --git a/.github/workflows/test-coding-standards.yml b/.github/workflows/test-coding-standards.yml index ac193d2..ba435fb 100644 --- a/.github/workflows/test-coding-standards.yml +++ b/.github/workflows/test-coding-standards.yml @@ -28,8 +28,8 @@ jobs: fail-fast: false matrix: php-version: - - '8.1' - '8.2' + - '8.3' steps: - name: Checkout diff --git a/.github/workflows/test-phpstan.yml b/.github/workflows/test-phpstan.yml index 571bf4f..f9274c9 100644 --- a/.github/workflows/test-phpstan.yml +++ b/.github/workflows/test-phpstan.yml @@ -40,7 +40,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.2' extensions: intl coverage: none From 8bbb1487a27c0fb7f5cc4c95762848aee569d958 Mon Sep 17 00:00:00 2001 From: Dimitri Sitchet Tomkeu Date: Thu, 15 Oct 2026 10:44:15 +0100 Subject: [PATCH 4/4] fix code style & phpstan --- phpstan-baseline.php | 54 +++++++++++++++++++++++++++++++++++----- spec/bootstrap.php | 6 ++--- src/Commands/Run.php | 2 +- src/Commands/Work.php | 2 +- src/Config/Registrar.php | 2 ++ src/RunResolver.php | 6 ++--- src/Scheduler.php | 7 +++--- 7 files changed, 62 insertions(+), 17 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index f2c5285..d7cac3c 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -19,18 +19,60 @@ 'count' => 1, 'path' => __DIR__ . '/src/Commands/Run.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method startOfMinute\\(\\) on BlitzPHP\\\\Utilities\\\\Date\\|string\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 2, - 'path' => __DIR__ . '/src/Commands/Work.php', -]; $ignoreErrors[] = [ 'message' => '#^While loop condition is always true\\.$#', 'identifier' => 'while.alwaysTrue', 'count' => 1, 'path' => __DIR__ . '/src/Commands/Work.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Access to constant class on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#', + 'identifier' => 'class.notFound', + 'count' => 1, + 'path' => __DIR__ . '/src/Scheduler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Access to property \\$driver on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#', + 'identifier' => 'class.notFound', + 'count' => 1, + 'path' => __DIR__ . '/src/Scheduler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Call to method execute\\(\\) on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#', + 'identifier' => 'class.notFound', + 'count' => 1, + 'path' => __DIR__ . '/src/Scheduler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Call to method queue\\(\\) on an unknown class BlitzPHP\\\\Queue\\\\Job\\.$#', + 'identifier' => 'class.notFound', + 'count' => 1, + 'path' => __DIR__ . '/src/Scheduler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^PHPDoc tag @var for variable \\$job contains unknown class BlitzPHP\\\\Queue\\\\Job\\.$#', + 'identifier' => 'class.notFound', + 'count' => 1, + 'path' => __DIR__ . '/src/Scheduler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\, string given\\.$#', + 'identifier' => 'argument.type', + 'count' => 1, + 'path' => __DIR__ . '/src/Scheduler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\, string given\\.$#', + 'identifier' => 'argument.type', + 'count' => 1, + 'path' => __DIR__ . '/src/Scheduler.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\$job of method BlitzPHP\\\\Tasks\\\\Scheduler\\:\\:job\\(\\) has invalid type BlitzPHP\\\\Queue\\\\Job\\.$#', + 'identifier' => 'class.notFound', + 'count' => 2, + 'path' => __DIR__ . '/src/Scheduler.php', +]; $ignoreErrors[] = [ 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\, string given\\.$#', 'identifier' => 'argument.type', diff --git a/spec/bootstrap.php b/spec/bootstrap.php index 8317149..71fe713 100644 --- a/spec/bootstrap.php +++ b/spec/bootstrap.php @@ -21,8 +21,8 @@ define('BLITZ_DEBUG', true); // Souvent, ces constantes sont prédéfinies, mais interroger la structure actuelle du répertoire comme un repli -defined('HOME_PATH') || define('HOME_PATH', realpath(rtrim(getcwd(), '\\/ ')) . DIRECTORY_SEPARATOR); -defined('VENDOR_PATH') || define('VENDOR_PATH', realpath(HOME_PATH . 'vendor') . DIRECTORY_SEPARATOR); +defined('HOME_PATH') || define('HOME_PATH', realpath(rtrim(getcwd(), '\\/ ')) . DIRECTORY_SEPARATOR); +defined('VENDOR_PATH') || define('VENDOR_PATH', realpath(HOME_PATH . 'vendor') . DIRECTORY_SEPARATOR); if (! is_file($autoload_file = realpath(VENDOR_PATH . 'autoload.php')) ?: '') { echo 'Votre fichier autoload de Composer ne semble pas être défini correctement. '; @@ -37,7 +37,7 @@ define('WEBROOT', APPLICATION_PATH); require_once $autoload_file; -require_once SYST_PATH . 'Initializer' . DIRECTORY_SEPARATOR. 'Boot.php'; +require_once SYST_PATH . 'Initializer' . DIRECTORY_SEPARATOR . 'Boot.php'; $paths = ['app' => APPLICATION_PATH, 'storage' => APPLICATION_PATH, 'test' => TEST_PATH, 'composer' => VENDOR_PATH]; Boot::test($paths, __FILE__); diff --git a/src/Commands/Run.php b/src/Commands/Run.php index f2a50dd..6a23330 100644 --- a/src/Commands/Run.php +++ b/src/Commands/Run.php @@ -30,7 +30,7 @@ class Run extends TaskCommand * {@inheritDoc} */ protected array $options = [ - '--task' => 'Exécuter une tâche spécifique par son alias.', + '--task' => ['Exécuter une tâche spécifique par son alias.'], ]; /** diff --git a/src/Commands/Work.php b/src/Commands/Work.php index 403df1f..0be23c3 100644 --- a/src/Commands/Work.php +++ b/src/Commands/Work.php @@ -25,7 +25,7 @@ class Work extends TaskCommand * {@inheritDoc} */ protected array $options = [ - '--run-output-file' => 'Le fichier vers lequel diriger la sortie de `tasks:run`.', + '--run-output-file' => ['Le fichier vers lequel diriger la sortie de `tasks:run`.'], ]; /** diff --git a/src/Config/Registrar.php b/src/Config/Registrar.php index 04e054a..06c8f51 100644 --- a/src/Config/Registrar.php +++ b/src/Config/Registrar.php @@ -15,6 +15,8 @@ class Registrar { /** * Enregistre les fichiers de configurations publiable + * + * @return list */ public static function config(): array { diff --git a/src/RunResolver.php b/src/RunResolver.php index 9eeaa8d..e6dea61 100644 --- a/src/RunResolver.php +++ b/src/RunResolver.php @@ -61,13 +61,13 @@ public function nextRun(string $expression, Date $next): Date foreach ($cron as $position => $value) { $satisfied = false; - $format = match($position) { + $format = match ($position) { 'monthDay' => 'd', 'weekDay' => 'c', 'minute' => 'm', 'hour' => 'H', - 'month' => 'M' - }; + 'month' => 'M', + }; if ($position === 'weekDay') { $value = $this->convertDOWToNumbers($value); } diff --git a/src/Scheduler.php b/src/Scheduler.php index a9afac1..ed4f463 100644 --- a/src/Scheduler.php +++ b/src/Scheduler.php @@ -14,6 +14,7 @@ namespace BlitzPHP\Tasks; use BlitzPHP\Contracts\Queue\ShouldQueue; +use BlitzPHP\Queue\Job; /** * @credit CodeIgniter4 - CodeIgniter\Tasks\Scheduler @@ -90,12 +91,12 @@ public function url(string $url): Task /** * Planifie l'execution d'un job dans la file d'attente. * - * @param class-string<\BlitzPHP\Queue\Job>|\BlitzPHP\Queue\Job $job + * @param class-string|Job $job */ - public function job(object|string $job, ?string $queue = null, ?string $driver = null) + public function job(object|string $job, ?string $queue = null, ?string $driver = null): Task { return $this->call(function () use ($job, $queue, $driver) { - /** @var \BlitzPHP\Queue\Job $job */ + /** @var Job $job */ $job = is_string($job) ? service('container')->make($job) : $job; if ($job instanceof ShouldQueue) {