Repository navigation
Internals Runtime Api RuntimeAPI
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/runtime/api/RuntimeAPI.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.
use cli\CLIHandler;
use cli\interfaces\CLICommand;
use event\EventDispatcher;
use object\ObjectHandler;
use package\model\InstalledPackage;
use runtime\enums\ERuntimeFlags;
use runtime\interface\api\IRuntimeAPI;
use runtime\interface\api\IRuntimeBaseCapabilities;
use runtime\interface\IRuntime;abstract class RuntimeAPI implements IRuntimeAPI, IRuntimeBaseCapabilitiesDeclarations 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 |
|---|---|---|
| $id | protected int $id; |
Used by setInfo(), getId(). |
| $name | protected string $name; |
Used by setInfo(), setShared(), getPassable(), getName(). |
| $rootPath | protected string $rootPath; |
Used by setInfo(), getLocalObject(). |
| $runtimePath | protected string $runtimePath; |
Used by setInfo(). |
| $package | protected InstalledPackage $package; |
Used by setInfo(), getPackage(), getInfo(). |
| $runtime | protected IRuntime $runtime; |
Used by setInfo(), getRuntime(), setRuntimeFlag(), waitForPackage(), setShared(), getShared(), hasFlags(), setSharable(), getPassable(). |
| $eventDispatcher | public EventDispatcher $eventDispatcher; |
Used by setInfo(). |
| $CLIHandler | public CLIHandler $CLIHandler; |
Used by addCommand(). |
| Method | Signature |
|---|---|
| setInfo | public function setInfo(IRuntime $runtime): void |
| getRuntime | public function getRuntime(): IRuntime |
| environmentSetup | public function environmentSetup(): void |
| setup | public function setup(): void |
| main | abstract public function main(): void |
| setRuntimeFlag | public function setRuntimeFlag(ERuntimeFlags $flag): void |
| waitForPackage | public function waitForPackage(string $package): void |
| waitForRuntime | public function waitForRuntime(string $package): void |
| setShared | public function setShared(string $name, mixed $share): void |
| getShared | public function getShared(string $name, string $shared, ?string $expectedType = null): mixed |
| hasFlags | public function hasFlags(bool $hasFlags = false): bool |
| addShared | public function addShared(string $name, object $instance): void |
| setSharable | public function setSharable(array $shared): void |
| getPassable | public function getPassable(string $runtimeName, ?string $className = null, ?string $type = null): ?object |
| getPackage | public function getPackage(): InstalledPackage |
| getId | public function getId(): int |
| getName | public function getName(): string |
| getInfo | public function getInfo(): array |
| getLocalObject | public function getLocalObject(string $pathFromRoot): ?object |
| addCommand | public function addCommand(CLICommand $command): void |
public function setInfo(IRuntime $runtime): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$runtime |
IRuntime $runtime |
Runtime state carrying package metadata, flags and request registries. |
State writes: $this->runtime, $this->package, $this->id, $this->name, $this->rootPath, $this->runtimePath, $this->eventDispatcher.
Implementation, validation guards and interaction order
public function setInfo(IRuntime $runtime): void
{
$this->runtime = $runtime;
$this->package = $runtime->getPackage();
$this->id = $runtime->getRuntimeId();
$this->name = $runtime->getRuntimeName();
$this->rootPath = rtrim($runtime->getRootPath(), DIRECTORY_SEPARATOR);
$this->runtimePath = $this->rootPath;
$this->eventDispatcher = $runtime->getEventDispatcher();
}public function getRuntime(): IRuntimeReturn expressions (including local callbacks): $this->runtime.
Implementation, validation guards and interaction order
public function getRuntime(): IRuntime { return $this->runtime; }public function environmentSetup(): void;Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.
public function setup(): void;Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.
abstract public function main(): void;Contract only: implementations supply the behavior. Parameter and return types are enforced by PHP; caller and implementation constraints follow the subsystem overview.
public function setRuntimeFlag(ERuntimeFlags $flag): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$flag |
ERuntimeFlags $flag |
Native ERuntimeFlags case; normalized/deduplicated before execution. |
Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.
Implementation, validation guards and interaction order
public function setRuntimeFlag(ERuntimeFlags $flag): void { $this->runtime->setFlags([...$this->runtime->getFlags(), $flag]); }public function waitForPackage(string $package): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$package |
string $package |
Package identifier or InstalledPackage metadata as indicated by the declared type. |
Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.
Implementation, validation guards and interaction order
public function waitForPackage(string $package): void { $this->runtime->setWaitFor([...$this->runtime->getWaitFor(), $package]); }public function waitForRuntime(string $package): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$package |
string $package |
Package identifier or InstalledPackage metadata as indicated by the declared type. |
Delegates to waitForPackage().
Implementation, validation guards and interaction order
public function waitForRuntime(string $package): void { $this->waitForPackage($package); }public function setShared(string $name, mixed $share): void| 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. |
$share |
mixed $share |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.
Implementation, validation guards and interaction order
public function setShared(string $name, mixed $share): void
{
$shared = $this->runtime->getSharedRegistry();
$shared[$this->name][$name] = $share;
$this->runtime->setSharedRegistry($shared);
}public function getShared(string $name, string $shared, ?string $expectedType = null): mixed| 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. |
$shared |
string $shared |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$expectedType |
?string $expectedType = null |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): $value.
Explicit exceptions: \runtime\exceptions\RuntimeException. 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 getShared(string $name, string $shared, ?string $expectedType = null): mixed
{
$value = $this->runtime->getSharedRegistry()[$name][$shared] ?? null;
if ($value !== null && $expectedType !== null && !$value instanceof $expectedType) {
throw new \runtime\exceptions\RuntimeException('Unexpected shared type ' . get_debug_type($value) . "; expected {$expectedType}.");
}
return $value;
}public function hasFlags(bool $hasFlags = false): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$hasFlags |
bool $hasFlags = false |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): $this->runtime->getFlags() !== [].
Implementation, validation guards and interaction order
public function hasFlags(bool $hasFlags = false): bool { return $this->runtime->getFlags() !== []; }public function addShared(string $name, object $instance): void| 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. |
$instance |
object $instance |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Delegates to setShared().
Implementation, validation guards and interaction order
public function addShared(string $name, object $instance): void { $this->setShared($name, $instance); }public function setSharable(array $shared): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$shared |
array $shared |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.
Implementation, validation guards and interaction order
public function setSharable(array $shared): void { $this->runtime->setSharedRegistry($shared); }public function getPassable(string $runtimeName, ?string $className = null, ?string $type = null): ?object| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$runtimeName |
string $runtimeName |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$className |
?string $className = null |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$type |
?string $type = null |
Expected class/type or enum selection according to the signature. |
One argument looks within this package; two arguments select another package.
Return expressions (including local callbacks): $instance !== null && ($type === null || $instance instanceof $type) ? $instance : null.
Implementation, validation guards and interaction order
/** One argument looks within this package; two arguments select another package. */
public function getPassable(string $runtimeName, ?string $className = null, ?string $type = null): ?object
{
$instance = $className === null
? ($this->runtime->getPassable($this->name)[$runtimeName] ?? null)
: ($this->runtime->getPassable($runtimeName)[$className] ?? null);
return $instance !== null && ($type === null || $instance instanceof $type) ? $instance : null;
}public function getPackage(): InstalledPackageReturn expressions (including local callbacks): $this->package.
Implementation, validation guards and interaction order
public function getPackage(): InstalledPackage { return $this->package; }public function getId(): intReturn expressions (including local callbacks): $this->id.
Implementation, validation guards and interaction order
public function getId(): int { return $this->id; }public function getName(): stringReturn expressions (including local callbacks): $this->name.
Implementation, validation guards and interaction order
public function getName(): string { return $this->name; }public function getInfo(): arrayReturn expressions (including local callbacks): $this->package->getInfo().
Implementation, validation guards and interaction order
public function getInfo(): array { return $this->package->getInfo(); }public function getLocalObject(string $pathFromRoot): ?object| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$pathFromRoot |
string $pathFromRoot |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): ObjectHandler::createObjectFromFile($this->rootPath . '/' . ltrim($pathFromRoot, '/')).
Implementation, validation guards and interaction order
public function getLocalObject(string $pathFromRoot): ?object
{
return ObjectHandler::createObjectFromFile($this->rootPath . '/' . ltrim($pathFromRoot, '/'));
}public function addCommand(CLICommand $command): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$command |
CLICommand $command |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
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 addCommand(CLICommand $command): void
{
if (PHP_SAPI === 'cli') {
if (!isset($this->CLIHandler)) throw new \LogicException('CLI handler is unavailable.');
$this->CLIHandler->addCommand($command);
}
}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