From 05cae402b50b6dc2b2b078780a183fabe010099c Mon Sep 17 00:00:00 2001 From: idanoo Date: Mon, 12 Sep 2022 19:50:02 +1200 Subject: [PATCH] 2.0.3 (2022-09-12) - Update composer packages - Added WoodpeckerCI tests - Updated links in composer package - Stricter typing --- .woodpecker/.lint.yml | 8 + .woodpecker/.test.yml | 25 ++ CHANGELOG.md | 6 + README.md | 8 +- bin/resque | 4 +- composer.json | 8 +- composer.lock | 548 +++++----------------------- ruleset.xml | 6 - src/Resque/Failure/Failure.php | 16 +- src/Resque/Job/Factory.php | 5 +- src/Resque/Job/FactoryInterface.php | 1 + src/Resque/Job/Job.php | 17 +- src/Resque/Job/Status.php | 8 +- src/Resque/Log.php | 18 +- src/Resque/Redis.php | 27 +- src/Resque/RedisException.php | 2 +- src/Resque/Resque.php | 11 +- src/Resque/Stat.php | 5 +- src/Resque/Worker.php | 11 +- tests/Resque/Tests/JobTest.php | 4 +- tests/bootstrap.php | 1 - 21 files changed, 215 insertions(+), 524 deletions(-) create mode 100644 .woodpecker/.lint.yml create mode 100644 .woodpecker/.test.yml diff --git a/.woodpecker/.lint.yml b/.woodpecker/.lint.yml new file mode 100644 index 0000000..6e3f90f --- /dev/null +++ b/.woodpecker/.lint.yml @@ -0,0 +1,8 @@ +pipeline: + lint: + image: php:8.1-cli + commands: + - apt update && apt install -y wget unzip git + - wget https://getcomposer.org/download/latest-stable/composer.phar + - php composer.phar install --dev + - php -d memory_limit=256M vendor/bin/phpcs -s --standard=ruleset.xml diff --git a/.woodpecker/.test.yml b/.woodpecker/.test.yml new file mode 100644 index 0000000..ebb53ed --- /dev/null +++ b/.woodpecker/.test.yml @@ -0,0 +1,25 @@ +matrix: + PHP_VERSION: + - 7.4 + - 8.0 + - 8.1 + +pipeline: + unit-tests: + image: php:${PHP_VERSION}-cli + commands: + - apt-get update -yq + - apt-get install git wget procps unzip -y + - pecl install -o -f redis && rm -rf /tmp/pear + - docker-php-ext-enable redis + - docker-php-ext-install pcntl + - wget https://getcomposer.org/download/latest-stable/composer.phar + - php composer.phar install --dev + - php vendor/bin/phpunit --verbose --configuration phpunit.xml + +services: + redis: + image: redis:latest + +depends_on: + - lint \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d2507a..8101a95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.0.3 (2022-09-12) +- Update composer packages +- Added WoodpeckerCI tests +- Updated links in composer package +- Stricter typing + ## 2.0.2 (2022-02-15) - Replace strftime with strtotime for PHP8.1 support - Added processing class into proc line for easier debugging diff --git a/README.md b/README.md index 4d248d3..b7025a0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ 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. @@ -58,7 +60,7 @@ If you're not familiar with Composer, please see . ```json { "require": { - "idanoo/php-resque": "^1.4" + "idanoo/php-resque": "^2.0" } } ``` @@ -80,7 +82,7 @@ Jobs are queued as follows: ```php // Required if redis is located elsewhere -Resque::setBackend('localhost:6379'); +Resque::setBackend('redis:6379'); $args = ['name' => 'TestName']; @@ -468,7 +470,7 @@ needing to directly examine the code), have a look at `HOWITWORKS.md`. ## Contributors ## ### Current Maintainers ### -* @iDanoo +* @idanoo ### Past Maintainer / Forked From ### diff --git a/bin/resque b/bin/resque index 91bd82a..073f05a 100755 --- a/bin/resque +++ b/bin/resque @@ -38,7 +38,9 @@ if (empty($QUEUE)) { */ $REDIS_BACKEND = getenv('REDIS_BACKEND'); -// Override redis DB numbers +/** + * REDIS_BACKEND_DB overrides default Redis DB + */ $REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB'); if (!empty($REDIS_BACKEND)) { if (empty($REDIS_BACKEND_DB)) { diff --git a/composer.json b/composer.json index 04c863b..f7438df 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": "http://www.github.com/idanoo/php-resque/", + "homepage": "https://tinker.nz/idanoo/php-resque/", "license": "MIT", "authors": [ { @@ -18,7 +18,7 @@ "require": { "php": ">7.4", "psr/log": "^1.1.0", - "colinmollenhour/credis": "^1.12.0" + "colinmollenhour/credis": "^1.13.0" }, "require-dev": { "phpunit/phpunit": "^9", @@ -38,7 +38,7 @@ } }, "support": { - "issues": "https://github.com/idanoo/php-resque/issues", - "source": "https://github.com/idanoo/php-resque" + "issues": "https://tinker.nz/idanoo/php-resque/issues", + "source": "https://tinker.nz/idanoo/php-resque" } } diff --git a/composer.lock b/composer.lock index 151c58c..a5714d6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,24 +4,27 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3b306efc1905a1f6cce0808d41fcf19c", + "content-hash": "67934d62707c83cdcba540469eff2fe7", "packages": [ { "name": "colinmollenhour/credis", - "version": "v1.12.1", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/colinmollenhour/credis.git", - "reference": "c27faa11724229986335c23f4b6d0f1d8d6547fb" + "reference": "85df015088e00daf8ce395189de22c8eb45c8d49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/colinmollenhour/credis/zipball/c27faa11724229986335c23f4b6d0f1d8d6547fb", - "reference": "c27faa11724229986335c23f4b6d0f1d8d6547fb", + "url": "https://api.github.com/repos/colinmollenhour/credis/zipball/85df015088e00daf8ce395189de22c8eb45c8d49", + "reference": "85df015088e00daf8ce395189de22c8eb45c8d49", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": ">=5.6.0" + }, + "suggest": { + "ext-redis": "Improved performance for communicating with redis" }, "type": "library", "autoload": { @@ -46,9 +49,9 @@ "homepage": "https://github.com/colinmollenhour/credis", "support": { "issues": "https://github.com/colinmollenhour/credis/issues", - "source": "https://github.com/colinmollenhour/credis/tree/v1.12.1" + "source": "https://github.com/colinmollenhour/credis/tree/v1.13.1" }, - "time": "2020-11-06T16:09:14+00:00" + "time": "2022-06-20T22:56:59+00:00" }, { "name": "psr/log", @@ -104,29 +107,30 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.0", + "doctrine/coding-standard": "^9", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.22" }, "type": "library", "autoload": { @@ -153,7 +157,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + "source": "https://github.com/doctrine/instantiator/tree/1.4.1" }, "funding": [ { @@ -169,29 +173,33 @@ "type": "tidelift" } ], - "time": "2020-11-10T18:47:58+00:00" + "time": "2022-03-03T08:28:38+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.10.2", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", "autoload": { @@ -216,7 +224,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" }, "funding": [ { @@ -224,20 +232,20 @@ "type": "tidelift" } ], - "time": "2020-11-13T09:40:50+00:00" + "time": "2022-03-03T13:19:32+00:00" }, { "name": "nikic/php-parser", - "version": "v4.13.2", + "version": "v4.15.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077" + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", "shasum": "" }, "require": { @@ -278,9 +286,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" }, - "time": "2021-11-30T19:35:32+00:00" + "time": "2022-09-04T07:30:47+00:00" }, { "name": "phar-io/manifest", @@ -344,16 +352,16 @@ }, { "name": "phar-io/version", - "version": "3.1.1", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "15a90844ad40f127afd244c0cad228de2a80052a" + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/15a90844ad40f127afd244c0cad228de2a80052a", - "reference": "15a90844ad40f127afd244c0cad228de2a80052a", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { @@ -389,256 +397,29 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.1" + "source": "https://github.com/phar-io/version/tree/3.2.1" }, - "time": "2022-02-07T21:56:48+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" - }, - "time": "2021-10-19T17:43:47+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.6.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" - }, - "time": "2022-01-04T19:58:01+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" - }, - "time": "2021-12-08T12:19:24+00:00" + "time": "2022-02-21T01:04:05+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.10", + "version": "9.2.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" + "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", - "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", + "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^4.14", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -687,7 +468,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" }, "funding": [ { @@ -695,7 +476,7 @@ "type": "github" } ], - "time": "2021-12-05T09:12:13+00:00" + "time": "2022-08-30T12:24:04+00:00" }, { "name": "phpunit/php-file-iterator", @@ -940,16 +721,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.13", + "version": "9.5.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "597cb647654ede35e43b137926dfdfef0fb11743" + "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743", - "reference": "597cb647654ede35e43b137926dfdfef0fb11743", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0aa6097bef9fd42458a9b3c49da32c6ce6129c5", + "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5", "shasum": "" }, "require": { @@ -964,8 +745,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -979,13 +759,9 @@ "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3.4", + "sebastian/type": "^3.1", "sebastian/version": "^3.0.2" }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { "ext-soap": "*", "ext-xdebug": "*" @@ -1000,11 +776,11 @@ } }, "autoload": { - "classmap": [ - "src/" - ], "files": [ "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1027,7 +803,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.24" }, "funding": [ { @@ -1039,7 +815,7 @@ "type": "github" } ], - "time": "2022-01-24T07:33:35+00:00" + "time": "2022-08-30T07:42:16+00:00" }, { "name": "sebastian/cli-parser", @@ -1407,16 +1183,16 @@ }, { "name": "sebastian/environment", - "version": "5.1.3", + "version": "5.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", "shasum": "" }, "require": { @@ -1458,7 +1234,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" }, "funding": [ { @@ -1466,7 +1242,7 @@ "type": "github" } ], - "time": "2020-09-28T05:52:38+00:00" + "time": "2022-04-03T09:37:03+00:00" }, { "name": "sebastian/exporter", @@ -1547,16 +1323,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.3", + "version": "5.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", "shasum": "" }, "require": { @@ -1599,7 +1375,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" }, "funding": [ { @@ -1607,7 +1383,7 @@ "type": "github" } ], - "time": "2021-06-11T13:31:12+00:00" + "time": "2022-02-14T08:28:10+00:00" }, { "name": "sebastian/lines-of-code", @@ -1898,28 +1674,28 @@ }, { "name": "sebastian/type", - "version": "2.3.4", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" + "reference": "fb44e1cc6e557418387ad815780360057e40753e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", - "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb44e1cc6e557418387ad815780360057e40753e", + "reference": "fb44e1cc6e557418387ad815780360057e40753e", "shasum": "" }, "require": { "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1942,7 +1718,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" + "source": "https://github.com/sebastianbergmann/type/tree/3.1.0" }, "funding": [ { @@ -1950,7 +1726,7 @@ "type": "github" } ], - "time": "2021-06-15T12:49:02+00:00" + "time": "2022-08-29T06:55:37+00:00" }, { "name": "sebastian/version", @@ -2007,16 +1783,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.6.2", + "version": "3.7.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "shasum": "" }, "require": { @@ -2059,89 +1835,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-12-12T21:44:58+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.24.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-10-20T20:35:02+00:00" + "time": "2022-06-18T07:21:10+00:00" }, { "name": "theseer/tokenizer", @@ -2192,64 +1886,6 @@ } ], "time": "2021-07-28T10:34:58+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" - }, - "time": "2021-03-09T10:59:23+00:00" } ], "aliases": [], @@ -2261,5 +1897,5 @@ "php": ">7.4" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/ruleset.xml b/ruleset.xml index c746767..7034ee6 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -15,11 +15,5 @@ - - 0 - - diff --git a/src/Resque/Failure/Failure.php b/src/Resque/Failure/Failure.php index 958fcf0..1a0b17f 100644 --- a/src/Resque/Failure/Failure.php +++ b/src/Resque/Failure/Failure.php @@ -25,8 +25,12 @@ class Failure * @param \Resque\Worker $worker Instance of Resque_Worker that was running this job when it failed. * @param string $queue The name of the queue that this job was fetched from. */ - public static function create($payload, \Exception $exception, \Resque\Worker $worker, $queue) - { + public static function create( + $payload, + \Exception $exception, + \Resque\Worker $worker, + $queue + ) { $backend = self::getBackend(); new $backend($payload, $exception, $worker, $queue); } @@ -34,11 +38,11 @@ class Failure /** * Return an instance of the backend for saving job failures. * - * @return object|string + * @return string */ public static function getBackend() { - if (self::$backend === null) { + if (is_null(self::$backend)) { self::$backend = '\\Resque\\Failure\\ResqueFailureRedis'; } @@ -51,8 +55,10 @@ class Failure * It is your responsibility to have the backend class loaded (or autoloaded) * * @param string $backend The class name of the backend to pipe failures to. + * + * @return void */ - public static function setBackend($backend) + public static function setBackend(string $backend): void { self::$backend = $backend; } diff --git a/src/Resque/Job/Factory.php b/src/Resque/Job/Factory.php index a25b98a..380ca05 100644 --- a/src/Resque/Job/Factory.php +++ b/src/Resque/Job/Factory.php @@ -15,7 +15,9 @@ class Factory implements FactoryInterface * @param $className * @param array $args * @param $queue + * * @return \Resque\Job\JobInterface + * * @throws \Resque\Exception */ public function create($className, $args, $queue) @@ -28,13 +30,14 @@ class Factory implements FactoryInterface if (!method_exists($className, 'perform')) { throw new \Resque\Exception( - 'Job class ' . $className . ' does not contain a perform method.' + 'Job class ' . $className . ' does not contain a perform() method.' ); } $instance = new $className(); $instance->args = $args; $instance->queue = $queue; + return $instance; } } diff --git a/src/Resque/Job/FactoryInterface.php b/src/Resque/Job/FactoryInterface.php index 279dead..a44d6ac 100644 --- a/src/Resque/Job/FactoryInterface.php +++ b/src/Resque/Job/FactoryInterface.php @@ -15,6 +15,7 @@ interface FactoryInterface * @param $className * @param array $args * @param $queue + * * @return \Resque\Job\JobInterface */ public function create($className, $args, $queue); diff --git a/src/Resque/Job/Job.php b/src/Resque/Job/Job.php index 4717e59..32ff7b2 100755 --- a/src/Resque/Job/Job.php +++ b/src/Resque/Job/Job.php @@ -62,7 +62,7 @@ class Job * * @throws \InvalidArgumentException */ - public static function create($queue, $class, $args = null, $monitor = false, $id = null) + public static function create($queue, $class, $args = null, $monitor = false, $id = null): string { if (is_null($id)) { $id = \Resque\Resque::generateJobId(); @@ -93,13 +93,13 @@ class Job * * @param string $queue The name of the queue to check for a job in. * - * @return false|object Null when there aren't any waiting jobs, instance of \Resque\Job\Job when a job was found. + * @return Job|null Null when there aren't any waiting jobs, instance of \Resque\Job\Job when a job was found. */ - public static function reserve($queue) + public static function reserve($queue): ?Job { $payload = \Resque\Resque::pop($queue); if (!is_array($payload)) { - return false; + return null; } return new Job($queue, $payload); @@ -112,13 +112,13 @@ class Job * @param array $queues * @param int $timeout * - * @return false|object Null when there aren't any waiting jobs, instance of \Resque\Job\Job when a job was found. + * @return Job|null Null when there aren't any waiting jobs, instance of \Resque\Job\Job when a job was found. */ - public static function reserveBlocking(array $queues, $timeout = null) + public static function reserveBlocking(array $queues, $timeout = null): ?Job { $item = \Resque\Resque::blpop($queues, $timeout); if (!is_array($item)) { - return false; + return null; } return new Job($item['queue'], $item['payload']); @@ -292,9 +292,10 @@ class Job */ public function getJobFactory() { - if ($this->jobFactory === null) { + if (is_null($this->jobFactory)) { $this->jobFactory = new Factory(); } + return $this->jobFactory; } } diff --git a/src/Resque/Job/Status.php b/src/Resque/Job/Status.php index 29d412e..2092820 100644 --- a/src/Resque/Job/Status.php +++ b/src/Resque/Job/Status.php @@ -59,7 +59,7 @@ class Status 'updated' => time(), 'started' => time(), ]; - \Resque\Resque::redis()->setex('job:' . $id . ':status', 172800, json_encode($statusPacket)); + \Resque\Resque::redis()->setex('job:' . $id . ':status', 86400, json_encode($statusPacket)); } /** @@ -98,7 +98,7 @@ class Status 'status' => $status, 'updated' => time(), ]; - \Resque\Resque::redis()->setex((string)$this, 172800, json_encode($statusPacket)); + \Resque\Resque::redis()->setex((string)$this, 86400, json_encode($statusPacket)); // Expire the status for completed jobs after 24 hours if (in_array($status, self::$completeStatuses)) { @@ -128,8 +128,10 @@ class Status /** * Stop tracking the status of a job. + * + * @return void */ - public function stop() + public function stop(): void { \Resque\Resque::redis()->del((string)$this); } diff --git a/src/Resque/Log.php b/src/Resque/Log.php index 986ae2b..e446a72 100644 --- a/src/Resque/Log.php +++ b/src/Resque/Log.php @@ -14,7 +14,7 @@ class Log extends \Psr\Log\AbstractLogger { public $logLevel; - public function __construct($logLevel = "warning") + public function __construct($logLevel = 'warning') { $this->logLevel = strtolower($logLevel); } @@ -30,14 +30,14 @@ class Log extends \Psr\Log\AbstractLogger public function log($level, $message, array $context = []) { $logLevels = [ - "emergency", - "alert", - "critical", - "error", - "warning", - "notice", - "info", - "debug", + 'emergency', + 'alert', + 'critical', + 'error', + 'warning', + 'notice', + 'info', + 'debug', ]; /** diff --git a/src/Resque/Redis.php b/src/Resque/Redis.php index 4b3b610..f726feb 100644 --- a/src/Resque/Redis.php +++ b/src/Resque/Redis.php @@ -104,9 +104,12 @@ class Redis /** * Set Redis namespace (prefix) default: resque + * * @param string $namespace + * + * @return void */ - public static function prefix($namespace) + public static function prefix(string $namespace): void { if (substr($namespace, -1) !== ':' && $namespace != '') { $namespace .= ':'; @@ -119,6 +122,7 @@ class Redis * @param int $database A database number to select. However, if we find a valid database number in the DSN the * DSN-supplied value will be used instead and this parameter is ignored. * @param object $client Optional \Credis_Client instance instantiated by you + * * @throws \Resque\RedisException */ public function __construct($server, $database = null, $client = null) @@ -167,7 +171,7 @@ class Redis * @return array An array of DSN compotnents, with 'false' values for any unknown components. e.g. * [host, port, db, user, pass, options] */ - public static function parseDsn($dsn) + public static function parseDsn($dsn): array { if ($dsn == '') { // Use a sensible default for an empty DNS string @@ -234,7 +238,9 @@ class Redis * * @param string $name The name of the method called. * @param array $args Array of supplied arguments to the method. + * * @return mixed Return value from Resident::call() based on the command. + * * @throws Resque_RedisException */ public function __call($name, $args) @@ -250,23 +256,18 @@ class Redis } try { return $this->driver->__call($name, $args); - } catch (\CredisException $e) { + } catch (\Exception $e) { throw new RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e); } } + /** + * Returns redis prefix + * + * @return string + */ public static function getPrefix(): string { return self::$defaultNamespace; } - - public static function removePrefix($string): string - { - $prefix = self::getPrefix(); - - if (substr($string, 0, strlen($prefix)) == $prefix) { - $string = substr($string, strlen($prefix), strlen($string)); - } - return $string; - } } diff --git a/src/Resque/RedisException.php b/src/Resque/RedisException.php index 4318e18..c875887 100644 --- a/src/Resque/RedisException.php +++ b/src/Resque/RedisException.php @@ -3,7 +3,7 @@ namespace Resque; /** - * Redis related exceptions + * Redis exceptions * * @package Resque * @author Daniel Mason diff --git a/src/Resque/Resque.php b/src/Resque/Resque.php index 710ed4d..06fff0d 100644 --- a/src/Resque/Resque.php +++ b/src/Resque/Resque.php @@ -12,7 +12,7 @@ namespace Resque; class Resque { - public const VERSION = '2.0.2'; + public const VERSION = '2.0.3'; public const DEFAULT_INTERVAL = 5; @@ -58,7 +58,7 @@ class Resque */ public static function redis() { - if (self::$redis !== null) { + if (!is_null(self::$redis)) { return self::$redis; } @@ -113,11 +113,14 @@ class Resque if ($encodedItem === false) { return false; } + self::redis()->sadd('queues', $queue); + $length = self::redis()->rpush('queue:' . $queue, $encodedItem); if ($length < 1) { return false; } + return true; } @@ -253,9 +256,9 @@ class Resque * * @param string $queue Queue to fetch next available job from. * - * @return false|object|\Resque\Job\Job + * @return \Resque\Job\Job|null */ - public static function reserve($queue) + public static function reserve($queue): ?\Resque\Job\Job { return \Resque\Job\Job::reserve($queue); } diff --git a/src/Resque/Stat.php b/src/Resque/Stat.php index 6d6bd8b..66cdb55 100644 --- a/src/Resque/Stat.php +++ b/src/Resque/Stat.php @@ -16,9 +16,10 @@ class Stat * Get the value of the supplied statistic counter for the specified statistic. * * @param string $stat The name of the statistic to get the stats for. - * @return mixed Value of the statistic. + * + * @return int Value of the statistic. */ - public static function get($stat): int + public static function get(string $stat): int { return (int)Resque::redis()->get('stat:' . $stat); } diff --git a/src/Resque/Worker.php b/src/Resque/Worker.php index 550bdef..9164437 100644 --- a/src/Resque/Worker.php +++ b/src/Resque/Worker.php @@ -284,7 +284,7 @@ class Worker if ($blocking === true) { $job = \Resque\Job\Job::reserveBlocking($queues, $timeout); - if ($job) { + if (!is_null($job)) { $this->logger->log(\Psr\Log\LogLevel::INFO, 'Found job on {queue}', ['queue' => $job->queue]); return $job; } @@ -292,7 +292,7 @@ class Worker foreach ($queues as $queue) { $this->logger->log(\Psr\Log\LogLevel::INFO, 'Checking {queue} for jobs', ['queue' => $queue]); $job = \Resque\Job\Job::reserve($queue); - if ($job) { + if (!is_null($job)) { $this->logger->log(\Psr\Log\LogLevel::INFO, 'Found job on {queue}', ['queue' => $job->queue]); return $job; } @@ -491,7 +491,7 @@ class Worker public function registerWorker() { Resque::redis()->sadd('workers', (string)$this); - Resque::redis()->setex('worker:' . (string)$this . ':started', 172800, date('D M d H:i:s T Y')); + Resque::redis()->setex('worker:' . (string)$this . ':started', 86400, date('D M d H:i:s T Y')); } /** @@ -527,7 +527,7 @@ class Worker 'run_at' => date('D M d H:i:s T Y'), 'payload' => $job->payload ]); - Resque::redis()->setex('worker:' . $job->worker, 172800, $data); + Resque::redis()->setex('worker:' . $job->worker, 86400, $data); } /** @@ -567,9 +567,10 @@ class Worker * Get a statistic belonging to this worker. * * @param string $stat Statistic to fetch. + * * @return int Statistic value. */ - public function getStat($stat) + public function getStat(string $stat): int { return \Resque\Stat::get($stat . ':' . $this); } diff --git a/tests/Resque/Tests/JobTest.php b/tests/Resque/Tests/JobTest.php index 40c5506..7c9f1b0 100644 --- a/tests/Resque/Tests/JobTest.php +++ b/tests/Resque/Tests/JobTest.php @@ -34,7 +34,7 @@ class JobTest extends TestCase \Resque\Resque::enqueue('jobs', '\Resque\Test\TestJob'); $job = \Resque\Job\Job::reserve('jobs'); - if ($job == false) { + if (is_null($job)) { $this->fail('Job could not be reserved.'); } $this->assertEquals('jobs', $job->queue); @@ -76,7 +76,7 @@ class JobTest extends TestCase { \Resque\Resque::enqueue('jobs', '\Resque\Test\TestJob'); \Resque\Job\Job::reserve('jobs'); - $this->assertFalse(\Resque\Job\Job::reserve('jobs')); + $this->assertNull(\Resque\Job\Job::reserve('jobs')); } public function testRecreatedJobMatchesExistingJob() diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4d3cf91..c93fc96 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,7 +11,6 @@ namespace Resque\Test; */ $loader = require __DIR__ . '/../vendor/autoload.php'; -// $loader->add('Resque_Tests', __DIR__); # Redis configuration global $redisTestServer;