Skip to content

Commit 0a79acb

Browse files
committed
Merge branch 'develop'
* develop: (37 commits) specify next release update documentation use more explicit int types use promoted properties fix deprecated code always return an error when signalled CS flag Failure::as() as internal CS remove useless code fix tests return an error when the channel or frame size is incorrect instead of throwing bump foundation make Continuation return an Attempt CS make MessageReader return an Attempt keep track of previous errors use Attempt as return type for all Connection methods make Commands return an Attempt make Client::run() return an Attempt to allow to add more error cases ...
2 parents eb34efb + 7c7077f commit 0a79acb

216 files changed

Lines changed: 2341 additions & 1737 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
name: CI
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
6-
phpunit:
6+
blackbox:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
1010
os: [ubuntu-latest]
11-
php-version: ['8.2', '8.3']
11+
php-version: ['8.2', '8.3', '8.4']
1212
dependencies: ['lowest', 'highest']
13-
name: 'PHPUnit'
13+
name: 'BlackBox (${{ matrix.os }}, ${{ matrix.php-version }}, ${{ matrix.dependencies }})'
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717
- uses: nijel/rabbitmq-action@v1.0.0
1818
with:
1919
rabbitmq version: '3.8-management'
@@ -25,49 +25,46 @@ jobs:
2525
coverage: xdebug
2626
ini-values: xdebug.max_nesting_level=2048
2727
- name: Composer
28-
uses: "ramsey/composer-install@v2"
28+
uses: "ramsey/composer-install@v3"
2929
with:
3030
dependency-versions: ${{ matrix.dependencies }}
31-
- name: PHPUnit
32-
run: vendor/bin/phpunit --coverage-clover=coverage.clover
33-
env:
34-
CI: 'true'
35-
- uses: codecov/codecov-action@v1
36-
with:
37-
token: ${{ secrets.CODECOV_TOKEN }}
38-
psalm:
39-
runs-on: ubuntu-latest
31+
- name: BlackBox
32+
run: php blackbox.php ci
33+
coverage:
34+
runs-on: ${{ matrix.os }}
4035
strategy:
4136
matrix:
42-
php-version: ['8.2', '8.3']
43-
name: 'Psalm'
37+
os: [ubuntu-latest]
38+
php-version: ['8.2', '8.3', '8.4']
39+
dependencies: ['lowest', 'highest']
40+
name: 'Coverage (${{ matrix.os }}, ${{ matrix.php-version }}, ${{ matrix.dependencies }})'
4441
steps:
4542
- name: Checkout
46-
uses: actions/checkout@v2
47-
- name: Setup PHP
48-
uses: shivammathur/setup-php@v2
43+
uses: actions/checkout@v4
44+
- uses: nijel/rabbitmq-action@v1.0.0
4945
with:
50-
php-version: ${{ matrix.php-version }}
51-
extensions: mbstring, intl
52-
- name: Composer
53-
uses: "ramsey/composer-install@v2"
54-
- name: Psalm
55-
run: vendor/bin/psalm --shepherd
56-
cs:
57-
runs-on: ubuntu-latest
58-
strategy:
59-
matrix:
60-
php-version: ['8.2']
61-
name: 'CS'
62-
steps:
63-
- name: Checkout
64-
uses: actions/checkout@v2
46+
rabbitmq version: '3.8-management'
6547
- name: Setup PHP
6648
uses: shivammathur/setup-php@v2
6749
with:
6850
php-version: ${{ matrix.php-version }}
6951
extensions: mbstring, intl
52+
coverage: xdebug
53+
ini-values: xdebug.max_nesting_level=2048
7054
- name: Composer
71-
uses: "ramsey/composer-install@v2"
72-
- name: CS
73-
run: vendor/bin/php-cs-fixer fix --diff --dry-run
55+
uses: "ramsey/composer-install@v3"
56+
with:
57+
dependency-versions: ${{ matrix.dependencies }}
58+
- name: BlackBox
59+
run: php blackbox.php ci
60+
env:
61+
ENABLE_COVERAGE: 'true'
62+
- uses: codecov/codecov-action@v4
63+
with:
64+
token: ${{ secrets.CODECOV_TOKEN }}
65+
psalm:
66+
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
67+
cs:
68+
uses: innmind/github-workflows/.github/workflows/cs.yml@main
69+
with:
70+
php-version: '8.2'

.github/workflows/release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Create release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release:
10+
uses: innmind/github-workflows/.github/workflows/release.yml@main
11+
secrets: inherit

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
composer.lock
22
vendor
3-
.phpunit.result.cache
4-
.phpunit.cache

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 6.0.0 - 2025-08-08
4+
5+
### Changed
6+
7+
- Requires `innmind/foundation:~1.7`
8+
- `Innmind\AMQP\Factory::make()` timeout argument is now expressed via `Innmind\TimeContinuum\Period`
9+
- `Innmind\AMQP\Model\Basic\Message` expiration is now expressed via `Innmind\TimeContinuum\Period`
10+
- `Innmind\AMQP\Failure` is now an exception that wraps each possible failure object
11+
- `Innmind\AMQP\Client::run()` now returns an `Innmind\Immutable\Attempt`
12+
- `Innmind\AMQP\Command::__invoke()` now must return an `Innmind\Immutable\Attempt`
13+
14+
### Fixed
15+
16+
- PHP `8.4` deprecations
17+
318
## 5.1.0 - 2024-06-16
419

520
### Changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017
3+
Copyright (c) 2017-present Innmind
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ This is an AMQP client implementing the version `0.9` of the protocol.
88

99
The goal of this implementation is to provide a PHP land implementation (for ease of use and readability) with a clear separation between the AMQP Model, transport layer and user API.
1010

11-
**Note**: This implementation couldn't have been done without [`php-amqplib`](https://packagist.org/packages/php-amqplib/php-amqplib) that helped a lot to figure out the details of the transport layer.
11+
> [!NOTE]
12+
> This implementation couldn't have been done without [`php-amqplib`](https://packagist.org/packages/php-amqplib/php-amqplib) that helped a lot to figure out the details of the transport layer.
1213
13-
**Important**: If you are using RabbitMQ be aware that it doesn't implemented the specification completely, `Qos` and `Recover` methods are not implemented. And if you find yourself using [`Value`](src/Transport/Frame/Value.php) implementations note that `ShortString`, `SignedLongLongInteger` and `SignedShortInteger` generate server errors on some methods (like using them as message headers).
14+
> [!IMPORTANT]
15+
> If you are using RabbitMQ be aware that it doesn't implemented the specification completely, `Qos` and `Recover` methods are not implemented. And if you find yourself using [`Value`](src/Transport/Frame/Value.php) implementations note that `ShortString`, `SignedLongLongInteger` and `SignedShortInteger` generate server errors on some methods (like using them as message headers).
1416
1517
[Documentation](docs)
1618

17-
**Important**: you must use [`vimeo/psalm`](https://packagist.org/packages/vimeo/psalm) to make sure you use this library correctly.
19+
> [!IMPORTANT]
20+
> You must use [`vimeo/psalm`](https://packagist.org/packages/vimeo/psalm) to make sure you use this library correctly.
1821
1922
## Installation
2023

@@ -34,8 +37,8 @@ use Innmind\AMQP\{
3437
Model\Basic\Message,
3538
Model\Exchange\Type,
3639
};
37-
use Innmind\Socket\Internet\Transport;
38-
use Innmind\TimeContinuum\Earth\ElapsedPeriod;
40+
use Innmind\IO\Sockets\Internet\Transport;
41+
use Innmind\TimeContinuum\Period;
3942
use Innmind\OperatingSystem\Factory as OSFactory;
4043
use Innmind\Url\Url;
4144
use Innmind\Immutable\Str;
@@ -45,17 +48,14 @@ $client = Factory::of($os)
4548
->make(
4649
Transport::tcp(),
4750
Url::of('amqp://guest:guest@localhost:5672/'),
48-
new ElapsedPeriod(1000), // timeout
51+
Period::second(1), // timeout
4952
)
5053
->with(DeclareExchange::of('crawler', Type::direct))
5154
->with(DeclareQueue::of('parser'))
5255
->with(Bind::of('crawler', 'parser'))
5356
->with(Publish::one(Message::of(Str::of('https://github.com')))->to('crawler'))
5457
->run(null)
55-
->match(
56-
static fn() => null, // success
57-
static fn($failure) => throw new \RuntimeException($failure::class),
58-
);
58+
->unwrap();
5959
```
6060

6161
The above example will declare an exchange named `crawler` and queue `parser` that will receive messages from our exchange. Finally it will publish a message with the payload `http://github.com/` to `crawler` (and the server will route it to `parser`).
@@ -77,10 +77,7 @@ $state = $client
7777
return $continuation->ack($state);
7878
}))
7979
->run(null) // <- this argument will passed as the state to the handler above
80-
->match(
81-
static fn($state) => $state,
82-
static fn($failure) => throw new \RuntimeException($failure::class),
83-
);
80+
->unwrap();
8481
echo $state; // will print "http://github.com/"
8582
// or
8683
$client
@@ -92,10 +89,7 @@ $client
9289
return $continuation->cancel($state); // instruct to stop receiving messages (current will be acknowledged first)
9390
}))
9491
->run(null)
95-
->match(
96-
static fn() => null, // in this case only reachable when you cancel the consumer
97-
static fn($failure) => throw new \RuntimeException($failure::class),
98-
);
92+
->unwrap(); // in this case only reachable when you cancel the consumer
9993
```
10094

10195
`reject()` and `requeue()` can also be used in the `get` callback.
@@ -129,4 +123,5 @@ Pid: 46862, Count: 4000, Time: 0.2366
129123

130124
So it appears _pure_ functions come at a cost!
131125

132-
**Note**: both benchmarks use manual acknowledgement of messages
126+
> [!NOTE]
127+
> both benchmarks use manual acknowledgement of messages

benchmark/client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
Factory,
88
Transport\Connection,
99
};
10-
use Innmind\Socket\Internet\Transport;
11-
use Innmind\TimeContinuum\Earth\ElapsedPeriod;
10+
use Innmind\IO\Sockets\Internet\Transport;
11+
use Innmind\TimeContinuum\Period;
1212
use Innmind\Url\Url;
1313
use Innmind\OperatingSystem\Factory as OSFactory;
1414

@@ -18,6 +18,6 @@
1818
->make(
1919
Transport::tcp(),
2020
Url::of('//guest:guest@localhost:5672/'),
21-
new ElapsedPeriod(1000),
21+
Period::second(1),
2222
)
2323
->listenSignals($os->process());

benchmark/consumer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
static fn($failure) => throw new \RuntimeException($failure::class),
3333
);
3434

35-
printf("Pid: %s, Count: %s, Time: %.4f\n", getmypid(), $count, microtime(true) - $start);
35+
printf("Pid: %s, Count: %s, Time: %.4f\n", (string) getmypid(), $count, microtime(true) - $start);

blackbox.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
require 'vendor/autoload.php';
5+
6+
use Innmind\BlackBox\{
7+
Application,
8+
PHPUnit\Load,
9+
Runner\CodeCoverage,
10+
};
11+
12+
Application::new($argv)
13+
->when(
14+
\getenv('ENABLE_COVERAGE') !== false,
15+
static fn(Application $app) => $app
16+
->codeCoverage(
17+
CodeCoverage::of(
18+
__DIR__.'/src/',
19+
__DIR__.'/tests/',
20+
)
21+
->dumpTo('coverage.clover')
22+
->enableWhen(true),
23+
)
24+
->scenariiPerProof(1),
25+
)
26+
->tryToProve(Load::directory(__DIR__.'/tests/'))
27+
->exit();

composer.json

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,8 @@
1616
},
1717
"require": {
1818
"php": "~8.2",
19-
"innmind/immutable": "~5.7",
20-
"innmind/time-continuum": "~3.1",
21-
"innmind/math": "~6.0",
22-
"innmind/url": "~4.1",
23-
"ramsey/uuid": "~4.0",
24-
"innmind/operating-system": "~5.0",
25-
"innmind/media-type": "~2.0",
26-
"innmind/filesystem": "~7.0",
27-
"innmind/stream": "~4.0",
28-
"innmind/io": "~2.6"
19+
"innmind/foundation": "^1.7.1",
20+
"ramsey/uuid": "~4.0"
2921
},
3022
"autoload": {
3123
"psr-4": {
@@ -38,10 +30,9 @@
3830
}
3931
},
4032
"require-dev": {
41-
"phpunit/phpunit": "~10.2",
4233
"psr/log": "~3.0",
43-
"vimeo/psalm": "~5.15",
44-
"innmind/black-box": "~5.5",
34+
"innmind/static-analysis": "^1.2.1",
35+
"innmind/black-box": "~6.5",
4536
"innmind/coding-standard": "~2.0"
4637
},
4738
"suggest": {

0 commit comments

Comments
 (0)