Skip to content

Commit a05e5c0

Browse files
authored
Merge pull request #5 from trylika/master
Upgrade SLM Version to support PHP 8
2 parents 935e3f8 + 7179f81 commit a05e5c0

File tree

10 files changed

+34
-97
lines changed

10 files changed

+34
-97
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
"bin-dir": "bin/"
1616
},
1717
"require": {
18-
"php": "^7.2",
19-
"laminas/laminas-console": "^2.7",
18+
"php": "^7.4 || ~8.0",
19+
"laminas/laminas-cli": "^1.1",
2020
"laminas/laminas-modulemanager": "^2.8",
2121
"laminas/laminas-stdlib": "^3.2",
2222
"laminas/laminas-eventmanager": "^3.2",
2323
"laminas/laminas-servicemanager": "^3.3",
2424
"laminas/laminas-mvc": "^3.1",
2525
"container-interop/container-interop": "^1.2",
26-
"php-amqplib/php-amqplib": "^2.7",
27-
"slm/queue": "^2.0",
28-
"psr/log": "^1.0"
26+
"php-amqplib/php-amqplib": "^3.1",
27+
"slm/queue": "^3.0",
28+
"psr/log": "^1.1"
2929
},
3030
"require-dev": {
31-
"phpunit/phpunit": "^7.3"
31+
"phpunit/phpunit": "^9.5"
3232
},
3333
"autoload": {
3434
"psr-4": {

config/module.config.php

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

3-
use SlmQueueRabbitMq\Controller\RabbitMqWorkerController;
4-
use SlmQueueRabbitMq\Factory\RabbitMqWorkerControllerFactory;
3+
use SlmQueueRabbitMq\ConfigFactory;
54
use SlmQueueRabbitMq\Strategy\IdleNapStrategy;
65
use SlmQueueRabbitMq\Worker\RabbitMqWorker;
76
use SlmQueueRabbitMq\Factory\RabbitMqWorkerFactory;
@@ -21,32 +20,15 @@
2120
IdleNapStrategy::class => InvokableFactory::class,
2221
],
2322
],
24-
],
25-
'service_manager' => [
26-
'factories' => [
27-
RabbitMqWorker::class => RabbitMqWorkerFactory::class,
28-
'SlmQueueRabbitMq\Config' => \SlmQueueRabbitMq\ConfigFactory::class,
23+
'worker_manager' => [
24+
'factories' => [
25+
RabbitMqWorker::class => RabbitMqWorkerFactory::class,
26+
],
2927
],
3028
],
31-
'controllers' => [
29+
'service_manager' => [
3230
'factories' => [
33-
RabbitMqWorkerController::class => RabbitMqWorkerControllerFactory::class,
34-
],
35-
],
36-
'console' => [
37-
'router' => [
38-
'routes' => [
39-
'slm-queue-rabbit_mq-worker' => [
40-
'type' => 'Simple',
41-
'options' => [
42-
'route' => 'queue rabbitmq <queue> --start',
43-
'defaults' => [
44-
'controller' => RabbitMqWorkerController::class,
45-
'action' => 'process'
46-
],
47-
],
48-
],
49-
],
31+
'SlmQueueRabbitMq\Config' => ConfigFactory::class,
5032
],
5133
],
5234
'slm-queue-rabbitmq' => [

src/ConfigFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class ConfigFactory implements FactoryInterface
99
{
1010
/**
1111
* @inheritdoc
12-
* @return array
1312
*/
1413
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
1514
{

src/Controller/RabbitMqWorkerController.php

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

src/Factory/RabbitMqWorkerControllerFactory.php

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

src/Factory/RabbitMqWorkerFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
use Interop\Container\ContainerInterface;
66
use Psr\Log\LoggerInterface;
77
use Psr\Log\NullLogger;
8-
use SlmQueue\Factory\WorkerFactory;
8+
use SlmQueue\Factory\WorkerAbstractFactory;
99
use SlmQueue\Strategy\StrategyPluginManager;
1010
use SlmQueue\Worker\WorkerInterface;
1111
use SlmQueueRabbitMq\Job\MessageRetryCounter;
1212
use SlmQueueRabbitMq\Worker\RabbitMqWorker;
1313
use Laminas\EventManager\EventManager;
1414
use Laminas\ServiceManager\Factory\FactoryInterface;
1515

16-
class RabbitMqWorkerFactory extends WorkerFactory implements FactoryInterface
16+
class RabbitMqWorkerFactory extends WorkerAbstractFactory implements FactoryInterface
1717
{
1818
/**
1919
* @inheritdoc

src/Module.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,21 @@
33
namespace SlmQueueRabbitMq;
44

55
use Laminas\Console\Adapter\AdapterInterface;
6-
use Laminas\ModuleManager\Feature;
6+
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
7+
use Laminas\ModuleManager\Feature\DependencyIndicatorInterface;
78

8-
class Module implements
9-
Feature\ConfigProviderInterface,
10-
Feature\ConsoleUsageProviderInterface,
11-
Feature\DependencyIndicatorInterface
9+
class Module implements ConfigProviderInterface, DependencyIndicatorInterface
1210
{
1311
/**
14-
* {@inheritDoc}
12+
* @inheritdoc
1513
*/
1614
public function getConfig()
1715
{
1816
return include __DIR__ . '/../config/module.config.php';
1917
}
2018

2119
/**
22-
* {@inheritDoc}
23-
*/
24-
public function getConsoleUsage(AdapterInterface $console)
25-
{
26-
return [
27-
'queue rabbitmq <queueName> --start' => 'Process the jobs',
28-
29-
['<queueName>', 'Queue\'s name to process'],
30-
];
31-
}
32-
33-
/**
34-
* {@inheritDoc}
20+
* @inheritdoc
3521
*/
3622
public function getModuleDependencies()
3723
{

src/Queue/RabbitMqQueue.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use SlmQueue\Job\JobInterface;
1010
use SlmQueue\Job\JobPluginManager;
1111
use SlmQueue\Queue\AbstractQueue;
12+
use SlmQueueRabbitMq\Worker\RabbitMqWorker;
1213

1314
class RabbitMqQueue extends AbstractQueue implements RabbitMqQueueInterface
1415
{
@@ -21,6 +22,8 @@ class RabbitMqQueue extends AbstractQueue implements RabbitMqQueueInterface
2122
/** @var array */
2223
private $defaultMessageOptions;
2324

25+
protected static $defaultWorkerName = RabbitMqWorker::class;
26+
2427
/**
2528
* @param Connection $connection
2629
* @param string $name

tests/Job/MessageRetryCounterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MessageRetryCounterTest extends TestCase
1313
/** @var MessageRetryCounter */
1414
private $messageRetryCounter;
1515

16-
protected function setUp()
16+
protected function setUp(): void
1717
{
1818
$this->messageRetryCounter = new MessageRetryCounter([
1919
'some_queue_name' => [

tests/phpunit.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<phpunit cacheResult="false">
2-
<testsuite name="SlmQueueRabbitMq Test Suite">
3-
<directory>./</directory>
4-
</testsuite>
5-
<filter>
6-
<whitelist>
7-
<directory>../src/*/</directory>
8-
</whitelist>
9-
</filter>
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" cacheResult="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory>../src/*/</directory>
6+
</include>
7+
</coverage>
8+
<testsuite name="SlmQueueRabbitMq Test Suite">
9+
<directory>./</directory>
10+
</testsuite>
1011
</phpunit>

0 commit comments

Comments
 (0)