Skip to content

Commit c821ce4

Browse files
authored
Merge pull request #4 from FortnoxAB/feature/bump-composer-deps
Bump composer dependencies and setup phpstan.
2 parents 5338472 + 70f9e0c commit c821ce4

File tree

9 files changed

+68
-46
lines changed

9 files changed

+68
-46
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
phpunit: ./vendor
2+
./vendor/bin/phpunit --configuration phpunit.xml.dist
3+
4+
phpstan: ./vendor
5+
./vendor/phpstan/phpstan/phpstan analyse -vvv --error-format=raw -c phpstan.neon.dist

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@
2828
}
2929
],
3030
"require": {
31-
"php": ">=5.6.0",
31+
"php": "^8.2",
3232
"colinmollenhour/credis": "~1.7",
33-
"psr/log": "~1.0"
33+
"psr/log": "^3.0"
3434
},
3535
"suggest": {
3636
"ext-pcntl": "REQUIRED for forking processes on platforms that support it (so anything but Windows).",
3737
"ext-proctitle": "Allows php-resque to rename the title of UNIX processes to show the status of a worker.",
3838
"ext-redis": "Native PHP extension for Redis connectivity. Credis will automatically utilize when available."
3939
},
4040
"require-dev": {
41-
"phpunit/phpunit": "^8.5"
41+
"phpunit/phpunit": "^10",
42+
"phpstan/phpstan": "^1.10"
4243
},
4344
"bin": [
4445
"bin/resque",

demo/php_error_job.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class PHP_Error_Job
33
{
44
public function perform()
55
{
6+
/* @phpstan-ignore-next-line */
67
callToUndefinedFunction();
78
}
8-
}
9+
}

lib/Resque/Log.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @author Chris Boulton <[email protected]>
77
* @license http://www.opensource.org/licenses/mit-license.php
88
*/
9-
class Resque_Log extends Psr\Log\AbstractLogger
9+
class Resque_Log extends Psr\Log\AbstractLogger
1010
{
1111
public $verbose;
1212

@@ -22,8 +22,7 @@ public function __construct($verbose = false) {
2222
* @param array $context Variables to replace { placeholder }
2323
* @return null
2424
*/
25-
public function log($level, $message, array $context = array())
26-
{
25+
public function log($level, $message, array $context = array()): void {
2726
if ($this->verbose) {
2827
fwrite(
2928
STDOUT,
@@ -43,7 +42,7 @@ public function log($level, $message, array $context = array())
4342
/**
4443
* Fill placeholders with the provided context
4544
* @author Jordi Boggiano [email protected]
46-
*
45+
*
4746
* @param string $message Message to be logged
4847
* @param array $context Array of variables to use in message
4948
* @return string
@@ -55,7 +54,7 @@ public function interpolate($message, array $context = array())
5554
foreach ($context as $key => $val) {
5655
$replace['{' . $key . '}'] = $val;
5756
}
58-
57+
5958
// interpolate replacement values into the message and return
6059
return strtr($message, $replace);
6160
}

lib/ResqueScheduler.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class ResqueScheduler
1111
{
1212
const VERSION = "0.1";
13-
13+
1414
/**
1515
* Enqueue a job in a given number of seconds from now.
1616
*
@@ -45,7 +45,7 @@ public static function enqueueAt($at, $queue, $class, $args = array())
4545

4646
$job = self::jobToHash($queue, $class, $args);
4747
self::delayedPush($at, $job);
48-
48+
4949
Resque_Event::trigger('afterSchedule', array(
5050
'at' => $at,
5151
'queue' => $queue,
@@ -87,7 +87,7 @@ public static function getDelayedQueueScheduleSize()
8787
*/
8888
public static function getDelayedTimestampSize($timestamp)
8989
{
90-
$timestamp = self::toTimestamp($timestamp);
90+
$timestamp = self::getTimestamp($timestamp);
9191
return Resque::redis()->llen('delayed:' . $timestamp, $timestamp);
9292
}
9393

@@ -144,7 +144,7 @@ public static function removeDelayedJobFromTimestamp($timestamp, $queue, $class,
144144

145145
return $count;
146146
}
147-
147+
148148
/**
149149
* Generate hash of all job properties to be saved in the scheduled queue.
150150
*
@@ -194,7 +194,7 @@ private static function getTimestamp($timestamp)
194194
if ($timestamp instanceof DateTime) {
195195
$timestamp = $timestamp->getTimestamp();
196196
}
197-
197+
198198
if ((int)$timestamp != $timestamp) {
199199
throw new ResqueScheduler_InvalidTimestampException(
200200
'The supplied timestamp value could not be converted to an integer.'
@@ -224,15 +224,15 @@ public static function nextDelayedTimestamp($at = null)
224224
else {
225225
$at = self::getTimestamp($at);
226226
}
227-
227+
228228
$items = Resque::redis()->zrangebyscore('delayed_queue_schedule', '-inf', $at, array('limit' => array(0, 1)));
229229
if (!empty($items)) {
230230
return $items[0];
231231
}
232-
232+
233233
return false;
234-
}
235-
234+
}
235+
236236
/**
237237
* Pop a job off the delayed queue for a given timestamp.
238238
*
@@ -243,9 +243,9 @@ public static function nextItemForTimestamp($timestamp)
243243
{
244244
$timestamp = self::getTimestamp($timestamp);
245245
$key = 'delayed:' . $timestamp;
246-
246+
247247
$item = json_decode(Resque::redis()->lpop($key), true);
248-
248+
249249
self::cleanupTimestamp($key, $timestamp);
250250
return $item;
251251
}
@@ -265,7 +265,7 @@ private static function validateJob($class, $queue)
265265
else if (empty($queue)) {
266266
throw new Resque_Exception('Jobs must be put in a queue.');
267267
}
268-
268+
269269
return true;
270270
}
271271
}

phpstan.neon.dist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parameters:
2+
level: 1
3+
phpVersion: 80200
4+
parallel:
5+
maximumNumberOfProcesses: 6
6+
cache:
7+
nodesByStringCountMax: 0
8+
paths:
9+
- bin
10+
- demo
11+
- extras
12+
- lib

phpunit.xml.dist

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
bootstrap="test/bootstrap.php"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
12-
>
13-
<testsuites>
14-
<testsuite name="Resque Test Suite">
15-
<directory>./test/Resque/</directory>
16-
</testsuite>
17-
</testsuites>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
4+
bootstrap="test/bootstrap.php"
5+
colors="true"
6+
failOnNotice="true"
7+
failOnWarning="true"
8+
failOnDeprecation="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
12+
cacheDirectory=".phpunit.cache">
1813

19-
<filter>
20-
<whitelist>
21-
<directory suffix=".php">./lib/Resque/</directory>
22-
</whitelist>
23-
</filter>
24-
</phpunit>
14+
<coverage/>
15+
16+
<testsuites>
17+
<testsuite name="Resque Test Suite">
18+
<directory>./test/Resque/</directory>
19+
</testsuite>
20+
</testsuites>
21+
22+
<source>
23+
<include>
24+
<directory suffix=".php">./lib/Resque/</directory>
25+
</include>
26+
</source>
27+
28+
</phpunit>

test/Resque/Tests/EventTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getEventTestJob()
4040
return $job;
4141
}
4242

43-
public function eventCallbackProvider()
43+
public static function eventCallbackProvider(): array
4444
{
4545
return array(
4646
array('beforePerform', 'beforePerformEventCallback'),

test/Resque/Tests/RedisTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testRedisExceptionsAreSurfaced()
2929
*
3030
* @return array
3131
*/
32-
public function validDsnStringProvider()
32+
public static function validDsnStringProvider(): array
3333
{
3434
return array(
3535
// Input , Expected output
@@ -166,7 +166,7 @@ public function validDsnStringProvider()
166166
* These DSN values should throw exceptions
167167
* @return array
168168
*/
169-
public function bogusDsnStringProvider()
169+
public static function bogusDsnStringProvider(): array
170170
{
171171
return array(
172172
array('http://foo.bar/'),

0 commit comments

Comments
 (0)