idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
52,700
protected function getJoinpointInvocationBody ( ReflectionMethod $ method ) : string { $ isStatic = $ method -> isStatic ( ) ; $ class = '\\' . __CLASS__ ; $ scope = $ isStatic ? 'static::class' : '$this' ; $ prefix = $ isStatic ? AspectContainer :: STATIC_METHOD_PREFIX : AspectContainer :: METHOD_PREFIX ; $ argumentLi...
Creates string definition for trait method body by method reflection
52,701
public function set ( string $ id , $ value , array $ tags = [ ] ) : void { $ this -> values [ $ id ] = $ value ; foreach ( $ tags as $ tag ) { $ this -> tags [ $ tag ] [ ] = $ id ; } }
Set a service into the container
52,702
public function share ( string $ id , Closure $ value , array $ tags = [ ] ) : void { $ value = function ( $ container ) use ( $ value ) { static $ sharedValue ; if ( $ sharedValue === null ) { $ sharedValue = $ value ( $ container ) ; } return $ sharedValue ; } ; $ this -> set ( $ id , $ value , $ tags ) ; }
Set a shared value in the container
52,703
public function get ( string $ id ) { if ( ! isset ( $ this -> values [ $ id ] ) ) { throw new OutOfBoundsException ( "Value {$id} is not defined in the container" ) ; } if ( $ this -> values [ $ id ] instanceof Closure ) { return $ this -> values [ $ id ] ( $ this ) ; } return $ this -> values [ $ id ] ; }
Return a service or value from the container
52,704
public function getByTag ( string $ tag ) : array { $ result = [ ] ; if ( isset ( $ this -> tags [ $ tag ] ) ) { foreach ( $ this -> tags [ $ tag ] as $ id ) { $ result [ $ id ] = $ this -> get ( $ id ) ; } } return $ result ; }
Return list of service tagged with marker
52,705
public function registerAspect ( Aspect $ aspect ) : void { $ refAspect = new ReflectionClass ( $ aspect ) ; $ this -> set ( "aspect.{$refAspect->name}" , $ aspect , [ 'aspect' ] ) ; $ this -> addResource ( $ refAspect -> getFileName ( ) ) ; }
Register an aspect in the container
52,706
public function isFresh ( int $ timestamp ) : bool { if ( ! $ this -> maxTimestamp && ! empty ( $ this -> resources ) ) { $ this -> maxTimestamp = max ( array_map ( 'filemtime' , $ this -> resources ) ) ; } return $ this -> maxTimestamp <= $ timestamp ; }
Checks the freshness of AOP cache
52,707
public function addUse ( string $ use , string $ useAlias = null ) : void { $ this -> generator -> addUse ( $ use , $ useAlias ) ; }
Adds use alias for this class
52,708
public static function injectJoinPoints ( string $ targetClassName ) : void { $ reflectionClass = new ReflectionClass ( $ targetClassName ) ; $ joinPointsProperty = $ reflectionClass -> getProperty ( JoinPointPropertyGenerator :: NAME ) ; $ joinPointsProperty -> setAccessible ( true ) ; $ advices = $ joinPointsProperty...
Inject advices into given class
52,709
public function generate ( ) : string { $ classCode = $ this -> generator -> generate ( ) ; return $ classCode . '\\' . __CLASS__ . '::injectJoinPoints(' . $ this -> generator -> getName ( ) . '::class);' ; }
Generates the source code of child class
52,710
protected static function wrapWithJoinPoints ( array $ classAdvices , string $ className ) : array { static $ accessor ; if ( ! isset ( $ accessor ) ) { $ aspectKernel = AspectKernel :: getInstance ( ) ; $ accessor = $ aspectKernel -> getContainer ( ) -> get ( 'aspect.advisor.accessor' ) ; } $ joinPoints = [ ] ; foreac...
Wrap advices with joinpoint object
52,711
protected function interceptMethods ( ReflectionClass $ originalClass , array $ methodNames ) : array { $ interceptedMethods = [ ] ; foreach ( $ methodNames as $ methodName ) { $ reflectionMethod = $ originalClass -> getMethod ( $ methodName ) ; $ methodBody = $ this -> getJoinpointInvocationBody ( $ reflectionMethod )...
Returns list of intercepted method generators for class by method names
52,712
protected function getJoinpointInvocationBody ( ReflectionMethod $ method ) : string { $ isStatic = $ method -> isStatic ( ) ; $ scope = $ isStatic ? 'static::class' : '$this' ; $ prefix = $ isStatic ? AspectContainer :: STATIC_METHOD_PREFIX : AspectContainer :: METHOD_PREFIX ; $ argumentList = new FunctionCallArgument...
Creates string definition for method body by method reflection
52,713
public function aroundFieldAccess ( FieldAccess $ fieldAccess ) { $ isRead = $ fieldAccess -> getAccessType ( ) == FieldAccess :: READ ; $ fieldAccess -> proceed ( ) ; if ( $ isRead ) { $ value = $ fieldAccess -> getValue ( ) ; } else { $ value = $ fieldAccess -> getValueToSet ( ) ; } echo "Calling After Interceptor fo...
Advice that controls an access to the properties
52,714
public function aroundCacheable ( MethodInvocation $ invocation ) { static $ memoryCache = [ ] ; $ time = microtime ( true ) ; $ obj = $ invocation -> getThis ( ) ; $ class = is_object ( $ obj ) ? get_class ( $ obj ) : $ obj ; $ key = $ class . ':' . $ invocation -> getMethod ( ) -> name ; if ( ! isset ( $ memoryCache ...
This advice intercepts an execution of cacheable methods
52,715
public function getCachePathForResource ( string $ resource ) { if ( ! $ this -> cacheDir ) { return false ; } return str_replace ( $ this -> appDir , $ this -> cacheDir , $ resource ) ; }
Returns cache path for requested file name
52,716
public function queryCacheState ( string $ resource = null ) : ? array { if ( $ resource === null ) { return $ this -> cacheState ; } if ( isset ( $ this -> newCacheState [ $ resource ] ) ) { return $ this -> newCacheState [ $ resource ] ; } if ( isset ( $ this -> cacheState [ $ resource ] ) ) { return $ this -> cacheS...
Tries to return an information for queried resource
52,717
public function flushCacheState ( bool $ force = false ) : void { if ( ( ! empty ( $ this -> newCacheState ) && is_writable ( $ this -> cacheDir ) ) || $ force ) { $ fullCacheMap = $ this -> newCacheState + $ this -> cacheState ; $ cachePath = substr ( var_export ( $ this -> cacheDir , true ) , 1 , - 1 ) ; $ rootPath =...
Flushes the cache state into the file
52,718
public static function getJoinPoint ( string $ functionName , array $ advices ) : FunctionInvocation { static $ accessor ; if ( $ accessor === null ) { $ accessor = AspectKernel :: getInstance ( ) -> getContainer ( ) -> get ( 'aspect.advisor.accessor' ) ; } $ filledAdvices = [ ] ; foreach ( $ advices as $ advisorName )...
Returns a joinpoint for specific function in the namespace
52,719
protected function getJoinpointInvocationBody ( ReflectionFunction $ function ) : string { $ class = '\\' . __CLASS__ ; $ argumentList = new FunctionCallArgumentListGenerator ( $ function ) ; $ argumentCode = $ argumentList -> generate ( ) ; $ return = 'return ' ; if ( $ function -> hasReturnType ( ) ) { $ returnType =...
Creates string definition for function method body by function reflection
52,720
public function enumerate ( ) : Iterator { $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( '*.php' ) -> in ( $ this -> getInPaths ( ) ) ; foreach ( $ this -> getExcludePaths ( ) as $ path ) { $ finder -> notPath ( $ path ) ; } $ iterator = $ finder -> getIterator ( ) ; if ( strpos ( PHP_OS , 'WIN' ) === 0 )...
Returns an enumerator for files
52,721
public function getFilter ( ) : Closure { $ rootDirectory = $ this -> rootDirectory ; $ includePaths = $ this -> includePaths ; $ excludePaths = $ this -> excludePaths ; return function ( SplFileInfo $ file ) use ( $ rootDirectory , $ includePaths , $ excludePaths ) { if ( $ file -> getExtension ( ) !== 'php' ) { retur...
Returns a filter callback for enumerating files
52,722
private function getInPaths ( ) : array { $ inPaths = [ ] ; foreach ( $ this -> includePaths as $ path ) { if ( strpos ( $ path , $ this -> rootDirectory , 0 ) === false ) { throw new UnexpectedValueException ( sprintf ( 'Path %s is not in %s' , $ path , $ this -> rootDirectory ) ) ; } $ path = str_replace ( '*' , '' ,...
Returns collection of directories to look at
52,723
private function getExcludePaths ( ) : array { $ excludePaths = [ ] ; foreach ( $ this -> excludePaths as $ path ) { $ path = str_replace ( '*' , '.*' , $ path ) ; $ excludePaths [ ] = '#' . str_replace ( $ this -> rootDirectory . '/' , '' , $ path ) . '#' ; } return $ excludePaths ; }
Returns the list of excluded paths
52,724
protected function resolveClassName ( Name $ name ) : Name { if ( strtolower ( $ name -> toString ( ) ) !== 'self' ) { return $ name ; } $ originalName = $ name ; $ name = clone $ originalName ; $ name -> setAttribute ( 'originalName' , $ originalName ) ; $ fullClassName = Name :: concat ( $ this -> namespace , $ this ...
Resolves self class name with value
52,725
private function resolveType ( $ node ) { if ( $ node instanceof Node \ NullableType ) { $ node -> type = $ this -> resolveType ( $ node -> type ) ; return $ node ; } if ( $ node instanceof Name ) { return $ this -> resolveClassName ( $ node ) ; } return $ node ; }
Helper method for resolving type nodes
52,726
public function proceed ( ) { if ( isset ( $ this -> advices [ $ this -> current ] ) ) { $ currentInterceptor = $ this -> advices [ $ this -> current ++ ] ; return $ currentInterceptor -> invoke ( $ this ) ; } if ( $ this -> closureToCall === null ) { $ this -> closureToCall = $ this -> reflectionMethod -> getClosure (...
Invokes original method and return result from it
52,727
private function removeMappingsFromTraits ( ClassMetadata $ metadata ) : void { $ traits = $ this -> getTraits ( $ metadata -> name ) ; foreach ( $ traits as $ trait ) { $ trait = new \ ReflectionClass ( $ trait ) ; foreach ( $ trait -> getProperties ( ) as $ property ) { $ name = $ property -> getName ( ) ; if ( isset...
Remove fields in Go! AOP proxied class metadata that are inherited from traits .
52,728
private function getTraits ( $ objectOrClass , $ autoload = true ) : array { if ( is_object ( $ objectOrClass ) ) { $ objectOrClass = get_class ( $ objectOrClass ) ; } if ( ! is_string ( $ objectOrClass ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Full qualified class name expected, got: "%s".' , gettype ( $...
Get ALL traits used by one class .
52,729
private function getConstructorBody ( array $ interceptedProperties ) : string { $ assocProperties = [ ] ; $ listProperties = [ ] ; foreach ( $ interceptedProperties as $ propertyName ) { $ assocProperties [ ] = " '{$propertyName}' => &\$target->{$propertyName}" ; $ listProperties [ ] = " \$target->{$prop...
Returns constructor code
52,730
public function getAdvicesForFunctions ( ReflectionFileNamespace $ namespace , array $ advisors ) : array { if ( ! $ this -> isInterceptFunctions ) { return [ ] ; } $ advices = [ ] ; foreach ( $ advisors as $ advisorId => $ advisor ) { if ( $ advisor instanceof Aop \ PointcutAdvisor ) { $ pointcut = $ advisor -> getPoi...
Returns list of function advices for namespace
52,731
public function getAdvicesForClass ( ReflectionClass $ class , array $ advisors ) : array { $ classAdvices = [ ] ; $ parentClass = $ class -> getParentClass ( ) ; $ originalClass = $ class ; if ( $ parentClass && strpos ( $ parentClass -> name , AspectContainer :: AOP_PROXIED_SUFFIX ) !== false ) { $ originalClass = $ ...
Return list of advices for class
52,732
private function getAdvicesFromAdvisor ( ReflectionClass $ class , Aop \ PointcutAdvisor $ advisor , string $ advisorId , Aop \ PointFilter $ filter ) : array { $ classAdvices = [ ] ; $ filterKind = $ filter -> getKind ( ) ; if ( $ filterKind & Aop \ PointFilter :: KIND_CLASS ) { if ( $ filter -> matches ( $ class ) ) ...
Returns list of advices from advisor and point filter
52,733
private function getIntroductionFromAdvisor ( ReflectionClass $ class , Aop \ IntroductionAdvisor $ advisor , string $ advisorId ) : array { $ classAdvices = [ ] ; if ( $ class -> isTrait ( ) ) { return $ classAdvices ; } $ introduction = $ advisor -> getAdvice ( ) ; $ introducedTrait = $ introduction -> getTrait ( ) ;...
Returns list of introduction advices from advisor
52,734
private function getFunctionAdvicesFromAdvisor ( ReflectionFileNamespace $ namespace , Aop \ PointcutAdvisor $ advisor , string $ advisorId , Aop \ PointFilter $ pointcut ) : array { $ functions = [ ] ; $ advices = [ ] ; $ listOfGlobalFunctions = get_defined_functions ( ) ; foreach ( $ listOfGlobalFunctions [ 'internal...
Returns list of function advices for specific namespace
52,735
public static function init ( array $ options , AspectContainer $ container ) : bool { $ loaders = spl_autoload_functions ( ) ; foreach ( $ loaders as & $ loader ) { $ loaderToUnregister = $ loader ; if ( is_array ( $ loader ) && ( $ loader [ 0 ] instanceof ClassLoader ) ) { $ originalLoader = $ loader [ 0 ] ; Annotati...
Initialize aspect autoloader and returns status whether initialization was successful or not
52,736
public function proceed ( ) { if ( isset ( $ this -> advices [ $ this -> current ] ) ) { $ currentInterceptor = $ this -> advices [ $ this -> current ++ ] ; return $ currentInterceptor -> invoke ( $ this ) ; } if ( $ this -> previousScope !== $ this -> instance ) { if ( $ this -> closureToCall === null ) { $ this -> cl...
Proceeds all registered advices for the static method and returns an invocation result
52,737
protected static function getStaticInvoker ( string $ className , string $ methodName ) : Closure { return function ( array $ args ) use ( $ className , $ methodName ) { return forward_static_call_array ( [ $ className , $ methodName ] , $ args ) ; } ; }
Returns static method invoker for the concrete method in the class
52,738
protected function matchPart ( Pointcut $ pointcut , $ point , $ context = null , $ instance = null , array $ arguments = null ) : bool { return $ pointcut -> matches ( $ point , $ context , $ instance , $ arguments ) && $ pointcut -> getClassFilter ( ) -> matches ( $ context ) ; }
Checks if point filter matches the point
52,739
public function transform ( StreamMetaData $ metadata ) : string { $ newExpressionFinder = new NodeFinderVisitor ( [ Node \ Expr \ New_ :: class ] ) ; $ traverser = new NodeTraverser ( ) ; $ traverser -> addVisitor ( $ newExpressionFinder ) ; $ traverser -> traverse ( $ metadata -> syntaxTree ) ; $ newExpressions = $ n...
Rewrites all new expressions with our implementation
52,740
protected static function construct ( string $ fullClassName , array $ arguments = [ ] ) : object { $ fullClassName = ltrim ( $ fullClassName , '\\' ) ; if ( ! isset ( self :: $ constructorInvocationsCache [ $ fullClassName ] ) ) { $ invocation = null ; $ dynamicInit = AspectContainer :: INIT_PREFIX . ':root' ; try { $...
Default implementation for accessing joinpoint or creating a new one on - fly
52,741
private function showRegisteredAspectsInfo ( SymfonyStyle $ io , array $ aspects ) : void { foreach ( $ aspects as $ aspect ) { $ this -> showAspectInfo ( $ io , $ aspect ) ; } }
Shows an information about registered aspects
52,742
private function showAspectInfo ( SymfonyStyle $ io , Aspect $ aspect ) : void { $ refAspect = new ReflectionObject ( $ aspect ) ; $ aspectName = $ refAspect -> getName ( ) ; $ io -> section ( $ aspectName ) ; $ io -> writeln ( 'Defined in: <info>' . $ refAspect -> getFileName ( ) . '</info>' ) ; $ docComment = $ refAs...
Displays an information about single aspect
52,743
private function showAspectPointcutsAndAdvisors ( SymfonyStyle $ io , Aspect $ aspect ) : void { $ container = $ this -> aspectKernel -> getContainer ( ) ; $ aspectLoader = $ container -> get ( 'aspect.loader' ) ; $ io -> writeln ( '<comment>Pointcuts and advices</comment>' ) ; $ aspectItems = $ aspectLoader -> load ( ...
Shows an information about aspect pointcuts and advisors
52,744
private function loadAdvisorsList ( AspectContainer $ aspectContainer ) : array { $ aspectLoader = $ aspectContainer -> get ( 'aspect.cached.loader' ) ; $ aspects = $ aspectLoader -> getUnloadedAspects ( ) ; foreach ( $ aspects as $ aspect ) { $ aspectLoader -> loadAndRegister ( $ aspect ) ; } $ advisors = $ aspectCont...
Collects list of advisors from the given aspect container
52,745
public static function serializeAdvice ( Closure $ adviceMethod ) : array { $ refAdvice = new ReflectionFunction ( $ adviceMethod ) ; return [ 'method' => $ refAdvice -> name , 'class' => $ refAdvice -> getClosureScopeClass ( ) -> name ] ; }
Serialize advice method into array
52,746
public static function unserializeAdvice ( array $ adviceData ) : Closure { $ aspectName = $ adviceData [ 'class' ] ; $ methodName = $ adviceData [ 'method' ] ; if ( ! isset ( static :: $ localAdvicesCache [ "$aspectName->$methodName" ] ) ) { $ aspect = AspectKernel :: getInstance ( ) -> getContainer ( ) -> getAspect (...
Unserialize an advice
52,747
final public function serialize ( ) : string { $ vars = array_filter ( get_object_vars ( $ this ) ) ; $ vars [ 'adviceMethod' ] = static :: serializeAdvice ( $ this -> adviceMethod ) ; return serialize ( $ vars ) ; }
Serializes an interceptor into string representation
52,748
final public function unserialize ( $ serialized ) : void { $ vars = unserialize ( $ serialized , [ 'allowed_classes' => false ] ) ; $ vars [ 'adviceMethod' ] = static :: unserializeAdvice ( $ vars [ 'adviceMethod' ] ) ; foreach ( $ vars as $ key => $ value ) { $ this -> $ key = $ value ; } }
Unserialize an interceptor from the string
52,749
protected static function configure ( AspectKernel $ kernel , string $ filterName , CachePathManager $ cacheManager ) : void { if ( self :: $ kernel !== null ) { throw new RuntimeException ( 'Filter injector can be configured only once.' ) ; } self :: $ kernel = $ kernel ; self :: $ options = $ kernel -> getOptions ( )...
Static configurator for filter
52,750
public static function rewrite ( $ originalResource , string $ originalDir = '' ) : string { static $ appDir , $ cacheDir , $ debug ; if ( $ appDir === null ) { extract ( self :: $ options , EXTR_IF_EXISTS ) ; } $ resource = ( string ) $ originalResource ; if ( $ resource [ 0 ] !== '/' ) { $ shouldCheckExistence = true...
Replace source path with correct one
52,751
public function transform ( StreamMetaData $ metadata ) : string { $ includeExpressionFinder = new NodeFinderVisitor ( [ Include_ :: class ] ) ; $ traverser = new NodeTraverser ( ) ; $ traverser -> addVisitor ( $ includeExpressionFinder ) ; $ traverser -> traverse ( $ metadata -> syntaxTree ) ; $ includeExpressions = $...
Wrap all includes into rewrite filter
52,752
public static function register ( string $ filterId = self :: FILTER_IDENTIFIER ) : void { if ( ! empty ( self :: $ filterId ) ) { throw new RuntimeException ( 'Stream filter already registered' ) ; } $ result = stream_filter_register ( $ filterId , __CLASS__ ) ; if ( $ result === false ) { throw new RuntimeException (...
Register current loader as stream filter in PHP
52,753
public static function transformCode ( StreamMetaData $ metadata ) : void { foreach ( self :: $ transformers as $ transformer ) { $ result = $ transformer -> transform ( $ metadata ) ; if ( $ result === SourceTransformer :: RESULT_ABORTED ) { break ; } } }
Transforms source code by passing it through all transformers
52,754
protected function getInterceptor ( BaseInterceptor $ metaInformation , Closure $ adviceCallback ) : Interceptor { $ adviceOrder = $ metaInformation -> order ; $ pointcutExpression = $ metaInformation -> value ; switch ( true ) { case ( $ metaInformation instanceof Annotation \ Before ) : return new Framework \ BeforeI...
Returns an interceptor instance by meta - type annotation and closure
52,755
public function getPointcut ( ) : Pointcut { if ( $ this -> pointcut === null ) { $ lexer = $ this -> container -> get ( 'aspect.pointcut.lexer' ) ; $ parser = $ this -> container -> get ( 'aspect.pointcut.parser' ) ; $ tokenStream = $ lexer -> lex ( $ this -> pointcutExpression ) ; $ this -> pointcut = $ parser -> par...
Get the Pointcut that drives this advisor .
52,756
private function getSource ( ) : string { $ transformedSource = '' ; foreach ( $ this -> tokenStream as $ token ) { $ transformedSource .= $ token [ 1 ] ?? $ token ; } return $ transformedSource ; }
Returns source code directly from tokens
52,757
private function setSource ( string $ newSource ) : void { $ rawTokens = token_get_all ( $ newSource ) ; foreach ( $ rawTokens as $ index => $ rawToken ) { $ this -> tokenStream [ $ index ] = is_array ( $ rawToken ) ? $ rawToken : [ T_STRING , $ rawToken ] ; } }
Sets the new source for this file
52,758
private static function getReader ( ) : Reader { if ( self :: $ annotationReader === null ) { self :: $ annotationReader = AspectKernel :: getInstance ( ) -> getContainer ( ) -> get ( 'aspect.annotation.reader' ) ; } return self :: $ annotationReader ; }
Returns an annotation reader
52,759
public function warmUp ( ) : void { $ options = $ this -> aspectKernel -> getOptions ( ) ; if ( empty ( $ options [ 'cacheDir' ] ) ) { throw new InvalidArgumentException ( 'Cache warmer require the `cacheDir` options to be configured' ) ; } $ enumerator = new Enumerator ( $ options [ 'appDir' ] , $ options [ 'includePa...
Warms up cache
52,760
protected function loadAspectKernel ( InputInterface $ input , OutputInterface $ output ) : void { $ loader = $ input -> getArgument ( 'loader' ) ; $ path = stream_resolve_include_path ( $ loader ) ; if ( ! is_readable ( $ path ) ) { throw new InvalidArgumentException ( "Invalid loader path: {$loader}" ) ; } ob_start (...
Loads aspect kernel .
52,761
public function init ( array $ options = [ ] ) { if ( $ this -> wasInitialized ) { return ; } $ this -> options = $ this -> normalizeOptions ( $ options ) ; define ( 'AOP_ROOT_DIR' , $ this -> options [ 'appDir' ] ) ; define ( 'AOP_CACHE_DIR' , $ this -> options [ 'cacheDir' ] ) ; $ container = $ this -> container = ne...
Init the kernel and make adjustments
52,762
protected function normalizeOptions ( array $ options ) : array { $ options = array_replace ( $ this -> getDefaultOptions ( ) , $ options ) ; $ options [ 'cacheDir' ] = PathResolver :: realpath ( $ options [ 'cacheDir' ] ) ; if ( ! $ options [ 'cacheDir' ] ) { throw new \ RuntimeException ( 'You need to provide valid c...
Normalizes options for the kernel
52,763
protected function registerTransformers ( ) : array { $ cacheManager = $ this -> getContainer ( ) -> get ( 'aspect.cache.path.manager' ) ; $ filterInjector = new FilterInjectorTransformer ( $ this , SourceTransformingLoader :: getId ( ) , $ cacheManager ) ; $ magicTransformer = new MagicConstantTransformer ( $ this ) ;...
Returns list of source transformers that will be applied to the PHP source
52,764
protected function addKernelResourcesToContainer ( AspectContainer $ container ) : void { $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 2 ) ; $ refClass = new ReflectionObject ( $ this ) ; $ container -> addResource ( $ trace [ 1 ] [ 'file' ] ) ; $ container -> addResource ( $ refClass -> getFileName ( ) ) ...
Add resources of kernel to the container
52,765
private function processTransformers ( StreamMetaData $ metadata ) : string { $ overallResult = self :: RESULT_ABSTAIN ; if ( $ this -> transformers instanceof Closure ) { $ delayedTransformers = $ this -> transformers ; $ this -> transformers = $ delayedTransformers ( ) ; } foreach ( $ this -> transformers as $ transf...
Iterates over transformers
52,766
public function registerLoaderExtension ( AspectLoaderExtension $ loader ) : void { $ targets = $ loader -> getTargets ( ) ; foreach ( $ targets as $ target ) { $ this -> loaders [ $ target ] [ ] = $ loader ; } }
Register an aspect loader extension
52,767
public function load ( Aspect $ aspect ) : array { $ loadedItems = [ ] ; $ refAspect = new \ ReflectionClass ( $ aspect ) ; if ( ! empty ( $ this -> loaders [ AspectLoaderExtension :: TARGET_CLASS ] ) ) { $ loadedItems += $ this -> loadFrom ( $ aspect , $ refAspect , $ this -> loaders [ AspectLoaderExtension :: TARGET_...
Loads an aspect with the help of aspect loaders but don t register it in the container
52,768
public function loadAndRegister ( Aspect $ aspect ) : void { $ loadedItems = $ this -> load ( $ aspect ) ; foreach ( $ loadedItems as $ itemId => $ item ) { if ( $ item instanceof Pointcut ) { $ this -> container -> registerPointcut ( $ item , $ itemId ) ; } if ( $ item instanceof Advisor ) { $ this -> container -> reg...
Loads and register all items of aspect in the container
52,769
public function getUnloadedAspects ( ) : array { $ unloadedAspects = [ ] ; foreach ( $ this -> container -> getByTag ( 'aspect' ) as $ aspect ) { if ( ! isset ( $ this -> loadedAspects [ get_class ( $ aspect ) ] ) ) { $ unloadedAspects [ ] = $ aspect ; } } return $ unloadedAspects ; }
Returns list of unloaded aspects in the container
52,770
protected function loadFrom ( Aspect $ aspect , Reflector $ reflector , array $ loaders ) : array { $ loadedItems = [ ] ; foreach ( $ loaders as $ loader ) { $ loaderKind = $ loader -> getKind ( ) ; switch ( $ loaderKind ) { case AspectLoaderExtension :: KIND_REFLECTION : if ( $ loader -> supports ( $ aspect , $ reflec...
Load definitions from specific aspect part into the aspect container
52,771
protected function getAnnotations ( Reflector $ reflector ) : array { switch ( true ) { case ( $ reflector instanceof ReflectionClass ) : return $ this -> annotationReader -> getClassAnnotations ( $ reflector ) ; case ( $ reflector instanceof ReflectionMethod ) : return $ this -> annotationReader -> getMethodAnnotation...
Return list of annotations for reflection point
52,772
protected function loadFromCache ( string $ fileName ) : array { $ content = file_get_contents ( $ fileName ) ; $ loadedItems = unserialize ( $ content ) ; return $ loadedItems ; }
Loads pointcuts and advisors from the file
52,773
protected function saveToCache ( array $ items , string $ fileName ) : void { $ content = serialize ( $ items ) ; $ directoryName = dirname ( $ fileName ) ; if ( ! is_dir ( $ directoryName ) ) { mkdir ( $ directoryName , $ this -> cacheFileMode , true ) ; } file_put_contents ( $ fileName , $ content , LOCK_EX ) ; chmod...
Save pointcuts and advisors to the file
52,774
final protected function parsePointcut ( Aspect $ aspect , $ reflection , string $ pointcutExpression ) : PointFilter { $ stream = $ this -> makeLexicalAnalyze ( $ aspect , $ reflection , $ pointcutExpression ) ; return $ this -> parseTokenStream ( $ reflection , $ pointcutExpression , $ stream ) ; }
General method for parsing pointcuts
52,775
private function makeLexicalAnalyze ( Aspect $ aspect , $ reflection , string $ pointcutExpression ) : TokenStream { try { $ resolvedThisPointcut = str_replace ( '$this' , \ get_class ( $ aspect ) , $ pointcutExpression ) ; $ stream = $ this -> pointcutLexer -> lex ( $ resolvedThisPointcut ) ; } catch ( RecognitionExce...
Performs lexical analyze of pointcut
52,776
private function parseTokenStream ( $ reflection , string $ pointcutExpression , TokenStream $ stream ) : PointFilter { try { $ pointcut = $ this -> pointcutParser -> parse ( $ stream ) ; } catch ( UnexpectedTokenException $ e ) { $ token = $ e -> getToken ( ) ; $ message = 'Unexpected token %s in the `%s` before %s, d...
Performs parsing of pointcut
52,777
private static function getDeclareErrorAdvice ( ) : Closure { static $ adviceMethod ; if ( ! $ adviceMethod ) { $ adviceMethod = function ( $ object , $ reflectorName , $ message , $ level = E_USER_NOTICE ) { $ class = is_string ( $ object ) ? $ object : get_class ( $ object ) ; $ message = vsprintf ( '[AOP Declare Err...
Returns an advice
52,778
public static function sortAdvices ( array $ advices ) : array { $ sortedAdvices = $ advices ; uasort ( $ sortedAdvices , function ( Advice $ first , Advice $ second ) { switch ( true ) { case $ first instanceof AdviceBefore && ! ( $ second instanceof AdviceBefore ) : return - 1 ; case $ first instanceof AdviceAround &...
Sorts advices by priority
52,779
public static function flatAndSortAdvices ( array $ advices ) : array { $ flattenAdvices = [ ] ; foreach ( $ advices as $ type => $ typedAdvices ) { foreach ( $ typedAdvices as $ name => $ concreteAdvices ) { if ( is_array ( $ concreteAdvices ) ) { $ flattenAdvices [ $ type ] [ $ name ] = array_keys ( self :: sortAdvic...
Replace concrete advices with list of ids
52,780
public function ensureScopeRule ( int $ stackLevel = 2 ) : void { $ property = $ this -> reflectionProperty ; $ isProtected = $ property -> isProtected ( ) ; $ isPrivate = $ property -> isPrivate ( ) ; if ( $ isProtected || $ isPrivate ) { $ backTrace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , $ stackLevel + 1 )...
Checks scope rules for accessing property
52,781
final public function & __invoke ( object $ instance , int $ accessType , & $ originalValue , $ newValue = NAN ) { if ( $ this -> level > 0 ) { $ this -> stackFrames [ ] = [ $ this -> instance , $ this -> accessType , & $ this -> value , & $ this -> newValue ] ; } try { ++ $ this -> level ; $ this -> current = 0 ; $ th...
Invokes current field access with all interceptors
52,782
private function adjustSelfTokens ( StreamMetaData $ metadata , array $ replacedNodes ) : void { foreach ( $ replacedNodes as $ replacedNode ) { $ position = $ replacedNode -> getAttribute ( 'startTokenPos' ) ; $ metadata -> tokenStream [ $ position ] [ 1 ] = $ replacedNode -> toString ( ) ; } }
Adjusts tokens in the source code
52,783
public function before ( string $ pointcutExpression , Closure $ adviceToInvoke ) : void { $ interceptor = new BeforeInterceptor ( $ adviceToInvoke , 0 , $ pointcutExpression ) ; $ this -> registerAdviceInContainer ( $ pointcutExpression , $ interceptor ) ; }
Declares the Before hook for specific pointcut expression
52,784
public function after ( string $ pointcutExpression , Closure $ adviceToInvoke ) : void { $ interceptor = new AfterInterceptor ( $ adviceToInvoke , 0 , $ pointcutExpression ) ; $ this -> registerAdviceInContainer ( $ pointcutExpression , $ interceptor ) ; }
Declares the After hook for specific pointcut expression
52,785
public function afterThrowing ( string $ pointcutExpression , Closure $ adviceToInvoke ) : void { $ interceptor = new AfterThrowingInterceptor ( $ adviceToInvoke , 0 , $ pointcutExpression ) ; $ this -> registerAdviceInContainer ( $ pointcutExpression , $ interceptor ) ; }
Declares the AfterThrowing hook for specific pointcut expression
52,786
public function around ( string $ pointcutExpression , Closure $ adviceToInvoke ) : void { $ interceptor = new AroundInterceptor ( $ adviceToInvoke , 0 , $ pointcutExpression ) ; $ this -> registerAdviceInContainer ( $ pointcutExpression , $ interceptor ) ; }
Declares the Around hook for specific pointcut expression
52,787
public function declareError ( string $ pointcutExpression , string $ message , int $ errorLevel = E_USER_ERROR ) : void { $ interceptor = new DeclareErrorInterceptor ( $ message , $ errorLevel , $ pointcutExpression ) ; $ this -> registerAdviceInContainer ( $ pointcutExpression , $ interceptor ) ; }
Declares the error message for specific pointcut expression with concrete error level
52,788
private function registerAdviceInContainer ( string $ pointcutExpression , Advice $ adviceToInvoke ) : void { $ this -> container -> registerAdvisor ( new LazyPointcutAdvisor ( $ this -> container , $ pointcutExpression , $ adviceToInvoke ) , $ this -> getPointcutId ( $ pointcutExpression ) ) ; }
General method to register advices
52,789
private function processSingleClass ( array $ advisors , StreamMetaData $ metadata , ReflectionClass $ class , bool $ useStrictMode ) : bool { $ advices = $ this -> adviceMatcher -> getAdvicesForClass ( $ class , $ advisors ) ; if ( empty ( $ advices ) ) { return false ; } $ advices = AbstractJoinpoint :: flatAndSortAd...
Performs weaving of single class if needed returns true if the class was processed
52,790
private function adjustOriginalClass ( ReflectionClass $ class , array $ advices , StreamMetaData $ streamMetaData , string $ newClassName ) : void { $ classNode = $ class -> getNode ( ) ; $ position = $ classNode -> getAttribute ( 'startTokenPos' ) ; do { if ( isset ( $ streamMetaData -> tokenStream [ $ position ] ) )...
Adjust definition of original class source to enable extending
52,791
private function processFunctions ( array $ advisors , StreamMetaData $ metadata , ReflectionFileNamespace $ namespace ) : bool { static $ cacheDirSuffix = '/_functions/' ; $ wasProcessedFunctions = false ; $ functionAdvices = $ this -> adviceMatcher -> getAdvicesForFunctions ( $ namespace , $ advisors ) ; $ cacheDir =...
Performs weaving of functions in the current namespace returns true if functions were processed false otherwise
52,792
private function saveProxyToCache ( ReflectionClass $ class , string $ childCode ) : string { static $ cacheDirSuffix = '/_proxies/' ; $ cacheDir = $ this -> cachePathManager -> getCacheDir ( ) . $ cacheDirSuffix ; $ relativePath = str_replace ( $ this -> options [ 'appDir' ] . DIRECTORY_SEPARATOR , '' , $ class -> get...
Save AOP proxy to the separate file anr returns the php source code for inclusion
52,793
private function loadAndRegisterAspects ( array $ unloadedAspects ) : void { foreach ( $ unloadedAspects as $ unloadedAspect ) { $ this -> aspectLoader -> loadAndRegister ( $ unloadedAspect ) ; } }
Utility method to load and register unloaded aspects
52,794
public function getClassFilter ( ) : PointFilter { if ( $ this -> classFilter === null ) { $ this -> classFilter = TruePointFilter :: getInstance ( ) ; } return $ this -> classFilter ; }
Return the class filter for this pointcut .
52,795
public function proceed ( ) { if ( isset ( $ this -> advices [ $ this -> current ] ) ) { $ currentInterceptor = $ this -> advices [ $ this -> current ++ ] ; return $ currentInterceptor -> invoke ( $ this ) ; } return $ this -> reflectionFunction -> invokeArgs ( $ this -> arguments ) ; }
Invokes original function and return result from it
52,796
public static function resolveFileName ( string $ fileName ) : string { $ suffix = '.php' ; $ pathParts = explode ( $ suffix , str_replace ( [ self :: $ rewriteToPath , DIRECTORY_SEPARATOR . '_proxies' ] , [ self :: $ rootPath , '' ] , $ fileName ) ) ; return $ pathParts [ 0 ] . $ suffix ; }
Resolves file name from the cache directory to the real application root dir
52,797
public function enterNode ( Node $ node ) { foreach ( $ this -> searchNodes as $ nodeClassName ) { if ( $ node instanceof $ nodeClassName ) { $ this -> foundNodes [ ] = $ node ; } } return null ; }
Called when entering a node .
52,798
public function parse ( $ str , $ context = null ) { $ this -> lexer -> setInput ( $ str ) ; $ this -> context = $ context ; $ rs = $ this -> parseInternal ( ) ; if ( null !== $ this -> lexer -> next ) { $ this -> syntaxError ( 'end of input' ) ; } return $ rs ; }
Parses the given input .
52,799
protected function match ( $ type ) { if ( ! $ this -> lexer -> isNext ( $ type ) ) { $ this -> syntaxError ( $ this -> lexer -> getName ( $ type ) ) ; } $ this -> lexer -> moveNext ( ) ; return $ this -> lexer -> token [ 0 ] ; }
Matches a token and returns its value .