Greenlight

Documentation

API reference

On this page

Sandbox API

This reference lists the sandboxes that isolate temporary test state.

These signatures are the public API.

Autoloaders

Namespace: Greenlight\Sandbox

Registers autoloaders and unregisters them when the test scope closes.

final class Autoloaders implements Disposable

View source

register()

public function register(callable $autoloader): void

PHPDoc:

View source

dispose()

public function dispose(): void

View source

EnvironmentVariables

Namespace: Greenlight\Sandbox

Updates getenv(), $_ENV, and $_SERVER together. It records each original value one time and restores the value during disposal.

final class EnvironmentVariables implements Disposable

View source

set()

public function set(string $name, string $value): void

PHPDoc:

View source

unset()

public function unset(string $name): void

PHPDoc:

View source

dispose()

public function dispose(): void

View source

StreamWrapperError

Namespace: Greenlight\Sandbox

A stream-wrapper sandbox cannot register or unregister a wrapper.

final class StreamWrapperError extends \RuntimeException

View source

registrationFailed()

public static function registrationFailed(
    string $scheme,
    ?string $warning,
    ?\Throwable $previous = null,
): self

View source

unregistrationFailed()

public static function unregistrationFailed(array $failures): self

PHPDoc:

View source

StreamWrappers

Namespace: Greenlight\Sandbox

Registers stream wrappers and unregisters them when the test scope closes.

final class StreamWrappers implements Disposable

View source

register()

public function register(string $scheme, string $wrapper): void

PHPDoc:

View source

dispose()

public function dispose(): void

PHPDoc:

View source

TemporaryDirectory

Namespace: Greenlight\Sandbox

Creates one root directory on first use. subdirectory() rejects traversal segments and symbolic links in the requested path. Disposal removes a symbolic link and leaves its target unchanged.

final class TemporaryDirectory implements Disposable

View source

__construct()

public function __construct(?string $temporaryRoot = null)

PHPDoc:

View source

path()

public function path(): string

PHPDoc:

View source

subdirectory()

public function subdirectory(string $name): string

PHPDoc:

View source

dispose()

public function dispose(): void

PHPDoc:

View source

TemporaryDirectoryError

Namespace: Greenlight\Sandbox

A temporary-directory operation cannot create, validate, or remove a path.

final class TemporaryDirectoryError extends \RuntimeException

View source

rootCreationFailed()

public static function rootCreationFailed(string $path, ?string $warning): self

View source

subdirectoryCreationFailed()

public static function subdirectoryCreationFailed(string $path, ?string $warning): self

View source

public static function symbolicLink(string $path): self

View source

rootLinkRemovalFailed()

public static function rootLinkRemovalFailed(string $path, ?string $warning): self

View source

entryRemovalFailed()

public static function entryRemovalFailed(string $entry, string $root): self

View source

rootRemovalFailed()

public static function rootRemovalFailed(string $path, ?string $warning): self

View source