Skip to content

Incorrect file/line blamed for errors caused by new SomeClass #7771

Closed
@dktapps

Description

@dktapps

Description

https://3v4l.org/UtjRl

This code should blame line 4, not line 7, since that's where the bogus constant is actually declared.


An example of where this is more problematic:

SomeClass.php

<?php

class SomeClass{
	public const INGOT = IDontExist::INGOT;
}

test.php

<?php

require 'SomeClass.php';

new SomeClass();

Resulted in this output:

Fatal error: Uncaught Error: Class "IDontExist" not found in C:\stable\test4.php:5

But I expected this output instead:

Fatal error: Uncaught Error: Class "IDontExist" not found in C:\stable\SomeClass.php:4

This frequently causes issues with my telemetry because incorrect subsystems are getting blamed for errors when third-party plugin code comes into play.

PHP Version

8.0.13

Operating System

Windows (doubtful if relevant)

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