Skip to content

Feature toggle for precise offsets in errors #11760

@ruudk

Description

@ruudk

Feature request

The following code produces 2 errors that look the same:

$a=[];

echo $a['someLongKeyThatMightNotExist'];
echo $a['someLongKeyThatMightExist'];
Offset 'someLongKeyThatMigh…' does not exist on array{}. offsetAccess.notFound
Offset 'someLongKeyThatMigh…' does not exist on array{}. offsetAccess.notFound

That also means that in the baseline, they show up as a single error that happens twice.

		-
			message: "#^Offset 'someLongKeyThatMigh…' does not exist on array\\{\\}\\.$#"
			count: 2
			path: src/MyFile.php

I understand that some values need to be truncated, but also for errors related to array offsets?

Would it be an idea to create a feature toggle for this? It can then be used in the offset related errors to toggle between value and precise.

Did PHPStan help you today? Did it make you happy in any way?

💙

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions