Skip to content

Commit b1d71e2

Browse files
authored
Merge pull request #6 from pdffiller/travis
travis
2 parents 4019b44 + f0b911f commit b1d71e2

File tree

8 files changed

+176
-9
lines changed

8 files changed

+176
-9
lines changed

.travis.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
sudo: false
2+
3+
language: php
4+
php:
5+
- '7.3'
6+
- '7.2'
7+
- '7.1'
8+
9+
matrix:
10+
fast_finish: true
11+
allow_failures:
12+
- php: 'master'
13+
14+
services:
15+
- redis-server
16+
17+
git:
18+
depth: 1
19+
20+
branches:
21+
only:
22+
- master
23+
- development
24+
25+
cache:
26+
apt: true
27+
ccache: true
28+
timeout: 604800
29+
directories:
30+
- $HOME/.composer/cache
31+
- $HOME/bin
32+
33+
env:
34+
global:
35+
- REDIS_HOST="127.0.0.1"
36+
- REDIS_PORT="6379"
37+
- REDIS_TIMEOUT="0.0"
38+
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"
39+
40+
before_install:
41+
- if [[ ! -z "${GH_TOKEN}" ]]; then composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"; fi;
42+
- ulimit -c unlimited -S || true
43+
44+
install:
45+
- composer install $DEFAULT_COMPOSER_FLAGS
46+
- |
47+
if [ ! -f $HOME/bin/infection ]; then
48+
wget https://github.com/infection/infection/releases/download/0.10.3/infection.phar
49+
wget https://github.com/infection/infection/releases/download/0.10.3/infection.phar.asc
50+
chmod +x infection.phar
51+
gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys 493B4AA0
52+
gpg --with-fingerprint --verify infection.phar.asc infection.phar
53+
mkdir -p $HOME/bin && mv infection.phar $HOME/bin/infection
54+
fi
55+
56+
before_script:
57+
- composer diagnose || true
58+
59+
script:
60+
- ./vendor/bin/phpunit --disallow-test-output
61+
62+
after_success:
63+
- if [[ ! -z "${CODECOV_TOKEN}" ]]; then (bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"); fi;
64+
65+
after_failure:
66+
- $(phpenv which php) -v
67+
- for m in `$(phpenv which php) -m | grep -e 'json\|pcntl\|posix\|sockets\|pcre'`; do php --ri $m; done
68+
69+
notifications:
70+
email: false
71+
72+
jobs:
73+
include:
74+
- stage: Static Code Analysis
75+
php: 7.2
76+
env: PHPStan
77+
script:
78+
- ./vendor/bin/phpstan analyse src/ --level max
79+
- stage: Static Code Analysis
80+
php: 7.2
81+
env: PHP_CodeSniffer
82+
before_script:
83+
- phpenv config-rm xdebug.ini || true
84+
script:
85+
- ./vendor/bin/phpcs src
86+
- stage: Mutation Testing
87+
php: 7.2
88+
script:
89+
- ./vendor/bin/phpunit --disallow-test-output
90+
- $HOME/bin/infection --threads=4

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
},
2121
"require-dev": {
2222
"illuminate/events": "5.6.*|5.7.*",
23+
"infection/infection": "^0.12.0",
2324
"orchestra/testbench": "~3.0",
24-
"phpunit/phpunit": ">=5.3 <8.0"
25+
"phpstan/phpstan": "^0.11.1",
26+
"phpunit/phpunit": ">=5.3 <8.0",
27+
"squizlabs/php_codesniffer": "^3.4"
2528
},
2629
"autoload": {
2730
"psr-4": {

infection.json.dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"source": {
3+
"directories": [
4+
"src"
5+
]
6+
},
7+
"timeout": 15,
8+
"logs": {
9+
"text": "infection-log.txt",
10+
"json": "infection-log.json",
11+
"badge": {
12+
"branch": "master"
13+
}
14+
}
15+
}

phpcs.xml.dist

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="LaravelQless">
3+
4+
<!--
5+
The name attribute of the ruleset tag is displayed
6+
when running PHP_CodeSniffer with the -v command line
7+
argument. The description tag below is not displayed anywhere
8+
except in this file, so it can contain information for
9+
developers who may change this file in the future.
10+
-->
11+
<description>The coding standard for LaravelQless</description>
12+
13+
<!-- Show sniff codes in all reports -->
14+
<arg value="s"/>
15+
16+
<!-- Use PSR-2 as a base -->
17+
<rule ref="PSR2"/>
18+
19+
<!-- Uncomment to use colors in progress or report -->
20+
<!-- arg name="colors" / -->
21+
22+
<!--
23+
If no files or directories are specified on the command line
24+
your custom standard can specify what files should be checked
25+
instead.
26+
Note that specifying any file or directory path
27+
on the command line will ignore all file tags.
28+
-->
29+
<file>src</file>
30+
<file>tests</file>
31+
32+
<!--
33+
You can hard-code ignore patterns directly into your
34+
custom standard so you don't have to specify the
35+
patterns on the command line.
36+
-->
37+
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
38+
<exclude-pattern>tests/publish.php</exclude-pattern>
39+
</ruleset>

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
reportUnmatchedIgnoredErrors: false
3+
ignoreErrors:
4+
- '#Cannot access offset#'
5+
- '#Method LaravelQless\\Queue\\QlessQueue::makePayload\(\) should return string but returns string|false.#'

src/Handler/DefaultHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
use LaravelQless\Contracts\JobHandler;
66
use Qless\Jobs\BaseJob;
77

8+
/**
9+
* Class DefaultHandler
10+
* @package LaravelQless\Handler
11+
*/
812
class DefaultHandler implements JobHandler
913
{
14+
/**
15+
* @param BaseJob $job
16+
*/
1017
public function perform(BaseJob $job): void
1118
{
1219
$job->perform();

src/Job/QlessJob.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ public function maxTries()
148148
/**
149149
* Get the number of seconds the job can run.
150150
*
151-
* @return int|null
151+
* @return int
152152
*/
153153
public function timeout()
154154
{
155-
return $this->job->ttl();
155+
return (int) $this->job->ttl();
156156
}
157157

158158
/**
159159
* Get the timestamp indicating when the job should timeout.
160160
*
161-
* @return int|null
161+
* @return int
162162
*/
163163
public function timeoutAt()
164164
{

src/Queue/QlessQueue.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
use Illuminate\Queue\InvalidPayloadException;
77
use Illuminate\Queue\Queue;
88
use LaravelQless\Contracts\JobHandler;
9+
use LaravelQless\Job\AbstractJob;
910
use LaravelQless\Job\QlessJob;
1011
use Qless\Client;
12+
use Qless\Jobs\BaseJob;
1113
use Qless\Topics\Topic;
1214

1315
/**
@@ -56,7 +58,7 @@ public function __construct(Client $connect, array $config)
5658
*/
5759
public function size($queue = null): int
5860
{
59-
return $this->getConnection()->length($queue);
61+
return $this->getConnection()->length($queue ?? '');
6062
}
6163

6264
/**
@@ -159,13 +161,14 @@ public function recur(int $interval, string $job, array $data, ?string $queueNam
159161
* Pop the next job off of the queue.
160162
*
161163
* @param string $queueName
162-
* @return \Illuminate\Contracts\Queue\Job|null|QlessJob
164+
* @return QlessJob|null
163165
*/
164166
public function pop($queueName = null)
165167
{
166168
/** @var \Qless\Queues\Queue $queue */
167169
$queue = $this->getConnection()->queues[$queueName];
168170

171+
/** @var BaseJob $job */
169172
$job = $queue->pop(self::WORKER_PREFIX . $this->connect->getWorkerName());
170173

171174
if (!$job) {
@@ -220,7 +223,7 @@ public function unSubscribe(string $topic, string $queueName = null): bool
220223
* @param array $options
221224
* @return array|string
222225
*/
223-
public function pushToTopic(string $topicName, string $job, array $data = [], array $options = []): array
226+
public function pushToTopic(string $topicName, string $job, array $data = [], array $options = [])
224227
{
225228
$topic = new Topic($topicName, $this->getConnection());
226229

@@ -247,10 +250,15 @@ public function pushToTopic(string $topicName, string $job, array $data = [], ar
247250
*/
248251
protected function makePayload($job, $data = [], $options = []): string
249252
{
250-
if (is_object($job)) {
253+
$displayName = '';
254+
if ($job instanceof AbstractJob) {
251255
$displayName = get_class($job);
252256
$data = array_merge($job->toArray(), $data);
253-
} else {
257+
} elseif (is_object($job)) {
258+
$displayName = get_class($job);
259+
}
260+
261+
if (is_string($job)) {
254262
$displayName = explode('@', $job)[0];
255263
}
256264

0 commit comments

Comments
 (0)