function CodeUnit::forFunction
@psalm-param callable-string $functionName
Throws
1 call to CodeUnit::forFunction()
- Mapper::stringToCodeUnits in vendor/
sebastian/ code-unit/ src/ Mapper.php
File
-
vendor/
sebastian/ code-unit/ src/ CodeUnit.php, line 190
Class
- CodeUnit
- @psalm-immutable
Namespace
SebastianBergmann\CodeUnitCode
public static function forFunction(string $functionName) : FunctionUnit {
$reflector = self::reflectorForFunction($functionName);
if (!$reflector->isUserDefined()) {
throw new InvalidCodeUnitException(sprintf('"%s" is not a user-defined function', $functionName));
}
return new FunctionUnit($functionName, $reflector->getFileName(), range($reflector->getStartLine(), $reflector->getEndLine()));
}