[TASK] Simplify returns in ConfigurationManager 15/25715/4
authorMichiel Roos <michiel@maxserv.nl>
Wed, 27 Nov 2013 19:39:20 +0000 (20:39 +0100)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Fri, 29 Nov 2013 17:20:11 +0000 (18:20 +0100)
writeLocalConfiguration() and writeAdditionalConfiguration()
have return statements like:
return $result === FALSE ? FALSE : TRUE;

This can be reduced to:
return $result;

Moreover the return value of canWriteConfiguration()
can be optimized as well.

Change-Id: I8e571459179e4bfeca3bba0a4969fb76d18058e2
Resolves: #54019
Releases: 6.2
Reviewed-on: https://review.typo3.org/25715
Reviewed-by: Markus Klein
Reviewed-by: Michiel Roos
Tested-by: Michiel Roos
Tested-by: Markus Klein
Reviewed-by: Oliver Klee
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
typo3/sysext/core/Classes/Configuration/ConfigurationManager.php

index 6682b81..7a66b75 100644 (file)
@@ -265,17 +265,8 @@ class ConfigurationManager {
         * @access private
         */
        public function canWriteConfiguration() {
-               $result = TRUE;
-               if (!@is_writable($this->pathTypo3Conf)) {
-                       $result = FALSE;
-               }
-               if (
-                       file_exists($this->getLocalConfigurationFileLocation())
-                       && !@is_writable($this->getLocalConfigurationFileLocation())
-               ) {
-                       $result = FALSE;
-               }
-               return $result;
+               $fileLocation = $this->getLocalConfigurationFileLocation();
+               return @is_writable($this->pathTypo3Conf) && (!file_exists($fileLocation) || @is_writable($fileLocation));
        }
 
        /**
@@ -318,7 +309,7 @@ class ConfigurationManager {
                        );
                }
                $configuration = Utility\ArrayUtility::sortByKeyRecursive($configuration);
-               $result = Utility\GeneralUtility::writeFile(
+               return Utility\GeneralUtility::writeFile(
                        $localConfigurationFile,
                        '<?php' . LF .
                                'return ' .
@@ -329,7 +320,6 @@ class ConfigurationManager {
                        '?>',
                        TRUE
                );
-               return $result === FALSE ? FALSE : TRUE;
        }
 
        /**
@@ -341,13 +331,12 @@ class ConfigurationManager {
         * @access private
         */
        public function writeAdditionalConfiguration(array $additionalConfigurationLines) {
-               $result = Utility\GeneralUtility::writeFile(
+               return Utility\GeneralUtility::writeFile(
                        PATH_site . $this->additionalConfigurationFile,
                        '<?php' . LF .
                                implode(LF, $additionalConfigurationLines) . LF .
                        '?>'
                );
-               return $result === FALSE ? FALSE : TRUE;
        }
 
        /**