private function processSingleClass(
        array $advisors,
        StreamMetaData $metadata,
        ReflectionClass $class,
        bool $useStrictMode
    ): bool {
        $advices = $this->adviceMatcher->getAdvicesForClass($class, $advisors);

        if (empty($advices)) {
            // Fast return if there aren't any advices for that class
            return false;
        }

        // Sort advices in advance to keep the correct order in cache, and leave only keys for the cache
        $advices = AbstractJoinpoint::flatAndSortAdvices($advices);

        // Prepare new class name
        $newClassName = $class->getShortName() . AspectContainer::AOP_PROXIED_SUFFIX;

        // Replace original class name with new
        $this->adjustOriginalClass($class, $advices, $metadata, $newClassName);
        $newParentName = $class->getNamespaceName() . '\\' . $newClassName;

        // Prepare child Aop proxy
        $childProxyGenerator = $class->isTrait()
            ? new TraitProxyGenerator($class, $newParentName, $advices, $this->useParameterWidening)
            : new ClassProxyGenerator($class, $newParentName, $advices, $this->useParameterWidening);

        $refNamespace = new ReflectionFileNamespace($class->getFileName(), $class->getNamespaceName());
        foreach ($refNamespace->getNamespaceAliases() as $fqdn => $alias) {
            // Either we have a string or Identifier node
            if ($alias !== null) {
                $childProxyGenerator->addUse($fqdn, (string) $alias);
            } else {
                $childProxyGenerator->addUse($fqdn);
            }
        }

        $childCode = $childProxyGenerator->generate();

        if ($useStrictMode) {
            $childCode = 'declare(strict_types=1);' . PHP_EOL . $childCode;
        }

        $contentToInclude = $this->saveProxyToCache($class, $childCode);

        // Get last token for this class
        $lastClassToken = $class->getNode()->getAttribute('endTokenPos');

        $metadata->tokenStream[$lastClassToken][1] .= PHP_EOL . $contentToInclude;

        return true;
    }
private function processSingleClass(
        array $advisors,
        StreamMetaData $metadata,
        ReflectionClass $class,
        bool $useStrictMode
    ): bool {
        $advices = $this->adviceMatcher->getAdvicesForClass($class, $advisors);

        if (empty($advices)) {
            // Fast return if there aren't any advices for that class
            return false;
        }

        // Sort advices in advance to keep the correct order in cache, and leave only keys for the cache
        $advices = AbstractJoinpoint::flatAndSortAdvices($advices);

        // Prepare new class name
        $newClassName = $class->getShortName() . AspectContainer::AOP_PROXIED_SUFFIX;

        // Replace original class name with new
        $this->adjustOriginalClass($class, $advices, $metadata, $newClassName);
        $newParentName = $class->getNamespaceName() . '\\' . $newClassName;

        // Prepare child Aop proxy
        $childProxyGenerator = $class->isTrait()
            ? new TraitProxyGenerator($class, $newParentName, $advices, $this->useParameterWidening)
            : new ClassProxyGenerator($class, $newParentName, $advices, $this->useParameterWidening);

        $refNamespace = new ReflectionFileNamespace($class->getFileName(), $class->getNamespaceName());
        foreach ($refNamespace->getNamespaceAliases() as $fqdn => $alias) {
            // Either we have a string or Identifier node
            if ($alias !== null) {
                $childProxyGenerator->addUse($fqdn, (string) $alias);
            } else {
                $childProxyGenerator->addUse($fqdn);
            }
        }

        $childCode = $childProxyGenerator->generate();

        if ($useStrictMode) {
            $childCode = 'declare(strict_types=1);' . PHP_EOL . $childCode;
        }

        $contentToInclude = $this->saveProxyToCache($class, $childCode);

        // Get last token for this class
        $lastClassToken = $class->getNode()->getAttribute('endTokenPos');

        $metadata->tokenStream[$lastClassToken][1] .= PHP_EOL . $contentToInclude;

        return true;
    }
private function processSingleClass ( array $ advisors , StreamMetaData $ metadata , ReflectionClass $ class , bool $ useStrictMode ) : bool { $ advices = $ this -> adviceMatcher -> getAdvicesForClass ( $ class , $ advisors ) ; if ( empty ( $ advices ) ) { // Fast return if there aren't any advices for that class return false ; } // Sort advices in advance to keep the correct order in cache, and leave only keys for the cache $ advices = AbstractJoinpoint :: flatAndSortAdvices ( $ advices ) ; // Prepare new class name $ newClassName = $ class -> getShortName ( ) . AspectContainer :: AOP_PROXIED_SUFFIX ; // Replace original class name with new $ this -> adjustOriginalClass ( $ class , $ advices , $ metadata , $ newClassName ) ; $ newParentName = $ class -> getNamespaceName ( ) . '\\' . $ newClassName ; // Prepare child Aop proxy $ childProxyGenerator = $ class -> isTrait ( ) ? new TraitProxyGenerator ( $ class , $ newParentName , $ advices , $ this -> useParameterWidening ) : new ClassProxyGenerator ( $ class , $ newParentName , $ advices , $ this -> useParameterWidening ) ; $ refNamespace = new ReflectionFileNamespace ( $ class -> getFileName ( ) , $ class -> getNamespaceName ( ) ) ; foreach ( $ refNamespace -> getNamespaceAliases ( ) as $ fqdn => $ alias ) { // Either we have a string or Identifier node if ( $ alias !== null ) { $ childProxyGenerator -> addUse ( $ fqdn , ( string ) $ alias ) ; } else { $ childProxyGenerator -> addUse ( $ fqdn ) ; } } $ childCode = $ childProxyGenerator -> generate ( ) ; if ( $ useStrictMode ) { $ childCode = 'declare(strict_types=1);' . PHP_EOL . $ childCode ; } $ contentToInclude = $ this -> saveProxyToCache ( $ class , $ childCode ) ; // Get last token for this class $ lastClassToken = $ class -> getNode ( ) -> getAttribute ( 'endTokenPos' ) ; $ metadata -> tokenStream [ $ lastClassToken ] [ 1 ] .= PHP_EOL . $ contentToInclude ; return true ; }
Performs weaving of single class if needed, returns true if the class was processed

@param Advisor[]       $advisors List of advisors
@param StreamMetaData  $metadata
@param ReflectionClass $class
@param bool            $useStrictMode If the source file used strict mode, the proxy should too
@return bool
Performs weaving of single class if needed returns true if the class was processed