Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect line number for PhanPluginMixedKeyNoKey and nested arrays #4852

Open
anomiex opened this issue Apr 15, 2024 · 0 comments
Open

Incorrect line number for PhanPluginMixedKeyNoKey and nested arrays #4852

anomiex opened this issue Apr 15, 2024 · 0 comments

Comments

@anomiex
Copy link

anomiex commented Apr 15, 2024

Phan version: 5.4.3, v5.x-dev 790e4f7
php-ast version: 1.1.1

Reproduction

  1. Create the following file
    <?php
    
    $var2 = array(
        1,
        'xxx' => 1,
    );
    
    $var = array(
        array(
            1,
        ),
        'xxx' => array(
            1,
        ),
    );
  2. Do phan --init, then run phan --plugin DuplicateArrayKeyPlugin test.php

Expected results

Errors reported on either the line of the array( or the line of the first element, e.g.

test.php:4 PhanPluginMixedKeyNoKey Should not mix array entries of the form [key => value,] with entries of the form [value,].
test.php:9 PhanPluginMixedKeyNoKey Should not mix array entries of the form [key => value,] with entries of the form [value,].

Actual results

For the nested array, the error is reported on the line of the first element of the nested array, even though that array does not have the problem.

test.php:4 PhanPluginMixedKeyNoKey Should not mix array entries of the form [key => value,] with entries of the form [value,].
test.php:10 PhanPluginMixedKeyNoKey Should not mix array entries of the form [key => value,] with entries of the form [value,].

Other notes

Probably the real bug is somewhere in PHP itself, putting the wrong line number in the AST. No idea where to begin reporting that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant