Skip to content

Commit

Permalink
Upgrade to Laravel 11 (#6)
Browse files Browse the repository at this point in the history
Upgrade to Laravel 11 and PHPUnit 11

---------

Co-authored-by: Jose Manuel Cardona <josemanuel.cardona@softonic.com>
  • Loading branch information
joskfg and josemanuel-cardona authored Jan 22, 2025
1 parent d30c18f commit 5e45417
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 119 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test
run: composer run-script tests
57 changes: 29 additions & 28 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');
->in(__DIR__.'/src')
->in(__DIR__.'/tests');

return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'new_with_braces' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_comment' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'ordered_imports' => ['imports_order' => null, 'sort_algorithm' => 'alpha'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_to_comment' => true,
'psr_autoloading' => true,
'return_type_declaration' => ['space_before' => 'none'],
'single_blank_line_before_namespace' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'whitespace_after_comma_in_array' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'new_with_parentheses' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_comment' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline' => true,
'no_unused_imports' => true,
'ordered_imports' => ['imports_order' => null, 'sort_algorithm' => 'alpha'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_to_comment' => true,
'psr_autoloading' => true,
'return_type_declaration' => ['space_before' => 'none'],
'blank_lines_before_namespace' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
"issues": "https://github.com/softonic/laravel-queue-job/issues"
},
"require": {
"php": "^8.0",
"laravel/framework": "^9.0|^10.0",
"vladimir-yuldashev/laravel-queue-rabbitmq": "^13.0"
"php": "^8.3",
"laravel/framework": "^11.0",
"vladimir-yuldashev/laravel-queue-rabbitmq": "^14.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^11.0",
"mockery/mockery": "^1.0",
"friendsofphp/php-cs-fixer": "^3.0",
"squizlabs/php_codesniffer": "^3",
"rector/rector": "^0.12.13",
"orchestra/testbench": "^7.00"
"rector/rector": "^1.0",
"orchestra/testbench": "^9.00"
},
"autoload": {
"psr-4": {
Expand All @@ -32,20 +32,20 @@
}
},
"scripts": {
"test": [
"tests": [
"@checkstyle",
"@phpunit"
],
"phpunit": "phpunit --coverage-text",
"phpunit": "phpunit",
"checkstyle": [
"PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff --dry-run --allow-risky=yes",
"rector --dry-run"
"PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff --allow-risky=yes",
"rector process"
],
"fix-checkstyle": [
"@php-cs-fixer",
"@rector"
],
"php-cs-fixer": "php-cs-fixer fix -v --diff --allow-risky=yes",
"rector": "rector"
"rector": "rector process"
}
}
36 changes: 32 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
version: '3.8'

services:
composer:
php:
volumes:
- ./:/app
image: composer:2.2

install:
volumes:
- ./:/app
image: composer:2.2
command: composer install --ignore-platform-req=ext-sockets

update:
volumes:
- ./:/app
image: composer:2.2
command: composer update --ignore-platform-req=ext-sockets

phpunit:
volumes:
- ./:/app
image: composer:2.2
command: composer phpunit

test:
volumes:
- ./:/app
image: composer:2.2
command: composer run tests

fixcs:
volumes:
- ./:/app
build: ./
image: composer:2.2
command: composer run fix-cs
38 changes: 11 additions & 27 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true">

<testsuites>
<testsuite name="Laravel Queue Job">
<directory>tests</directory>
<testsuite name="All">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/clover.xml"/>
</logging>

</phpunit>
65 changes: 45 additions & 20 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,49 @@

declare(strict_types=1);

use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;

return static function (ContainerConfigurator $containerConfigurator): void {
// get parameters
$parameters = $containerConfigurator->parameters();

// Define what rule sets will be applied
$containerConfigurator->import(SetList::DEAD_CODE);
$containerConfigurator->import(SetList::PHP_80);
$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
$containerConfigurator->import(SetList::TYPE_DECLARATION);
$containerConfigurator->import(SetList::EARLY_RETURN);
$containerConfigurator->import(SetList::PRIVATIZATION);

// get services (needed for register a single rule)
// $services = $containerConfigurator->services();

// register a single rule
// $services->set(TypedPropertyRector::class);
};
return RectorConfig::configure()
->withSkip(
[
// CodeQuality
CompleteDynamicPropertiesRector::class,
DisallowedEmptyRuleFixerRector::class,
// CodingStyle
CatchExceptionNameMatchingTypeRector::class,
EncapsedStringsToSprintfRector::class,
// EarlyReturn
ReturnBinaryOrToEarlyReturnRector::class,
// TypeDeclaration
AddArrowFunctionReturnTypeRector::class,
ReturnTypeFromStrictTypedCallRector::class,
]
)
->withAutoloadPaths([__DIR__ . '/vendor/autoload.php'])
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withImportNames()
->withPhpSets(php83: true)
->withSets(
[
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_110,
]
)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
earlyReturn: true
);
7 changes: 5 additions & 2 deletions src/RabbitMQJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Softonic\LaravelQueueJob;

use Illuminate\Support\Facades\Config;
use Override;
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob as BaseJob;

class RabbitMQJob extends BaseJob
{
private const HANDLER_NOT_CONFIGURED_MESSAGE = 'HandlerNotConfigured';
private const string HANDLER_NOT_CONFIGURED_MESSAGE = 'HandlerNotConfigured';

private array $messageHandlers = [];

Expand All @@ -16,6 +17,7 @@ class RabbitMQJob extends BaseJob
*
* @return array
*/
#[Override]
public function payload()
{
$this->messageHandlers = $this->getMessageHandlers($this->getRabbitMQMessage()->getRoutingKey());
Expand All @@ -26,7 +28,8 @@ public function payload()
];
}

public function fire()
#[Override]
public function fire(): void
{
$payload = $this->payload();

Expand Down
6 changes: 4 additions & 2 deletions src/RabbitMQQueueWithDeclare.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Softonic\LaravelQueueJob;

use Illuminate\Support\Arr;
use Override;
use PhpAmqpLib\Connection\AbstractConnection;
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue;

Expand All @@ -23,11 +24,12 @@ public function __construct(AbstractConnection $connection, string $default, arr
}
}

public function getQueueArguments(string $destination): array
#[Override]
protected function getQueueArguments(string $destination): array
{
$arguments = parent::getQueueArguments($destination);

if ($this->getQueueMaxLength()) {
if ($this->getQueueMaxLength() !== 0) {
$arguments['x-max-length'] = $this->getQueueMaxLength();
}

Expand Down
Loading

0 comments on commit 5e45417

Please sign in to comment.