[BUGFIX] Wrong usage of count on SimpleXMLElement 65/33265/2
authorStefan Froemken <froemken@gmail.com>
Fri, 10 Oct 2014 12:00:04 +0000 (14:00 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 11 Oct 2014 15:27:53 +0000 (17:27 +0200)
SimpleXMLElement comes with its own count implementation,
so no need to call count() on that Element.
Further I have updated some type annotations.

Resolves: #62130
Releases master,6.2
Change-Id: I2d52d54172d2898a89f0649330dc37ebddfe40c7
Reviewed-on: http://review.typo3.org/33265
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php

index 031d974..ac18b6f 100644 (file)
@@ -86,13 +86,14 @@ class LocallangXmlParser extends \TYPO3\CMS\Core\Localization\Parser\AbstractXml
        /**
         * Parse the given language key tag
         *
-        * @param SimpleXMLElement $bodyOfFileTag
+        * @param \SimpleXMLElement $bodyOfFileTag
         * @param string $element
         * @return array
         */
        protected function getParsedDataForElement(\SimpleXMLElement $bodyOfFileTag, $element) {
                $parsedData = array();
-               if (count($bodyOfFileTag->children()) == 0) {
+               $children = $bodyOfFileTag->children();
+               if ($children->count() == 0) {
                        // Check for externally-referenced resource:
                        // <languageKey index="fr">EXT:yourext/path/to/localized/locallang.xml</languageKey>
                        $reference = sprintf('%s', $bodyOfFileTag);
@@ -100,7 +101,8 @@ class LocallangXmlParser extends \TYPO3\CMS\Core\Localization\Parser\AbstractXml
                                return $this->getParsedTargetData(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($reference));
                        }
                }
-               foreach ($bodyOfFileTag->children() as $translationElement) {
+               /** @var \SimpleXMLElement $translationElement */
+               foreach ($children as $translationElement) {
                        if ($translationElement->getName() === 'label') {
                                // If restype would be set, it could be metadata from Gettext to XLIFF conversion (and we don't need this data)
                                $parsedData[(string) $translationElement['index']][0] = array(