From 2738a6d20ebde5da0d8eb96c6c2b2cc30750245a Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 29 Aug 2021 00:33:20 +0200 Subject: Check for "is_file" in the SPL class autoloader --- core/application.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'core/application.php') diff --git a/core/application.php b/core/application.php index 8d0b8a3..cb2e5b2 100644 --- a/core/application.php +++ b/core/application.php @@ -21,11 +21,15 @@ if(!version_compare(PHP_VERSION, '7.3', '>=')) { define('ROOT', dirname(__DIR__).'/'); #=============================================================================== -# Autoload register for classes +# Register autoloader for classes #=============================================================================== -spl_autoload_register(function($classname) { - $classname = str_replace('\\', '/', $classname); - require "namespace/{$classname}.php"; +spl_autoload_register(function($className) { + $classPath = str_replace('\\', '/', $className); + $classPath = ROOT."core/namespace/{$classPath}.php"; + + if(is_file($classPath)) { + require $classPath; + } }); #=============================================================================== -- cgit v1.2.3