Skip to content

level key of log_record_array Psalm type causes SA issues in TestLogger::has*() methods #18

@mbabker

Description

@mbabker

With this simplified example:

new Psr\Log\Test\TestLogger()->hasInfo([
    'message' => 'Message',
    'context' => [
        'foo' => 'Foo',
        'bar'  => 123,
    ],
]);

After updating to 1.2.0 and getting the changes from #15 I'm getting this error from PHPStan:

Parameter #1 $record of method Psr\Log\Test\TestLogger::hasInfo() expects array{level: string, message: string|Stringable, context: array{exception?: Throwable}}|string, array{message: 'Message', context: array{foo: 'Foo', bar: 123}} given.
🪪  argument.type
💡  Type #1 from the union: Array does not have offset 'level'.

Considering the level is a separate argument for TestLogger::hasRecord() and the key from the array is not used at all here, the log_record_array type seems like it might not be the best array shape for the $record argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions