Repository navigation
Internals Installer Package VerifyStructure
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/installer/package/VerifyStructure.php · Snapshot 8411f4287706.
Installation validates archives and manifests, moves files, persists metadata, copies data into storage, invokes an optional hook and emits an event. These operations do not form one atomic transaction.
use installer\interfaces\package\IVerifyStructure;
use RuntimeException;class VerifyStructure implements IVerifyStructureDeclarations 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 |
|---|---|---|
| $required | private array $required; |
Used by addFile(), addDirectory(), verify(). |
| $scanned | private array $scanned; |
Used by __construct(), verify(), scanDirectory(). |
| Constructor-promoted | private readonly string $root |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Method | Signature |
|---|---|
| __construct | public function __construct( private readonly string $root ) |
| addFile | public function addFile(string $file): IVerifyStructure |
| addDirectory | public function addDirectory(string $dir): IVerifyStructure |
| verify | public function verify(): bool |
| generateStructure | private function generateStructure(): void |
| scanDirectory | private function scanDirectory(string $dir): void |
public function __construct(
private readonly string $root
)| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$root |
private readonly string $root |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
State writes: $this->scanned.
Implementation, validation guards and interaction order
public function __construct(
private readonly string $root
){
$this->scanned = [
"directories" => [],
"files" => []
];
}public function addFile(string $file): IVerifyStructure| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$file |
string $file |
Uploaded file array, file object or path according to the declared contract. |
State writes: $this->required["files"][].
Return expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function addFile(string $file): IVerifyStructure
{
$this->required["files"][] = $file;
return $this;
}public function addDirectory(string $dir): IVerifyStructure| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$dir |
string $dir |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
State writes: $this->required["directories"][].
Return expressions (including local callbacks): $this.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function addDirectory(string $dir): IVerifyStructure
{
$this->required["directories"][] = $dir;
return $this;
}public function verify(): boolReturn expressions (including local callbacks): false; true.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function verify(): bool
{
$this->generateStructure();
foreach ($this->required["files"] ?? [] as $file) {
if (!in_array($file, $this->scanned["files"], true)
|| !is_readable($this->root . DIRECTORY_SEPARATOR . $file)) {
return false;
}
}
foreach ($this->required["directories"] ?? [] as $dir) {
if (!in_array($dir, $this->scanned["directories"], true)) {
return false;
}
}
return true;
}private function generateStructure(): voidExplicit 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
//Helper function
private function generateStructure(): void
{
if(!is_dir($this->root)) {
throw new RuntimeException("Root directory of the package does not exist. $this->root");
}
$this->scanDirectory($this->root);
}private function scanDirectory(string $dir): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$dir |
string $dir |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
State writes: $this->scanned["directories"][], $this->scanned["files"][].
Implementation, validation guards and interaction order
private function scanDirectory(string $dir): void
{
$scan = scandir($dir);
unset($scan[0], $scan[1]);
foreach($scan as $entry) {
$fullPath = $dir . DIRECTORY_SEPARATOR . $entry;
$relativePath = substr($fullPath, strlen($this->root) + 1);
if(is_dir($fullPath)) {
$this->scanned["directories"][] = $relativePath;
$this->scanDirectory($fullPath);
} else {
$this->scanned["files"][] = $relativePath;
}
}
}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