<commit_before><?php

namespace WsdlToPhp\PhpGenerator\Element;

class PhpAnnotationBlock extends AbstractElement
{
    /**
     * @param string $name
     */
    public function __construct(array $annotations = array())
    {
        parent::__construct('_');
        $this->setAnnotations($annotations);
    }
    /**
     * @param string[]|array[]|PhpAnnotation[] $annotations
     * @throws \InvalidArgumentException
     * @return PhpAnnotationBlock
     */
    protected function setAnnotations(array $annotations)
    {
        if (!self::annotationsAreValid($annotations)) {
            throw new \InvalidArgumentException('Annotations are not valid');
        }
        $this->children = self::transformAnnotations($annotations);
        return $this;
    }
    /**
     * @param string[]|array[]|PhpAnnotation[] $annotations
     * @return PhpAnnotation[]
     */
    protected static function transformAnnotations(array $annotations)
    {
        $finalAnnotations = array();
        foreach ($annotations as $annotation) {
            $finalAnnotations[] = self::transformAnnotation($annotation);
        }
        return $finalAnnotations;
    }
    /**
     * @param string|array|PhpAnnotation $annotation
     * @return PhpAnnotation
     */
    protected static function transformAnnotation($annotation)
    {
        if ($annotation instanceof PhpAnnotation) {
            return $annotation;
        } elseif (is_array($annotation)) {
            return new PhpAnnotation(array_key_exists('name', $annotation) ? $annotation['name'] : PhpAnnotation::NO_NAME, $annotation['content']);
        }
        return new PhpAnnotation(PhpAnnotation::NO_NAME, $annotation);
    }
    /**
     * @param string[]|array[]|PhpAnnotation[] $annotations
     * @return bool
     */
    protected static function annotationsAreValid(array $annotations)
    {
        $valid = true;
        foreach ($annotations as $annotation) {
            $valid &= self::annotationIsValid($annotation);
        }
        return (bool)$valid;
    }
    /**
     * @param string|array|PhpAnnotation $annotation
     * @return bool
     */
    protected static function annotationIsValid($annotation)
    {
        return (is_string($annotation) && !empty($annotation)) || (is_array($annotation) && array_key_exists('content', $annotation)) || $annotation instanceof PhpAnnotation;
    }
    /**
     * @param mixed $child
     * @throws \InvalidArgumentException
     * @return PhpAnnotation
     */
    public function addChild($child)
    {
        if (!$this->childrenIsValid($child)) {
            return parent::addChild($child);
        }
        $this->children[] = $this->transformAnnotation($child);
        return $this;
    }
    /**
     * @see \WsdlToPhp\PhpGenerator\Element\AbstractElement::getPhpDeclaration()
     * @return string
     */
    public function getPhpDeclaration()
    {
        return '';
    }
    /**
     * defines authorized children element types
     * @return string[]
     */
    public function getChildrenTypes()
    {
        return array(
            'array',
            'string',
            'WsdlToPhp\\PhpGenerator\\Element\\PhpAnnotation',
        );
    }
    /**
     * Allows to generate content before children content is generated
     * @param int $indentation
     * @return string
     */
    public function getLineBeforeChildren($indentation = null)
    {
        return parent::OPEN_ANNOTATION;
    }
    /**
     * Allows to generate content after children content is generated
     * @param int $indentation
     * @return string
     */
    public function getLineAfterChildren($indentation = null)
    {
        return parent::CLOSE_ANNOTATION;
    }
}<commit_msg>fix issue when generating annotation block within another element with identation set<commit_after><?php

namespace WsdlToPhp\PhpGenerator\Element;

class PhpAnnotationBlock extends AbstractElement
{
    /**
     * @param string $name
     */
    public function __construct(array $annotations = array())
    {
        parent::__construct('_');
        $this->setAnnotations($annotations);
    }
    /**
     * @param string[]|array[]|PhpAnnotation[] $annotations
     * @throws \InvalidArgumentException
     * @return PhpAnnotationBlock
     */
    protected function setAnnotations(array $annotations)
    {
        if (!self::annotationsAreValid($annotations)) {
            throw new \InvalidArgumentException('Annotations are not valid');
        }
        $this->children = self::transformAnnotations($annotations);
        return $this;
    }
    /**
     * @param string[]|array[]|PhpAnnotation[] $annotations
     * @return PhpAnnotation[]
     */
    protected static function transformAnnotations(array $annotations)
    {
        $finalAnnotations = array();
        foreach ($annotations as $annotation) {
            $finalAnnotations[] = self::transformAnnotation($annotation);
        }
        return $finalAnnotations;
    }
    /**
     * @param string|array|PhpAnnotation $annotation
     * @return PhpAnnotation
     */
    protected static function transformAnnotation($annotation)
    {
        if ($annotation instanceof PhpAnnotation) {
            return $annotation;
        } elseif (is_array($annotation)) {
            return new PhpAnnotation(array_key_exists('name', $annotation) ? $annotation['name'] : PhpAnnotation::NO_NAME, $annotation['content']);
        }
        return new PhpAnnotation(PhpAnnotation::NO_NAME, $annotation);
    }
    /**
     * @param string[]|array[]|PhpAnnotation[] $annotations
     * @return bool
     */
    protected static function annotationsAreValid(array $annotations)
    {
        $valid = true;
        foreach ($annotations as $annotation) {
            $valid &= self::annotationIsValid($annotation);
        }
        return (bool)$valid;
    }
    /**
     * @param string|array|PhpAnnotation $annotation
     * @return bool
     */
    protected static function annotationIsValid($annotation)
    {
        return (is_string($annotation) && !empty($annotation)) || (is_array($annotation) && array_key_exists('content', $annotation)) || $annotation instanceof PhpAnnotation;
    }
    /**
     * @param mixed $child
     * @throws \InvalidArgumentException
     * @return PhpAnnotation
     */
    public function addChild($child)
    {
        if (!$this->childrenIsValid($child)) {
            return parent::addChild($child);
        }
        $this->children[] = $this->transformAnnotation($child);
        return $this;
    }
    /**
     * @see \WsdlToPhp\PhpGenerator\Element\AbstractElement::getPhpDeclaration()
     * @return string
     */
    public function getPhpDeclaration()
    {
        return '';
    }
    /**
     * defines authorized children element types
     * @return string[]
     */
    public function getChildrenTypes()
    {
        return array(
            'array',
            'string',
            'WsdlToPhp\\PhpGenerator\\Element\\PhpAnnotation',
        );
    }
    /**
     * Allows to generate content before children content is generated
     * @param int $indentation
     * @return string
     */
    public function getLineBeforeChildren($indentation = null)
    {
        return $this->getIndentedString(parent::OPEN_ANNOTATION, $indentation);
    }
    /**
     * Allows to generate content after children content is generated
     * @param int $indentation
     * @return string
     */
    public function getLineAfterChildren($indentation = null)
    {
        return $this->getIndentedString(parent::CLOSE_ANNOTATION, $indentation);
    }
}
{'fraction_non_alphanumeric': 0.11843840675283566, 'fraction_numerical': 0.0, 'mean_word_length': 2.624760994263862, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '2988180', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1961, 'n_words': 427}