*
* @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
*
/**
* 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
* 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)
* 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
* @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;
}
* @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);
* @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);
* @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
$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)) {
} // 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
*
* @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
}
}
- /**
- * 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;
- }
-
}