Skip to content

Commit

Permalink
Merge pull request #6 from MarwanAlsoltany/dev
Browse files Browse the repository at this point in the history
Fix deprecations and add backward compatibility
  • Loading branch information
MarwanAlsoltany authored Sep 14, 2020
2 parents 5b18a9f + 78e7e12 commit f689346
Show file tree
Hide file tree
Showing 119 changed files with 745 additions and 644 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ sudo: required
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4

services:
Expand All @@ -15,7 +18,7 @@ addons:

env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest --prefer-stable"
- COMPOSER_FLAGS="--prefer-stable --prefer-dist"

cache:
directories:
Expand All @@ -25,11 +28,11 @@ cache:
before_script:
- sudo service rabbitmq-server restart
- composer self-update
- composer update --prefer-dist $COMPOSER_FLAGS
- composer update $COMPOSER_FLAGS

script:
- vendor/bin/phpunit --coverage-clover=coverage.clover

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ All notable changes to AMQP Agent will be documented in this file.
- Update methods signature on the corresponding interface (AbstractWorkerInterface)
- Update DocBlocks of other classes to reference the newly created methods.
- Rebuild documentation.

## [1.1.1] - 2020-09-14
- Update composer.json
- Pump minimum php-amqplib version.
- Downgrade minimum php version.
- Update dev requirements versions to match php version.
- Update branch-alias.
- Update scripts field.
- Add conflict field.
- Fix php < 7.4 type hinting incompatibility
- remove return type "self" from methods signature in all interfaces.
- Fix php-amqplib v2.12.0 deprecations
- Fix references to deprecated properties in php-amqplib v2.12.0.
- Change AbstractWorker arguments method to a static method
- Refactor some internal functionalities in different classes
- Update tests so that they run faster
- Update Travis config
- Rebuild documentation
64 changes: 33 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ An elegant wrapper around the famous php-amqplib for 90% use case.
[![Travis Build Status][travis-icon]][travis-href]
[![StyleCI Code Style][styleci-icon]][styleci-href]

[php-icon]: https://img.shields.io/badge/php-%5E7.4-yellow?style=flat-square
[php-icon]: https://img.shields.io/badge/php-%5E7.1-yellow?style=flat-square
[version-icon]: https://img.shields.io/packagist/v/marwanalsoltany/amqp-agent.svg?style=flat-square
[license-icon]: https://img.shields.io/badge/license-LGPL_2.1_or_later-red.svg?style=flat-square
[maintenance-icon]: https://img.shields.io/badge/maintained-yes-orange.svg?style=flat-square
Expand Down Expand Up @@ -98,6 +98,8 @@ Run:
composer update
```

![#ff6347](https://via.placeholder.com/11/f03c15/000000?text=+) **Note:** *AMQP Agent supports now PHP 7.1 by default starting from version v1.1.1, if you used the `php7.1-compatibility` branch in older versions, update your composer.json!*

---


Expand Down Expand Up @@ -164,54 +166,54 @@ If you want to fine-tune and tweak AMQP Agent configuration to your exact needs,
<?php return [
// Global
'connectionOptions' => [
'host' => 'your-rabbitmq-server.com',
'port' => 5672,
'user' => 'your-username',
'password' => 'your-password',
'vhost' => '/'
'host' => 'your-rabbitmq-server.com',
'port' => 5672,
'user' => 'your-username',
'password' => 'your-password',
'vhost' => '/'
],
'queueOptions' => [
'queue' => 'your.queue.name',
'durable' => true,
'nowait' => false
'queue' => 'your.queue.name',
'durable' => true,
'nowait' => false
],
// Publisher
'exchangeOptions' => [
'exchange' => 'your.exchange.name',
'type' => 'direct'
'exchange' => 'your.exchange.name',
'type' => 'direct'
],
'bindOptions' => [
'queue' => 'your.queue.name',
'exchange' => 'your.exchange.name'
'queue' => 'your.queue.name',
'exchange' => 'your.exchange.name'
],
'messageOptions' => [
'properties' => [
'content_type' => 'application/json',
'content_encoding' => 'UTF-8',
'delivery_mode' => 2
'properties' => [
'content_type' => 'application/json',
'content_encoding' => 'UTF-8',
'delivery_mode' => 2
]
],
'publishOptions' => [
'exchange' => 'your.exchange.name',
'routing_key' => 'your.route.name'
'exchange' => 'your.exchange.name',
'routing_key' => 'your.route.name'
],
// Consumer
'qosOptions' => [
'prefetch_count' => 25
'prefetch_count' => 25
],
'waitOptions' => [
'timeout' => 3600
'timeout' => 3600
],
'consumeOptions' => [
'queue' => 'your.queue.name',
'consumer_tag' => 'your.consumer.name',
'callback' => 'YourNamespace\YourClass::yourCallback'
'queue' => 'your.queue.name',
'consumer_tag' => 'your.consumer.name',
'callback' => 'YourNamespace\YourClass::yourCallback'
]
];

```

![#ff6347](https://via.placeholder.com/11/f03c15/000000?text=+) **Note:** *Array key names suffixed with `Option` are specific to AMQP Agent.*
![#ff6347](https://via.placeholder.com/11/f03c15/000000?text=+) **Note:** *Array key names suffixed with `Options` are specific to AMQP Agent.*


---
Expand All @@ -224,7 +226,7 @@ Before we start with examples, we have to clarify a few things. It's worth menti
#### The ways a worker can be retrieved

1. The simplest way is to instantiate a worker directly i.e. using `new` keyword. This way requires passing parameters via the constructor, method calls, or public property assignment.
2. The more advanced way is Retrieving a singleton worker i.e `PublisherSingleton::getInstance()`. This way requires passing parameters via `getInstance()` method, method calls, or public property assignment.
2. The more advanced way is retrieving a singleton worker i.e `PublisherSingleton::getInstance()`. This way requires passing parameters via `getInstance()` method, method calls, or public property assignment.
3. The more advanced but recommended way is to use an instance of the `Client` class. This way also makes code more readable as the parameters are retrieved from the passed config.


Expand Down Expand Up @@ -587,7 +589,7 @@ $publisher->publish(
);

// Since we have two consumers now, one from the original worker
// and the one other gets started later in the callback. We have
// and the other gets started later in the callback. We have
// to publish two channel-closing commands to stop the consumers.
// These will be added at the end after low importance messages.
$iterator = 2;
Expand Down Expand Up @@ -657,7 +659,7 @@ $consumer->queue([
])
]);

// Overwriting the dafault quality of service.
// Overwriting the default quality of service.
$consumer->qos([
'prefetch_count' => 1,
]);
Expand Down Expand Up @@ -722,7 +724,7 @@ $callback = function($message, &$client, $callback) {
$consumer->consume(
$callback,
[
&$client, // Is used to refetch the consumer, serlializer, and logger.
&$client, // Is used to refetch the consumer, serializer, and logger.
$callback // This gets passed to the consumer that get started by the callback.
],
[
Expand All @@ -731,7 +733,7 @@ $consumer->consume(
);

// Here we have to wait using waitForAll() method
// because we have consumers that start dynamicly.
// because we have consumers that start dynamically.
$consumer->waitForAll();

// Close the connection with RabbitMQ server.
Expand All @@ -741,7 +743,7 @@ $consumer->disconnect();

![#1e90ff](https://via.placeholder.com/11/1e90ff/000000?text=+) **Fact:** *You can make the code in Publisher/Consumer Advanced Examples way more easer if you make all parameters' changes in a config file and pass it to the client instead of the default.*

![#32cd32](https://via.placeholder.com/11/32cd32/000000?text=+) **Advice:** *AMQP Agent code-base is well document, please refere to [this link](https://marwanalsoltany.github.io/amqp-agent/classes.html) to have a look over all classes and methods.*
![#32cd32](https://via.placeholder.com/11/32cd32/000000?text=+) **Advice:** *AMQP Agent code-base is well documented, please refere to [this link](https://marwanalsoltany.github.io/amqp-agent/classes.html) to have a look over all classes and methods.*


---
Expand Down
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"authors": [
{
"name": "Marwan Al-Soltany",
"email": "[email protected]",
"email": "MarwanAlsoltany+gh@gmail.com",
"homepage": "https://marwanalsoltany.github.io/",
"role": "Developer"
}
Expand All @@ -26,23 +26,26 @@
"issues": "https://github.com/MarwanAlsoltany/amqp-agent/issues"
},
"require": {
"php" : "^7.4",
"php-amqplib/php-amqplib": "^2.11"
"php" : "^7.1",
"php-amqplib/php-amqplib": "^2.12"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5.5",
"theseer/phpdox": "^0.12.0",
"phpunit/phpunit": "~8.5",
"phploc/phploc": "^5.0.0",
"phpunit/phpunit": "^7.5.20",
"phploc/phploc": "^4.0.1",
"phpmd/phpmd": "^2.8.1"
},
"conflict": {
"php": "7.4.0 - 7.4.1"
},
"scripts": {
"sniff": "vendor/bin/phpcs --report=xml --report-file=build/phpcs/index.xml src",
"sniff-global": "phpcs --report=xml --report-file=build/phpcs/index.xml src",
"detect": "vendor/bin/phpmd src xml naming,unusedcode --reportfile build/phpmd/index.xml --strict --ignore-violations-on-exit",
"detect-global": "phpmd src xml naming,unusedcode --reportfile build/phpmd/index.xml --strict --ignore-violations-on-exit",
"test": "vendor/bin/phpunit --do-not-cache-result",
"test-global": "phpunit --do-not-cache-result",
"test": "vendor/bin/phpunit",
"test-global": "phpunit",
"measure": "vendor/bin/phploc src --log-xml=build/phploc/index.xml",
"measure-global": "phploc src --log-xml=build/phploc/index.xml",
"document": "vendor/bin/phpdox",
Expand All @@ -66,7 +69,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.1-dev"
}
},
"config": {
Expand Down
8 changes: 4 additions & 4 deletions docs/classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ <h2 id="MAKS_AmqpAgent_Helper">\MAKS\AmqpAgent\Helper</h2>
<td>
<a href="classes/MAKS_AmqpAgent_Helper_Logger.html">Logger</a>
</td>
<td>A class to write logs, exposing methods that work statically and on instantiation.</td>
<td>A class to write logs, exposing methods that work statically and on instantiation. This class DOES NOT implement \Psr\Log\LoggerInterface.</td>
<td class="testresult-PASSED">PASSED</td>
</tr>
<tr>
Expand Down Expand Up @@ -218,7 +218,7 @@ <h2 id="MAKS_AmqpAgent_Worker">\MAKS\AmqpAgent\Worker</h2>
<td>
<a href="classes/MAKS_AmqpAgent_Worker_AbstractWorkerSingleton.html">AbstractWorkerSingleton</a>
</td>
<td>An abstract class implementing mapping functions to turn a normal worker into a singleton.</td>
<td>An abstract class implementing mapping functions (proxy functions) to turn a normal worker into a singleton.</td>
<td class="testresult-PASSED">PASSED</td>
</tr>
<tr>
Expand All @@ -232,7 +232,7 @@ <h2 id="MAKS_AmqpAgent_Worker">\MAKS\AmqpAgent\Worker</h2>
<td>
<a href="classes/MAKS_AmqpAgent_Worker_ConsumerSingleton.html">ConsumerSingleton</a>
</td>
<td>A singleton version of the Consumer class. Static and const properties are accessed via object operator (-&gt; not ::).</td>
<td>A singleton version of the Consumer class.</td>
<td class="testresult-PASSED">PASSED</td>
</tr>
<tr>
Expand All @@ -246,7 +246,7 @@ <h2 id="MAKS_AmqpAgent_Worker">\MAKS\AmqpAgent\Worker</h2>
<td>
<a href="classes/MAKS_AmqpAgent_Worker_PublisherSingleton.html">PublisherSingleton</a>
</td>
<td>A singleton version of the Publisher class. Static and const properties are accessed via object operator (-&gt; not ::).</td>
<td>A singleton version of the Publisher class.</td>
<td class="testresult-PASSED">PASSED</td>
</tr>
</tbody>
Expand Down
12 changes: 6 additions & 6 deletions docs/classes/MAKS_AmqpAgent_Client.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ <h4>A class returns everything AMQP Agent has to offer. A simple service contain
<ul/>
<h2 id="synopsis">Synopsis</h2>
<div class="synopsis">class Client
{<br/><ul class="none"><li>// members</li><li>private <span title="MAKS\AmqpAgent\Config">Config</span> <a href="#members">$config</a>;
</li><li>private <span title="MAKS\AmqpAgent\Worker\Publisher">Publisher</span> <a href="#members">$publisher</a>;
</li><li>private <span title="MAKS\AmqpAgent\Worker\Consumer">Consumer</span> <a href="#members">$consumer</a>;
</li><li>private <span title="MAKS\AmqpAgent\Helper\Serializer">Serializer</span> <a href="#members">$serializer</a>;
</li><li>private <span title="MAKS\AmqpAgent\Helper\Logger">Logger</span> <a href="#members">$logger</a>;
{<br/><ul class="none"><li>// members</li><li>protected <span title="MAKS\AmqpAgent\Config">Config</span> <a href="#members">$config</a>;
</li><li>protected <span title="MAKS\AmqpAgent\Worker\Publisher">Publisher</span> <a href="#members">$publisher</a>;
</li><li>protected <span title="MAKS\AmqpAgent\Worker\Consumer">Consumer</span> <a href="#members">$consumer</a>;
</li><li>protected <span title="MAKS\AmqpAgent\Helper\Serializer">Serializer</span> <a href="#members">$serializer</a>;
</li><li>protected <span title="MAKS\AmqpAgent\Helper\Logger">Logger</span> <a href="#members">$logger</a>;
</li></ul><ul class="none"><li>// methods</li><li>public void <a title="MAKS\AmqpAgent\Client" href="../classes/MAKS_AmqpAgent_Client/__construct.html">__construct</a>()
</li><li>public mixed <a title="MAKS\AmqpAgent\Client" href="../classes/MAKS_AmqpAgent_Client/__get.html">__get</a>()
</li><li>public Config|Publisher|Consumer|Serializer|Logger <a title="MAKS\AmqpAgent\Client" href="../classes/MAKS_AmqpAgent_Client/get.html">get</a>()
Expand All @@ -107,7 +107,7 @@ <h2 id="coverage">Coverage</h2>
</table>
<h2 id="members">Members</h2>
<div class="styled members">
<h4>private</h4>
<h4>protected</h4>
<ul class="members">
<li id="config"><strong>$config</strong>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/MAKS_AmqpAgent_Config.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h2 id="coverage">Coverage</h2>
<tr>
<td>Lines</td>
<td class="percent">100%</td>
<td class="nummeric">41 / 41</td>
<td class="nummeric">42 / 42</td>
</tr>
</table>
<h2 id="violations">Violations</h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/MAKS_AmqpAgent_Config/setConfigPath.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h2 id="tests">Test Coverage</h2>
<div class="styled">
<h3>Information</h3>
<ul class="styled">
<li>Coverage: 9/9 Lines (100%)</li>
<li>Coverage: 10/10 Lines (100%)</li>
<li>Tests: 2</li>
<li>Passed: 2 (100%)</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/MAKS_AmqpAgent_Helper_Example.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2 id="coverage">Coverage</h2>
<tr>
<td>Lines</td>
<td class="percent">100%</td>
<td class="nummeric">13 / 13</td>
<td class="nummeric">12 / 12</td>
</tr>
</table>
<h2 id="members">Members</h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/MAKS_AmqpAgent_Helper_Example/callback.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h2 id="tests">Test Coverage</h2>
<div class="styled">
<h3>Information</h3>
<ul class="styled">
<li>Coverage: 13/13 Lines (100%)</li>
<li>Coverage: 12/12 Lines (100%)</li>
<li>Tests: 1</li>
<li>Passed: 1 (100%)</li>
</ul>
Expand Down
8 changes: 4 additions & 4 deletions docs/classes/MAKS_AmqpAgent_Helper_Logger.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
<a href="#methods">Methods</a>
</li>
<li>
<a href="../source/Helper/Logger.php.html#line18">Source</a>
<a href="../source/Helper/Logger.php.html#line17">Source</a>
</li>
</ul>
</nav>
<section>
<h1 id="introduction"><small>MAKS\AmqpAgent\Helper\</small>Logger</h1>
<h4>A class to write logs, exposing methods that work statically and on instantiation.</h4>
<h4>A class to write logs, exposing methods that work statically and on instantiation. This class DOES NOT implement \Psr\Log\LoggerInterface.</h4>
<p/>
<ul/>
<h2 id="synopsis">Synopsis</h2>
Expand Down Expand Up @@ -99,7 +99,7 @@ <h2 id="coverage">Coverage</h2>
<tr>
<td>Lines</td>
<td class="percent">100%</td>
<td class="nummeric">40 / 40</td>
<td class="nummeric">42 / 42</td>
</tr>
</table>
<h2 id="members">Members</h2>
Expand All @@ -119,7 +119,7 @@ <h2 id="methods">Methods</h2>
<h4>protected</h4>
<ul>
<li id="emit"><a title="MAKS\AmqpAgent\Helper\Logger" href="../classes/MAKS_AmqpAgent_Helper_Logger/emit.html">emit()</a>
— Generates a user-level notice, warning or error with styling.</li>
— Generates a user-level notice, warning, or an error with styling.</li>
</ul>
<h4>public</h4>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/MAKS_AmqpAgent_Helper_Logger/__construct.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<a href="#tests">Tests</a>
</li>
<li>
<a href="../../source/Helper/Logger.php.html#line38">Source</a>
<a href="../../source/Helper/Logger.php.html#line37">Source</a>
</li>
</ul>
</nav>
Expand Down
Loading

0 comments on commit f689346

Please sign in to comment.