2.0.3 (2022-09-12)

- Update composer packages
- Added WoodpeckerCI tests
- Updated links in composer package
- Stricter typing
This commit is contained in:
idanoo 2022-09-12 19:50:02 +12:00
parent f9a22e7b8a
commit 05cae402b5
Signed by: idanoo
GPG Key ID: 387387CDBC02F132
21 changed files with 215 additions and 524 deletions

8
.woodpecker/.lint.yml Normal file
View File

@ -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

25
.woodpecker/.test.yml Normal file
View File

@ -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

View File

@ -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) ## 2.0.2 (2022-02-15)
- Replace strftime with strtotime for PHP8.1 support - Replace strftime with strtotime for PHP8.1 support
- Added processing class into proc line for easier debugging - Added processing class into proc line for easier debugging

View File

@ -1,6 +1,8 @@
php-resque: PHP Resque Worker (and Enqueue) 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 Resque is a Redis-backed library for creating background jobs, placing
those jobs on one or more queues, and processing them later. those jobs on one or more queues, and processing them later.
@ -58,7 +60,7 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
```json ```json
{ {
"require": { "require": {
"idanoo/php-resque": "^1.4" "idanoo/php-resque": "^2.0"
} }
} }
``` ```
@ -80,7 +82,7 @@ Jobs are queued as follows:
```php ```php
// Required if redis is located elsewhere // Required if redis is located elsewhere
Resque::setBackend('localhost:6379'); Resque::setBackend('redis:6379');
$args = ['name' => 'TestName']; $args = ['name' => 'TestName'];
@ -468,7 +470,7 @@ needing to directly examine the code), have a look at `HOWITWORKS.md`.
## Contributors ## ## Contributors ##
### Current Maintainers ### ### Current Maintainers ###
* @iDanoo * @idanoo
### Past Maintainer / Forked From ### ### Past Maintainer / Forked From ###

View File

@ -38,7 +38,9 @@ if (empty($QUEUE)) {
*/ */
$REDIS_BACKEND = getenv('REDIS_BACKEND'); $REDIS_BACKEND = getenv('REDIS_BACKEND');
// Override redis DB numbers /**
* REDIS_BACKEND_DB overrides default Redis DB
*/
$REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB'); $REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB');
if (!empty($REDIS_BACKEND)) { if (!empty($REDIS_BACKEND)) {
if (empty($REDIS_BACKEND_DB)) { if (empty($REDIS_BACKEND_DB)) {

View File

@ -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.", "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"], "keywords": ["job", "background", "redis", "resque", "php"],
"homepage": "http://www.github.com/idanoo/php-resque/", "homepage": "https://tinker.nz/idanoo/php-resque/",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
{ {
@ -18,7 +18,7 @@
"require": { "require": {
"php": ">7.4", "php": ">7.4",
"psr/log": "^1.1.0", "psr/log": "^1.1.0",
"colinmollenhour/credis": "^1.12.0" "colinmollenhour/credis": "^1.13.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9", "phpunit/phpunit": "^9",
@ -38,7 +38,7 @@
} }
}, },
"support": { "support": {
"issues": "https://github.com/idanoo/php-resque/issues", "issues": "https://tinker.nz/idanoo/php-resque/issues",
"source": "https://github.com/idanoo/php-resque" "source": "https://tinker.nz/idanoo/php-resque"
} }
} }

548
composer.lock generated
View File

@ -4,24 +4,27 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3b306efc1905a1f6cce0808d41fcf19c", "content-hash": "67934d62707c83cdcba540469eff2fe7",
"packages": [ "packages": [
{ {
"name": "colinmollenhour/credis", "name": "colinmollenhour/credis",
"version": "v1.12.1", "version": "v1.13.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/colinmollenhour/credis.git", "url": "https://github.com/colinmollenhour/credis.git",
"reference": "c27faa11724229986335c23f4b6d0f1d8d6547fb" "reference": "85df015088e00daf8ce395189de22c8eb45c8d49"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/colinmollenhour/credis/zipball/c27faa11724229986335c23f4b6d0f1d8d6547fb", "url": "https://api.github.com/repos/colinmollenhour/credis/zipball/85df015088e00daf8ce395189de22c8eb45c8d49",
"reference": "c27faa11724229986335c23f4b6d0f1d8d6547fb", "reference": "85df015088e00daf8ce395189de22c8eb45c8d49",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.4.0" "php": ">=5.6.0"
},
"suggest": {
"ext-redis": "Improved performance for communicating with redis"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -46,9 +49,9 @@
"homepage": "https://github.com/colinmollenhour/credis", "homepage": "https://github.com/colinmollenhour/credis",
"support": { "support": {
"issues": "https://github.com/colinmollenhour/credis/issues", "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", "name": "psr/log",
@ -104,29 +107,30 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
"version": "1.4.0", "version": "1.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/instantiator.git", "url": "https://github.com/doctrine/instantiator.git",
"reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc",
"reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0" "php": "^7.1 || ^8.0"
}, },
"require-dev": { "require-dev": {
"doctrine/coding-standard": "^8.0", "doctrine/coding-standard": "^9",
"ext-pdo": "*", "ext-pdo": "*",
"ext-phar": "*", "ext-phar": "*",
"phpbench/phpbench": "^0.13 || 1.0.0-alpha2", "phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^0.12", "phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^0.12", "phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.22"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -153,7 +157,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/doctrine/instantiator/issues", "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": [ "funding": [
{ {
@ -169,29 +173,33 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-11-10T18:47:58+00:00" "time": "2022-03-03T08:28:38+00:00"
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
"version": "1.10.2", "version": "1.11.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/myclabs/DeepCopy.git", "url": "https://github.com/myclabs/DeepCopy.git",
"reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614",
"reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0" "php": "^7.1 || ^8.0"
}, },
"conflict": {
"doctrine/collections": "<1.6.8",
"doctrine/common": "<2.13.3 || >=3,<3.2.2"
},
"require-dev": { "require-dev": {
"doctrine/collections": "^1.0", "doctrine/collections": "^1.6.8",
"doctrine/common": "^2.6", "doctrine/common": "^2.13.3 || ^3.2.2",
"phpunit/phpunit": "^7.1" "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -216,7 +224,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/myclabs/DeepCopy/issues", "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": [ "funding": [
{ {
@ -224,20 +232,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-11-13T09:40:50+00:00" "time": "2022-03-03T13:19:32+00:00"
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.13.2", "version": "v4.15.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "210577fe3cf7badcc5814d99455df46564f3c077" "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900",
"reference": "210577fe3cf7badcc5814d99455df46564f3c077", "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -278,9 +286,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/nikic/PHP-Parser/issues", "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", "name": "phar-io/manifest",
@ -344,16 +352,16 @@
}, },
{ {
"name": "phar-io/version", "name": "phar-io/version",
"version": "3.1.1", "version": "3.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phar-io/version.git", "url": "https://github.com/phar-io/version.git",
"reference": "15a90844ad40f127afd244c0cad228de2a80052a" "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/15a90844ad40f127afd244c0cad228de2a80052a", "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
"reference": "15a90844ad40f127afd244c0cad228de2a80052a", "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -389,256 +397,29 @@
"description": "Library for handling version information and constraints", "description": "Library for handling version information and constraints",
"support": { "support": {
"issues": "https://github.com/phar-io/version/issues", "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" "time": "2022-02-21T01:04:05+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"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "9.2.10", "version": "9.2.17",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8",
"reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-libxml": "*", "ext-libxml": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"nikic/php-parser": "^4.13.0", "nikic/php-parser": "^4.14",
"php": ">=7.3", "php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3", "phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2", "phpunit/php-text-template": "^2.0.2",
@ -687,7 +468,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "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": [ "funding": [
{ {
@ -695,7 +476,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-12-05T09:12:13+00:00" "time": "2022-08-30T12:24:04+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -940,16 +721,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "9.5.13", "version": "9.5.24",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "597cb647654ede35e43b137926dfdfef0fb11743" "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0aa6097bef9fd42458a9b3c49da32c6ce6129c5",
"reference": "597cb647654ede35e43b137926dfdfef0fb11743", "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -964,8 +745,7 @@
"phar-io/manifest": "^2.0.3", "phar-io/manifest": "^2.0.3",
"phar-io/version": "^3.0.2", "phar-io/version": "^3.0.2",
"php": ">=7.3", "php": ">=7.3",
"phpspec/prophecy": "^1.12.1", "phpunit/php-code-coverage": "^9.2.13",
"phpunit/php-code-coverage": "^9.2.7",
"phpunit/php-file-iterator": "^3.0.5", "phpunit/php-file-iterator": "^3.0.5",
"phpunit/php-invoker": "^3.1.1", "phpunit/php-invoker": "^3.1.1",
"phpunit/php-text-template": "^2.0.3", "phpunit/php-text-template": "^2.0.3",
@ -979,13 +759,9 @@
"sebastian/global-state": "^5.0.1", "sebastian/global-state": "^5.0.1",
"sebastian/object-enumerator": "^4.0.3", "sebastian/object-enumerator": "^4.0.3",
"sebastian/resource-operations": "^3.0.3", "sebastian/resource-operations": "^3.0.3",
"sebastian/type": "^2.3.4", "sebastian/type": "^3.1",
"sebastian/version": "^3.0.2" "sebastian/version": "^3.0.2"
}, },
"require-dev": {
"ext-pdo": "*",
"phpspec/prophecy-phpunit": "^2.0.1"
},
"suggest": { "suggest": {
"ext-soap": "*", "ext-soap": "*",
"ext-xdebug": "*" "ext-xdebug": "*"
@ -1000,11 +776,11 @@
} }
}, },
"autoload": { "autoload": {
"classmap": [
"src/"
],
"files": [ "files": [
"src/Framework/Assert/Functions.php" "src/Framework/Assert/Functions.php"
],
"classmap": [
"src/"
] ]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -1027,7 +803,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "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": [ "funding": [
{ {
@ -1039,7 +815,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-01-24T07:33:35+00:00" "time": "2022-08-30T07:42:16+00:00"
}, },
{ {
"name": "sebastian/cli-parser", "name": "sebastian/cli-parser",
@ -1407,16 +1183,16 @@
}, },
{ {
"name": "sebastian/environment", "name": "sebastian/environment",
"version": "5.1.3", "version": "5.1.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/environment.git", "url": "https://github.com/sebastianbergmann/environment.git",
"reference": "388b6ced16caa751030f6a69e588299fa09200ac" "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7",
"reference": "388b6ced16caa751030f6a69e588299fa09200ac", "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1458,7 +1234,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/environment/issues", "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": [ "funding": [
{ {
@ -1466,7 +1242,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-09-28T05:52:38+00:00" "time": "2022-04-03T09:37:03+00:00"
}, },
{ {
"name": "sebastian/exporter", "name": "sebastian/exporter",
@ -1547,16 +1323,16 @@
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
"version": "5.0.3", "version": "5.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git", "url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1599,7 +1375,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues", "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": [ "funding": [
{ {
@ -1607,7 +1383,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-06-11T13:31:12+00:00" "time": "2022-02-14T08:28:10+00:00"
}, },
{ {
"name": "sebastian/lines-of-code", "name": "sebastian/lines-of-code",
@ -1898,28 +1674,28 @@
}, },
{ {
"name": "sebastian/type", "name": "sebastian/type",
"version": "2.3.4", "version": "3.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/type.git", "url": "https://github.com/sebastianbergmann/type.git",
"reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" "reference": "fb44e1cc6e557418387ad815780360057e40753e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb44e1cc6e557418387ad815780360057e40753e",
"reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", "reference": "fb44e1cc6e557418387ad815780360057e40753e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.3" "php": ">=7.3"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.3" "phpunit/phpunit": "^9.5"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.3-dev" "dev-master": "3.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -1942,7 +1718,7 @@
"homepage": "https://github.com/sebastianbergmann/type", "homepage": "https://github.com/sebastianbergmann/type",
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/type/issues", "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": [ "funding": [
{ {
@ -1950,7 +1726,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-06-15T12:49:02+00:00" "time": "2022-08-29T06:55:37+00:00"
}, },
{ {
"name": "sebastian/version", "name": "sebastian/version",
@ -2007,16 +1783,16 @@
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "3.6.2", "version": "3.7.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619",
"reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2059,89 +1835,7 @@
"source": "https://github.com/squizlabs/PHP_CodeSniffer", "source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
}, },
"time": "2021-12-12T21:44:58+00:00" "time": "2022-06-18T07:21:10+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"
}, },
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",
@ -2192,64 +1886,6 @@
} }
], ],
"time": "2021-07-28T10:34:58+00:00" "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": [], "aliases": [],
@ -2261,5 +1897,5 @@
"php": ">7.4" "php": ">7.4"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.2.0" "plugin-api-version": "2.3.0"
} }

View File

@ -15,11 +15,5 @@
<ini name="memory_limit" value="256M"/> <ini name="memory_limit" value="256M"/>
<rule ref="PSR12"> <rule ref="PSR12">
<!-- <severity>8</severity> -->
<show_warnings>0</show_warnings>
</rule> </rule>
<!-- <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>src</exclude-pattern>
</rule> -->
</ruleset> </ruleset>

View File

@ -25,8 +25,12 @@ class Failure
* @param \Resque\Worker $worker Instance of Resque_Worker that was running this job when it failed. * @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. * @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(); $backend = self::getBackend();
new $backend($payload, $exception, $worker, $queue); new $backend($payload, $exception, $worker, $queue);
} }
@ -34,11 +38,11 @@ class Failure
/** /**
* Return an instance of the backend for saving job failures. * Return an instance of the backend for saving job failures.
* *
* @return object|string * @return string
*/ */
public static function getBackend() public static function getBackend()
{ {
if (self::$backend === null) { if (is_null(self::$backend)) {
self::$backend = '\\Resque\\Failure\\ResqueFailureRedis'; self::$backend = '\\Resque\\Failure\\ResqueFailureRedis';
} }
@ -51,8 +55,10 @@ class Failure
* It is your responsibility to have the backend class loaded (or autoloaded) * 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. * @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; self::$backend = $backend;
} }

View File

@ -15,7 +15,9 @@ class Factory implements FactoryInterface
* @param $className * @param $className
* @param array $args * @param array $args
* @param $queue * @param $queue
*
* @return \Resque\Job\JobInterface * @return \Resque\Job\JobInterface
*
* @throws \Resque\Exception * @throws \Resque\Exception
*/ */
public function create($className, $args, $queue) public function create($className, $args, $queue)
@ -28,13 +30,14 @@ class Factory implements FactoryInterface
if (!method_exists($className, 'perform')) { if (!method_exists($className, 'perform')) {
throw new \Resque\Exception( 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 = new $className();
$instance->args = $args; $instance->args = $args;
$instance->queue = $queue; $instance->queue = $queue;
return $instance; return $instance;
} }
} }

View File

@ -15,6 +15,7 @@ interface FactoryInterface
* @param $className * @param $className
* @param array $args * @param array $args
* @param $queue * @param $queue
*
* @return \Resque\Job\JobInterface * @return \Resque\Job\JobInterface
*/ */
public function create($className, $args, $queue); public function create($className, $args, $queue);

View File

@ -62,7 +62,7 @@ class Job
* *
* @throws \InvalidArgumentException * @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)) { if (is_null($id)) {
$id = \Resque\Resque::generateJobId(); $id = \Resque\Resque::generateJobId();
@ -93,13 +93,13 @@ class Job
* *
* @param string $queue The name of the queue to check for a job in. * @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); $payload = \Resque\Resque::pop($queue);
if (!is_array($payload)) { if (!is_array($payload)) {
return false; return null;
} }
return new Job($queue, $payload); return new Job($queue, $payload);
@ -112,13 +112,13 @@ class Job
* @param array $queues * @param array $queues
* @param int $timeout * @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); $item = \Resque\Resque::blpop($queues, $timeout);
if (!is_array($item)) { if (!is_array($item)) {
return false; return null;
} }
return new Job($item['queue'], $item['payload']); return new Job($item['queue'], $item['payload']);
@ -292,9 +292,10 @@ class Job
*/ */
public function getJobFactory() public function getJobFactory()
{ {
if ($this->jobFactory === null) { if (is_null($this->jobFactory)) {
$this->jobFactory = new Factory(); $this->jobFactory = new Factory();
} }
return $this->jobFactory; return $this->jobFactory;
} }
} }

View File

@ -59,7 +59,7 @@ class Status
'updated' => time(), 'updated' => time(),
'started' => 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, 'status' => $status,
'updated' => time(), '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 // Expire the status for completed jobs after 24 hours
if (in_array($status, self::$completeStatuses)) { if (in_array($status, self::$completeStatuses)) {
@ -128,8 +128,10 @@ class Status
/** /**
* Stop tracking the status of a job. * Stop tracking the status of a job.
*
* @return void
*/ */
public function stop() public function stop(): void
{ {
\Resque\Resque::redis()->del((string)$this); \Resque\Resque::redis()->del((string)$this);
} }

View File

@ -14,7 +14,7 @@ class Log extends \Psr\Log\AbstractLogger
{ {
public $logLevel; public $logLevel;
public function __construct($logLevel = "warning") public function __construct($logLevel = 'warning')
{ {
$this->logLevel = strtolower($logLevel); $this->logLevel = strtolower($logLevel);
} }
@ -30,14 +30,14 @@ class Log extends \Psr\Log\AbstractLogger
public function log($level, $message, array $context = []) public function log($level, $message, array $context = [])
{ {
$logLevels = [ $logLevels = [
"emergency", 'emergency',
"alert", 'alert',
"critical", 'critical',
"error", 'error',
"warning", 'warning',
"notice", 'notice',
"info", 'info',
"debug", 'debug',
]; ];
/** /**

View File

@ -104,9 +104,12 @@ class Redis
/** /**
* Set Redis namespace (prefix) default: resque * Set Redis namespace (prefix) default: resque
*
* @param string $namespace * @param string $namespace
*
* @return void
*/ */
public static function prefix($namespace) public static function prefix(string $namespace): void
{ {
if (substr($namespace, -1) !== ':' && $namespace != '') { if (substr($namespace, -1) !== ':' && $namespace != '') {
$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 * @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. * DSN-supplied value will be used instead and this parameter is ignored.
* @param object $client Optional \Credis_Client instance instantiated by you * @param object $client Optional \Credis_Client instance instantiated by you
*
* @throws \Resque\RedisException * @throws \Resque\RedisException
*/ */
public function __construct($server, $database = null, $client = null) 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. * @return array An array of DSN compotnents, with 'false' values for any unknown components. e.g.
* [host, port, db, user, pass, options] * [host, port, db, user, pass, options]
*/ */
public static function parseDsn($dsn) public static function parseDsn($dsn): array
{ {
if ($dsn == '') { if ($dsn == '') {
// Use a sensible default for an empty DNS string // 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 string $name The name of the method called.
* @param array $args Array of supplied arguments to the method. * @param array $args Array of supplied arguments to the method.
*
* @return mixed Return value from Resident::call() based on the command. * @return mixed Return value from Resident::call() based on the command.
*
* @throws Resque_RedisException * @throws Resque_RedisException
*/ */
public function __call($name, $args) public function __call($name, $args)
@ -250,23 +256,18 @@ class Redis
} }
try { try {
return $this->driver->__call($name, $args); return $this->driver->__call($name, $args);
} catch (\CredisException $e) { } catch (\Exception $e) {
throw new RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e); throw new RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e);
} }
} }
/**
* Returns redis prefix
*
* @return string
*/
public static function getPrefix(): string public static function getPrefix(): string
{ {
return self::$defaultNamespace; 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;
}
} }

View File

@ -3,7 +3,7 @@
namespace Resque; namespace Resque;
/** /**
* Redis related exceptions * Redis exceptions
* *
* @package Resque * @package Resque
* @author Daniel Mason <daniel@m2.nz> * @author Daniel Mason <daniel@m2.nz>

View File

@ -12,7 +12,7 @@ namespace Resque;
class Resque class Resque
{ {
public const VERSION = '2.0.2'; public const VERSION = '2.0.3';
public const DEFAULT_INTERVAL = 5; public const DEFAULT_INTERVAL = 5;
@ -58,7 +58,7 @@ class Resque
*/ */
public static function redis() public static function redis()
{ {
if (self::$redis !== null) { if (!is_null(self::$redis)) {
return self::$redis; return self::$redis;
} }
@ -113,11 +113,14 @@ class Resque
if ($encodedItem === false) { if ($encodedItem === false) {
return false; return false;
} }
self::redis()->sadd('queues', $queue); self::redis()->sadd('queues', $queue);
$length = self::redis()->rpush('queue:' . $queue, $encodedItem); $length = self::redis()->rpush('queue:' . $queue, $encodedItem);
if ($length < 1) { if ($length < 1) {
return false; return false;
} }
return true; return true;
} }
@ -253,9 +256,9 @@ class Resque
* *
* @param string $queue Queue to fetch next available job from. * @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); return \Resque\Job\Job::reserve($queue);
} }

View File

@ -16,9 +16,10 @@ class Stat
* Get the value of the supplied statistic counter for the specified statistic. * 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. * @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); return (int)Resque::redis()->get('stat:' . $stat);
} }

View File

@ -284,7 +284,7 @@ class Worker
if ($blocking === true) { if ($blocking === true) {
$job = \Resque\Job\Job::reserveBlocking($queues, $timeout); $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]); $this->logger->log(\Psr\Log\LogLevel::INFO, 'Found job on {queue}', ['queue' => $job->queue]);
return $job; return $job;
} }
@ -292,7 +292,7 @@ class Worker
foreach ($queues as $queue) { foreach ($queues as $queue) {
$this->logger->log(\Psr\Log\LogLevel::INFO, 'Checking {queue} for jobs', ['queue' => $queue]); $this->logger->log(\Psr\Log\LogLevel::INFO, 'Checking {queue} for jobs', ['queue' => $queue]);
$job = \Resque\Job\Job::reserve($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]); $this->logger->log(\Psr\Log\LogLevel::INFO, 'Found job on {queue}', ['queue' => $job->queue]);
return $job; return $job;
} }
@ -491,7 +491,7 @@ class Worker
public function registerWorker() public function registerWorker()
{ {
Resque::redis()->sadd('workers', (string)$this); 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'), 'run_at' => date('D M d H:i:s T Y'),
'payload' => $job->payload '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. * Get a statistic belonging to this worker.
* *
* @param string $stat Statistic to fetch. * @param string $stat Statistic to fetch.
*
* @return int Statistic value. * @return int Statistic value.
*/ */
public function getStat($stat) public function getStat(string $stat): int
{ {
return \Resque\Stat::get($stat . ':' . $this); return \Resque\Stat::get($stat . ':' . $this);
} }

View File

@ -34,7 +34,7 @@ class JobTest extends TestCase
\Resque\Resque::enqueue('jobs', '\Resque\Test\TestJob'); \Resque\Resque::enqueue('jobs', '\Resque\Test\TestJob');
$job = \Resque\Job\Job::reserve('jobs'); $job = \Resque\Job\Job::reserve('jobs');
if ($job == false) { if (is_null($job)) {
$this->fail('Job could not be reserved.'); $this->fail('Job could not be reserved.');
} }
$this->assertEquals('jobs', $job->queue); $this->assertEquals('jobs', $job->queue);
@ -76,7 +76,7 @@ class JobTest extends TestCase
{ {
\Resque\Resque::enqueue('jobs', '\Resque\Test\TestJob'); \Resque\Resque::enqueue('jobs', '\Resque\Test\TestJob');
\Resque\Job\Job::reserve('jobs'); \Resque\Job\Job::reserve('jobs');
$this->assertFalse(\Resque\Job\Job::reserve('jobs')); $this->assertNull(\Resque\Job\Job::reserve('jobs'));
} }
public function testRecreatedJobMatchesExistingJob() public function testRecreatedJobMatchesExistingJob()

View File

@ -11,7 +11,6 @@ namespace Resque\Test;
*/ */
$loader = require __DIR__ . '/../vendor/autoload.php'; $loader = require __DIR__ . '/../vendor/autoload.php';
// $loader->add('Resque_Tests', __DIR__);
# Redis configuration # Redis configuration
global $redisTestServer; global $redisTestServer;