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

Warning: Illegal offset type #486

Open
pdias opened this issue May 12, 2018 · 4 comments
Open

Warning: Illegal offset type #486

pdias opened this issue May 12, 2018 · 4 comments

Comments

@pdias
Copy link

pdias commented May 12, 2018

Q A
Bundle version dev-master
Symfony version 3.4
PHP version 7.1.8

Expected behavior

Extract translation in xliff format

Actual behavior

Extracting Translations for locale en
Keep old translations: No
Output-Path: D:\wamp\www\My\src\Sa\AvadocBundle/Resources/translations
Directories: D:\wamp\www\My\src\Sa\AvadocBundle
Excluded Directories: Tests
Excluded Names: *Test.php, *TestCase.php
Output-Format: xliff
Custom Extractors: # none #
============================================================
Loading catalogues from "D:\wamp\www\My\src\Sa\AvadocBundle/Resources/translations"
Extracting translation keys
Extracting messages from directory : D:\wamp\www\My\src\Sa\AvadocBundle

In TranslationContainerExtractor.php line 89:
                                
  Warning: Illegal offset type

Steps to reproduce

In this case I extract from the AvadocBundle bundle...

console translation:extract -b AvadocBundle --output-format xliff en

This happens since the last update (nikic / php-parser v4.0.1)... reverting to version 1.4.1, extracts correctly.

@pdias
Copy link
Author

pdias commented May 12, 2018

Now the class PhpParser\Node\Stmt\UseUse in nikic/php-parser v4.0.1, getting the property alias ( $node->alias ) will return always null.
If we use the method getAlias ( $node->getAlias() ) this will return a Identifier object.

To solve this error we must change line 89 from TranslationContainerExtractor.php to this:

$this->useStatements[$node->name->getLast()] = implode('\\', $node->name->parts);

@pdias
Copy link
Author

pdias commented May 13, 2018

Another problem... this version (dev-master) is not respecting the translation_domain of forms...

@pdias
Copy link
Author

pdias commented May 13, 2018

FormExtrator must be changed to respect translation domains.

Line 105:

if (!is_string($node->name)) {
    return;
}

must be changed to:

if (!$node->name instanceof Node\Identifier) {
   return;
}

and

Line 109:

$name = strtolower($node->name);

must be changed to:

$name = $node->name->toLowerString();

I do not know if there are no more changes to make ...

Tomorrow I make a PR

@carlos-mg89
Copy link

Have all these changes been applied @pdias ? I see this issue is still open, and I'm getting the same error.

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