]> git.mxchange.org Git - core.git/blobdiff - framework/loader/class_ClassLoader.php
Continued:
[core.git] / framework / loader / class_ClassLoader.php
index fab4e559a640c56363f79845b2d64fffaa42ce80..9e0e4bacf06e35c18356a0df568735a3ed29861a 100644 (file)
@@ -17,7 +17,7 @@ use \SplFileInfo;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            1.5.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -62,12 +62,12 @@ class ClassLoader {
        /**
         * Array with all found classes
         */
-       private $foundClasses = array();
+       private $foundClasses = [];
 
        /**
         * List of loaded classes
         */
-       private $loadedClasses = array();
+       private $loadedClasses = [];
 
        /**
         * Suffix with extension for all class files
@@ -83,7 +83,7 @@ class ClassLoader {
         * A list for directory names (no leading/trailing slashes!) which not be scanned by the path scanner
         * @see scanLocalPath
         */
-       private $ignoreList = array();
+       private $ignoreList = [];
 
        /**
         * Debug this class loader? (true = yes, false = no)
@@ -134,7 +134,7 @@ class ClassLoader {
         * Registered paths where test classes can be found. These are all relative
         * to base_path .
         */
-       private static $testPaths = array();
+       private static $testPaths = [];
 
        /**
         * The protected constructor. Please use the factory method below, or use
@@ -351,7 +351,7 @@ class ClassLoader {
         * @param       $strictNamingConvention Whether to strictly check naming-convention
         * @return      void
         */
-       public static function enableStrictNamingConventionCheck ($strictNamingConvention = true) {
+       public static function enableStrictNamingConventionCheck (bool $strictNamingConvention = true) {
                self::$strictNamingConvention = $strictNamingConvention;
        }
 
@@ -362,7 +362,7 @@ class ClassLoader {
         * @param       $relativePath   Relative path to test classes
         * @return      void
         */
-       public static function registerTestsPath ($relativePath) {
+       public static function registerTestsPath (string $relativePath) {
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: relativePath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $relativePath);
 
@@ -379,7 +379,7 @@ class ClassLoader {
         * @param       $className      Name of the class to load
         * @return      void
         */
-       public static function autoLoad ($className) {
+       public static function autoLoad (string $className) {
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
 
@@ -413,7 +413,7 @@ class ClassLoader {
         * @param       $ignoreList             An optional list (array forced) of directory and file names which shall be ignored
         * @return      void
         */
-       public function scanClassPath ($basePath, array $ignoreList = array() ) {
+       public function scanClassPath (string $basePath, array $ignoreList = [] ) {
                // Is a list has been restored from cache, don't read it again
                if ($this->listCached === true) {
                        // Abort here
@@ -455,7 +455,7 @@ class ClassLoader {
                        $currentEntry = $iteratorInstance->current();
 
                        // Get filename from iterator which is the class' name (according naming-convention)
-                       $fileName = $currentEntry->getFileName();
+                       $fileName = $currentEntry->getFilename();
 
                        // Current entry must be a file, not smaller than 100 bytes and not on ignore list
                        if ((!$currentEntry->isFile()) || (in_array($fileName, $this->ignoreList)) || ($currentEntry->getSize() < 100)) {
@@ -484,6 +484,31 @@ class ClassLoader {
                } // END - while
        }
 
+       /**
+        * Getter for total include counter
+        *
+        * @return      $total  Total loaded include files
+        */
+       public final function getTotal () {
+               return $this->total;
+       }
+
+       /**
+        * Getter for a printable list of included main/interfaces/exceptions
+        *
+        * @param       $includeList    A printable include list
+        */
+       public function getPrintableIncludeList () {
+               // Prepare the list
+               $includeList = '';
+               foreach ($this->loadedClasses as $classFile) {
+                       $includeList .= basename($classFile) . '<br />' . PHP_EOL;
+               } // END - foreach
+
+               // And return it
+               return $includeList;
+       }
+
        /**
         * Initializes our loader class
         *
@@ -540,11 +565,9 @@ class ClassLoader {
         * @return      void
         * @throws      InvalidArgumentException        If strict-checking is enabled and class name is not following naming-convention
         */
-       private function loadClassFile ($className) {
-               // Trace message
-               //* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
-
+       private function loadClassFile (string $className) {
                // The class name should contain at least 2 back-slashes, so split at them
+               //* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
                $classNameParts = explode("\\", $className);
 
                // At least 3 parts should be there
@@ -589,29 +612,4 @@ class ClassLoader {
                }
        }
 
-       /**
-        * Getter for total include counter
-        *
-        * @return      $total  Total loaded include files
-        */
-       public final function getTotal () {
-               return $this->total;
-       }
-
-       /**
-        * Getter for a printable list of included main/interfaces/exceptions
-        *
-        * @param       $includeList    A printable include list
-        */
-       public function getPrintableIncludeList () {
-               // Prepare the list
-               $includeList = '';
-               foreach ($this->loadedClasses as $classFile) {
-                       $includeList .= basename($classFile) . '<br />' . PHP_EOL;
-               } // END - foreach
-
-               // And return it
-               return $includeList;
-       }
-
 }