From 275528b21ed82d2121ea91c31d91b37d27825514 Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Sun, 10 Nov 2013 19:56:47 +0100 Subject: [PATCH 1/2] Skip keys with the @Ignore annotation in the FormExtractor Fixes #20 --- Translation/Extractor/File/FormExtractor.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Translation/Extractor/File/FormExtractor.php b/Translation/Extractor/File/FormExtractor.php index c2bc4e9a..74070a1d 100644 --- a/Translation/Extractor/File/FormExtractor.php +++ b/Translation/Extractor/File/FormExtractor.php @@ -187,7 +187,7 @@ private function parseItem($item, $domain = null) // get doc comment $ignore = false; $desc = $meaning = $docComment = null; - + if ($item->key) { $docComment = $item->key->getDocComment(); } @@ -207,10 +207,11 @@ private function parseItem($item, $domain = null) // check if the value is explicitly set to false => e.g. for FormField that should be rendered without label $ignore = $ignore || $item->value->value == false; + if ($ignore) { + return; + } + if (!$item->value instanceof \PHPParser_Node_Scalar_String) { - if ($ignore) { - return; - } $message = sprintf('Unable to extract translation id for form label/title/placeholder from non-string values, but got "%s" in %s on line %d. Please refactor your code to pass a string, or add "/** @Ignore */".', get_class($item->value), $this->file, $item->value->getLine()); if ($this->logger) { From 0e710dc04ff21c183e4bdd0a994788909b795765 Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Sun, 10 Nov 2013 21:51:44 +0100 Subject: [PATCH 2/2] Trigger Travis --- Translation/Extractor/File/FormExtractor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Translation/Extractor/File/FormExtractor.php b/Translation/Extractor/File/FormExtractor.php index 74070a1d..c103b3b2 100644 --- a/Translation/Extractor/File/FormExtractor.php +++ b/Translation/Extractor/File/FormExtractor.php @@ -184,10 +184,10 @@ private function parseDefaultsCall($name, \PHPParser_Node $node) private function parseItem($item, $domain = null) { - // get doc comment $ignore = false; $desc = $meaning = $docComment = null; + // get doc comment if ($item->key) { $docComment = $item->key->getDocComment(); }