From fb58ac83d5e07c8bc7ca43e8f786d24a0c058401 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 6 Apr 2024 08:43:22 +0200 Subject: [PATCH 1/3] try reproducing bug5795 --- tests/end-to-end/regression/5795.phpt | 27 +++++++++++++++++++ .../regression/5795/Issue5795Test.php | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/end-to-end/regression/5795.phpt create mode 100644 tests/end-to-end/regression/5795/Issue5795Test.php diff --git a/tests/end-to-end/regression/5795.phpt b/tests/end-to-end/regression/5795.phpt new file mode 100644 index 00000000000..512de1f5bea --- /dev/null +++ b/tests/end-to-end/regression/5795.phpt @@ -0,0 +1,27 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/issues/5795 +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +... 3 / 3 (100%) + +Time: %s, Memory: %s + +Issue5795 (PHPUnit\TestFixture\Issue5795\Issue5795) + ✔ This test should make phpunit spit a PHP Warning ! with data set #0 + ✔ This test should make phpunit spit a PHP Warning ! with data set #1 + ✔ This test should make phpunit spit a PHP Warning ! with data set #2 + +OK (3 tests, 3 assertions) diff --git a/tests/end-to-end/regression/5795/Issue5795Test.php b/tests/end-to-end/regression/5795/Issue5795Test.php new file mode 100644 index 00000000000..b39f05d86cd --- /dev/null +++ b/tests/end-to-end/regression/5795/Issue5795Test.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\Issue5795; + +use PHPUnit\Framework\TestCase; + +final class Issue5795Test extends TestCase +{ + /** + * @testWith [1] + * [2] + * [3] + * + * @testdox This test should make phpunit spit a PHP Warning ! + */ + public function testExample($arg): void + { + $this->assertIsInt($arg); + } +} From 26cce77958a50aa57d7a89e53a841676b7e99bb8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 14 Apr 2024 08:34:29 +0200 Subject: [PATCH 2/3] Update .php-cs-fixer.dist.php --- .php-cs-fixer.dist.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 4baa0c9d196..8c0b6055c63 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -15,6 +15,8 @@ ->in(__DIR__ . '/tests/end-to-end') ->in(__DIR__ . '/tests/unit') ->notName('DeprecatedPhpFeatureTest.php') + // don't mangle whitespaces in this test, which are required for the error reproduce + ->notName('Issue5795Test.php') ->notName('ReadonlyClass.php') ->notName('*.phpt'); From 9f951cace701903a96eb47685b2f278f6510013f Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 14 Apr 2024 08:36:19 +0200 Subject: [PATCH 3/3] Fix "PHP Warning: Uninitialized string offset 0" --- src/Metadata/Api/DataProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Metadata/Api/DataProvider.php b/src/Metadata/Api/DataProvider.php index 93e85770dd4..f9c250f8409 100644 --- a/src/Metadata/Api/DataProvider.php +++ b/src/Metadata/Api/DataProvider.php @@ -256,7 +256,7 @@ private function dataProvidedByTestWithAnnotation(string $className, string $met foreach (explode("\n", $annotationContent) as $candidateRow) { $candidateRow = trim($candidateRow); - if ($candidateRow[0] !== '[') { + if ($candidateRow === '' || $candidateRow[0] !== '[') { break; }