[TASK] Avoid possibly undefined variables 83/63483/7
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Fri, 28 Feb 2020 16:20:17 +0000 (17:20 +0100)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 6 Mar 2020 12:26:56 +0000 (13:26 +0100)
phpstan identified a bunch of possibly undefined
variables which is fixed with this patch.

Releases: master
Resolves: #90581
Change-Id: If41bee3dcd972d26f8eff18dbcbc61ad1fe79e7f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63483
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Guido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaFlexPrepare.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/indexed_search/Classes/Hook/CrawlerHook.php
typo3/sysext/indexed_search/Classes/Indexer.php

index 60b3f7c..5cff610 100644 (file)
@@ -703,8 +703,8 @@ class PageLayoutController
         }
 
         $this->pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
+        $h_func_b = '';
         if ($this->getBackendUser()->check('tables_select', 'tt_content')) {
-            $h_func_b = '';
             // Toggle hidden ContentElements
 
             if ($numberOfHiddenElements > 0) {
index fa0a5d4..42c46ef 100644 (file)
@@ -83,6 +83,7 @@ class TcaFlexPrepare implements FormDataProviderInterface
                 );
                 $dataStructureArray = $flexFormTools->parseDataStructureByIdentifier($dataStructureIdentifier);
             } catch (InvalidParentRowException|InvalidParentRowLoopException|InvalidParentRowRootException|InvalidPointerFieldValueException|InvalidIdentifierException $e) {
+                $dataStructureIdentifier = null;
             } finally {
                 // Add the identifier to TCA to use it later during rendering
                 $result['processedTca']['columns'][$fieldName]['config']['dataStructureIdentifier'] = $dataStructureIdentifier;
index bc87af8..5e8c13a 100644 (file)
@@ -521,6 +521,8 @@ class PageLayoutView implements LoggerAwareInterface
                 // Add colgroups
                 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
                 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
+                $colSpan = 0;
+                $rowSpan = 0;
                 $grid .= '<colgroup>';
                 for ($i = 0; $i < $colCount; $i++) {
                     $grid .= '<col />';
index 9cb8a2b..0c63d25 100644 (file)
@@ -375,6 +375,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication
         if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'] || $this->isAdmin()) {
             return 1;
         }
+        $checkRec = [];
         $fetchPageFromDatabase = true;
         if (is_array($idOrRow)) {
             if (empty($idOrRow['uid'])) {
index ca79781..47bcd1b 100644 (file)
@@ -5655,6 +5655,7 @@ class DataHandler implements LoggerAwareInterface
             $remapFlexForms = [];
             $hookPayload = [];
 
+            $newValue = null;
             foreach ($this->remapStack as $remapAction) {
                 // If no position index for the arguments was set, skip this remap action:
                 if (!is_array($remapAction['pos'])) {
index 3c377b1..7faf6cd 100644 (file)
@@ -668,6 +668,7 @@ class CrawlerHook
         $indexerObj->backend_setFreeIndexUid($cfgRec['uid'], $cfgRec['set_id']);
         $indexerObj->forceIndexing = true;
         $theContent = '';
+        $theTitle = '';
         foreach ($fieldList as $k => $v) {
             if (!$k) {
                 $theTitle = $r[$v];
index c5bd055..74c4286 100644 (file)
@@ -706,6 +706,7 @@ class Indexer
         $expBody = preg_split('/\\<\\!\\-\\-[\\s]?TYPO3SEARCH_/', $body);
         if (count($expBody) > 1) {
             $body = '';
+            $prev = '';
             foreach ($expBody as $val) {
                 $part = explode('-->', $val, 2);
                 if (trim($part[0]) === 'begin') {