From 3c7e20e364335395a0399596d421f15ac425f773 Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Tue, 7 Feb 2023 02:19:09 +0000 Subject: [PATCH] 2.1.0 (2023-02-07) - PHP 8.2 compatibility --- .gitlab-ci.yml | 4 +- CHANGELOG.md | 4 + README.md | 2 - composer.json | 15 +++- composer.lock | 142 ++++++++++++++++++++++++++++++++- ruleset.xml | 18 ++++- src/Resque/Job/Factory.php | 4 + src/Resque/Job/Job.php | 2 +- src/Resque/Resque.php | 2 +- tests/Resque/Tests/JobTest.php | 10 +++ tests/bootstrap.php | 12 +++ 11 files changed, 200 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc5de3a..fe02d9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,8 +8,8 @@ # Install pcntl and redis extentions pecl install -o -f redis \ - && rm -rf /tmp/pear \ - && docker-php-ext-enable redis + && rm -rf /tmp/pear \ + && docker-php-ext-enable redis docker-php-ext-install pcntl # Install Composer diff --git a/CHANGELOG.md b/CHANGELOG.md index 8101a95..5e5634f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.0 (2022-02-07) +- Add PHP 8.1 / 8.2 unit tests +- Updated code to be PHP 8.2 compliant + ## 2.0.3 (2022-09-12) - Update composer packages - Added WoodpeckerCI tests diff --git a/README.md b/README.md index b7025a0..4c6ceb9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ php-resque: PHP Resque Worker (and Enqueue) =========================================== -[![Build Status](https://ci.tinker.nz/api/badges/idanoo/php-resque/status.svg)](https://ci.tinker.nz/idanoo/php-resque) - Resque is a Redis-backed library for creating background jobs, placing those jobs on one or more queues, and processing them later. diff --git a/composer.json b/composer.json index f7438df..60c281f 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ }, "description": "Redis backed library for creating background jobs and processing them later. Based on resque for Ruby. Originally forked from chrisboulton/php-resque.", "keywords": ["job", "background", "redis", "resque", "php"], - "homepage": "https://tinker.nz/idanoo/php-resque/", + "homepage": "https://gitlab.com/idanoo/php-resque/", "license": "MIT", "authors": [ { @@ -22,7 +22,9 @@ }, "require-dev": { "phpunit/phpunit": "^9", - "squizlabs/php_codesniffer": "3.*" + "squizlabs/php_codesniffer": "3.*", + "phpcompatibility/php-compatibility": "^9.3", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" }, "bin": [ "bin/resque" @@ -38,7 +40,12 @@ } }, "support": { - "issues": "https://tinker.nz/idanoo/php-resque/issues", - "source": "https://tinker.nz/idanoo/php-resque" + "issues": "https://gitlab.com/idanoo/php-resque/issues", + "source": "https://gitlab.com/idanoo/php-resque" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/composer.lock b/composer.lock index a5714d6..f3910d0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "67934d62707c83cdcba540469eff2fe7", + "content-hash": "3f81232ce308e8074ac0beeaec83a3eb", "packages": [ { "name": "colinmollenhour/credis", @@ -105,6 +105,84 @@ } ], "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "time": "2023-01-05T11:28:13+00:00" + }, { "name": "doctrine/instantiator", "version": "1.4.1", @@ -401,6 +479,68 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.17", diff --git a/ruleset.xml b/ruleset.xml index 7034ee6..6bd9f60 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,10 +1,9 @@ - - PSR12 + + PHP8.2 Ruleset . - - vendor/ + vendor tests/ @@ -12,8 +11,19 @@ + + + + + + + + + + diff --git a/src/Resque/Job/Factory.php b/src/Resque/Job/Factory.php index 380ca05..be04d8e 100644 --- a/src/Resque/Job/Factory.php +++ b/src/Resque/Job/Factory.php @@ -11,6 +11,10 @@ namespace Resque\Job; */ class Factory implements FactoryInterface { + public ?Job $job; + public string $queue; + public array $args; + /** * @param $className * @param array $args diff --git a/src/Resque/Job/Job.php b/src/Resque/Job/Job.php index 32ff7b2..8249559 100755 --- a/src/Resque/Job/Job.php +++ b/src/Resque/Job/Job.php @@ -174,7 +174,7 @@ class Job */ public function getInstance() { - if (!is_null($this->instance)) { + if (isset($this->instance) && !is_null($this->instance)) { return $this->instance; } diff --git a/src/Resque/Resque.php b/src/Resque/Resque.php index 06fff0d..e4872f9 100644 --- a/src/Resque/Resque.php +++ b/src/Resque/Resque.php @@ -12,7 +12,7 @@ namespace Resque; class Resque { - public const VERSION = '2.0.3'; + public const VERSION = '2.1.0'; public const DEFAULT_INTERVAL = 5; diff --git a/tests/Resque/Tests/JobTest.php b/tests/Resque/Tests/JobTest.php index 7c9f1b0..f6c261f 100644 --- a/tests/Resque/Tests/JobTest.php +++ b/tests/Resque/Tests/JobTest.php @@ -397,6 +397,11 @@ class JobTest extends TestCase class SomeJobClass implements \Resque\Job\JobInterface { + public static $called = false; + public $args = false; + public $queue; + public $job; + /** * @return bool */ @@ -408,6 +413,11 @@ class SomeJobClass implements \Resque\Job\JobInterface class Some_Stub_Factory implements \Resque\Job\FactoryInterface { + public static $called = false; + public $args = false; + public $queue; + public $job; + /** * @param $className * @param array $args diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c93fc96..cf26e96 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -35,6 +35,9 @@ if (function_exists('pcntl_signal')) { class TestJob { public static $called = false; + public $args = false; + public $queue; + public $job; public function perform() { @@ -48,6 +51,11 @@ class FailingJobException extends \Exception class FailingJob { + public static $called = false; + public $args = false; + public $queue; + public $job; + public function perform() { throw new FailingJobException('Message!'); @@ -62,6 +70,8 @@ class TestJobWithSetUp { public static $called = false; public $args = false; + public $queue; + public $job; public function setUp() { @@ -78,6 +88,8 @@ class TestJobWithTearDown { public static $called = false; public $args = false; + public $queue; + public $job; public function perform() {