[TASK] Streamline PHP assignments and comments 15/55915/2
authorBenni Mack <benni@typo3.org>
Tue, 27 Feb 2018 06:53:59 +0000 (07:53 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 27 Feb 2018 08:24:03 +0000 (09:24 +0100)
Use shortening parameters on places that haven't been touched in a while
since PHP 7.0 was a requirement.

Fix PHPdoc comments on various places.

Use booleans instead of integers on variables clearly defined and evaluated
as booleans.

Resolves: #84057
Releases: master
Change-Id: If0ef1a58622a98f4ae5769f953c4c62121abdc89
Reviewed-on: https://review.typo3.org/55915
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/Controller/BackendController.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/FormProtection/FormProtectionFactory.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Page/PageGenerator.php
typo3/sysext/workspaces/Classes/Controller/PreviewController.php

index cde55f5..d5788f2 100644 (file)
@@ -400,7 +400,7 @@ class BackendController
             'username' => htmlspecialchars($beUser->user['username']),
             'pageModule' => $pageModule,
             'inWorkspace' => $beUser->workspace !== 0,
-            'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup'] : false
+            'showRefreshLoginPopup' => (bool)($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup'] ?? false)
         ];
         $this->js .= '
        TYPO3.configuration = ' . json_encode($t3Configuration) . ';
index 4b6edc1..bed1d84 100644 (file)
@@ -603,9 +603,7 @@ class BackendUtility
             $id = (int)$id;
             if (!$id) {
                 if (static::getBackendUserAuthentication()->isAdmin()) {
-                    $path = '/';
-                    $pageinfo['_thePath'] = $path;
-                    return $pageinfo;
+                    return ['_thePath' => '/'];
                 }
             } else {
                 $pageinfo = self::getRecord('pages', $id, '*', $perms_clause);
index a987dc3..874a0a0 100644 (file)
@@ -40,7 +40,7 @@ use TYPO3\CMS\Core\Utility\MathUtility;
  *
  * This class is used to authenticate a login user.
  * The class is used by both the frontend and backend.
- * In both cases this class is a parent class to BackendUserAuthentication and FrontenUserAuthentication
+ * In both cases this class is a parent class to BackendUserAuthentication and FrontendUserAuthentication
  *
  * See Inside TYPO3 for more information about the API of the class and internal variables.
  */
index 73ef168..8bff844 100644 (file)
@@ -4077,7 +4077,6 @@ class DataHandler implements LoggerAwareInterface
      */
     public function copyRecord_procFilesRefs($conf, $uid, $value)
     {
-        // Prepend absolute paths to files:
         if ($conf['type'] !== 'group' || ($conf['internal_type'] !== 'file' && $conf['internal_type'] !== 'file_reference')) {
             return $value;
         }
@@ -4098,6 +4097,7 @@ class DataHandler implements LoggerAwareInterface
         }
         // Traverse this array of files:
         $uploadFolder = $conf['internal_type'] === 'file' ? $conf['uploadfolder'] : '';
+        // Prepend absolute paths to files
         $dest = PATH_site . $uploadFolder;
         $newValue = [];
         foreach ($theFileValues as $file) {
index 6b0a4fc..0957da1 100644 (file)
@@ -178,7 +178,7 @@ class FormProtectionFactory
      * Creates an instance for the requested class $className
      * and stores it internally.
      *
-     * @param array $className
+     * @param string $className
      * @param array<int, mixed> $constructorArguments
      * @throws \InvalidArgumentException
      * @return AbstractFormProtection
index 635cc84..53b61b0 100644 (file)
@@ -896,7 +896,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
                     // See http://forge.typo3.org/issues/27740
                     $_SERVER['HTTP_COOKIE'] .= ';' . $cookieName . '=' . $fe_sParts[0];
                 }
-                $this->fe_user->forceSetCookie = 1;
+                $this->fe_user->forceSetCookie = true;
                 $this->fe_user->dontSetCookie = false;
                 unset($cookieName);
             }
@@ -1804,10 +1804,10 @@ class TypoScriptFrontendController implements LoggerAwareInterface
         $this->getPageAndRootline();
         // Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's from other domains are not possible.
         if ($domainStartPage && is_array($this->rootLine)) {
-            $idFound = 0;
+            $idFound = false;
             foreach ($this->rootLine as $key => $val) {
                 if ($val['uid'] == $domainStartPage) {
-                    $idFound = 1;
+                    $idFound = true;
                     break;
                 }
             }
index 95b9fb9..2d0b075 100644 (file)
@@ -207,7 +207,7 @@ class PageGenerator
         }
         // Begin header section:
         if ($tsfe->config['config']['htmlTag_setParams'] !== 'none') {
-            $_attr = $tsfe->config['config']['htmlTag_setParams'] ? $tsfe->config['config']['htmlTag_setParams'] : GeneralUtility::implodeAttributes($htmlTagAttributes);
+            $_attr = $tsfe->config['config']['htmlTag_setParams'] ?: GeneralUtility::implodeAttributes($htmlTagAttributes);
         } else {
             $_attr = '';
         }
@@ -788,11 +788,9 @@ class PageGenerator
                 $script = 'typo3temp/assets/css/' . GeneralUtility::shortMD5($str) . '.css';
                 break;
         }
-        // Write file:
-        if ($script) {
-            if (!@is_file(PATH_site . $script)) {
-                GeneralUtility::writeFileToTypo3tempDir(PATH_site . $script, $str);
-            }
+        // Write file
+        if ($script && !@is_file(PATH_site . $script)) {
+            GeneralUtility::writeFileToTypo3tempDir(PATH_site . $script, $str);
         }
         return $script;
     }
index 857f188..3850a7d 100644 (file)
@@ -221,7 +221,7 @@ class PreviewController extends AbstractController
             'username' => htmlspecialchars($backendUser->user['username']),
             'pageModule' => $pageModule,
             'inWorkspace' => $backendUser->workspace !== 0,
-            'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup'] : false
+            'showRefreshLoginPopup' => (bool)($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup'] ?? false)
         ];
 
         return 'TYPO3.configuration = ' . json_encode($t3Configuration) . ';';