Skip to content

Commit 5fbfe4b

Browse files
Merge pull request #7 from LinioIT/feat/7.4
fix: migrate to 7.4
2 parents 782d846 + 14e9183 commit 5fbfe4b

20 files changed

+122
-172
lines changed

.php_cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ return PhpCsFixer\Config::create()
1313
'array_syntax' => ['syntax' => 'short'],
1414
'blank_line_after_opening_tag' => true,
1515
'concat_space' => ['spacing' => 'one'],
16+
'class_attributes_separation' => ['elements' => ['method']],
1617
'declare_strict_types' => true,
1718
'increment_style' => ['style' => 'post'],
1819
'is_null' => ['use_yoda_style' => false],
@@ -22,7 +23,7 @@ return PhpCsFixer\Config::create()
2223
'modernize_types_casting' => true,
2324
'no_multiline_whitespace_before_semicolons' => true,
2425
'no_superfluous_elseif' => true,
25-
'no_superfluous_phpdoc_tags' => true,
26+
'no_superfluous_phpdoc_tags' => false,
2627
'no_useless_else' => true,
2728
'no_useless_return' => true,
2829
'ordered_imports' => true,
@@ -31,6 +32,7 @@ return PhpCsFixer\Config::create()
3132
'php_unit_construct' => true,
3233
'php_unit_dedicate_assert' => true,
3334
'return_assignment' => true,
35+
'single_blank_line_at_eof' => true,
3436
'single_line_comment_style' => true,
3537
'ternary_to_null_coalescing' => true,
3638
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],

.travis.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
language: php
22

33
php:
4-
- 7.0
5-
6-
cache:
7-
directories:
8-
- vendor
4+
- 7.4
95

106
install:
117
- travis_retry composer install --no-interaction --prefer-source
128

139
script:
14-
- vendor/bin/php-cs-fixer fix --dry-run -v
15-
- vendor/bin/phpunit --verbose
10+
- composer test
1611

1712
matrix:
1813
fast_finish: true

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The recommended way to install Linio Queue is [through composer](http://getcompo
1212
```JSON
1313
{
1414
"require": {
15-
"linio/queue": "~1.0"
15+
"linio/queue": "~3.0"
1616
}
1717
}
1818
```
@@ -35,21 +35,19 @@ Silex, a service provider is included. Just register it:
3535
```php
3636
<?php
3737

38-
$app->register(new \Linio\Component\Queue\Provider\QueueServiceProvider(), [
39-
'queue.adapter_name' => 'rabbit',
40-
'queue.adapter_options' => [
41-
'host' => 'localhost',
42-
'port' => 5672,
43-
'username' => 'guest',
44-
'password' => 'guest',
45-
'vhost' => '/'
46-
],
47-
]);
38+
use Linio\Component\Queue\QueueService;
39+
use Linio\Component\Queue\Adapter;
4840

49-
```
41+
$queue = new QueueService();
42+
$queue->setAdapter(new Adapter\RabbitAdapter([
43+
'host' => 'localhost',
44+
'port' => 5672,
45+
'username' => 'guest',
46+
'password' => 'guest',
47+
'vhost' => '/'
48+
]));
5049

51-
Note that must provide an adapter name and an array of options. Each adapter
52-
has different configuration options that are injected by the `AdapterFactory`.
50+
```
5351

5452
In order to create a work queue, you must extend the abstract class `Job`:
5553

composer.json

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
{
2-
"name": "linio/queue",
3-
"description": "Abstracts work queues, used to distribute time-consuming tasks among multiple workers.",
4-
"keywords": ["linio", "queue", "rabbit", "rabbitmq", "distributed"],
5-
"type": "library",
6-
"license": "BSD-3-Clause",
7-
"require": {
8-
"php": ">=7.1",
9-
"psr/log": "^1.0",
10-
"linio/util": "^2.0",
11-
"php-amqplib/php-amqplib": "^2.6"
12-
},
13-
"require-dev": {
14-
"phpunit/phpunit": ">=5.0",
15-
"friendsofphp/php-cs-fixer": "^2.4"
16-
},
17-
"autoload": {
18-
"psr-4": {
19-
"Linio\\Component\\": "src/"
20-
}
21-
},
22-
"autoload-dev": {
23-
"psr-4": {
24-
"Linio\\Component\\": "tests/"
25-
}
2+
"name": "linio/queue",
3+
"description": "Abstracts work queues, used to distribute time-consuming tasks among multiple workers.",
4+
"keywords": ["linio", "queue", "rabbit", "rabbitmq", "distributed"],
5+
"type": "library",
6+
"license": "BSD-3-Clause",
7+
"require": {
8+
"php": "^7.4",
9+
"psr/log": "^1.0",
10+
"linio/util": "^3.0",
11+
"php-amqplib/php-amqplib": "^2.11"
12+
},
13+
"require-dev": {
14+
"friendsofphp/php-cs-fixer": "^2.16",
15+
"phpstan/phpstan": "^0.12",
16+
"phpunit/phpunit": "^8.5"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"Linio\\Component\\": "src/"
2621
}
22+
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"Linio\\Component\\": "tests/"
26+
}
27+
},
28+
"scripts": {
29+
"lint": "php-cs-fixer fix --verbose --show-progress=estimating",
30+
"lint:check": "php-cs-fixer fix --dry-run --verbose --show-progress=estimating",
31+
"phpunit": "phpunit",
32+
"phpstan": "phpstan analyze",
33+
"test": [
34+
"@lint:check",
35+
"@phpunit",
36+
"@phpstan"
37+
]
38+
}
2739
}

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: max
3+
checkMissingIterableValueType: false
4+
paths:
5+
- src

phpunit.xml.ci

Lines changed: 0 additions & 35 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5-
backupGlobals="false"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
stopOnFailure="false"
11-
bootstrap="./vendor/autoload.php">
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
executionOrder="depends,defects"
6+
forceCoversAnnotation="true"
7+
beStrictAboutCoversAnnotation="true"
8+
beStrictAboutOutputDuringTests="true"
9+
beStrictAboutTodoAnnotatedTests="true"
10+
verbose="true">
1211
<testsuites>
13-
<testsuite name="Linio Framework Test Suite">
14-
<directory>./tests</directory>
12+
<testsuite name="default">
13+
<directory suffix="Test.php">tests</directory>
1514
</testsuite>
1615
</testsuites>
16+
1717
<filter>
18-
<whitelist addUncoveredFilesFromWhitelist="true">
19-
<directory suffix=".php">./src</directory>
20-
<exclude>
21-
<directory suffix="Interface.php">./src</directory>
22-
<directory suffix="Aware.php">./src</directory>
23-
<directory suffix="Trait.php">./src</directory>
24-
</exclude>
18+
<whitelist processUncoveredFilesFromWhitelist="true">
19+
<directory suffix=".php">src</directory>
2520
</whitelist>
2621
</filter>
2722
</phpunit>

src/Queue/Adapter/NullAdapter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
class NullAdapter implements AdapterInterface
1111
{
12+
protected array $config;
13+
1214
public function __construct(array $config = [])
1315
{
16+
$this->config = $config;
1417
}
1518

1619
public function add(Job $job): void

src/Queue/Adapter/RabbitAdapter.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@
1212

1313
class RabbitAdapter implements AdapterInterface
1414
{
15-
/**
16-
* @var AMQPChannel
17-
*/
18-
protected $channel;
19-
20-
/**
21-
* @var array
22-
*/
23-
protected $config = [];
15+
protected ?AMQPChannel $channel = null;
16+
protected array $config = [];
2417

2518
public function __construct(array $config = [])
2619
{
@@ -37,15 +30,15 @@ public function add(Job $job): void
3730
public function perform(Job $job): void
3831
{
3932
$this->getChannel()->queue_declare($job->getQueue(), true, $job->isPersistent(), false, false);
40-
$this->getChannel()->basic_qos(null, 1, null);
33+
$this->getChannel()->basic_qos(0, 1, false);
4134
$this->getChannel()->basic_consume($job->getQueue(), '', false, false, false, false, function ($message) use ($job): void {
4235
$job->setPayload($message->body);
4336
$job->perform();
4437

4538
if ($job->isFinished()) {
4639
$message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
4740
} else {
48-
$this->channel->basic_nack($message->delivery_info['delivery_tag'], false, true);
41+
$this->getChannel()->basic_nack($message->delivery_info['delivery_tag'], false, true);
4942
}
5043
});
5144

src/Queue/AdapterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface AdapterInterface
88
{
99
public function __construct(array $config);
1010

11-
public function add(Job $job);
11+
public function add(Job $job): void;
1212

13-
public function perform(Job $job);
13+
public function perform(Job $job): void;
1414
}

0 commit comments

Comments
 (0)