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

fatal error while scanning a php file #1

Closed
mjrider opened this issue Nov 5, 2019 · 4 comments
Closed

fatal error while scanning a php file #1

mjrider opened this issue Nov 5, 2019 · 4 comments

Comments

@mjrider
Copy link

mjrider commented Nov 5, 2019

I'm getting the following error:

PHP Fatal error:  Uncaught Error: Call to undefined method PhpParser\Node\Expr\Variable::getLast() in .../vendor/gettext/php-scanner/src/PhpNodeVisitor.php:31

the line of code triggering the error is:

    $phpScanner->scanFile($file->getRelativePathname());

the contents of the file which would still trigger the error

<?php

class AuthMiddleware
{
    public function test()
    {
       return __('Accessing the Backoffice is not allowed at this time.');
    }
}

Versions:

gettext/gettext                     v5.0.0             PHP gettext manager
gettext/languages                   2.5.0              gettext languages with plural rules
gettext/php-scanner                 v1.0.0             PHP scanner for gettext
oscarotero added a commit that referenced this issue Nov 7, 2019
@oscarotero
Copy link
Member

Hi, @mjrider
Sorry for the late response, for some reason, I wasn't waching this repo, so didn't get any notification.

I just commit your code but couldn't reproduce this error. f9f0bed
Could I get more info? Maybe by creating a test case reproducing the error?

@mjrider
Copy link
Author

mjrider commented Nov 11, 2019

i reduced the script to trigger the error to

<?php
require_once __DIR__ . '/../vendor/autoload.php';

use Gettext\Scanner\PhpScanner;
use Gettext\Translations;

$phpScanner = new PhpScanner(
    Translations::create()
);

$phpScanner->scanFile('app/Lib/Helpers.php');
$phpScanner->scanFile('app/Middlewares/AuthMiddleware.php');

first file doesn't have translations, works fine
second file has 1 translation, and fails

But i still cant get it to fail in the php-scanner unti tests

@mjrider
Copy link
Author

mjrider commented Nov 11, 2019

it seems that i didn't produce the correct reproduction scenario.

see master...mjrider:master for the change in the testcase

oscarotero added a commit that referenced this issue Nov 11, 2019
@oscarotero
Copy link
Member

Fixed in v1.0.1
Thanks for reporting!

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

2 participants