Repository: getsentry/sentry-php (php)

Issue:
Run tests against php 8.2
PHP 8.2 will be released in Nov '22. We should start running our test suite against this version as well, to catch potential issues early.

Pull request:
ci: Run test suite against PHP 8.2
Closes #1337 

Patch:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yml
similarity index 74%
rename from .github/workflows/ci.yaml
rename to .github/workflows/ci.yml
index 3f4c257..cf0ba4e 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yml
@@ -23,6 +23,7 @@ jobs:
           - '7.4'
           - '8.0'
           - '8.1'
+          - '8.2'
         dependencies:
           - lowest
           - highest
@@ -55,15 +56,23 @@ jobs:
 
       - name: Install highest dependencies
         run: composer update --no-progress --no-interaction --prefer-dist
-        if: ${{ matrix.dependencies == 'highest' }}
+        if: ${{ matrix.dependencies == 'highest' && matrix.php != '8.2' }}
 
-      - name: Restrict lowest Symfony version on PHP 8.1
+      - name: Install highest PHP 8.2 dependencies
+        run: composer update --no-progress --no-interaction --prefer-dist --ignore-platform-req=php
+        if: ${{ matrix.dependencies == 'highest' && matrix.php == '8.2' }}
+
+      - name: Restrict lowest Symfony version on PHP 8.1 & 8.2
         run: composer require symfony/options-resolver:^4.4.30 --no-update
-        if: ${{ matrix.dependencies == 'lowest' && matrix.php == '8.1' }}
+        if: ${{ matrix.dependencies == 'lowest' && matrix.php == '8.1' || matrix.php == '8.2' }}
 
       - name: Install lowest dependencies
         run: composer update --no-progress --no-interaction --prefer-dist --prefer-lowest
-        if: ${{ matrix.dependencies == 'lowest' }}
+        if: ${{ matrix.dependencies == 'lowest' && matrix.php != '8.2' }}
+
+      - name: Install lowest PHP 8.2 dependencies
+        run: composer update --no-progress --no-interaction --prefer-dist --prefer-lowest --ignore-platform-req=php
+        if: ${{ matrix.dependencies == 'lowest' && matrix.php == '8.2' }}
 
       - name: Run tests
         run: vendor/bin/phpunit --coverage-clover=build/coverage-report.xml
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 0f5d147..0310647 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,14 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
-         backupGlobals="true"
-         colors="true"
-         bootstrap="tests/bootstrap.php"
-         cacheResult="false"
-         beStrictAboutOutputDuringTests="true"
+<phpunit
+    backupGlobals="true"
+    colors="true"
+    bootstrap="tests/bootstrap.php"
+    cacheResult="false"
+    beStrictAboutOutputDuringTests="true"
 >
     <php>
-        <env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
+        <env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
     </php>
 
     <testsuites>
@@ -18,23 +17,11 @@
         </testsuite>
     </testsuites>
 
-    <coverage>
-        <include>
-            <directory suffix=".php">src</directory>
-        </include>
-    </coverage>
-
-    <filter>
-        <whitelist>
-            <directory suffix=".php">src</directory>
-        </whitelist>
-    </filter>
-
     <listeners>
-        <listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
+        <listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
     </listeners>
 
     <extensions>
-        <extension class="Sentry\Tests\SentrySdkExtension" />
+        <extension class="Sentry\Tests\SentrySdkExtension"/>
     </extensions>
 </phpunit>


Test patch:
diff --git a/tests/Serializer/AbstractSerializerTest.php b/tests/Serializer/AbstractSerializerTest.php
index 7d421f1..af3e891 100644
--- a/tests/Serializer/AbstractSerializerTest.php
+++ b/tests/Serializer/AbstractSerializerTest.php
@@ -538,7 +538,7 @@ public function serializationForBadStringsDataProvider(): array
         $utf8String = 'äöü';
 
         return [
-            [utf8_decode($utf8String), $utf8String, 'ISO-8859-1, ASCII, UTF-8'],
+            [mb_convert_encoding($utf8String, 'ISO-8859-1', 'UTF-8'), $utf8String, 'ISO-8859-1, ASCII, UTF-8'],
             ["\xC2\xA2\xC2", "\xC2\xA2\x3F"], // ill-formed 2-byte character U+00A2 (CENT SIGN)
         ];
     }
@@ -563,11 +563,7 @@ protected function invokeSerialization(AbstractSerializer $serializer, $input)
     }
 }
 
-/**
- * Class SerializerTestObject.
- *
- * @property mixed $keys
- */
+#[\AllowDynamicProperties]
 class SerializerTestObject
 {
     private $foo = 'bar';