@jymfony/autoloader
Advanced tools
Comparing version 0.1.0-alpha.3 to 0.1.0-alpha.4
{ | ||
"name": "@jymfony/autoloader", | ||
"version": "0.1.0-alpha.3", | ||
"version": "0.1.0-alpha.4", | ||
"description": "Jymfony Autoloader", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@jymfony/util": "0.1.0-alpha.3" | ||
"@jymfony/util": "0.1.0-alpha.4" | ||
}, | ||
@@ -24,0 +24,0 @@ "devDependencies": { |
@@ -1,3 +0,1 @@ | ||
global.__jymfony = global.__jymfony || {}; | ||
const Finder = require('./Finder'); | ||
@@ -8,9 +6,18 @@ const Namespace = require('./Namespace'); | ||
/** | ||
* Main autoloader. | ||
* Singleton class: the constructor returns always the | ||
* same instance (in the same global context) | ||
* | ||
* @memberOf Jymfony.Component.Autoloader | ||
* @type Autoloader | ||
*/ | ||
module.exports = class Autoloader { | ||
class Autoloader { | ||
/** | ||
* Constructor. | ||
* | ||
* @param {undefined|Jymfony.Component.Autoloader.Finder} finder | ||
* @param {Object} globalObject | ||
*/ | ||
constructor(finder = undefined, globalObject = global) { | ||
if (globalObject.__jymfony.autoload) { | ||
return; | ||
if (globalObject.__jymfony && globalObject.__jymfony.autoload) { | ||
return globalObject.__jymfony.autoload; | ||
} | ||
@@ -22,6 +29,30 @@ | ||
/** | ||
* @type {boolean} | ||
* @private | ||
*/ | ||
this._debug = false; | ||
/** | ||
* @type {boolean} | ||
* @private | ||
*/ | ||
this._registered = false; | ||
/** | ||
* @type {Jymfony.Component.Autoloader.Finder} | ||
* @private | ||
*/ | ||
this._finder = finder; | ||
/** | ||
* @type {Object} | ||
* @private | ||
*/ | ||
this._global = globalObject; | ||
this._global.__jymfony = this._global.__jymfony || {}; | ||
/** | ||
* @type {Jymfony.Component.Autoloader.Autoloader} | ||
*/ | ||
this._global.__jymfony.autoload = this; | ||
@@ -145,2 +176,4 @@ } | ||
} | ||
}; | ||
} | ||
module.exports = Autoloader; |
/** | ||
* @memberOf Jymfony.Component.Autoloader.Exception | ||
* @type ClassNotFoundException | ||
*/ | ||
module.exports = class ClassNotFoundException extends Error { | ||
}; | ||
class ClassNotFoundException extends Error { | ||
} | ||
module.exports = ClassNotFoundException; |
/** | ||
* @memberOf Jymfony.Component.Autoloader.Exception | ||
* @type ReflectionException | ||
*/ | ||
module.exports = class ReflectionException extends Error { | ||
}; | ||
class ReflectionException extends Error { | ||
} | ||
module.exports = ReflectionException; |
@@ -6,5 +6,4 @@ let ClassNotFoundException = undefined; | ||
* @memberOf Jymfony.Component.Autoloader | ||
* @type Namespace | ||
*/ | ||
module.exports = class Namespace { | ||
class Namespace { | ||
/** | ||
@@ -244,2 +243,4 @@ * Namespace constructor | ||
} | ||
}; | ||
} | ||
module.exports = Namespace; |
@@ -408,14 +408,24 @@ const ReflectionException = require('../Exception/ReflectionException'); | ||
let part; | ||
let original = parts.join('.'); | ||
parts = [ ...parts ].reverse(); | ||
while (part = parts.pop()) { | ||
if (undefined === start) { | ||
throw new ReflectionException('Requesting non-existent class ' + original); | ||
// Save autoload debug flag. | ||
let debug = __jymfony.autoload.debug; | ||
__jymfony.autoload.debug = false; | ||
try { | ||
let original = parts.join('.'); | ||
parts = [ ...parts ].reverse(); | ||
while (part = parts.pop()) { | ||
if (undefined === start) { | ||
throw new ReflectionException('Requesting non-existent class ' + original); | ||
} | ||
start = start[part]; | ||
} | ||
start = start[part]; | ||
return start; | ||
} finally { | ||
// Restore debug flag. | ||
__jymfony.autoload.debug = debug; | ||
} | ||
return start; | ||
} | ||
@@ -422,0 +432,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55031
20
1588
+ Added@jymfony/exceptions@0.1.0-alpha.4(transitive)
+ Added@jymfony/util@0.1.0-alpha.4(transitive)
- Removed@jymfony/exceptions@0.1.0-alpha.3(transitive)
- Removed@jymfony/util@0.1.0-alpha.3(transitive)
Updated@jymfony/util@0.1.0-alpha.4