| Q |
A |
| PHPUnit version |
9.5.3 |
| PHP version |
7.4.16 |
| Installation Method |
Composer |
Summary
When a non int/string key is provided from a generator dataprovider you get an error. This is to be expected. However the error does not make it obvious what went wrong.
Current behavior
vendor/bin/phpunit --debug
Warning: array_key_exists(): The first argument should be either a string or an integer in /project/vendor/phpunit/phpunit/src/Util/Annotation/DocBlock.php on line 438
How to reproduce
Create a dataprovider that has a non int/string key. and use it in a test (This is valid in PHP btw https://3v4l.org/sbeOf)
Expected behavior
I'd expect to get an error with a clear message, telling me that i'm using a non int/string key in a dataprovider, which is not supported. Prehaps with the type i am using.
Because the error mentions Util/Annotation/DocBlock.php we initially though phpunit was failing due to a wrong annotation somewhere.
Summary
When a non int/string key is provided from a generator dataprovider you get an error. This is to be expected. However the error does not make it obvious what went wrong.
Current behavior
How to reproduce
Create a dataprovider that has a non int/string key. and use it in a test (This is valid in PHP btw https://3v4l.org/sbeOf)
Expected behavior
I'd expect to get an error with a clear message, telling me that i'm using a non int/string key in a dataprovider, which is not supported. Prehaps with the type i am using.
Because the error mentions
Util/Annotation/DocBlock.phpwe initially though phpunit was failing due to a wrong annotation somewhere.