grumphp icon indicating copy to clipboard operation
grumphp copied to clipboard

Phpparser excludes filename from error message

Open rubenflush opened this issue 2 years ago • 1 comments

Q A
Version 1.12.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets -

When an error is found by the phpparser task, it will show an error message indicating the problem. However, the file path without filename is used instead of the filename which makes it harder to fix the problem.

My configuration

# grumphp.yml
grumphp:
  tasks:
    phpparser:
      visitors:
        declare_strict_types: ~

Steps to reproduce:

# Generate empty folder
mkdir tmp
cd tmp
git init
echo "vendor" > .gitignore
pbpaste > grumphp.yml

composer require --dev phpro/grumphp
composer require nikic/php-parser

mkdir -p src/resources
echo "<?php" > src/resources/nl.php
git add .

# Run GrumPHP:
./vendor/bin/grumphp run

Result:

[ERROR] src/resources: No "declare(strict_types = 1)" found in file!

Expected result:

[ERROR] src/resources/nl.php: No "declare(strict_types = 1)" found in file!

rubenflush avatar Sep 14 '22 07:09 rubenflush

Thanks for reporting. This should be an easy fix. Do you wanna give it a try?

My hunch is that this line is not correct: https://github.com/phpro/grumphp/blob/6c3ca70a9185e76f3e914ddfcbcf4c7f541326a2/src/Parser/Php/Visitor/AbstractVisitor.php#L30

veewee avatar Sep 14 '22 07:09 veewee