Skip to content

Commit

Permalink
Add support PHP 8.4 (fix deprecations)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhukV committed Feb 23, 2025
1 parent 21dde35 commit b0a2892
Show file tree
Hide file tree
Showing 211 changed files with 123 additions and 2,837 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
coverage: "none"
extensions: "json,amqp"
ini-values: "memory_limit=-1"
php-version: "8.2"
php-version: "8.4"
tools: "composer"

- name: Install vendors
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:

strategy:
matrix:
php: [ '8.2', '8.3' ]
php: [ '8.2', '8.3', '8.4' ]

services:
rabbitmq:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

v2.1.2
------

* Add support PHP 8.4 (remove all deprecations).

v2.1.1
------

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.2-cli
FROM php:8.4-cli

MAINTAINER Vitalii Zhuk <v.zhuk@fivelab.org>

Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@
"require-dev": {
"ext-amqp": "*",
"ext-sockets": "*",
"phpunit/phpunit": "~10.1",
"phpmetrics/phpmetrics": "~2.7",
"phpstan/phpstan": "~1.11.0",
"phpunit/phpunit": "~11.5",
"phpmetrics/phpmetrics": "~3.0",
"phpstan/phpstan": "~2.1.6",
"escapestudios/symfony2-coding-standard": "~3.5",
"guzzlehttp/guzzle": "~6.5.6",
"symfony/console": "~5.4 | ~6.0",
"guzzlehttp/guzzle": "~7.0",
"symfony/console": "~5.4 | ~6.0 | ~7.0",
"ramsey/uuid": "~4.7",
"fivelab/transactional": "~2.0",
"fivelab/ci-rules": "dev-master",
"psr/log": "*",
"php-amqplib/php-amqplib": "^3.5"
},

"minimum-stability": "RC",

"suggest": {
"ext-amqp": "For use amqp extension.",
"ext-sockets": "For php-amqplib",
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ parameters:
level: 8
paths:
- src

ignoreErrors:
-
message: '#^Property FiveLab\\Component\\Amqp\\Command\\.+::\$(defaultName|defaultDescription) has no type specified.$#'
path: src/
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="./vendor/autoload.php"
>
Expand Down
40 changes: 3 additions & 37 deletions src/Adapter/Amqp/Channel/AmqpChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,78 +18,44 @@
use FiveLab\Component\Amqp\Connection\ConnectionInterface;
use FiveLab\Component\Amqp\Connection\SpoolConnection;

/**
* The channel provided via php-amqp extension.
*/
class AmqpChannel implements ChannelInterface
readonly class AmqpChannel implements ChannelInterface
{
/**
* Constructor.
*
* @param AmqpConnection|SpoolConnection $connection
* @param \AMQPChannel $channel
*/
public function __construct(
private readonly AmqpConnection|SpoolConnection $connection,
private readonly \AMQPChannel $channel
private AmqpConnection|SpoolConnection $connection,
private \AMQPChannel $channel
) {
}

/**
* Get original channel
*
* @return \AMQPChannel
*/
public function getChannel(): \AMQPChannel
{
return $this->channel;
}

/**
* Get the connection
*
* @return ConnectionInterface
*/
public function getConnection(): ConnectionInterface
{
return $this->connection;
}

/**
* {@inheritdoc}
*/
public function getPrefetchCount(): int
{
return $this->channel->getPrefetchCount();
}

/**
* {@inheritdoc}
*/
public function setPrefetchCount(int $prefetchCount): void
{
$this->channel->setPrefetchCount($prefetchCount);
}

/**
* {@inheritdoc}
*/
public function startTransaction(): void
{
$this->channel->startTransaction();
}

/**
* {@inheritdoc}
*/
public function commitTransaction(): void
{
$this->channel->commitTransaction();
}

/**
* {@inheritdoc}
*/
public function rollbackTransaction(): void
{
$this->channel->rollbackTransaction();
Expand Down
18 changes: 0 additions & 18 deletions src/Adapter/Amqp/Channel/AmqpChannelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,16 @@
use FiveLab\Component\Amqp\Connection\ConnectionFactoryInterface;
use FiveLab\Component\Amqp\Connection\SpoolConnection;

/**
* The factory for create channel provided via php-amqp extension.
*/
class AmqpChannelFactory implements ChannelFactoryInterface, \SplObserver
{
/**
* @var AmqpChannel|null
*/
private ?AmqpChannel $channel = null;

/**
* Constructor.
*
* @param ConnectionFactoryInterface $connectionFactory
* @param ChannelDefinition $definition
*/
public function __construct(
private readonly ConnectionFactoryInterface $connectionFactory,
private readonly ChannelDefinition $definition // @phpstan-ignore-line
) {
}

/**
* {@inheritdoc}
*/
public function create(): ChannelInterface
{
if ($this->channel) {
Expand Down Expand Up @@ -74,9 +59,6 @@ public function create(): ChannelInterface
return $this->channel;
}

/**
* {@inheritdoc}
*/
public function update(\SplSubject $subject): void
{
$this->channel = null;
Expand Down
32 changes: 0 additions & 32 deletions src/Adapter/Amqp/Connection/AmqpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,19 @@
use FiveLab\Component\Amqp\Exception\ConnectionException;
use FiveLab\Component\Amqp\SplSubjectTrait;

/**
* The connection provided via php-amqp extension.
*/
class AmqpConnection implements ConnectionInterface
{
use SplSubjectTrait;

/**
* Constructor.
*
* @param \AMQPConnection $connection
*/
public function __construct(private readonly \AMQPConnection $connection)
{
}

/**
* Get original connection
*
* @return \AMQPConnection
*/
public function getConnection(): \AMQPConnection
{
return $this->connection;
}

/**
* {@inheritdoc}
*/
public function connect(): void
{
try {
Expand All @@ -60,45 +44,29 @@ public function connect(): void
}
}

/**
* {@inheritdoc}
*/
public function isConnected(): bool
{
return $this->connection->isConnected();
}

/**
* {@inheritdoc}
*/
public function disconnect(): void
{
$this->connection->disconnect();

$this->notify();
}

/**
* {@inheritdoc}
*/
public function reconnect(): void
{
$this->disconnect();
$this->connect();
}

/**
* {@inheritdoc}
*/
public function setReadTimeout(float $timeout): void
{
// @phpstan-ignore-next-line
$this->connection->setReadTimeout($timeout);
}

/**
* {@inheritdoc}
*/
public function getReadTimeout(): float
{
return $this->connection->getReadTimeout();
Expand Down
14 changes: 0 additions & 14 deletions src/Adapter/Amqp/Connection/AmqpConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,10 @@
use FiveLab\Component\Amqp\Connection\Driver;
use FiveLab\Component\Amqp\Connection\Dsn;

/**
* The factory for create connection provided via php-amqp extension.
*/
class AmqpConnectionFactory implements ConnectionFactoryInterface
{
/**
* @var AmqpConnection|null
*/
private ?AmqpConnection $connection = null;

/**
* Constructor.
*
* @param Dsn $dsn
*/
public function __construct(private readonly Dsn $dsn)
{
if ($this->dsn->driver !== Driver::AmqpExt) {
Expand All @@ -44,9 +33,6 @@ public function __construct(private readonly Dsn $dsn)
}
}

/**
* {@inheritdoc}
*/
public function create(): ConnectionInterface
{
if ($this->connection) {
Expand Down
21 changes: 0 additions & 21 deletions src/Adapter/Amqp/Exchange/AmqpExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,24 @@
use FiveLab\Component\Amqp\Exchange\ExchangeInterface;
use FiveLab\Component\Amqp\Message\Message;

/**
* The exchanged provided via php-amqp extension.
*/
readonly class AmqpExchange implements ExchangeInterface
{
/**
* Constructor.
*
* @param AmqpChannel $channel
* @param \AMQPExchange $exchange
*/
public function __construct(
private AmqpChannel $channel,
private \AMQPExchange $exchange
) {
}

/**
* {@inheritdoc}
*/
public function getChannel(): ChannelInterface
{
return $this->channel;
}

/**
* {@inheritdoc}
*/
public function getName(): string
{
return $this->exchange->getName() ?: '';
}

/**
* {@inheritdoc}
*/
public function publish(Message $message, string $routingKey = ''): void
{
$headers = $message->headers->all();
Expand Down Expand Up @@ -95,9 +77,6 @@ public function publish(Message $message, string $routingKey = ''): void
$this->exchange->publish($message->payload->data, $routingKey, AMQP_NOPARAM, $options);
}

/**
* {@inheritdoc}
*/
public function delete(): void
{
$this->exchange->delete();
Expand Down
Loading

0 comments on commit b0a2892

Please sign in to comment.