Repository navigation
Internals Object ObjectHandler
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/object/ObjectHandler.php · Snapshot 8411f4287706.
ObjectFactory configures lazy instances by file/class, constructor arguments, properties and ordered method calls. ObjectHandler chooses a concrete class declared by a file.
class ObjectHandlerNo own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.
| Method | Signature |
|---|---|
| classFromFile | public static function classFromFile(string $filename): ?string |
| createObjectFromFile | public static function createObjectFromFile(string $filename): ?object |
public static function classFromFile(string $filename): ?string| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$filename |
string $filename |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Select a class declared by this file, rather than a dependency it autoloaded.
Return expressions (including local callbacks): $class; null.
Explicit exceptions: \RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
External effects include include_once.
Implementation, validation guards and interaction order
/** Select a class declared by this file, rather than a dependency it autoloaded. */
public static function classFromFile(string $filename): ?string
{
$path = realpath($filename);
if ($path === false || !is_file($path)) throw new \RuntimeException("File not found: {$filename}");
include_once $path;
foreach (get_declared_classes() as $class) {
$reflection = new \ReflectionClass($class);
if ($reflection->getFileName() === $path && !$reflection->isAbstract()) return $class;
}
return null;
}public static function createObjectFromFile(string $filename): ?object| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$filename |
string $filename |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): $class === null ? null : new $class().
Implementation, validation guards and interaction order
public static function createObjectFromFile(string $filename): ?object
{
$class = self::classFromFile($filename);
return $class === null ? null : new $class();
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes