Skip to content

Wrong line number reported in case of a multiline parameter list #8810

Closed

Description

@slapoguzov

Description

PHP reports the wrong line number in stacktrace in case of a multiline parameter list, for example:

<?php

function test()
{
    myAssert(             //this line is expected to be reported
        false,
        "message"      //this line will be reported
    );
}

function myAssert($a, $b)
{
    if(!$a) throw new ErrorException($b);
}

test();

The following stacktrace will be reported:

    0.0001     394432   1. {main}() /Users/Aleksandr.Slapoguzov/PhpstormProjects/test/test2.php:0
    0.0001     394432   2. test() /Users/Aleksandr.Slapoguzov/PhpstormProjects/test/test2.php:16
    0.0001     394432   3. myAssert($a = FALSE, $b = 'message') /Users/Aleksandr.Slapoguzov/PhpstormProjects/test/test2.php:7

But I expected this output instead:

    0.0001     394432   1. {main}() /Users/Aleksandr.Slapoguzov/PhpstormProjects/test/test2.php:0
    0.0001     394432   2. test() /Users/Aleksandr.Slapoguzov/PhpstormProjects/test/test2.php:16
    0.0001     394432   3. myAssert($a = FALSE, $b = 'message') /Users/Aleksandr.Slapoguzov/PhpstormProjects/test/test2.php:5

Although the 7th line is part of the failed function call, it would be better to report the 5th line.

PHP Version

PHP 8.1.0

Operating System

MacOS

Activity

  1. iluuu1994 commented on Jun 17, 2022

    @iluuu1994
    Member

    Has been like this for ages, so reclassifying as a feature request.

  2. self-assigned this
    on Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions