From e0731e262b63ad56225b2ec378704de177489671 Mon Sep 17 00:00:00 2001 From: Maxime Patteri Date: Sun, 29 Nov 2026 21:59:31 +0100 Subject: [PATCH 1/2] Allow symfony/mailer 6.4, 7.4 and 8.x symfony/mailer ^5.4 blocks php-censor from upgrading Symfony (5.4 is end of life). Widen the constraint to ^5.4 || ^6.4 || ^7.4 || ^8.0, nothing else changes. Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ad93a84..92ace11 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "php": ">=8.1.0", "ext-json": "*", "psr/container": "^1.1", - "symfony/mailer": "^5.4" + "symfony/mailer": "^5.4 || ^6.4 || ^7.4 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.5", From fe795296eb3060e4f0e9504fab4820f16ecf936d Mon Sep 17 00:00:00 2001 From: Maxime Patteri Date: Mon, 30 Nov 2026 17:14:38 +0100 Subject: [PATCH 2/2] Upgrade to PHP 8.4+ and align dependencies with php-censor - php >=8.4.0, symfony/mailer ^7.4 || ^8.0, psr/container ^1.1 || ^2.0 - Dev tools: PHPUnit 13, php-cs-fixer 3.90, Infection 0.35, Psalm 6/7, PHPMD 3, parallel-lint 1.4, Rector 2; phpcpd and phploc removed (abandoned) - PHPUnit config migrated, mocks without expectations replaced by stubs - Rector config rewritten for Rector 2, Psalm unused-code checks disabled - ${var} interpolation fixed (deprecated since PHP 8.2) - Code style updated for php-cs-fixer 3.95 (function_declaration: "fn (") - CI: ubuntu-latest, PHP 8.4/8.5, $GITHUB_OUTPUT, actions updated Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yaml | 20 ++++---- .gitignore | 1 + Makefile | 12 ++--- README.md | 2 +- composer.json | 25 +++++----- phpunit.xml.dist | 36 +++++--------- psalm.xml.dist | 3 ++ rector.php | 31 ++++-------- src/Email/Email.php | 4 +- src/Plugin/PathResolver.php | 4 +- tests/src/Plugin/PathResolverTest.php | 14 +++--- tests/src/Plugin/PluginTest.php | 70 +++++++++++++-------------- 12 files changed, 99 insertions(+), 123 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 667b2b8..a939bcc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,14 +4,14 @@ on: ['push', 'pull_request'] jobs: testsuite: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php-version: ['8.1', '8.2', '8.3'] + php-version: ['8.4', '8.5'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -22,14 +22,14 @@ jobs: - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - name: Get date part for cache key id: key-date - run: echo "::set-output name=date::$(date +'%Y-%m')" + run: echo "date=$(date +'%Y-%m')" >> "$GITHUB_OUTPUT" - name: Cache composer dependencies - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }} @@ -39,12 +39,12 @@ jobs: - name: Run tests run: | - if [[ ${{ matrix.php-version }} == '8.1' ]]; then - export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml + if [[ ${{ matrix.php-version }} == '8.4' ]]; then + export CODECOVERAGE=1 && vendor/bin/phpunit --coverage-clover=coverage.xml else vendor/bin/phpunit fi - name: Submit code coverage - if: matrix.php-version == '8.1' - uses: codecov/codecov-action@v1 + if: matrix.php-version == '8.4' + uses: codecov/codecov-action@v4 diff --git a/.gitignore b/.gitignore index 6956207..0e363bc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /.php-cs-fixer.cache /.phpunit.result.cache +/.phpunit.cache /tests/var/log/*.log /tests/var/coverage diff --git a/Makefile b/Makefile index 9074700..a2cd617 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,26 @@ -PHP?=php8.1 +PHP?=php8.4 COMPOSER=/usr/local/bin/composer php-info: - @echo "Default PHP version: $(PHP) (Run with custom PHP version: make install PHP=php8.2).\n"; + @echo "Default PHP version: $(PHP) (Run with custom PHP version: make install PHP=php8.5).\n"; list: php-info ## List @sed -rn 's/^([a-zA-Z_-]+):.*?## (.*)$$/"\1" "\2"/p' < $(MAKEFILE_LIST) | xargs printf "%-20s%s\n" -install: php-info ## Install dependencies (make install PHP=php8.0) +install: php-info ## Install dependencies (make install PHP=php8.5) @if [ ! -d "vendor" ]; then $(PHP) $(COMPOSER) install; fi; -install-force: php-info ## Force install dependencies (make install PHP=php8.0) +install-force: php-info ## Force install dependencies (make install PHP=php8.5) $(PHP) $(COMPOSER) install update: php-info ## Update dependencies @$(PHP) $(COMPOSER) update test: php-info install ## Run PHPUnit tests - $(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist --verbose + $(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist test-coverage: php-info install ## Run PHPUnit tests with coverage report - $(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist --verbose --coverage-text --coverage-html=tests/var/coverage + $(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist --coverage-text --coverage-html=tests/var/coverage mutation-test: php-info install ## Run Infection mutation tests $(PHP) vendor/bin/infection --threads=4 --show-mutations -vvv diff --git a/README.md b/README.md index 4c9b142..8a936e6 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Versions | Version | Branch | Latest | Description | PHP version | |---------|---------------|---------|---------------------------------------------------------|-------------| | `1.0` | `release-1.0` | `1.0.0` | Current stable version. Partial used in PHP Censor 2.0+ | `>= 7.4` | -| `2.0` | `master` | - | Feature major version for PHP Censor 3.0 (WIP) | `>= 8.1` | +| `2.0` | `master` | - | Feature major version for PHP Censor 3.0 (WIP) | `>= 8.4` | Installation ------------ diff --git a/composer.json b/composer.json index 92ace11..559251c 100644 --- a/composer.json +++ b/composer.json @@ -38,30 +38,27 @@ } }, "require": { - "php": ">=8.1.0", + "php": ">=8.4.0", "ext-json": "*", - "psr/container": "^1.1", - "symfony/mailer": "^5.4 || ^6.4 || ^7.4 || ^8.0" + "psr/container": "^1.1 || ^2.0", + "symfony/mailer": "^7.4 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^9.5", - "friendsofphp/php-cs-fixer": "^3.4", - "infection/infection": "^0.25", - "vimeo/psalm": "^4.16", - "phpmd/phpmd": "^1.5", - "sebastian/phpcpd": "^6.0", - "phploc/phploc": "^7.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "rector/rector": "^1.0" + "phpunit/phpunit": "^13.0", + "friendsofphp/php-cs-fixer": "^3.90", + "infection/infection": "^0.35", + "vimeo/psalm": "^6.0 || ^7.0", + "phpmd/phpmd": "^3.0", + "php-parallel-lint/php-parallel-lint": "^1.4", + "rector/rector": "^2.2" }, "extra": { "platform": { - "php": "8.1.*" + "php": "8.4.*" } }, "config": { "allow-plugins": { - "composer/package-versions-deprecated": true, "infection/extension-installer": true } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0ade200..eafe8df 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,13 @@ - - - - ./tests/src - - - - - ./src - - + + + + ./tests/src + + + + + ./src + + diff --git a/psalm.xml.dist b/psalm.xml.dist index 4e9226b..57a39fc 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -2,6 +2,9 @@ paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', - ]); - - $rectorConfig->skip([]); - - $rectorConfig->importNames(); - $rectorConfig->importShortClasses(false); - - // register a single rule - $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); - - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_81, -/* SetList::PHP_81, - SetList::CODE_QUALITY, - SetList::DEAD_CODE,*/ - ]); -}; + ]) + ->withImportNames(importShortClasses: false) + ->withRules([ + InlineConstructorDefaultToPropertyRector::class, + ExplicitNullableParamTypeRector::class, + ]) + ->withPhpSets(php81: true); diff --git a/src/Email/Email.php b/src/Email/Email.php index cdbbfdb..52aab6f 100644 --- a/src/Email/Email.php +++ b/src/Email/Email.php @@ -21,7 +21,7 @@ class Email implements EmailInterface public function addEmailTo(string $email, ?string $name = null): self { $this->emailsTo[] = $name - ? "${name} <${email}>" + ? "{$name} <{$email}>" : $email; return $this; @@ -51,7 +51,7 @@ public function setIsHtml(bool $isHtml = false): self public function addCarbonCopyEmail(string $email, ?string $name = null): self { $this->carbonCopyEmails[] = $name - ? "${name} <${email}>" + ? "{$name} <{$email}>" : $email; return $this; diff --git a/src/Plugin/PathResolver.php b/src/Plugin/PathResolver.php index 8a6e7a6..181c9d7 100644 --- a/src/Plugin/PathResolver.php +++ b/src/Plugin/PathResolver.php @@ -88,7 +88,7 @@ public function resolveIgnores(array $pluginIgnores, bool $onlyInBuildPath = tru if ($pluginIgnores) { $ignores = \array_merge( $ignores, - \array_filter($pluginIgnores, fn($item) => !empty($item)) + \array_filter($pluginIgnores, fn ($item) => !empty($item)) ); } @@ -219,7 +219,7 @@ private function getBuildIgnores(): array if ($buildSettingsIgnores) { $this->buildIgnores = \array_filter( $buildSettingsIgnores, - fn(string $item) => !empty($item) + fn (string $item) => !empty($item) ); } } diff --git a/tests/src/Plugin/PathResolverTest.php b/tests/src/Plugin/PathResolverTest.php index 8e4ec7c..86bc276 100644 --- a/tests/src/Plugin/PathResolverTest.php +++ b/tests/src/Plugin/PathResolverTest.php @@ -9,23 +9,23 @@ use PHPCensor\Common\Plugin\PathResolver; use PHPCensor\Common\Plugin\PathResolverInterface; use PHPCensor\Common\VariableInterpolatorInterface; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; class PathResolverTest extends TestCase { /** - * @var BuildInterface|MockObject + * @var BuildInterface|Stub */ private $build; /** - * @var BuildLoggerInterface|MockObject + * @var BuildLoggerInterface|Stub */ private $buildLogger; /** - * @var MockObject|VariableInterpolatorInterface + * @var Stub|VariableInterpolatorInterface */ private $variableInterpolator; @@ -54,14 +54,14 @@ public function setUp(): void '/\\' ) . '/'; - $this->build = $this->createMock(BuildInterface::class); + $this->build = $this->createStub(BuildInterface::class); $this->build ->method('getBuildPath') ->willReturn($this->buildPath); - $this->buildLogger = $this->createMock(BuildLoggerInterface::class); + $this->buildLogger = $this->createStub(BuildLoggerInterface::class); - $this->variableInterpolator = $this->createMock(VariableInterpolatorInterface::class); + $this->variableInterpolator = $this->createStub(VariableInterpolatorInterface::class); $this->variableInterpolator ->method('interpolate') ->willReturnArgument(0); diff --git a/tests/src/Plugin/PluginTest.php b/tests/src/Plugin/PluginTest.php index 73dee38..8a113c1 100644 --- a/tests/src/Plugin/PluginTest.php +++ b/tests/src/Plugin/PluginTest.php @@ -15,7 +15,7 @@ use PHPCensor\Common\Plugin\Plugin; use PHPCensor\Common\Project\ProjectInterface; use PHPCensor\Common\VariableInterpolatorInterface; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; @@ -101,52 +101,52 @@ protected function getPluginDefaultBinaryNames(): array class PluginTest extends TestCase { /** - * @var BuildInterface|MockObject + * @var BuildInterface|Stub */ private $build; /** - * @var MockObject|ProjectInterface + * @var ProjectInterface|Stub */ private $project; /** - * @var ApplicationInterface|MockObject + * @var ApplicationInterface|Stub */ private $application; /** - * @var BuildLoggerInterface|MockObject + * @var BuildLoggerInterface|Stub */ private $buildLogger; /** - * @var BuildErrorWriterInterface|MockObject + * @var BuildErrorWriterInterface|Stub */ private $buildErrorWriter; /** - * @var BuildMetaWriterInterface|MockObject + * @var BuildMetaWriterInterface|Stub */ private $buildMetaWriter; /** - * @var CommandExecutorInterface|MockObject + * @var CommandExecutorInterface|Stub */ private $commandExecutor; /** - * @var MockObject|VariableInterpolatorInterface + * @var Stub|VariableInterpolatorInterface */ private $variableInterpolator; /** - * @var MockObject|PathResolverInterface + * @var PathResolverInterface|Stub */ private $pathResolver; /** - * @var ContainerInterface|MockObject + * @var ContainerInterface|Stub */ private $container; @@ -161,28 +161,28 @@ public function setUp(): void '/\\' ) . '/'; - $this->build = $this->createMock(BuildInterface::class); + $this->build = $this->createStub(BuildInterface::class); $this->build ->method('getBuildPath') ->willReturn($this->buildPath); - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([]); - $this->variableInterpolator = $this->createMock(VariableInterpolatorInterface::class); + $this->variableInterpolator = $this->createStub(VariableInterpolatorInterface::class); $this->variableInterpolator ->method('interpolate') - ->willReturnCallback(fn($string) => \str_replace(['%BUILD_PATH%'], $this->buildPath, (string) $string)); - - $this->buildLogger = $this->createMock(BuildLoggerInterface::class); - $this->buildErrorWriter = $this->createMock(BuildErrorWriterInterface::class); - $this->buildMetaWriter = $this->createMock(BuildMetaWriterInterface::class); - $this->commandExecutor = $this->createMock(CommandExecutorInterface::class); - $this->pathResolver = $this->createMock(PathResolverInterface::class); - $this->application = $this->createMock(ApplicationInterface::class); - $this->container = $this->createMock(ContainerInterface::class); + ->willReturnCallback(fn ($string) => \str_replace(['%BUILD_PATH%'], $this->buildPath, (string) $string)); + + $this->buildLogger = $this->createStub(BuildLoggerInterface::class); + $this->buildErrorWriter = $this->createStub(BuildErrorWriterInterface::class); + $this->buildMetaWriter = $this->createStub(BuildMetaWriterInterface::class); + $this->commandExecutor = $this->createStub(CommandExecutorInterface::class); + $this->pathResolver = $this->createStub(PathResolverInterface::class); + $this->application = $this->createStub(ApplicationInterface::class); + $this->container = $this->createStub(ContainerInterface::class); } public function testConstructSuccess(): void @@ -223,7 +223,7 @@ public function testConstructSuccessWithDefaultBuildSettings(): void $this->assertEquals([], $plugin->getBuildSettings()->all()); - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -248,7 +248,7 @@ public function testConstructSuccessWithDefaultBuildSettings(): void public function testConstructSuccessWithAlternativeBuildSettings(): void { - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -300,7 +300,7 @@ public function testConstructSuccessWithDefaultPluginOptions(): void $this->assertEquals([], $plugin->getOptions()->all()); - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -325,7 +325,7 @@ public function testConstructSuccessWithDefaultPluginOptions(): void public function testConstructSuccessWithAlternativePluginOptions(): void { - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -361,7 +361,7 @@ public function testConstructSuccessWithAlternativePluginOptions(): void ], ], $plugin->getOptions()->all()); - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -430,7 +430,7 @@ public function testConstructSuccessWithDefaultBinaryNames(): void public function testConstructSuccessWithBinaryNamesString(): void { - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -458,7 +458,7 @@ public function testConstructSuccessWithBinaryNamesString(): void 'executable.phar', ], $plugin->getBinaryNames()); - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -488,7 +488,7 @@ public function testConstructSuccessWithBinaryNamesString(): void public function testConstructSuccessWithBinaryNamesArray(): void { - $this->project = $this->createMock(ProjectInterface::class); + $this->project = $this->createStub(ProjectInterface::class); $this->project ->method('getBuildConfig') ->willReturn([ @@ -543,7 +543,7 @@ public function testDefaultCanExecute(): void public function testGetArtifactPath(): void { - $this->application = $this->createMock(ApplicationInterface::class); + $this->application = $this->createStub(ApplicationInterface::class); $this->application ->method('getArtifactsPath') ->willReturn('/var/www/php-censor.localhost/public/artifacts/'); @@ -578,7 +578,7 @@ public function testGetArtifactPath(): void public function testGetArtifactPathForBranch(): void { - $this->application = $this->createMock(ApplicationInterface::class); + $this->application = $this->createStub(ApplicationInterface::class); $this->application ->method('getArtifactsPath') ->willReturn('/var/www/php-censor.localhost/public/artifacts/'); @@ -613,7 +613,7 @@ public function testGetArtifactPathForBranch(): void public function testGetArtifactLink(): void { - $this->application = $this->createMock(ApplicationInterface::class); + $this->application = $this->createStub(ApplicationInterface::class); $this->application ->method('getArtifactsLink') ->willReturn('https://php-censor.localhost/artifacts/'); @@ -648,7 +648,7 @@ public function testGetArtifactLink(): void public function testGetArtifactLinkForBranch(): void { - $this->application = $this->createMock(ApplicationInterface::class); + $this->application = $this->createStub(ApplicationInterface::class); $this->application ->method('getArtifactsLink') ->willReturn('https://php-censor.localhost/artifacts/');