Codeception / Codeception

Full-stack testing PHP framework
http://codeception.com
MIT License
4.75k stars 1.3k forks source link

"Warning: Uninitialized string offset 1 in Parser.php:160" when using readonly on anonymous classes #6755

Open neontsun opened 1 month ago

neontsun commented 1 month ago

What are you trying to achieve?

In some of our testcases we use anonymous classes. When creating an anonymous readonly class, this class issues a warning. The tests run fine though.

What do you get instead?

vendor/bin/codecept run
Codeception PHP Testing Framework v5.1.2

Uninitialized string offset 1 at /var/www/api/vendor/codeception/codeception/src/Codeception/Lib/Parser.php:160

Provide test source code if related

<?php

namespace Shared\Tests\Unit\Domain\ValueObject;

use Throwable;

final class AbstractCollectionTest extends \Codeception\Test\Unit
{
    protected UnitTester $tester;

    public function testCreateVo(): void
    {
        try {
            new readonly class (12) extends AbstractValueObject {
                public function __construct(
                    public mixed $value,
                ) {}
            };

            $this->tester->assertTrue(true);
        } catch (Throwable $e) {
            $this->tester->fail($e->getMessage());
        }
    }
}

Details

# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

actor: UnitTester
modules:
    enabled:
        - Asserts
step_decorators: ~