From 7890d324861502c37180e8963cbf7a928562028a Mon Sep 17 00:00:00 2001 From: Marcin Gil Date: Fri, 11 Apr 2025 11:47:19 +0200 Subject: [PATCH 1/6] PHP 8.2: Dynamic Properties are deprecated https://php.watch/versions/8.2/dynamic-properties-deprecated --- Tests/Framework/AssertTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/Framework/AssertTest.php b/Tests/Framework/AssertTest.php index b57055f4bd1..5517d48fc31 100644 --- a/Tests/Framework/AssertTest.php +++ b/Tests/Framework/AssertTest.php @@ -66,6 +66,7 @@ class Framework_AssertTest extends PHPUnit_Framework_TestCase { protected $filesDirectory; + protected $html; protected function setUp() { From 20b8e500002248e1a024f2635e1d2edc67f4ec66 Mon Sep 17 00:00:00 2001 From: Maciej Holyszko <14310995+falkenhawk@users.noreply.github.com> Date: Wed, 1 Apr 2026 15:40:38 +0200 Subject: [PATCH 2/6] add PHP 8.3 to CI matrix, update actions/checkout to v3 --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 885fe3d3945..3dfd0bc9eb7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" php_invoker: [true, false] coverage: [false] experimental: [false] @@ -39,7 +40,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 From de343f288e5b92f20ac933e0079ceb8605a0e578 Mon Sep 17 00:00:00 2001 From: Maciej Holyszko <14310995+falkenhawk@users.noreply.github.com> Date: Wed, 1 Apr 2026 15:40:42 +0200 Subject: [PATCH 3/6] update README with PHP 8.3 compat and composer v1 install note --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c7f1c2f8493..bc309957068 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ -# PHPUnit 3.7.x php 5.3-8.2 compatible +# PHPUnit 3.7.x php 5.3-8.3 compatible -This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.2. +This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.3. The package was created especially for testing https://github.com/zf1s packages. All credits go to original PHPUnit author and contributors. + +## Installing + +This package requires composer v1 due to its PEAR repository dependency. +You can switch composer versions with `composer self-update --1` and `composer self-update --2`. From b415e366a6d389d753ed8f316d35e6f2f7f98718 Mon Sep 17 00:00:00 2001 From: Maciej Holyszko <14310995+falkenhawk@users.noreply.github.com> Date: Wed, 1 Apr 2026 16:13:29 +0200 Subject: [PATCH 4/6] move PEAR from composer dependency to pear CLI, switch to composer v2, skip .phpt tests gracefully --- .github/workflows/tests.yml | 15 ++++++++++++--- PHPUnit/Extensions/PhptTestCase.php | 5 ++--- README.md | 5 ----- composer.json | 10 +--------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3dfd0bc9eb7..b454a83300a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,13 +48,22 @@ jobs: php-version: ${{ matrix.php }} ini-values: display_errors=off, log_errors=on extensions: xdebug, ctype, dom, json, pcre, reflection, spl - # Since "The PEAR repository has been removed from Composer 2.0" it makes "composer install" to fail on this repo - # revert to composer v1 (and run it outside the checkouted repo, because composer v2 is basically stuck on that error on any command) - tools: composer:v1 + tools: composer env: # https://github.com/shivammathur/setup-php/issues/407#issuecomment-773675741 fail-fast: true + # PEAR_RunTest is needed for .phpt tests. The composer v2 packagist version + # of pear/pear requires PHP 5.4+, and the PHP 5.3-compatible version that was + # previously installable via composer v1 is no longer available since packagist + # dropped composer v1 support. Install via pear CLI provided by setup-php instead. + # + # pear install without sudo fails on PHP 5.6+ with "php_dir is not writeable" + # because setup-php creates root-owned PEAR directories for those versions. + # pear channel-update is needed to avoid "channel has updated its protocols" warning. + - name: Install PEAR + run: sudo pear channel-update pear.php.net && sudo pear install --force PEAR + - name: Install dependencies env: INSTALL_PHP_INVOKER: "${{ matrix.php_invoker == true }}" diff --git a/PHPUnit/Extensions/PhptTestCase.php b/PHPUnit/Extensions/PhptTestCase.php index bb66bdc23eb..ccbe8821228 100644 --- a/PHPUnit/Extensions/PhptTestCase.php +++ b/PHPUnit/Extensions/PhptTestCase.php @@ -44,9 +44,7 @@ */ if (stream_resolve_include_path('PEAR/RunTest.php')) { - $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE); require_once 'PEAR/RunTest.php'; - error_reporting($currentErrorReporting); } /** @@ -122,7 +120,8 @@ public function count() public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array()) { if (!class_exists('PEAR_RunTest', FALSE)) { - throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.'); + $result->addFailure($this, new PHPUnit_Framework_SkippedTestError('PEAR_RunTest not available'), 0); + return $result; } if (isset($GLOBALS['_PEAR_destructor_object_list']) && diff --git a/README.md b/README.md index bc309957068..07921b2c32f 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,3 @@ This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibilit The package was created especially for testing https://github.com/zf1s packages. All credits go to original PHPUnit author and contributors. - -## Installing - -This package requires composer v1 due to its PEAR repository dependency. -You can switch composer versions with `composer self-update --1` and `composer self-update --2`. diff --git a/composer.json b/composer.json index 0bd52ed7d03..eeba5c0a9f5 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,6 @@ "support": { "issues": "https://github.com/zf1s/phpunit/issues" }, - "repositories": [ - { - "type": "pear", - "url": "https://pear.php.net" - } - ], "require": { "php": ">=5.3.3", "phpunit/php-text-template": "^1.2.1", @@ -46,9 +40,7 @@ "ext-reflection": "*", "ext-spl": "*" }, - "require-dev": { - "pear-pear.php.net/pear": "~1.9|~1.10" - }, + "require-dev": {}, "suggest": { "phpunit/php-invoker": "~1.1" }, From fd756faa7194a43e5b9acdf29d071e7705620e89 Mon Sep 17 00:00:00 2001 From: Maciej Holyszko <14310995+falkenhawk@users.noreply.github.com> Date: Wed, 1 Apr 2026 17:40:00 +0200 Subject: [PATCH 5/6] fix PHP 8.3 deprecations in GlobalState: ReflectionProperty::setValue() single-arg and PEAR globals backup --- PHPUnit/Util/GlobalState.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/PHPUnit/Util/GlobalState.php b/PHPUnit/Util/GlobalState.php index 08457fd89ed..008e691e98c 100644 --- a/PHPUnit/Util/GlobalState.php +++ b/PHPUnit/Util/GlobalState.php @@ -107,6 +107,10 @@ public static function backupGlobals(array $blacklist) } } + // skip PEAR globals to avoid "Creation of dynamic property" deprecation + // on PHP 8.2+ when unserializing PEAR_Registry objects + $blacklist[] = '_PEAR_Config_instance'; + foreach (array_keys($GLOBALS) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && @@ -133,6 +137,9 @@ public static function restoreGlobals(array $blacklist) } } + // skip PEAR globals (see comment in backupGlobals) + $blacklist[] = '_PEAR_Config_instance'; + foreach (array_keys($GLOBALS) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && @@ -343,7 +350,8 @@ public static function restoreStaticAttributes() foreach ($staticAttributes as $name => $value) { $reflector = new ReflectionProperty($className, $name); $reflector->setAccessible(TRUE); - $reflector->setValue(unserialize($value)); + // two-arg form: single-arg setValue() for static properties is deprecated in PHP 8.3 + $reflector->setValue(null, unserialize($value)); } } From ded06d51df6119fcb5858e0b102b50c2b6c3e303 Mon Sep 17 00:00:00 2001 From: Maciej Holyszko <14310995+falkenhawk@users.noreply.github.com> Date: Wed, 1 Apr 2026 17:43:31 +0200 Subject: [PATCH 6/6] enable deprecation reporting on CI (error_reporting=E_ALL) --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b454a83300a..70717843640 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,7 +46,9 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - ini-values: display_errors=off, log_errors=on + # setup-php defaults to production ini which excludes E_DEPRECATED, + # override to catch deprecation warnings in tests + ini-values: error_reporting=E_ALL, display_errors=on, log_errors=on extensions: xdebug, ctype, dom, json, pcre, reflection, spl tools: composer env: