<commit_before><?php
namespace DoctrineORMModule\Form\Annotation;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;
use DoctrineModule\Form\Element;
use Zend\EventManager\EventInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\ListenerAggregateInterface;

class ElementAnnotationsListener implements ListenerAggregateInterface
{
    /**
     * @var AnnotationBuilder
     */
    protected $builder;

    /**
     * @var \Zend\Stdlib\CallbackHandler[]
     */
    protected $listeners = array();

    /**
     * Constructor. AnnotationBuilder is required for access to the ObjectManager
     * and the entity to retrieve class metadata.
     *
     * @param AnnotationBuilder $builder
     */
    public function __construct(AnnotationBuilder $builder)
    {
        $this->builder = $builder;
    }

    /**
     * Detach listeners
     *
     * @param  EventManagerInterface $events
     *
     * @return void
     */
    public function detach(EventManagerInterface $events)
    {
        foreach ($this->listeners as $index => $listener) {
            if (false !== $events->detach($listener)) {
                unset($this->listeners[$index]);
            }
        }
    }

    /**
     * Attach listeners
     *
     * @param  \Zend\EventManager\EventManagerInterface $events
     *
     * @return void
     */
    public function attach(EventManagerInterface $events)
    {
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleAttributesAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleFilterAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleRequiredAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleTypeAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleValidatorAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleToManyAnnotation'));
        $this->listeners[] = $events->attach('checkForExclude', array($this, 'handleExcludeAnnotation'));
    }

    /**
     * Handle ToOne relationships.
     *
     * @param \Zend\EventManager\EventInterface $event
     *
     * @return void
     */
    public function handleToOneAnnotation(EventInterface $event)
    {
        $annotation = $event->getParam('annotation');

        if (!($annotation instanceof ManyToOne || $annotation instanceof OneToOne)) {
            return;
        }

        $targetClass = $this->getTargetClass($event);

        if (!$targetClass) {
            return;
        }

        /** @var \ArrayObject $elementSpec */
        $elementSpec = $event->getParam('elementSpec');

        if (!isset($elementSpec['spec'])) {
            $elementSpec['spec'] = array();
        }<commit_msg>Added missing callback for handleToOneAnnotation.<commit_after><?php
namespace DoctrineORMModule\Form\Annotation;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;
use DoctrineModule\Form\Element;
use Zend\EventManager\EventInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\ListenerAggregateInterface;

class ElementAnnotationsListener implements ListenerAggregateInterface
{
    /**
     * @var AnnotationBuilder
     */
    protected $builder;

    /**
     * @var \Zend\Stdlib\CallbackHandler[]
     */
    protected $listeners = array();

    /**
     * Constructor. AnnotationBuilder is required for access to the ObjectManager
     * and the entity to retrieve class metadata.
     *
     * @param AnnotationBuilder $builder
     */
    public function __construct(AnnotationBuilder $builder)
    {
        $this->builder = $builder;
    }

    /**
     * Detach listeners
     *
     * @param  EventManagerInterface $events
     *
     * @return void
     */
    public function detach(EventManagerInterface $events)
    {
        foreach ($this->listeners as $index => $listener) {
            if (false !== $events->detach($listener)) {
                unset($this->listeners[$index]);
            }
        }
    }

    /**
     * Attach listeners
     *
     * @param  \Zend\EventManager\EventManagerInterface $events
     *
     * @return void
     */
    public function attach(EventManagerInterface $events)
    {
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleAttributesAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleFilterAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleRequiredAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleTypeAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleValidatorAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleToManyAnnotation'));
        $this->listeners[] = $events->attach('configureElement', array($this, 'handleToOneAnnotation'));
        $this->listeners[] = $events->attach('checkForExclude', array($this, 'handleExcludeAnnotation'));
    }

    /**
     * Handle ToOne relationships.
     *
     * @param \Zend\EventManager\EventInterface $event
     *
     * @return void
     */
    public function handleToOneAnnotation(EventInterface $event)
    {
        $annotation = $event->getParam('annotation');

        if (!($annotation instanceof ManyToOne || $annotation instanceof OneToOne)) {
            return;
        }

        $targetClass = $this->getTargetClass($event);

        if (!$targetClass) {
            return;
        }

        /** @var \ArrayObject $elementSpec */
        $elementSpec = $event->getParam('elementSpec');

        if (!isset($elementSpec['spec'])) {
            $elementSpec['spec'] = array();
        }
{'fraction_non_alphanumeric': 0.13510520487264674, 'fraction_numerical': 0.0, 'mean_word_length': 3.070830650354153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, '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': '6346785', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1683, 'n_words': 324}