diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index 1e5f5a829..c28f6a88e 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -178,7 +178,7 @@ class Dispatcher private function getController(string $controller) { if (!isset($this->controllers[$controller])) { - if (realpath($path = ROOT_PATH . '/' . str_replace('\\', '/', $controller) . '.php') === false) { + if (!file_exists($path = ROOT_PATH . '/' . str_replace('\\', '/', $controller) . '.php')) { throw new PathException($path); } diff --git a/Log/FileLogger.php b/Log/FileLogger.php index ce79d414d..592d1b369 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -103,13 +103,9 @@ class FileLogger implements LoggerInterface } if (is_dir($lpath) || strpos($lpath, '.') === false) { - File::create($path = $lpath . '/' . date('Y-m-d') . '.log'); - - $path = realpath($path); + File::create($path = $path . '/' . date('Y-m-d') . '.log'); } else { File::create($lpath); - - $path = realpath($lpath); } $this->path = $path; diff --git a/Math/Finance/FinanceFormulas.php b/Math/Finance/FinanceFormulas.php index c69677a5c..f00ec8c21 100644 --- a/Math/Finance/FinanceFormulas.php +++ b/Math/Finance/FinanceFormulas.php @@ -52,6 +52,8 @@ class FinanceFormulas /** * Annual Percentage Yield * + * @latex r = \left(APY + 1\right)^{\frac{1}{n}} \cdot n - 1 + * * @param float $apy Annual percentage yield * @param int $n Number of times compounded * @@ -62,7 +64,7 @@ class FinanceFormulas */ public static function getStateAnnualInterestRateOfAPY(float $apy, int $n) : float { - return (pow($apy + 1, 1 / $n) - 1) * $n; + return pow($apy + 1, 1 / $n) * $n - 1; } /** diff --git a/Module/InfoManager.php b/Module/InfoManager.php index e4370aeac..66b3dc112 100644 --- a/Module/InfoManager.php +++ b/Module/InfoManager.php @@ -73,11 +73,11 @@ class InfoManager */ public function load() { - if (($path = realpath($this->path)) === false) { + if (!file_exists($this->path)) { throw new PathException($this->path); } - $this->info = json_decode(file_get_contents($path), true); + $this->info = json_decode(file_get_contents($this->path), true); } /** diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 08edeb1a9..2c1193e49 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -124,9 +124,9 @@ abstract class ModuleAbstract public static function getLocalization(string $language, string $destination) : array { $lang = []; - if (($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) !== false) { + if (file_exists($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) { /** @noinspection PhpIncludeInspection */ - $lang = include $path; + $lang = include $oldPath; } return $lang; diff --git a/Router/Router.php b/Router/Router.php index 8e561df51..14a042552 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -61,7 +61,7 @@ class Router */ public function importFromFile(string $path) : bool { - if (file_exists($path)) { + if (stream_resolve_include_path($path) !== false) { /** @noinspection PhpIncludeInspection */ $this->routes += include $path; diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index dd032574f..7cdad8627 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -194,9 +194,8 @@ class Directory extends FileAbstract implements DirectoryInterface */ public static function delete(string $path) : bool { - $path = realpath($oldPath = $path); - if ($path === false || !is_dir($path) || StringUtils::startsWith($path, ROOT_PATH)) { - throw new PathException($oldPath); + if (!file_exists($path) || !is_dir($path)) { + throw new PathException($path); } $files = scandir($path); diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 796cc6353..585efe1c7 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -205,9 +205,7 @@ abstract class ViewAbstract implements \Serializable */ public function serialize() { - $path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php'); - - if ($path === false) { + if (!file_exists(__DIR__ . '/../..' . $this->template . '.tpl.php')) { return $this->toArray(); } @@ -247,10 +245,10 @@ abstract class ViewAbstract implements \Serializable */ public function render() : string { - $path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php'); + $path = __DIR__ . '/../..' . $this->template . '.tpl.php'; - if ($path === false) { - throw new PathException($oldPath); + if (!file_exists($path)) { + throw new PathException($path); } ob_start();