From ba865a67f30574ff901bc7cb66ae068a0dd8bcde Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 29 Aug 2016 21:52:14 +0200 Subject: [PATCH] Removing file_exists --- Autoloader.php | 13 ++++++------- Views/ViewAbstract.php | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Autoloader.php b/Autoloader.php index 1adc9a825..f92859284 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -39,19 +39,18 @@ class Autoloader * * @return void * - * @throws \Exception Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation. + * @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation. * * @since 1.0.0 * @author Dennis Eichhorn */ public static function default_autoloader(string $class) { - if (($classNew = self::exists($class)) !== false) { - /** @noinspection PhpIncludeInspection */ - include __DIR__ . '/../' . $classNew . '.php'; - } else { - throw new AutoloaderException($class); - } + $class = ltrim($class, '\\'); + $class = str_replace(['_', '\\'], DIRECTORY_SEPARATOR, $class); + + /** @noinspection PhpIncludeInspection */ + include_once __DIR__ . '/../' . $class . '.php'; } /** diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 585efe1c7..35b0af89f 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -205,7 +205,7 @@ abstract class ViewAbstract implements \Serializable */ public function serialize() { - if (!file_exists(__DIR__ . '/../..' . $this->template . '.tpl.php')) { + if (empty($this->template)) { return $this->toArray(); }