Skip to content

Internals Runtime Runtime

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

runtime\Runtime

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/runtime/Runtime.php · Snapshot 8411f4287706.

Runtime state, package API classes, loader, executor and orchestrator have separate responsibilities. Dependency validation precedes package code and nested execution restores context.

Imports and dependencies

use event\EventDispatcher;
use package\model\InstalledPackage;
use runtime\enums\ERuntimeStatus;
use runtime\interface\IRuntime;

Runtime

Declaration and architectural role

class Runtime implements IRuntime

Source description (behavioral corrections are recorded in Known discrepancies):

Execution state for one installed package, independent of its package API.

Constants, enum cases, traits and properties

Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.

Member Declaration Purpose or source contract
$rootPath public string $rootPath = ''; Used by __construct(), getRootPath().
$waitFor public array $waitFor = []; Used by setWaitFor(), getWaitFor().
$flags public array $flags = []; Used by setFlags(), getFlags().
$shared public array $shared = []; Used by setSharedRegistry(), getSharedRegistry().
$passables public array $passables = []; Used by setPassable(), getPassable().
$eventDispatcher public ?EventDispatcher $eventDispatcher = null; Used by setEventDispatcher(), getEventDispatcher().
$status public ERuntimeStatus $status = ERuntimeStatus::NOT_STARTED; Used by setRuntimeStatus(), getRuntimeStatus().
Constructor-promoted public function __construct(private readonly ?InstalledPackage $package = null) Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct(private readonly ?InstalledPackage $package = null)
create public static function create(?InstalledPackage $package = null): self
setEventDispatcher public function setEventDispatcher(EventDispatcher $dispatcher): void
getEventDispatcher public function getEventDispatcher(): EventDispatcher
setRuntimeStatus public function setRuntimeStatus(ERuntimeStatus $status): void
getRuntimeStatus public function getRuntimeStatus(): ERuntimeStatus
getPackage public function getPackage(): InstalledPackage
getRuntimeId public function getRuntimeId(): int
getRuntimeName public function getRuntimeName(): string
getRootPath public function getRootPath(): string
setFlags public function setFlags(array $flags): void
getFlags public function getFlags(): array
setWaitFor public function setWaitFor(array $packages): void
getWaitFor public function getWaitFor(): array
setPassable public function setPassable(array $passables): void
getPassable public function getPassable(string $name): array
setSharedRegistry public function setSharedRegistry(array $shared): void
getSharedRegistry public function getSharedRegistry(): array

__construct

Source line 20

public function __construct(private readonly ?InstalledPackage $package = null)

Parameters

Parameter Type, modifiers and default Purpose
$package private readonly ?InstalledPackage $package = null Package identifier or InstalledPackage metadata as indicated by the declared type.

State writes: $this->rootPath.

Implementation, validation guards and interaction order
public function __construct(private readonly ?InstalledPackage $package = null)
    {
        if ($package !== null) {
            $this->rootPath = $package->getPackagePath() . DIRECTORY_SEPARATOR;
        }
    }

create

Source line 27

public static function create(?InstalledPackage $package = null): self

Parameters

Parameter Type, modifiers and default Purpose
$package ?InstalledPackage $package = null Package identifier or InstalledPackage metadata as indicated by the declared type.

Return expressions (including local callbacks): new self($package).

Implementation, validation guards and interaction order
public static function create(?InstalledPackage $package = null): self { return new self($package); }

setEventDispatcher

Source line 28

public function setEventDispatcher(EventDispatcher $dispatcher): void

Parameters

Parameter Type, modifiers and default Purpose
$dispatcher EventDispatcher $dispatcher Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->eventDispatcher.

Implementation, validation guards and interaction order
public function setEventDispatcher(EventDispatcher $dispatcher): void { $this->eventDispatcher = $dispatcher; }

getEventDispatcher

Source line 29

public function getEventDispatcher(): EventDispatcher

Return expressions (including local callbacks): $this->eventDispatcher ?? throw new \LogicException('Runtime event dispatcher has not been initialized.').

Explicit exceptions: \LogicException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.

Implementation, validation guards and interaction order
public function getEventDispatcher(): EventDispatcher
    {
        return $this->eventDispatcher ?? throw new \LogicException('Runtime event dispatcher has not been initialized.');
    }

setRuntimeStatus

Source line 33

public function setRuntimeStatus(ERuntimeStatus $status): void

Parameters

Parameter Type, modifiers and default Purpose
$status ERuntimeStatus $status Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->status.

Implementation, validation guards and interaction order
public function setRuntimeStatus(ERuntimeStatus $status): void { $this->status = $status; }

getRuntimeStatus

Source line 34

public function getRuntimeStatus(): ERuntimeStatus

Return expressions (including local callbacks): $this->status.

Implementation, validation guards and interaction order
public function getRuntimeStatus(): ERuntimeStatus { return $this->status; }

getPackage

Source line 35

public function getPackage(): InstalledPackage

Return expressions (including local callbacks): $this->package ?? throw new \LogicException('Runtime has no installed package.').

Explicit exceptions: \LogicException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.

Implementation, validation guards and interaction order
public function getPackage(): InstalledPackage
    {
        return $this->package ?? throw new \LogicException('Runtime has no installed package.');
    }

getRuntimeId

Source line 39

public function getRuntimeId(): int

Return expressions (including local callbacks): $this->getPackage()->getId().

Implementation, validation guards and interaction order
public function getRuntimeId(): int { return $this->getPackage()->getId(); }

getRuntimeName

Source line 40

public function getRuntimeName(): string

Return expressions (including local callbacks): $this->getPackage()->getName().

Implementation, validation guards and interaction order
public function getRuntimeName(): string { return $this->getPackage()->getName(); }

getRootPath

Source line 41

public function getRootPath(): string

Return expressions (including local callbacks): $this->rootPath.

Implementation, validation guards and interaction order
public function getRootPath(): string { return $this->rootPath; }

setFlags

Source line 42

public function setFlags(array $flags): void

Parameters

Parameter Type, modifiers and default Purpose
$flags array $flags List of runtime flag cases; invalid non-enum entries fail normalization.

State writes: $this->flags.

Implementation, validation guards and interaction order
public function setFlags(array $flags): void { $this->flags = $flags; }

getFlags

Source line 43

public function getFlags(): array

Return expressions (including local callbacks): $this->flags.

Implementation, validation guards and interaction order
public function getFlags(): array { return $this->flags; }

setWaitFor

Source line 44

public function setWaitFor(array $packages): void

Parameters

Parameter Type, modifiers and default Purpose
$packages array $packages Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->waitFor.

Implementation, validation guards and interaction order
public function setWaitFor(array $packages): void { $this->waitFor = $packages; }

getWaitFor

Source line 45

public function getWaitFor(): array

Return expressions (including local callbacks): $this->waitFor.

Implementation, validation guards and interaction order
public function getWaitFor(): array { return $this->waitFor; }

setPassable

Source line 46

public function setPassable(array $passables): void

Parameters

Parameter Type, modifiers and default Purpose
$passables array $passables Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->passables.

Implementation, validation guards and interaction order
public function setPassable(array $passables): void { $this->passables = $passables; }

getPassable

Source line 47

public function getPassable(string $name): array

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Return expressions (including local callbacks): $this->passables[$name] ?? [].

Implementation, validation guards and interaction order
public function getPassable(string $name): array { return $this->passables[$name] ?? []; }

setSharedRegistry

Source line 48

public function setSharedRegistry(array $shared): void

Parameters

Parameter Type, modifiers and default Purpose
$shared array $shared Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->shared.

Implementation, validation guards and interaction order
public function setSharedRegistry(array $shared): void { $this->shared = $shared; }

getSharedRegistry

Source line 49

public function getSharedRegistry(): array

Return expressions (including local callbacks): $this->shared.

Implementation, validation guards and interaction order
public function getSharedRegistry(): array { return $this->shared; }

Related types

Clone this wiki locally