mediatekformation

InterceptorGenerator
in package

Utility to create pre- and post- method interceptors around a given method body

Tags
private
  • this class is just here as a small utility for this component, don't use it in your own code

Table of Contents

TEMPLATE  = <<<'PHP' if (isset($this->{{$prefixInterceptorsName}}[{{$name}}])) { $returnEarly = false; $prefixReturnValue = $this->{{$prefixInterceptorsName}}[{{$name}}]->__invoke($this, $this->{{$valueHolderName}}, {{$name}}, {{$paramsString}}, $returnEarly); if ($returnEarly) { {{$returnEarlyPrefixExpression}} } } {{$methodBody}} if (isset($this->{{$suffixInterceptorsName}}[{{$name}}])) { $returnEarly = false; $suffixReturnValue = $this->{{$suffixInterceptorsName}}[{{$name}}]->__invoke($this, $this->{{$valueHolderName}}, {{$name}}, {{$paramsString}}, $returnValue, $returnEarly); if ($returnEarly) { {{$returnEarlySuffixExpression}} } } {{$returnExpression}} PHP
createInterceptedMethodBody()  : string

Constants

TEMPLATE

private mixed TEMPLATE = <<<'PHP' if (isset($this->{{$prefixInterceptorsName}}[{{$name}}])) { $returnEarly = false; $prefixReturnValue = $this->{{$prefixInterceptorsName}}[{{$name}}]->__invoke($this, $this->{{$valueHolderName}}, {{$name}}, {{$paramsString}}, $returnEarly); if ($returnEarly) { {{$returnEarlyPrefixExpression}} } } {{$methodBody}} if (isset($this->{{$suffixInterceptorsName}}[{{$name}}])) { $returnEarly = false; $suffixReturnValue = $this->{{$suffixInterceptorsName}}[{{$name}}]->__invoke($this, $this->{{$valueHolderName}}, {{$name}}, {{$paramsString}}, $returnValue, $returnEarly); if ($returnEarly) { {{$returnEarlySuffixExpression}} } } {{$returnExpression}} PHP

Methods

createInterceptedMethodBody()

public static createInterceptedMethodBody(string $methodBody, MethodGenerator $method, PropertyGenerator $valueHolder, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors, ReflectionMethod|null $originalMethod) : string
Parameters
$methodBody : string

the body of the previously generated code. It MUST assign the return value to a variable $returnValue instead of directly returning

$method : MethodGenerator
$valueHolder : PropertyGenerator
$prefixInterceptors : PropertyGenerator
$suffixInterceptors : PropertyGenerator
$originalMethod : ReflectionMethod|null
Return values
string

Search results