From 0e8dace350bdb61164e3a8287a791f8e980ad92d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Fri, 22 Aug 2025 00:17:06 +0200 Subject: [PATCH 1/3] chore: update Symfony version requirements and CI workflows for compatibility with Symfony 7.0 --- .../workflows/composer-require-checker.yml | 35 ++++++++++++++--- .github/workflows/phpstan.yml | 38 +++++++++++++++++-- .github/workflows/phpunit.yml | 27 +++++++++++-- README.md | 2 +- README.zh-CN.md | 2 +- composer.json | 18 ++++----- tests/Integration/ContainerAopTest.php | 15 ++++---- 7 files changed, 105 insertions(+), 32 deletions(-) diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 9673fb6..1f3e16f 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -11,16 +11,29 @@ permissions: jobs: build: - + name: Composer Require Check runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + symfony_version: + - "6.4.*" + - "7.0.*" + php_version: + - 8.2 + - 8.3 + - 8.4 + exclude: + - php_version: 8.2 + symfony_version: "7.0.*" steps: - uses: actions/checkout@v4 - - name: Setup PHP 8.1 + - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: ${{ matrix.php_version }} - name: Validate composer.json and composer.lock run: composer validate --strict @@ -30,12 +43,22 @@ jobs: uses: actions/cache@v3 with: path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-php-${{ matrix.php_version }}-symfony-${{ matrix.symfony_version }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-php- + ${{ runner.os }}-php-${{ matrix.php_version }}-symfony-${{ matrix.symfony_version }}- + ${{ runner.os }}-php-${{ matrix.php_version }}- - name: Install dependencies - run: composer install --prefer-dist --no-progress + run: | + composer require --no-update "symfony/framework-bundle:${{ matrix.symfony_version }}" + composer require --no-update "symfony/dependency-injection:${{ matrix.symfony_version }}" + composer require --no-update "symfony/config:${{ matrix.symfony_version }}" + composer require --no-update "symfony/console:${{ matrix.symfony_version }}" + composer require --no-update "symfony/expression-language:${{ matrix.symfony_version }}" + composer require --no-update "symfony/http-kernel:${{ matrix.symfony_version }}" + composer require --no-update "symfony/stopwatch:${{ matrix.symfony_version }}" + composer require --no-update "symfony/yaml:${{ matrix.symfony_version }}" + composer install --prefer-dist --no-progress - name: Run run: XDEBUG_MODE=off ./vendor/bin/composer-require-checker check composer.json diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index e2b9343..ebbd310 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -11,12 +11,32 @@ permissions: jobs: build: - + name: PHPStan Check runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + symfony_version: + - "6.4.*" + - "7.0.*" + php_version: + - 8.2 + - 8.3 + - 8.4 + exclude: + - php_version: 8.2 + symfony_version: "7.0.*" steps: - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + extensions: mbstring, intl, xml, ctype, iconv + coverage: none + - name: Validate composer.json and composer.lock run: composer validate --strict @@ -25,12 +45,22 @@ jobs: uses: actions/cache@v3 with: path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-php-${{ matrix.php_version }}-symfony-${{ matrix.symfony_version }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-php- + ${{ runner.os }}-php-${{ matrix.php_version }}-symfony-${{ matrix.symfony_version }}- + ${{ runner.os }}-php-${{ matrix.php_version }}- - name: Install dependencies - run: composer install --prefer-dist --no-progress + run: | + composer require --no-update "symfony/framework-bundle:${{ matrix.symfony_version }}" + composer require --no-update "symfony/dependency-injection:${{ matrix.symfony_version }}" + composer require --no-update "symfony/config:${{ matrix.symfony_version }}" + composer require --no-update "symfony/console:${{ matrix.symfony_version }}" + composer require --no-update "symfony/expression-language:${{ matrix.symfony_version }}" + composer require --no-update "symfony/http-kernel:${{ matrix.symfony_version }}" + composer require --no-update "symfony/stopwatch:${{ matrix.symfony_version }}" + composer require --no-update "symfony/yaml:${{ matrix.symfony_version }}" + composer install --prefer-dist --no-progress - name: Run PHPStan run: ./vendor/bin/phpstan analyse src -l 1 \ No newline at end of file diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index b2da065..4938189 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -3,7 +3,7 @@ on: [push, pull_request] jobs: phpunit: - name: PHP-${{ matrix.php_version }}-${{ matrix.perfer }} + name: PHP-${{ matrix.php_version }}-Symfony-${{ matrix.symfony_version }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -13,11 +13,30 @@ jobs: - 8.2 - 8.3 - 8.4 - perfer: - - stable + symfony_version: + - "6.4.*" + - "7.0.*" + exclude: + - php_version: 8.1 + symfony_version: "7.0.*" steps: - uses: actions/checkout@master + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + extensions: mbstring, intl, xml, ctype, iconv, pdo_sqlite + coverage: none - name: Install Dependencies - run: composer update --prefer-dist --no-interaction --no-suggest --prefer-${{ matrix.perfer }} + run: | + composer require --no-update "symfony/framework-bundle:${{ matrix.symfony_version }}" + composer require --no-update "symfony/dependency-injection:${{ matrix.symfony_version }}" + composer require --no-update "symfony/config:${{ matrix.symfony_version }}" + composer require --no-update "symfony/console:${{ matrix.symfony_version }}" + composer require --no-update "symfony/expression-language:${{ matrix.symfony_version }}" + composer require --no-update "symfony/http-kernel:${{ matrix.symfony_version }}" + composer require --no-update "symfony/stopwatch:${{ matrix.symfony_version }}" + composer require --no-update "symfony/yaml:${{ matrix.symfony_version }}" + composer update --prefer-dist --no-interaction - name: Run PHPUnit run: ./vendor/bin/phpunit tests diff --git a/README.md b/README.md index 5149b0d..0b7269a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ AopBundle is a Symfony bundle that implements Aspect-Oriented Programming (AOP) ## Requirements - PHP 8.1+ -- Symfony 6.4+ +- Symfony 6.4+ or 7.0+ ## Installation diff --git a/README.zh-CN.md b/README.zh-CN.md index 2d42705..1c45a11 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -11,7 +11,7 @@ AopBundle 是一个基于 Symfony 的 AOP (面向切面编程) 实现包。它 ## 系统要求 - PHP 8.1+ -- Symfony 6.4+ +- Symfony 6.4+ 或 7.0+ ## 安装方法 diff --git a/composer.json b/composer.json index 2082a90..33170d5 100644 --- a/composer.json +++ b/composer.json @@ -5,15 +5,15 @@ "require": { "php": "^8.1", "friendsofphp/proxy-manager-lts": "^1.0.18", - "symfony/config": "^6.4", - "symfony/console": "^6.4", - "symfony/dependency-injection": "^6.4", - "symfony/expression-language": "^6.4", - "symfony/framework-bundle": "^6.4", - "symfony/http-kernel": "^6.4", - "symfony/service-contracts": "^3.5", - "symfony/stopwatch": "^6.4", - "symfony/yaml": "^6.4 || ^7.1", + "symfony/config": "^6.4|^7.0", + "symfony/console": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/framework-bundle": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/service-contracts": "^3.5|^4.0", + "symfony/stopwatch": "^6.4|^7.0", + "symfony/yaml": "^6.4|^7.0", "tourze/arrayable": "0.0.*" }, "require-dev": { diff --git a/tests/Integration/ContainerAopTest.php b/tests/Integration/ContainerAopTest.php index 27f46d9..5ce5b30 100644 --- a/tests/Integration/ContainerAopTest.php +++ b/tests/Integration/ContainerAopTest.php @@ -25,7 +25,7 @@ public function testAopWithContainer(): void // Set up proxy manager services $cacheDir = sys_get_temp_dir() . '/aop-test-' . uniqid(); @mkdir($cacheDir, 0777, true); - + $fileLocatorDef = new Definition(FileLocator::class); $fileLocatorDef->setArguments([$cacheDir]); $container->setDefinition('sf-aop.file-locator', $fileLocatorDef); @@ -58,19 +58,19 @@ public function testAopWithContainer(): void $aspectDef->addTag(Aspect::TAG_NAME); $aspectDef->setPublic(true); $container->setDefinition('test.aspect', $aspectDef); - + // Add compiler pass $container->addCompilerPass(new AopAttributeCompilerPass()); // Compile container $container->compile(); - + // Get services /** @var ContainerTestService $service */ $service = $container->get('test.service'); /** @var ContainerTestAspect $aspect */ $aspect = $container->get('test.aspect'); - + // Test method interception $result = $service->doWork(); @@ -79,7 +79,8 @@ public function testAopWithContainer(): void // Verify result is not modified (AfterReturning doesn't support it) $this->assertEquals('original', $result); - + + /* // Test exception handling $aspect->log = []; try { @@ -89,10 +90,10 @@ public function testAopWithContainer(): void $this->assertEquals('Test error', $e->getMessage()); $this->assertEquals(['afterThrowing'], $aspect->log); } - + */ // Clean up if (is_dir($cacheDir)) { - $this->removeDirectory($cacheDir); + //$this->removeDirectory($cacheDir); } } From d73d0dca3b7f4ae334da6c40c24a6a8a921bb12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Fri, 22 Aug 2025 00:26:46 +0200 Subject: [PATCH 2/3] refactor(ContainerAopTest): remove commented-out code and ensure directory cleanup is active --- tests/Integration/ContainerAopTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/Integration/ContainerAopTest.php b/tests/Integration/ContainerAopTest.php index 5ce5b30..34eb56e 100644 --- a/tests/Integration/ContainerAopTest.php +++ b/tests/Integration/ContainerAopTest.php @@ -80,7 +80,6 @@ public function testAopWithContainer(): void // Verify result is not modified (AfterReturning doesn't support it) $this->assertEquals('original', $result); - /* // Test exception handling $aspect->log = []; try { @@ -90,13 +89,13 @@ public function testAopWithContainer(): void $this->assertEquals('Test error', $e->getMessage()); $this->assertEquals(['afterThrowing'], $aspect->log); } - */ + // Clean up if (is_dir($cacheDir)) { - //$this->removeDirectory($cacheDir); + $this->removeDirectory($cacheDir); } } - + private function removeDirectory(string $dir): void { if (!is_dir($dir)) { From a8ed98bd4999217737e2236c24bc2a42bea203dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Fri, 22 Aug 2025 00:32:24 +0200 Subject: [PATCH 3/3] style(ContainerAopTest): remove unnecessary blank line for cleaner code --- tests/Integration/ContainerAopTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/ContainerAopTest.php b/tests/Integration/ContainerAopTest.php index 34eb56e..9b22955 100644 --- a/tests/Integration/ContainerAopTest.php +++ b/tests/Integration/ContainerAopTest.php @@ -64,7 +64,7 @@ public function testAopWithContainer(): void // Compile container $container->compile(); - + // Get services /** @var ContainerTestService $service */ $service = $container->get('test.service');