<commit_before><?php
/**
 * TjoAnnotationRouter library (https://github.com/tomphp/TjoAnnotationRouter)
 *
 * @link https://github.com/tomphp/TjoAnnotationRouter for the canonical source repository
 * @license http://opensource.org/licenses/MIT The MIT License (MIT)
 */

namespace TjoAnnotationRouter\Parser;

use ArrayObject;
use Zend\Code\Annotation\AnnotationCollection;
use Zend\Code\Annotation\AnnotationManager;
use Zend\Code\Reflection\ClassReflection;

/**
 * Parses the routing annotations for a given controller into Router config.
 *
 * @author <NAME> <<EMAIL>>
 */
class ControllerParser
{
    /**
     * The ZF2 annotation manager.
     *
     * @var AnnotationManager
     */
    protected $annotationManager;

    /**
     * Processes the annotations for the controller.
     *
     * @var ControllerAnnotationProcessor
     */
    protected $processor;

    /**
     * Inject the required objects.
     *
     * @param AnnotationManager $annotationManager
     */
    public function __construct(
        AnnotationManager $annotationManager,
        ControllerAnnotationProcessor $processor
    ) {
        $this->annotationManager = $annotationManager;
        $this->processor = $processor;
    }

    /**
     * Builds the config for a controller.
     *
     * @param  ClassReflection $reflection
     * @param  ArrayObject     $config
     * @return void
     */
    public function parseReflectedController(ClassReflection $reflection, ArrayObject $config)
    {
        $annotations = $reflection->getAnnotations($this->annotationManager);

        if ($annotations instanceof AnnotationCollection) {
            $this->processor->processController($annotations);
        }

        foreach ($reflection->getMethods() as $method) {
            $annotations = $method->getAnnotations($this->annotationManager);

            $this->processor->processMethod($method->getName(), $annotations, $config);
        }
    }
}<commit_msg>Only call process method if AnnotationCollection is found.<commit_after><?php
/**
 * TjoAnnotationRouter library (https://github.com/tomphp/TjoAnnotationRouter)
 *
 * @link https://github.com/tomphp/TjoAnnotationRouter for the canonical source repository
 * @license http://opensource.org/licenses/MIT The MIT License (MIT)
 */

namespace TjoAnnotationRouter\Parser;

use ArrayObject;
use Zend\Code\Annotation\AnnotationCollection;
use Zend\Code\Annotation\AnnotationManager;
use Zend\Code\Reflection\ClassReflection;

/**
 * Parses the routing annotations for a given controller into Router config.
 *
 * @author <NAME> <<EMAIL>>
 */
class ControllerParser
{
    /**
     * The ZF2 annotation manager.
     *
     * @var AnnotationManager
     */
    protected $annotationManager;

    /**
     * Processes the annotations for the controller.
     *
     * @var ControllerAnnotationProcessor
     */
    protected $processor;

    /**
     * Inject the required objects.
     *
     * @param AnnotationManager $annotationManager
     */
    public function __construct(
        AnnotationManager $annotationManager,
        ControllerAnnotationProcessor $processor
    ) {
        $this->annotationManager = $annotationManager;
        $this->processor = $processor;
    }

    /**
     * Builds the config for a controller.
     *
     * @param  ClassReflection $reflection
     * @param  ArrayObject     $config
     * @return void
     */
    public function parseReflectedController(ClassReflection $reflection, ArrayObject $config)
    {
        $annotations = $reflection->getAnnotations($this->annotationManager);

        if ($annotations instanceof AnnotationCollection) {
            $this->processor->processController($annotations);
        }

        foreach ($reflection->getMethods() as $method) {
            $annotations = $method->getAnnotations($this->annotationManager);

            if (!$annotations instanceof AnnotationCollection) {
                continue;
            }

            $this->processor->processMethod($method->getName(), $annotations, $config);
        }
    }
}
{'fraction_non_alphanumeric': 0.1059896475228001, 'fraction_numerical': 0.0004929751047572097, 'mean_word_length': 2.943634596695821, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3309034', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1011, 'n_words': 242}