class RuntimeInputs

internal  
 

The inputs the booted application was built from, declared as one dependency by everything that reads the booted application.

Bindings, macros, drivers, commands and registrations come from code the boot ran, which no analyzed file references, so the files the boot loaded and the environment variables it can read are tracked instead. A Testbench package boots from a disposable runtime copy, so copied paths are tracked through their skeleton source.

Properties

static protected Application|null $application

The application the analyzer booted.

static protected list<string> $includedFiles

The files loaded once the application had booted.

static protected array<string, true> $classes

The lowercased names of the classes, interfaces and traits loaded once the application had booted.

static protected array<string, true> $classFiles

The files declaring the classes, interfaces and traits loaded once the application had booted.

static protected string|null $environmentFile

The environment file an application boot selects from, or null for a Testbench package, whose application loads no environment file.

static protected bool $packageApplication

Whether the analyzer booted a Testbench application for a package rather than an application's own.

Methods

__construct(ReflectionProvider $reflectionProvider, DeclarationDependencyTracker $declarationDependencyTracker, EnvironmentVariableScanner $environmentVariableScanner, ConfigSourceResolver $configSourceResolver, RuntimeInputsResultCacheValueExtension $valueExtension, string $tmpDir)

Create a new runtime inputs instance.

static void
captureBoot(Application $app, string|null $environmentFile, bool $packageApplication)

Capture what the boot loaded.

bool
isPackageApplication()

Determine whether the analyzer booted a Testbench application for a package.

void
track(Scope|ClassReflection $dependent)

Declare that the analysis of the current file, or what a class declares, depends on the booted application.

void
trackClass(Scope|ClassReflection $dependent, string $className)

Declare that the dependent depends on what a class the booted application selected declares.

void
trackSources(Scope|ClassReflection $dependent, string $className, string|null $baseClass)

Declare that the dependent depends on the declarations and code of a class the booted application selected and the analysis runs.

void
trackViews(Scope|ClassReflection $dependent)

Declare that the dependent depends on which views exist.

void
trackLinkedDirectories(Scope $scope, array $directories, string $pattern = '*')

Declare that the analysis of the current file depends on the names and contents of the files in directories, as the view finder and translation loader read them.

string
sourcePath(string $path)

Get the path to track for a file the analysis reads.

string
sourceDirectory(string $directory, string $pattern = '*')

Get the directory to track for files in it the analysis reads, as sourcePath() does for a file.

Details

at line 139
__construct(ReflectionProvider $reflectionProvider, DeclarationDependencyTracker $declarationDependencyTracker, EnvironmentVariableScanner $environmentVariableScanner, ConfigSourceResolver $configSourceResolver, RuntimeInputsResultCacheValueExtension $valueExtension, string $tmpDir)

Create a new runtime inputs instance.

Parameters

ReflectionProvider $reflectionProvider
DeclarationDependencyTracker $declarationDependencyTracker
EnvironmentVariableScanner $environmentVariableScanner
ConfigSourceResolver $configSourceResolver
RuntimeInputsResultCacheValueExtension $valueExtension
string $tmpDir

at line 156
static void captureBoot(Application $app, string|null $environmentFile, bool $packageApplication)

Capture what the boot loaded.

Called by the analyzer's bootstrap file once the application has booted, before analysis loads anything else.

Parameters

Application $app
string|null $environmentFile
bool $packageApplication

Return Value

void

at line 176
bool isPackageApplication()

Determine whether the analyzer booted a Testbench application for a package.

Return Value

bool

at line 186
void track(Scope|ClassReflection $dependent)

Declare that the analysis of the current file, or what a class declares, depends on the booted application.

Parameters

Scope|ClassReflection $dependent

Return Value

void

at line 203
void trackClass(Scope|ClassReflection $dependent, string $className)

Declare that the dependent depends on what a class the booted application selected declares.

Resolving a binding can load its class after boot, outside the runtime inputs, and a declared type is read without loading its class at all.

Parameters

Scope|ClassReflection $dependent
string $className

Return Value

void

at line 221
void trackSources(Scope|ClassReflection $dependent, string $className, string|null $baseClass)

Declare that the dependent depends on the declarations and code of a class the booted application selected and the analysis runs.

Method bodies and property defaults are not declarations, so the files declaring the class and its parents below the base class, or all of them without one, with their traits and the constants their defaults read, are tracked too.

Parameters

Scope|ClassReflection $dependent
string $className
string|null $baseClass

Return Value

void

at line 247
void trackViews(Scope|ClassReflection $dependent)

Declare that the dependent depends on which views exist.

Only the names of the files in the booted finder's directories matter, so editing a template does not invalidate it. The finder's directories come from the boot.

Parameters

Scope|ClassReflection $dependent

Return Value

void

at line 268
void trackLinkedDirectories(Scope $scope, array $directories, string $pattern = '*')

Declare that the analysis of the current file depends on the names and contents of the files in directories, as the view finder and translation loader read them.

Both find files through symlinked directories, which PHPStan's directory dependency does not enter.

Parameters

Scope $scope
array $directories
string $pattern

Return Value

void

at line 292
string sourcePath(string $path)

Get the path to track for a file the analysis reads.

A file in the runtime copy is tracked through its skeleton source while the two are identical. A file the copy changed or added has no known source and keeps its runtime path, which disappears with the copy, so it is analyzed again on every run.

Parameters

string $path

Return Value

string

at line 300
string sourceDirectory(string $directory, string $pattern = '*')

Get the directory to track for files in it the analysis reads, as sourcePath() does for a file.

Parameters

string $directory
string $pattern

Return Value

string