diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index b229445..5d6931d 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -1,5 +1,5 @@ on: - pull_request: + pull_request_target: paths-ignore: - 'docs/**' - 'README.md' @@ -17,6 +17,7 @@ jobs: secrets: token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} with: + repository: ${{ github.event.pull_request.head.repo.full_name }} os: >- ['ubuntu-latest'] php: >- diff --git a/Makefile b/Makefile index e75c933..715fa38 100644 --- a/Makefile +++ b/Makefile @@ -3,29 +3,29 @@ export COMPOSE_PROJECT_NAME=yii-queue-amqp help: ## Display help information @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' -build: ## Build an image from a docker-compose file. Params: {{ v=8.1 }}. Default latest PHP 8.1 - docker-compose -f tests/docker-compose.yml up -d --build +build: ## Build an image from a docker-compose file. Params: {{ v=81 }} + docker compose -f tests/docker-compose.yml up -d --build down: ## Stop and remove containers, networks - docker-compose -f tests/docker-compose.yml down + docker compose -f tests/docker-compose.yml down -test: ## Run tests. Params: {{ v=8.1 }}. Default latest PHP 8.1 - docker-compose -f tests/docker-compose.yml build --pull php$(v) - docker-compose -f tests/docker-compose.yml run php$(v) vendor/bin/phpunit --debug +test: ## Run tests. Params: {{ v=81 }} + docker compose -f tests/docker-compose.yml build --pull php$(v) + docker compose -f tests/docker-compose.yml run php$(v) vendor/bin/phpunit --debug make down sh: ## Enter the container with the application - docker-compose -f tests/docker-compose.yml run php$(v) + docker compose -f tests/docker-compose.yml run php$(v) -mutation-test: ## Run mutation tests. Params: {{ v=8.1 }}. Default latest PHP 8.1 - docker-compose -f tests/docker-compose.yml build --pull php$(v) - docker-compose -f tests/docker-compose.yml run php$(v) php -dpcov.enabled=1 -dpcov.directory=. vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered +mutation-test: ## Run mutation tests. Params: {{ v=81 }} + docker compose -f tests/docker-compose.yml build --pull php$(v) + docker compose -f tests/docker-compose.yml run php$(v) php -dpcov.enabled=1 -dpcov.directory=. vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered make down -coverage: ## Run code coverage. Params: {{ v=8.1 }}. Default latest PHP 8.1 +coverage: ## Run code coverage. Params: {{ v=81 }} docker-compose -f tests/docker-compose.yml run php$(v) vendor/bin/phpunit --coverage-clover coverage.xml make down -static-analyze: ## Run code static analyze. Params: {{ v=8.1 }}. Default latest PHP 8.1 - docker-compose -f tests/docker-compose.yml run php$(v) vendor/bin/psalm --config=psalm.xml --shepherd --stats --php-version=8.1 +static-analyze: ## Run code static analyze. Params: {{ v=81 }} + docker compose -f tests/docker-compose.yml run php$(v) vendor/bin/psalm --config=psalm.xml --shepherd --stats --php-version=8.1 make down diff --git a/composer.json b/composer.json index 623ebfb..428f884 100644 --- a/composer.json +++ b/composer.json @@ -34,12 +34,12 @@ "infection/infection": "^0.27.8||^0.29.0", "maglnet/composer-require-checker": "^4.4", "phpunit/phpunit": "^9.5", - "rector/rector": "^1.0", + "rector/rector": "^2.0.15", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", "symfony/console": "^6.0", "symfony/process": "^6.0", - "vimeo/psalm": "^5.20||^6.0", + "vimeo/psalm": "^5.26.1 || ^6.10.3", "yiisoft/test-support": "^3.0" }, "autoload": { diff --git a/psalm.xml b/psalm.xml index 50c3ada..08707dd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,6 +3,8 @@ errorLevel="1" findUnusedBaselineEntry="true" findUnusedCode="false" + ensureOverrideAttribute="false" + strictBinaryOperands="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" diff --git a/rector.php b/rector.php index 2dd9fb0..e68f803 100644 --- a/rector.php +++ b/rector.php @@ -4,32 +4,23 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; -use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; -use Rector\Set\ValueObject\LevelSetList; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', - ]); - - // register a single rule - $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); - - // define sets of rules - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_81, - ]); - - $rectorConfig->skip([ + ]) + ->withPhpSets(php81: true) + ->withRules([ + InlineConstructorDefaultToPropertyRector::class, + ]) + ->withSkip([ ClosureToArrowFunctionRector::class, - JsonThrowOnErrorRector::class, ReadOnlyPropertyRector::class, NullToStrictStringFuncCallArgRector::class, ReturnNeverTypeRector::class, ]); -}; diff --git a/src/Exception/ExchangeDeclaredException.php b/src/Exception/ExchangeDeclaredException.php index 0db3d37..dae3383 100644 --- a/src/Exception/ExchangeDeclaredException.php +++ b/src/Exception/ExchangeDeclaredException.php @@ -7,10 +7,8 @@ use InvalidArgumentException; use Yiisoft\FriendlyException\FriendlyExceptionInterface; -class ExchangeDeclaredException extends InvalidArgumentException implements FriendlyExceptionInterface +final class ExchangeDeclaredException extends InvalidArgumentException implements FriendlyExceptionInterface { - protected $message = 'Can\'t set channel name implicitly when an exchange is declared'; - public function getName(): string { return 'Exchange is declared'; diff --git a/src/Exception/NotImplementedException.php b/src/Exception/NotImplementedException.php index 2ffb116..3e624e0 100644 --- a/src/Exception/NotImplementedException.php +++ b/src/Exception/NotImplementedException.php @@ -6,6 +6,6 @@ use RuntimeException; -class NotImplementedException extends RuntimeException +final class NotImplementedException extends RuntimeException { } diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 3740f81..9571add 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.5" - x-php: &php volumes: - ./runtime:/app/tests/runtime