Closed
Description
Preconditions (*)
- Magento 2.3
- PHP 7.2
Steps to reproduce (*)
- Create a new module
- Create a test with data provider returning anonymous class
./bin/magento setup:di:compile
Expected result (*)
- Compilation succed
Actual result (*)
Notice: Uninitialized string offset: 1 in /var/www/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php on line 219
My sample test class looks like this:
<?php
namespace OskarLaska\Xyz\Test\Unit;
class TestTest extends \PHPUnit\Framework\TestCase
{
/**
* @param $theObject
*
* @dataProvider someProvider
*/
public function testX($theObject)
{
$this->assertEquals('It works!', $theObject->callMe());
}
public function someProvider()
{
return [
'test' => [
new class {
public function callMe() {
return 'It works!';
}
}
]
];
}
}
Not sure if the anonymous class needs to be in data provider of PHPUnit's test. I saw other issues with anonymous classes resolved hence I provide my specific case.