| Q |
A |
| PHPUnit version |
10.5.16 (also in 9.x) |
| PHP version |
8.2.14 |
| Installation Method |
Composer |
Summary
Using @testWith might generate PHP Warning: Uninitialized string offset: 0
Current behavior
You launch phpunit and before you see the header you see 2 Warnings
How to reproduce
This is quite easy. You have to use @testwith in a way that it is followed with a blank line. For example,
/**
* @testWith [1]
* [2]
* [3]
*
* @testdox This test should make phpunit spit a PHP Warning !
*/
public function testExample($arg): void
{
$this->assertIsInt($arg);
}
This is probably related to the explode("\n", ...) that includes empty lines in between annotations
|
foreach (explode("\n", $annotationContent) as $candidateRow) { |
Expected behavior
No PHP warning.
Workaround
You can move the @testWith statement at the end of the comment section.
/**
* @testdox This test should NOT make phpunit spit a PHP Warning anymore...
*
* @testWith [1]
* [2]
* [3]
*/
public function testExample($arg): void
{
$this->assertIsInt($arg);
}
Summary
Using
@testWithmight generatePHP Warning: Uninitialized string offset: 0Current behavior
You launch phpunit and before you see the header you see 2 Warnings
How to reproduce
This is quite easy. You have to use
@testwithin a way that it is followed with a blank line. For example,This is probably related to the
explode("\n", ...)that includes empty lines in between annotationsphpunit/src/Metadata/Api/DataProvider.php
Line 252 in cd49a71
Expected behavior
No PHP warning.
Workaround
You can move the
@testWithstatement at the end of the comment section.