class Wizard
Hierarchy
- class \SebastianBergmann\CodeUnitReverseLookup\Wizard
Expanded class hierarchy of Wizard
2 files declare their use of Wizard
- CodeCoverage.php in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage.php - ExcludeList.php in vendor/
phpunit/ phpunit/ src/ Util/ ExcludeList.php
2 string references to 'Wizard'
- ViewAddForm::validateForm in core/
modules/ views_ui/ src/ ViewAddForm.php - Form validation handler.
- views.services.yml in core/
modules/ views/ views.services.yml - core/modules/views/views.services.yml
File
-
vendor/
sebastian/ code-unit-reverse-lookup/ src/ Wizard.php, line 24
Namespace
SebastianBergmann\CodeUnitReverseLookupView source
class Wizard {
/**
* @psalm-var array<string,array<int,string>>
*/
private array $lookupTable = [];
/**
* @psalm-var array<class-string,true>
*/
private array $processedClasses = [];
/**
* @psalm-var array<string,true>
*/
private array $processedFunctions = [];
public function lookup(string $filename, int $lineNumber) : string {
if (!isset($this->lookupTable[$filename][$lineNumber])) {
$this->updateLookupTable();
}
if (isset($this->lookupTable[$filename][$lineNumber])) {
return $this->lookupTable[$filename][$lineNumber];
}
return $filename . ':' . $lineNumber;
}
private function updateLookupTable() : void {
$this->processClassesAndTraits();
$this->processFunctions();
}
private function processClassesAndTraits() : void {
$classes = get_declared_classes();
$traits = get_declared_traits();
/* @noinspection PhpConditionAlreadyCheckedInspection */
assert(is_array($traits));
foreach (array_merge($classes, $traits) as $classOrTrait) {
if (isset($this->processedClasses[$classOrTrait])) {
continue;
}
foreach ((new ReflectionClass($classOrTrait))->getMethods() as $method) {
$this->processFunctionOrMethod($method);
}
$this->processedClasses[$classOrTrait] = true;
}
}
private function processFunctions() : void {
foreach (get_defined_functions()['user'] as $function) {
if (isset($this->processedFunctions[$function])) {
continue;
}
$this->processFunctionOrMethod(new ReflectionFunction($function));
$this->processedFunctions[$function] = true;
}
}
private function processFunctionOrMethod(ReflectionFunctionAbstract $functionOrMethod) : void {
if ($functionOrMethod->isInternal()) {
return;
}
$name = $functionOrMethod->getName();
if ($functionOrMethod instanceof ReflectionMethod) {
$name = $functionOrMethod->getDeclaringClass()
->getName() . '::' . $name;
}
if (!isset($this->lookupTable[$functionOrMethod->getFileName()])) {
$this->lookupTable[$functionOrMethod->getFileName()] = [];
}
foreach (range($functionOrMethod->getStartLine(), $functionOrMethod->getEndLine()) as $line) {
$this->lookupTable[$functionOrMethod->getFileName()][$line] = $name;
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
Wizard::$lookupTable | private | property | @psalm-var array<string,array<int,string>> |
Wizard::$processedClasses | private | property | @psalm-var array<class-string,true> |
Wizard::$processedFunctions | private | property | @psalm-var array<string,true> |
Wizard::lookup | public | function | |
Wizard::processClassesAndTraits | private | function | |
Wizard::processFunctionOrMethod | private | function | |
Wizard::processFunctions | private | function | |
Wizard::updateLookupTable | private | function |