diff --git a/extension/Classes/Core/Helper/Path.php b/extension/Classes/Core/Helper/Path.php index 39ef5693b025f797f8ca564c75f32329cdacd5d8..78d426ad261fd211c4f741d427bf1b3b3d2d1972 100644 --- a/extension/Classes/Core/Helper/Path.php +++ b/extension/Classes/Core/Helper/Path.php @@ -93,30 +93,33 @@ class Path } /** + * @param array $pathPartsToAppend * @return string * @throws \UserFormException */ - public static function absoluteApp(/* path parts to append */): string + public static function absoluteApp(...$pathPartsToAppend): string { - return self::realpath(self::cwdToApp(func_get_args())); + return self::realpath(self::cwdToApp(), ...$pathPartsToAppend); } /** + * @param array $pathPartsToAppend * @return string * @throws \UserFormException */ - public static function absoluteExt(/* path parts to append */): string + public static function absoluteExt(...$pathPartsToAppend): string { - return self::realpath(self::cwdToExt(func_get_args())); + return self::realpath(self::cwdToExt(), ...$pathPartsToAppend); } /** + * @param array $pathPartsToAppend * @return string * @throws \UserFormException */ - public static function absoluteLog(/* path parts to append */): string + public static function absoluteLog(...$pathPartsToAppend): string { - return self::realpath(self::cwdToLog(func_get_args())); + return self::realpath(self::cwdToLog(), ...$pathPartsToAppend); } /** @@ -263,7 +266,9 @@ class Path /** * Override the paths of sql.log, qfq.log, mail.log using the values from the config file or Typo3. * + * @throws \CodeException * @throws \UserFormException + * @throws \UserReportException */ public static function overrideLogPathsFromConfig() { @@ -474,18 +479,20 @@ EOF; } /** - * PHP System function: realpath() with QFQ exception + * PHP System function: realpath() with QFQ exception. + * The first argument must be a path from CWD to something that exists. Otherwise an exception is thrown! * - * @param string $path + * @param string $cwdToSomethingThatExists This file/dir MUST exist! Otherwise exception! + * @param array $pathPartsToAppend The appended path doesnt have to exist. * @return string * @throws \UserFormException */ - private static function realpath(string $path): string + private static function realpath(string $cwdToSomethingThatExists, ...$pathPartsToAppend): string { - $result = realpath($path); - if ($result === false) { - Thrower::userFormException('Path not found.', "Either file/dir not exists or access not permitted: $path."); + $absolutePath = realpath($cwdToSomethingThatExists); + if ($absolutePath === false) { + Thrower::userFormException('Path not found.', "Either file/dir not exists or access not permitted: $cwdToSomethingThatExists."); } - return $result; + return self::join($absolutePath, ...$pathPartsToAppend); } } \ No newline at end of file