Skip to content

Internals Object ObjectHandler

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

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.

ObjectHandler

Declaration and architectural role

class ObjectHandler

Constants, enum cases, traits and properties

No own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.

Method index

Method Signature
classFromFile public static function classFromFile(string $filename): ?string
createObjectFromFile public static function createObjectFromFile(string $filename): ?object

classFromFile

Source line 7

public static function classFromFile(string $filename): ?string

Parameters

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;
    }

createObjectFromFile

Source line 18

public static function createObjectFromFile(string $filename): ?object

Parameters

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();
    }

Clone this wiki locally