Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.4'
tools: php-cs-fixer

- name: PHP Coding Standards Fixer
Expand All @@ -28,17 +28,26 @@ jobs:
name: PHPStan
steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6 # or alternative dependency management
- uses: php-actions/phpstan@v3

# Runs the PHPStan the project depends on, with the command from the Makefile. The
# php-actions/phpstan action brings its own version, which cannot be kept in step with
# composer.json — and PHPStan 1 cannot parse Symfony 8.
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
path: src/
level: 9
php-version: '8.4'

- name: Install dependencies
run: composer update --prefer-dist --no-progress

- name: PHPStan
run: vendor/bin/phpstan analyse src --level=9

phpunit:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.4', '8.5']
mode: ['high-deps', 'low-deps']
fail-fast: false
name: PHP ${{ matrix.php-versions }} tests with ${{ matrix.mode }}
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

A Symfony Bundle to use when you want to assert that messages used with Message brokers such like RabbitMQ are compliant with the Zero Downtime Deployment.

## Requirements

- PHP 8.4 and above
- Symfony 7.4 or 8

## Getting started
### Installation
First, install the bundle with composer:
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^8.1.0",
"symfony/console": "^6.2|^7.0"
"php": "^8.4",
"symfony/console": "^7.4|^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.1",
"symfony/browser-kit": "^6.2|^7.0",
"symfony/framework-bundle": "^6.2|^7.0",
"symfony/yaml": "^6.2|^7.0",
"symfony/messenger": "^6.2|^7.0"
"symfony/browser-kit": "^7.4|^8.0",
"symfony/framework-bundle": "^7.4|^8.0",
"symfony/yaml": "^7.4|^8.0",
"symfony/messenger": "^7.4|^8.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/MessageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function forcePropertyValue(object $object, string $property, mixed $val
$reflectionProperty = $reflectionProperty->getDeclaringClass()->getProperty($property);
}

$reflectionProperty->setAccessible(true);
// No setAccessible() call: it has had no effect since PHP 8.1 and is deprecated in 8.5.
$reflectionProperty->setValue($object, $value);
}
}
22 changes: 14 additions & 8 deletions src/Serializer/ZddMessageMessengerSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ public function serialize(object $data): string

public function deserialize(string $data): object
{
/** @var array{body: string, headers?: array<string, string>} $dataArray */
$dataArray = \json_decode($data, true, 512, \JSON_THROW_ON_ERROR);
if (!\is_array($dataArray)) {
throw new \InvalidArgumentException(sprintf('Array expected, %s provided', \gettype($data)));
$decoded = \json_decode($data, true, 512, \JSON_THROW_ON_ERROR);
if (!\is_array($decoded)) {
throw new \InvalidArgumentException(sprintf('Array expected, %s provided', \gettype($decoded)));
}

/** @var array{body: string, headers?: array<string, string>} $encodedEnvelope */
$encodedEnvelope = $decoded;

try {
$envelope = $this->serializer->decode($dataArray);
if (!$envelope instanceof Envelope) {
throw new \InvalidArgumentException(sprintf('%s expected, %s provided', Envelope::class, \gettype($data)));
$message = $this->serializer->decode($encodedEnvelope)->getMessage();

// Since Symfony 8, PhpSerializer no longer throws when a message cannot be rebuilt:
// MessageDecodingFailedException::wrap() returns an envelope carrying the failure as
// its message. Earlier versions throw, which the catch below still handles.
if ($message instanceof MessageDecodingFailedException) {
throw new UnableToDeserializeException(previous: $message);
}

return $envelope->getMessage();
return $message;
} catch (MessageDecodingFailedException $e) {
throw new UnableToDeserializeException(previous: $e);
}
Expand Down
Loading