<commit_before><?php

namespace Jackalope\NodeType;

use ArrayIterator;
use Exception;

use PHPCR\PropertyType;
use PHPCR\ValueFormatException;
use PHPCR\NodeType\NodeTypeInterface;
use PHPCR\NodeType\ConstraintViolationException;
use PHPCR\NodeType\NoSuchNodeTypeException;

/**
 * {@inheritDoc}
 *
 * In Jackalope, the only information stored and thus available at
 * instantiation is the list of declared supertype names, child node type names
 * and property definition instances acquired from the NodeTypeDefinition.
 * All other information in this class is deduced from this when requested.
 *
 * @api
 */
class NodeType extends NodeTypeDefinition implements NodeTypeInterface
{
    /**
     * Cache of the declared super NodeType instances so they need to be
     * instantiated only once.
     *
     * @var array
     */
    protected $declaredSupertypes = null;
    /**
     * Cache of the aggregated super node type names so they need to be
     * aggregated only once.
     * @var array
     */
    protected $superTypeNames = null;
    /**
     * Cache of the aggregated super NodeType instances so they need to be
     * instantiated only once.
     */
    protected $superTypes = null;
    /**
     * Cache of the collected property definitions so they need to be
     * instantiated only once.
     * @var array
     */
    protected $propertyDefinitions = null;
    /**
     * Cache of the aggregated child node definitions from this type and all
     * its super type so they need to be gathered and instantiated only once.
     * @var array
     */
    protected $childNodeDefinitions = null;

    /**
     * {@inheritDoc}
     *
     * @api
     */
    public function getSupertypes()
    {
        if (null === $this->superTypes) {
            $this->superTypes = array();
            foreach ($this->getDeclaredSupertypes() as $superType) {
                $this->superTypes[] = $superType;
                $this->superTypes = array_merge($this->superTypes, $superType->getSupertypes());
            }
        }
        return $this->superTypes;
    }

    /**
     * {@inheritDoc}
     *
     * @api
     */
    protected function getSupertypeNames()
    {
        if (null === $this->superTypeNames) {
            $this->superTypeNames = array();
            foreach ($this->getSupertypes() as $superType) {
                $this->superTypeNames[] = $superType->getName();
            }
        }
        return $this->superTypeNames;
    }

    /**
     * {@inheritDoc}
     *
     * @api
     */
    public function getDeclaredSupertypes()
    {
        if (null === $this->declaredSupertypes) {
            $this->declaredSupertypes = array();
            foreach ($this->declaredSuperTypeNames as $declaredSuperTypeName) {
                $this->declaredSupertypes[] = $this->nodeTypeManager->getNodeType($declaredSuperTypeName);
            }
        }
        return $this->declaredSupertypes;
    }

    /**
     * {@inheritDoc}
     *
     * @api
     */<commit_msg>jsr-333: make NodeType::getSupertypeNames public as its now part of the interface. strange that we already had the implementation...<commit_after><?php

namespace Jackalope\NodeType;

use ArrayIterator;
use Exception;

use PHPCR\PropertyType;
use PHPCR\ValueFormatException;
use PHPCR\NodeType\NodeTypeInterface;
use PHPCR\NodeType\ConstraintViolationException;
use PHPCR\NodeType\NoSuchNodeTypeException;

/**
 * {@inheritDoc}
 *
 * In Jackalope, the only information stored and thus available at
 * instantiation is the list of declared supertype names, child node type names
 * and property definition instances acquired from the NodeTypeDefinition.
 * All other information in this class is deduced from this when requested.
 *
 * @api
 */
class NodeType extends NodeTypeDefinition implements NodeTypeInterface
{
    /**
     * Cache of the declared super NodeType instances so they need to be
     * instantiated only once.
     *
     * @var array
     */
    protected $declaredSupertypes = null;
    /**
     * Cache of the aggregated super node type names so they need to be
     * aggregated only once.
     * @var array
     */
    protected $superTypeNames = null;
    /**
     * Cache of the aggregated super NodeType instances so they need to be
     * instantiated only once.
     */
    protected $superTypes = null;
    /**
     * Cache of the collected property definitions so they need to be
     * instantiated only once.
     * @var array
     */
    protected $propertyDefinitions = null;
    /**
     * Cache of the aggregated child node definitions from this type and all
     * its super type so they need to be gathered and instantiated only once.
     * @var array
     */
    protected $childNodeDefinitions = null;

    /**
     * {@inheritDoc}
     *
     * @api
     */
    public function getSupertypes()
    {
        if (null === $this->superTypes) {
            $this->superTypes = array();
            foreach ($this->getDeclaredSupertypes() as $superType) {
                $this->superTypes[] = $superType;
                $this->superTypes = array_merge($this->superTypes, $superType->getSupertypes());
            }
        }
        return $this->superTypes;
    }

    /**
     * {@inheritDoc}
     *
     * @api
     */
    public function getSupertypeNames()
    {
        if (null === $this->superTypeNames) {
            $this->superTypeNames = array();
            foreach ($this->getSupertypes() as $superType) {
                $this->superTypeNames[] = $superType->getName();
            }
        }
        return $this->superTypeNames;
    }

    /**
     * {@inheritDoc}
     *
     * @api
     */
    public function getDeclaredSupertypes()
    {
        if (null === $this->declaredSupertypes) {
            $this->declaredSupertypes = array();
            foreach ($this->declaredSuperTypeNames as $declaredSuperTypeName) {
                $this->declaredSupertypes[] = $this->nodeTypeManager->getNodeType($declaredSuperTypeName);
            }
        }
        return $this->declaredSupertypes;
    }

    /**
     * {@inheritDoc}
     *
     * @api
     */
{'fraction_non_alphanumeric': 0.10271508014393196, 'fraction_numerical': 0.0004906771344455348, 'mean_word_length': 2.310774228478614, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '506151', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1651, 'n_words': 485}