Open Jarown opened 7 years ago
I get the same exception but with another case.
The choices_as_values
allows me to use the symfony3 format for the array (http://symfony.com/doc/2.8/reference/forms/types/choice.html#choices-as-values).
Another point to add is that I don't want JMS to parse these choices, since I don't have any "key" and only values, but @Ignore
seems to have no effect at all.
Q | A |
---|---|
Bundle version | 1.3.1 |
Symfony version | 2.8.18 |
PHP version | 5.6 |
Here's the code:
$builder
->add('activated', ChoiceType::class, array(
'choices' => array(
'1',
'0',
'inherited'
),
'choices_as_values' => true,
))
;
Here's the stack:
PHP Fatal error: Call to a member function getDocComment() on null in /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Extractor/File/FormExtractor.php on line 350
PHP Stack trace:
PHP 1. {main}() /opt/rgsupv-dashboard/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /opt/rgsupv-dashboard/app/console:22
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /opt/rgsupv-dashboard/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:122
PHP 4. Symfony\Component\Console\Application->doRun() /opt/rgsupv-dashboard/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:92
PHP 5. Symfony\Component\Console\Application->doRunCommand() /opt/rgsupv-dashboard/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
PHP 6. Symfony\Component\Console\Command\Command->run() /opt/rgsupv-dashboard/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:872
PHP 7. JMS\TranslationBundle\Command\ExtractTranslationCommand->execute() /opt/rgsupv-dashboard/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:267
PHP 8. JMS\TranslationBundle\Translation\Updater->process() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Command/ExtractTranslationCommand.php:131
PHP 9. JMS\TranslationBundle\Translation\Updater->setConfig() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Updater.php:143
PHP 10. JMS\TranslationBundle\Translation\ExtractorManager->extract() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Updater.php:253
PHP 11. JMS\TranslationBundle\Translation\Extractor\FileExtractor->extract() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/ExtractorManager.php:137
PHP 12. call_user_func_array:{/opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Extractor/FileExtractor.php:235}() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Extractor/FileExtractor.php:235
PHP 13. JMS\TranslationBundle\Translation\Extractor\File\FormExtractor->visitPhpFile() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Extractor/FileExtractor.php:235
PHP 14. PhpParser\NodeTraverser->traverse() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Extractor/File/FormExtractor.php:440
PHP 15. PhpParser\NodeTraverser->traverseArray() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
PHP 16. PhpParser\NodeTraverser->traverseNode() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
PHP 17. PhpParser\NodeTraverser->traverseArray() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
PHP 18. PhpParser\NodeTraverser->traverseNode() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
PHP 19. PhpParser\NodeTraverser->traverseArray() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
PHP 20. PhpParser\NodeTraverser->traverseNode() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
PHP 21. PhpParser\NodeTraverser->traverseArray() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
PHP 22. PhpParser\NodeTraverser->traverseNode() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
PHP 23. PhpParser\NodeTraverser->traverseArray() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
PHP 24. PhpParser\NodeTraverser->traverseNode() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
PHP 25. JMS\TranslationBundle\Translation\Extractor\File\FormExtractor->enterNode() /opt/rgsupv-dashboard/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:88
PHP 26. JMS\TranslationBundle\Translation\Extractor\File\FormExtractor->parseChoiceNode() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Extractor/File/FormExtractor.php:141
PHP 27. JMS\TranslationBundle\Translation\Extractor\File\FormExtractor->parseItem() /opt/rgsupv-dashboard/vendor/jms/translation-bundle/JMS/TranslationBundle/Translation/Extractor/File/FormExtractor.php:248
[Symfony\Component\Debug\Exception\FatalErrorException]
Error: Call to a member function getDocComment() on null
EDIT: After applying, @Jarown 's modifications, it worked like a charm. Could you make a PR with them? (For the time being I'll just use a personal fork)
Expected behavior
translation:extract
does not result in fatal errorsActual behavior
translation:extract
throws this fatal in the described situation below[Symfony\Component\Debug\Exception\FatalThrowableError] Call to a member function getDocComment() on null
Steps to reproduce
Run for attached files:
bin/console translation:extract en --bundle=MyBundle
Steps to reproduce
It looks like the items in the 'choices'-array cause this error. The attached patch fixes the fatal by checking first if
value
is an object, before calling the function.FatalThrowableError.patch.txt StatisticsTrackingHelper.php.txt MyApiFormType.php.txt