[TASK] Make HtmlParserTest notice free 63/56663/8
authorJan Helke <typo3@helke.de>
Sun, 15 Apr 2018 06:14:02 +0000 (08:14 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 9 Jun 2018 19:30:40 +0000 (21:30 +0200)
Releases: master
Resolves: #84724
Change-Id: I92a7ccbc88463d3fb3925185247331acf2977e40
Reviewed-on: https://review.typo3.org/56663
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Html/HtmlParser.php
typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php

index 9141f01..bc8a1cf 100644 (file)
@@ -396,7 +396,7 @@ class HtmlParser
                 $tok = substr($tok, $eocPos + 10);
                 $inCdata = false;
                 $skipTag = true;
-            } elseif (substr($tok, 0, 3) === '!--') {
+            } elseif (strpos($tok, '!--') === 0) {
                 if (($eocPos = strpos($tok, '-->')) === false) {
                     // Comment started in this token but it does end in the same token. Set a flag to skip till the end of comment
                     $newContent[$c++] = '<' . $tok;
@@ -407,7 +407,7 @@ class HtmlParser
                 $newContent[$c++] = '<' . substr($tok, 0, $eocPos + 3);
                 $tok = substr($tok, $eocPos + 3);
                 $skipTag = true;
-            } elseif (substr($tok, 0, 10) === '![CDATA[*/') {
+            } elseif (strpos($tok, '![CDATA[*/') === 0) {
                 if (($eocPos = strpos($tok, '/*]]>*/')) === false) {
                     // Comment started in this token but it does end in the same token. Set a flag to skip till the end of comment
                     $newContent[$c++] = '<' . $tok;
@@ -421,7 +421,7 @@ class HtmlParser
             }
             $firstChar = $tok[0];
             // It is a tag... (first char is a-z0-9 or /) (fixed 19/01 2004). This also avoids triggering on <?xml..> and <!DOCTYPE..>
-            if (!$skipTag && preg_match('/[[:alnum:]\\/]/', $firstChar) == 1) {
+            if (!$skipTag && preg_match('/[[:alnum:]\\/]/', $firstChar) === 1) {
                 $tagEnd = strpos($tok, '>');
                 // If there is and end-bracket...      tagEnd can't be 0 as the first character can't be a >
                 if ($tagEnd) {
@@ -439,32 +439,33 @@ class HtmlParser
                             // If NOT an endtag, do attribute processing (added dec. 2003)
                             if (!$endTag) {
                                 // Override attributes
-                                if ((string)$tags[$tagName]['overrideAttribs'] !== '') {
+                                if (isset($tags[$tagName]['overrideAttribs']) && (string)$tags[$tagName]['overrideAttribs'] !== '') {
                                     $tagParts[1] = $tags[$tagName]['overrideAttribs'];
                                 }
                                 // Allowed tags
-                                if ((string)$tags[$tagName]['allowedAttribs'] !== '') {
+                                if (isset($tags[$tagName]['allowedAttribs']) && (string)$tags[$tagName]['allowedAttribs'] !== '') {
                                     // No attribs allowed
                                     if ((string)$tags[$tagName]['allowedAttribs'] === '0') {
                                         $tagParts[1] = '';
-                                    } elseif (trim($tagParts[1])) {
+                                    } elseif (isset($tagParts[1]) && trim($tagParts[1])) {
                                         $tagAttrib = $this->get_tag_attributes($tagParts[1]);
                                         $tagParts[1] = '';
                                         $newTagAttrib = [];
-                                        if (!($tList = $tags[$tagName]['_allowedAttribs'])) {
-                                            // Just explode attribts for tag once
-                                            $tList = ($tags[$tagName]['_allowedAttribs'] = GeneralUtility::trimExplode(',', strtolower($tags[$tagName]['allowedAttribs']), true));
-                                        }
+                                        $tList = (array)(
+                                            $tags[$tagName]['_allowedAttribs']
+                                            ?? GeneralUtility::trimExplode(',', strtolower($tags[$tagName]['allowedAttribs']), true)
+                                        );
                                         foreach ($tList as $allowTag) {
                                             if (isset($tagAttrib[0][$allowTag])) {
                                                 $newTagAttrib[$allowTag] = $tagAttrib[0][$allowTag];
                                             }
                                         }
+
                                         $tagParts[1] = $this->compileTagAttribs($newTagAttrib, $tagAttrib[1]);
                                     }
                                 }
                                 // Fixed attrib values
-                                if (is_array($tags[$tagName]['fixAttrib'])) {
+                                if (isset($tags[$tagName]['fixAttrib']) && is_array($tags[$tagName]['fixAttrib'])) {
                                     $tagAttrib = $this->get_tag_attributes($tagParts[1]);
                                     $tagParts[1] = '';
                                     foreach ($tags[$tagName]['fixAttrib'] as $attr => $params) {
@@ -474,7 +475,7 @@ class HtmlParser
                                         if (!empty($params['unset'])) {
                                             unset($tagAttrib[0][$attr]);
                                         }
-                                        if (!isset($tagAttrib[0][$attr]) && (string)$params['default'] !== '') {
+                                        if (!empty($params['default']) && !isset($tagAttrib[0][$attr])) {
                                             $tagAttrib[0][$attr] = $params['default'];
                                         }
                                         if ($params['always'] || isset($tagAttrib[0][$attr])) {
@@ -497,7 +498,7 @@ class HtmlParser
                                                     $tagAttrib[0][$attr] = MathUtility::forceIntegerInRange($tagAttrib[0][$attr], (int)$params['range'][0]);
                                                 }
                                             }
-                                            if (is_array($params['list'])) {
+                                            if (isset($params['list']) && is_array($params['list'])) {
                                                 // For the class attribute, remove from the attribute value any class not in the list
                                                 // Classes are case sensitive
                                                 if ($attr === 'class') {
@@ -561,7 +562,7 @@ class HtmlParser
                                 $tagParts[1] = '';
                             }
                             // Protecting the tag by converting < and > to &lt; and &gt; ??
-                            if ($tags[$tagName]['protect']) {
+                            if (!empty($tags[$tagName]['protect'])) {
                                 $lt = '&lt;';
                                 $gt = '&gt;';
                             } else {
@@ -569,26 +570,26 @@ class HtmlParser
                                 $gt = '>';
                             }
                             // Remapping tag name?
-                            if ($tags[$tagName]['remap']) {
+                            if (!empty($tags[$tagName]['remap'])) {
                                 $tagParts[0] = $tags[$tagName]['remap'];
                             }
                             // rmTagIfNoAttrib
-                            if ($endTag || trim($tagParts[1]) || !$tags[$tagName]['rmTagIfNoAttrib']) {
-                                $setTag = 1;
+                            if ($endTag || empty($tags[$tagName]['rmTagIfNoAttrib']) || trim($tagParts[1] ?? '')) {
+                                $setTag = true;
                                 // Remove this closing tag if $tagName was among $TSconfig['removeTags']
-                                if ($endTag && $tags[$tagName]['allowedAttribs'] === 0 && $tags[$tagName]['rmTagIfNoAttrib'] === 1) {
-                                    $setTag = 0;
+                                if ($endTag && isset($tags[$tagName]['allowedAttribs']) && $tags[$tagName]['allowedAttribs'] === 0 && $tags[$tagName]['rmTagIfNoAttrib'] === 1) {
+                                    $setTag = false;
                                 }
-                                if ($tags[$tagName]['nesting']) {
-                                    if (!is_array($tagRegister[$tagName])) {
+                                if (isset($tags[$tagName]['nesting'])) {
+                                    if (!isset($tagRegister[$tagName])) {
                                         $tagRegister[$tagName] = [];
                                     }
                                     if ($endTag) {
-                                        $correctTag = 1;
+                                        $correctTag = true;
                                         if ($tags[$tagName]['nesting'] === 'global') {
                                             $lastEl = end($tagStack);
                                             if ($tagName !== $lastEl) {
-                                                if (in_array($tagName, $tagStack)) {
+                                                if (in_array($tagName, $tagStack, true)) {
                                                     while (!empty($tagStack) && $tagName !== $lastEl) {
                                                         $elPos = end($tagRegister[$lastEl]);
                                                         unset($newContent[$elPos]);
@@ -598,12 +599,12 @@ class HtmlParser
                                                     }
                                                 } else {
                                                     // In this case the
-                                                    $correctTag = 0;
+                                                    $correctTag = false;
                                                 }
                                             }
                                         }
                                         if (empty($tagRegister[$tagName]) || !$correctTag) {
-                                            $setTag = 0;
+                                            $setTag = false;
                                         } else {
                                             array_pop($tagRegister[$tagName]);
                                             if ($tags[$tagName]['nesting'] === 'global') {
@@ -619,7 +620,7 @@ class HtmlParser
                                 }
                                 if ($setTag) {
                                     // Setting the tag
-                                    $newContent[$c++] = $lt . ($endTag ? '/' : '') . trim($tagParts[0] . ' ' . $tagParts[1]) . ($emptyTag ? ' /' : '') . $gt;
+                                    $newContent[$c++] = $lt . ($endTag ? '/' : '') . trim($tagParts[0] . ' ' . ($tagParts[1] ?? '')) . ($emptyTag ? ' /' : '') . $gt;
                                 }
                             }
                         } else {
@@ -881,7 +882,7 @@ class HtmlParser
                     if (!is_array($keepTags[$key])) {
                         $keepTags[$key] = [];
                     }
-                    if (is_array($tagC['fixAttrib.'])) {
+                    if (isset($tagC['fixAttrib.']) && is_array($tagC['fixAttrib.'])) {
                         foreach ($tagC['fixAttrib.'] as $atName => $atConfig) {
                             if (is_array($atConfig)) {
                                 $atName = substr($atName, 0, -1);
@@ -898,9 +899,8 @@ class HtmlParser
                             }
                         }
                     }
-                    unset($tagC['fixAttrib.']);
-                    unset($tagC['fixAttrib']);
-                    if (isset($tagC['rmTagIfNoAttrib']) && $tagC['rmTagIfNoAttrib'] && empty($tagC['nesting'])) {
+                    unset($tagC['fixAttrib.'], $tagC['fixAttrib']);
+                    if (!empty($tagC['rmTagIfNoAttrib']) && empty($tagC['nesting'])) {
                         $tagC['nesting'] = 1;
                     }
                     $keepTags[$key] = array_merge($keepTags[$key], $tagC);
index 8913a11..3465a76 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Core\Tests\Unit\Html;
 
 /*
@@ -15,23 +17,19 @@ namespace TYPO3\CMS\Core\Tests\Unit\Html;
  */
 
 use TYPO3\CMS\Core\Html\HtmlParser;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Testcase for \TYPO3\CMS\Core\Html\HtmlParser
  */
-class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class HtmlParserTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @var \TYPO3\CMS\Core\Html\HtmlParser
      */
     protected $subject = null;
 
-    protected function setUp()
+    protected function setUp(): void
     {
         $this->subject = new HtmlParser();
     }
@@ -39,7 +37,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @return array
      */
-    public function cDataWillRemainUnmodifiedDataProvider()
+    public function cDataWillRemainUnmodifiedDataProvider(): array
     {
         return [
             'single-line CDATA' => [
@@ -66,56 +64,66 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      *
      * @return array
      */
-    public function splitIntoBlockDataProvider()
+    public function splitIntoBlockDataProvider(): array
     {
         return [
             'splitBlock' => [
                 'h1,span',
                 '<body><h1>Title</h1><span>Note</span></body>',
                 false,
-                ['<body>',
+                [
+                    '<body>',
                     '<h1>Title</h1>',
                     '',
                     '<span>Note</span>',
-                    '</body>']
+                    '</body>'
+                ]
             ],
             'splitBlock br' => [
                 'h1,span',
                 '<body><h1>Title</h1><br /><span>Note</span><br /></body>',
                 false,
-                ['<body>',
+                [
+                    '<body>',
                     '<h1>Title</h1>',
                     '<br />',
                     '<span>Note</span>',
-                    '<br /></body>']
+                    '<br /></body>'
+                ]
             ],
             'splitBlock with attribute' => [
                 'h1,span',
                 '<body><h1 class="title">Title</h1><span>Note</span></body>',
                 false,
-                ['<body>',
+                [
+                    '<body>',
                     '<h1 class="title">Title</h1>',
                     '',
                     '<span>Note</span>',
-                    '</body>']
+                    '</body>'
+                ]
             ],
             'splitBlock span with attribute' => [
                 'span',
                 '<body><h1>Title</h1><span class="title">Note</span></body>',
                 false,
-                ['<body><h1>Title</h1>',
+                [
+                    '<body><h1>Title</h1>',
                     '<span class="title">Note</span>',
-                    '</body>']
+                    '</body>'
+                ]
             ],
             'splitBlock without extra end tags' => [
                 'h1,span,div',
                 '<body><h1>Title</h1><span>Note</span></body></div>',
                 true,
-                ['<body>',
+                [
+                    '<body>',
                     '<h1>Title</h1>',
                     '',
                     '<span>Note</span>',
-                    '</body>']
+                    '</body>'
+                ]
             ],
         ];
     }
@@ -128,7 +136,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param array $expected The expected result
      * @dataProvider splitIntoBlockDataProvider
      */
-    public function splitIntoBlock($tag, $content, $eliminateExtraEndTags, $expected)
+    public function splitIntoBlock(string $tag, string $content, bool $eliminateExtraEndTags, array $expected): void
     {
         $this->assertSame($expected, $this->subject->splitIntoBlock($tag, $content, $eliminateExtraEndTags));
     }
@@ -139,7 +147,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $expected
      * @dataProvider cDataWillRemainUnmodifiedDataProvider
      */
-    public function xHtmlCleaningDoesNotModifyCDATA($source, $expected)
+    public function xHtmlCleaningDoesNotModifyCDATA(string $source, string $expected): void
     {
         $result = $this->subject->HTMLcleaner($source, [], 1);
         $this->assertSame($expected, $result);
@@ -148,7 +156,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * Data provider for spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured
      */
-    public static function spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider()
+    public static function spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider(): array
     {
         return [
             'Span tag with no attrib' => [
@@ -172,7 +180,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $expectedResult
      * @dataProvider spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider
      */
-    public function tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured($content, $expectedResult)
+    public function tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured(string $content, string $expectedResult): void
     {
         $tsConfig = [
             'allowTags' => 'span',
@@ -189,7 +197,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType()
+    public function rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType(): void
     {
         $tsConfig = [
             'allowTags' => 'div,span',
@@ -206,7 +214,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      *
      * @return array
      */
-    public static function localNestingCorrectlyRemovesInvalidTagsDataProvider()
+    public static function localNestingCorrectlyRemovesInvalidTagsDataProvider(): array
     {
         return [
             'Valid nesting is untouched' => [
@@ -238,7 +246,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $content
      * @param string $expectedResult
      */
-    public function localNestingCorrectlyRemovesInvalidTags($content, $expectedResult)
+    public function localNestingCorrectlyRemovesInvalidTags(string $content, string $expectedResult): void
     {
         $tsConfig = [
             'allowTags' => 'div,span,b,i',
@@ -252,7 +260,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      *
      * @return array
      */
-    public static function globalNestingCorrectlyRemovesInvalidTagsDataProvider()
+    public static function globalNestingCorrectlyRemovesInvalidTagsDataProvider(): array
     {
         return [
             'Valid nesting is untouched' => [
@@ -284,7 +292,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $content
      * @param string $expectedResult
      */
-    public function globalNestingCorrectlyRemovesInvalidTags($content, $expectedResult)
+    public function globalNestingCorrectlyRemovesInvalidTags(string $content, string $expectedResult): void
     {
         $tsConfig = [
             'allowTags' => 'span,div,b,i',
@@ -296,7 +304,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @return array
      */
-    public function emptyTagsDataProvider()
+    public function emptyTagsDataProvider(): array
     {
         return [
             [0, null, false, '<h1></h1>', '<h1></h1>'],
@@ -338,13 +346,18 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @test
      * @dataProvider emptyTagsDataProvider
      * @param bool $stripOn TRUE if stripping should be activated.
-     * @param string $tagList Comma separated list of tags that should be stripped.
+     * @param string|bool $tagList Comma separated list of tags that should be stripped.
      * @param bool $treatNonBreakingSpaceAsEmpty If TRUE &nbsp; will be considered empty.
      * @param string $content The HTML code that should be modified.
      * @param string $expectedResult The expected HTML code result.
      */
-    public function stripEmptyTags($stripOn, $tagList, $treatNonBreakingSpaceAsEmpty, $content, $expectedResult)
-    {
+    public function stripEmptyTags(
+        bool $stripOn,
+        $tagList,
+        bool $treatNonBreakingSpaceAsEmpty,
+        string $content,
+        string $expectedResult
+    ): void {
         $tsConfig = [
             'keepNonMatchedTags' => 1,
             'stripEmptyTags' => $stripOn,
@@ -361,7 +374,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @return array
      */
-    public function stripEmptyTagsKeepsConfiguredTagsDataProvider()
+    public function stripEmptyTagsKeepsConfiguredTagsDataProvider(): array
     {
         return [
             [
@@ -387,8 +400,12 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $content The HTML content that should be parsed.
      * @param string $expectedResult The expected HTML code result.
      */
-    public function stripEmptyTagsKeepsConfiguredTags($tagList, $treatNonBreakingSpaceAsEmpty, $content, $expectedResult)
-    {
+    public function stripEmptyTagsKeepsConfiguredTags(
+        string $tagList,
+        bool $treatNonBreakingSpaceAsEmpty,
+        string $content,
+        string $expectedResult
+    ): void {
         $tsConfig = [
             'keepNonMatchedTags' => 1,
             'stripEmptyTags' => 1,
@@ -409,7 +426,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $content The content that should be parsed by the HTMLcleaner.
      * @return string The parsed content.
      */
-    protected function parseConfigAndCleanHtml(array $tsConfig, $content)
+    protected function parseConfigAndCleanHtml(array $tsConfig, string $content): string
     {
         $config = $this->subject->HTMLparserConfig($tsConfig);
         return $this->subject->HTMLcleaner($content, $config[0], $config[1], $config[2], $config[3]);
@@ -420,7 +437,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      *
      * @return array
      */
-    public function getFirstTagDataProvider()
+    public function getFirstTagDataProvider(): array
     {
         return [
             ['<body><span></span></body>', '<body>'],
@@ -440,7 +457,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $str HTML string with tags
      * @param string $expected The expected result.
      */
-    public function getFirstTag($str, $expected)
+    public function getFirstTag(string $str, string $expected): void
     {
         $this->assertEquals($expected, $this->subject->getFirstTag($str));
     }
@@ -450,27 +467,39 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      *
      * @return array
      */
-    public function getFirstTagNameDataProvider()
+    public function getFirstTagNameDataProvider(): array
     {
         return [
-            ['<body><span></span></body>',
+            [
+                '<body><span></span></body>',
                 false,
-                'BODY'],
-            ['<body><span></span></body>',
+                'BODY'
+            ],
+            [
+                '<body><span></span></body>',
                 true,
-                'body'],
-            ['<div class="test"><span></span></div>',
+                'body'
+            ],
+            [
+                '<div class="test"><span></span></div>',
                 false,
-                'DIV'],
-            ['<div><span class="test"></span></div>',
+                'DIV'
+            ],
+            [
+                '<div><span class="test"></span></div>',
                 false,
-                'DIV'],
-            ['<br /><span class="test"></span>',
+                'DIV'
+            ],
+            [
+                '<br /><span class="test"></span>',
                 false,
-                'BR'],
-            ['<img src="test.jpg" />',
+                'BR'
+            ],
+            [
+                '<img src="test.jpg" />',
                 false,
-                'IMG'],
+                'IMG'
+            ],
         ];
     }
 
@@ -484,7 +513,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param bool $preserveCase If set, then the tag is NOT converted to uppercase by case is preserved.
      * @param string $expected The expected result.
      */
-    public function getFirstTagName($str, $preserveCase, $expected)
+    public function getFirstTagName(string $str, bool $preserveCase, string $expected): void
     {
         $this->assertEquals($expected, $this->subject->getFirstTagName($str, $preserveCase));
     }
@@ -492,15 +521,24 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @return array
      */
-    public function removeFirstAndLastTagDataProvider()
+    public function removeFirstAndLastTagDataProvider(): array
     {
         return [
             ['<span>Wrapper<div>Some content</div></span>', 'Wrapper<div>Some content</div>'],
             ['<td><tr>Some content</tr></td>', '<tr>Some content</tr>'],
-            ['Something before<span>Wrapper<div>Some content</div></span>Something after', 'Wrapper<div>Some content</div>'],
+            [
+                'Something before<span>Wrapper<div>Some content</div></span>Something after',
+                'Wrapper<div>Some content</div>'
+            ],
             ['<span class="hidden">Wrapper<div>Some content</div></span>', 'Wrapper<div>Some content</div>'],
-            ['<span>Wrapper<div class="hidden">Some content</div></span>', 'Wrapper<div class="hidden">Some content</div>'],
-            ['Some stuff before <span>Wrapper<div class="hidden">Some content</div></span> and after', 'Wrapper<div class="hidden">Some content</div>'],
+            [
+                '<span>Wrapper<div class="hidden">Some content</div></span>',
+                'Wrapper<div class="hidden">Some content</div>'
+            ],
+            [
+                'Some stuff before <span>Wrapper<div class="hidden">Some content</div></span> and after',
+                'Wrapper<div class="hidden">Some content</div>'
+            ],
         ];
     }
 
@@ -513,7 +551,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $str String to process
      * @param string $expectedResult
      */
-    public function removeFirstAndLastTag($str, $expectedResult)
+    public function removeFirstAndLastTag(string $str, string $expectedResult): void
     {
         $this->assertEquals($expectedResult, $this->subject->removeFirstAndLastTag($str));
     }
@@ -521,21 +559,28 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @return array
      */
-    public function getTagAttributesDataProvider()
+    public function getTagAttributesDataProvider(): array
     {
         return [
             [
                 '<a href="" data-shortCut="DXB" required>',
                 [
                     ['href' => '', 'data-shortcut' => 'DXB', 'required' => ''],
-                    ['href' => ['origTag' => 'href', 'dashType' => '"'], 'data-shortcut' => ['origTag' => 'data-shortCut', 'dashType' => '"'], 'required' => ['origTag' => 'required']]
+                    [
+                        'href' => ['origTag' => 'href', 'dashType' => '"'],
+                        'data-shortcut' => ['origTag' => 'data-shortCut', 'dashType' => '"'],
+                        'required' => ['origTag' => 'required']
+                    ]
                 ]
             ],
             [
                 '<ul STYLE=\'background-image: (url: "fra.png")\' data-shortcut=FRA>',
                 [
                     ['style' => 'background-image: (url: "fra.png")', 'data-shortcut' => 'FRA'],
-                    ['style' => ['origTag' => 'STYLE', 'dashType' => '\''], 'data-shortcut' => ['origTag' => 'data-shortcut', 'dashType' => '']]
+                    [
+                        'style' => ['origTag' => 'STYLE', 'dashType' => '\''],
+                        'data-shortcut' => ['origTag' => 'data-shortcut', 'dashType' => '']
+                    ]
                 ]
             ]
 
@@ -551,7 +596,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param string $tag String to process
      * @param array $expectedResult
      */
-    public function getTagAttributes($tag, $expectedResult)
+    public function getTagAttributes(string $tag, array $expectedResult): void
     {
         $this->assertEquals($expectedResult, $this->subject->get_tag_attributes($tag));
     }
@@ -559,7 +604,7 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @return array
      */
-    public function stripEmptyTagsDataProvider()
+    public function stripEmptyTagsDataProvider(): array
     {
         return [
             // Testing wrongly encapsulated and upper/lowercase tags
@@ -605,8 +650,15 @@ class HtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      * @param bool $treatNonBreakingSpaceAsEmpty If TRUE tags containing only &nbsp; entities will be treated as empty.
      * @param string $expectedResult
      */
-    public function rawStripEmptyTagsTest($content, $tagList, $treatNonBreakingSpaceAsEmpty, $expectedResult)
-    {
-        $this->assertEquals($expectedResult, $this->subject->stripEmptyTags($content, $tagList, $treatNonBreakingSpaceAsEmpty));
+    public function rawStripEmptyTagsTest(
+        string $content,
+        string $tagList,
+        bool $treatNonBreakingSpaceAsEmpty,
+        string $expectedResult
+    ): void {
+        $this->assertEquals(
+            $expectedResult,
+            $this->subject->stripEmptyTags($content, $tagList, $treatNonBreakingSpaceAsEmpty)
+        );
     }
 }