Skip to content

Commit

Permalink
refactor: Removed Version Parameter from Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Oct 21, 2024
1 parent 89d0363 commit 45efa1a
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions webfiori/framework/autoload/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@
*
* The class aims to provide all needed utilities to autoload any classes
* which are within the scope of the framework. In addition, the developer
* can add his own custom folders to the autoloader. More to that, the autoloader
* will load any class which exist in the folder 'vendor' if composer
* is used to collect the dependencies. To activate this feature, the constant
* 'LOAD_COMPOSER_PACKAGES' must be defined and set to true. The class can be used independent of
* any other component to load classes.
* can add his own custom folders to the autoloader.
*
* @author Ibrahim
*
* @version 1.1.7
*/
class ClassLoader {
/**
* The name of the file that represents autoloader's cache.
* @var string
* @since 1.1.6
*/
const CACHE_NAME = 'class-loader.cache';
/**
Expand All @@ -41,7 +35,6 @@ class ClassLoader {
* <li>throw-exception</li>,
* <li>do-nothing</li>
* </ul>
* @since 1.1.6
*/
const ON_FAIL_ACTIONS = [
'throw-exception',
Expand All @@ -54,23 +47,20 @@ class ClassLoader {
*
* @var array
*
* @since 1.1.6
*/
private $cacheArr;
/**
* An array that contains the names of all loaded class.
*
* @var array
*
* @since 1.1.4
*/
private $loadedClasses;
/**
* A single instance of the class 'ClassLoader'.
*
* @var ClassLoader
*
* @since 1.0
*/
private static $loader;
/**
Expand All @@ -79,23 +69,20 @@ class ClassLoader {
*
* @var string|callable
*
* @since 1.1.3
*/
private $onFail;
/**
* The relative root directory that is used to search on.
*
* @var string
*
* @since 1.0
*/
private $rootDir;
/**
* An array of folders to search on.
*
* @var array
*
* @since 1.0
*/
private $searchFolders;

Expand All @@ -107,7 +94,6 @@ class ClassLoader {
* @param string $onFail
* @throws ClassLoaderException
* @throws Exception
* @since 1.0
*/
private function __construct(string $root = '', array $searchFolders = [], bool $defineRoot = false, string $onFail = self::ON_FAIL_ACTIONS[0]) {
$this->searchFolders = [];
Expand Down Expand Up @@ -252,13 +238,13 @@ public static function get(array $options = [
*
* This method can be used in case the class that the user tries to load does
* not comply with PSR-4 standard for placing classes in correct folder
* with correct namespace.
* with correct namespace. Once loaded, it will be added to the cache.
*
* @param string $className The name of the class that will be loaded.
*
* @param string $classWithNs The full name of the class including its namespace.
*
* @param string $path The path to PHP file that has class implementation.
* @param string $filePath The path to PHP file that has class implementation.
*
* @return bool If file is exist and class is loaded, true is returned. False
* otherwise.
Expand Down Expand Up @@ -326,7 +312,6 @@ public function addClassMap(string $className, string $classWithNs, string $path
*
* @return array An array that contains all cached classes information.
* @throws Exception
* @since 1.1.7
*/
public static function getCacheArray(): array {
return self::get()->cacheArr;
Expand Down Expand Up @@ -364,7 +349,6 @@ public static function getCachePath() : string {
* @throws Exception
* loaded.
*
* @since 1.0
*/
public static function getClassPath(string $className, string $namespace = null, bool $load = false): array {
$retVal = [];
Expand Down Expand Up @@ -397,7 +381,6 @@ public static function getClassPath(string $className, string $namespace = null,
* @return array An array of all added search folders.
*
* @throws Exception
* @since 1.1.1
*/
public static function getFolders(): array {
$folders = [];
Expand Down Expand Up @@ -427,7 +410,6 @@ public static function getFolders(): array {
* @return array An associative array that contains loaded classes info.
*
* @throws Exception
* @since 1.1.4
*/
public static function getLoadedClasses(): array {
return self::get()->loadedClasses;
Expand All @@ -446,7 +428,6 @@ public static function getLoadedClasses(): array {
* Else, it will return false.
*
* @throws Exception
* @since 1.1.5
*/
public static function isLoaded(string $class, string $ns = null): bool {
foreach (self::getLoadedClasses() as $classArr) {
Expand Down Expand Up @@ -474,7 +455,6 @@ public static function isLoaded(string $class, string $ns = null): bool {
* are inside the given directory will be included in the search.
*
* @throws Exception
* @since 1.1.2
*/
public static function newSearchFolder(string $dir, bool $incSubFolders = true) {
self::get()->addSearchDirectory($dir,$incSubFolders);
Expand All @@ -486,7 +466,6 @@ public static function newSearchFolder(string $dir, bool $incSubFolders = true)
* @return string The root directory that is used to search inside.
*
* @throws Exception
* @since 1.1.5
*/
public static function root(): string {
return self::get()->getRoot();
Expand All @@ -503,7 +482,6 @@ public static function root(): string {
* </ul>
*
* @throws Exception
* @since 1.1.5
*/
public static function setOnFail($onFail) {
if (is_callable($onFail)) {
Expand All @@ -528,7 +506,6 @@ public static function setOnFail($onFail) {
* @param string $appendRoot If set to true, Root directory of the search will
* be added as a prefix to the path.
*
* @since 1.0
*
* @deprecated since version 1.1.2
*/
Expand Down Expand Up @@ -605,7 +582,6 @@ private static function checkComposer() {
*
* @return array
*
* @since 1.1.6
*/
private static function getComposerVendorDirs(): array {
$DS = DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -639,7 +615,6 @@ private static function getComposerVendorDirs(): array {
*
* @return string The root directory that is used to search inside.
*
* @since 1.0
*/
private function getRoot(): string {
return $this->rootDir;
Expand All @@ -652,7 +627,6 @@ private function getRoot(): string {
*
* @throws ClassLoaderException
* @throws Exception
* @since 1.0
*/
private function loadClass(string $classWithNs) {
$cArr = explode('\\', $classWithNs);
Expand Down Expand Up @@ -835,7 +809,6 @@ private function parseCacheString($str) {
/**
* Read the file which contains autoloader cached content.
*
* @since 1.1.6
*/
private function readCache() {
$autoloadCachePath = $this->getRoot().DIRECTORY_SEPARATOR.APP_DIR.DIRECTORY_SEPARATOR.'sto';
Expand All @@ -855,7 +828,6 @@ private function readCache() {
* This method is called every time a new class is loaded to update the cache.
*
* @throws Exception
* @since 1.1.6
*/
private function updateCacheHelper() {
$autoloadCache = self::getCachePath();
Expand Down

0 comments on commit 45efa1a

Please sign in to comment.