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

Extractor misunderstands my "label" key #227

Closed
ntoniazzi opened this issue Jan 22, 2015 · 2 comments
Closed

Extractor misunderstands my "label" key #227

ntoniazzi opened this issue Jan 22, 2015 · 2 comments
Labels

Comments

@ntoniazzi
Copy link

I declare an array which contains a label key. The value needs to be translated, so I call the trans method. When I run the extractor on my file, it complains that this id is not a string but a PHPParser_Node_Expr_MethodCall. In fact, it sees the label key as being part of a form definition.

$myArray = [
    'target' => 'something',
    /** @Desc("description") @Meaning("meaning") */
    'label'  => $translator->trans('my.id')
];

The error message reads:

Unable to extract translation id for form label from non-string values, but got "PHPParser_Node_Expr_MethodCall" in src/Alt/Bundle/BduBundle/Controller/MainController.php on line 104. Please refactor your code to pass a string, or add "/** @ignore */".

Well, I could change the name of my key, but if there is better solution.

@sadortun
Copy link

duplicate of #126

I think the parser expect a label key in a array to contain a string/translation key

Have you tried

$myArray = [
    'target' => 'something',
    /** @Desc("description") @Meaning("meaning") */
    'label'  => 'my.id'
];

@Nyholm Nyholm added the Parser label Mar 24, 2016
@Nyholm
Copy link
Collaborator

Nyholm commented Aug 4, 2016

Thank you @sadortun. You are correct.

@Nyholm Nyholm closed this as completed Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants