<commit_before><?php

namespace wcf\data\page;

use wcf\data\DatabaseObjectDecorator;

/**
 * Represents a page node element.
 *
 * @author  <NAME>
 * @copyright   2001-2019 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\Data\Page
 * @since   3.0
 *
 * @method  Page    getDecoratedObject()
 * @mixin   Page
 */
class PageNode extends DatabaseObjectDecorator implements \Countable, \RecursiveIterator
{
    /**
     * parent node
     * @var PageNode
     */
    protected $parentNode;

    /**
     * children of this node
     * @var PageNode[]
     */
    protected $children = [];

    /**
     * node depth
     * @var int
     */
    protected $depth = 0;

    /**
     * iterator position
     * @var int
     */
    private $position = 0;

    /**
     * @inheritDoc
     */
    protected static $baseClass = Page::class;

    /**
     * Creates a new PageNode object.
     *
     * @param PageNode $parentNode
     * @param Page $page
     * @param int $depth
     */
    public function __construct($parentNode = null, ?Page $page = null, $depth = 0)
    {
        if ($page === null) {
            $page = new Page(null, []);
        }
        parent::__construct($page);

        $this->parentNode = $parentNode;
        $this->depth = $depth;
    }

    /**
     * Sets the children of this node.
     *
     * @param PageNode[] $children
     */
    public function setChildren(array $children)
    {
        $this->children = $children;
    }

    /**
     * Returns the parent node
     *
     * @return  PageNode
     */
    public function getParentNode()
    {
        return $this->parentNode;
    }

    /**
     * Returns the number of children.
     */
    public function count(): int
    {
        return \count($this->children);
    }

    /**
     * @inheritDoc
     */
    public function rewind()
    {
        $this->position = 0;
    }

    /**
     * @inheritDoc
     */
    public function valid()
    {
        return isset($this->children[$this->position]);
    }

    /**
     * @inheritDoc
     */
    public function next()
    {
        $this->position++;
    }

    /**
     * @inheritDoc
     */
    public function current()
    {
        return $this->children[$this->position];
    }

    /**
     * @inheritDoc
     */
    public function key()
    {
        return $this->position;
    }

    /**
     * @inheritDoc
     */
    public function getChildren()
    {
        return $this->children[$this->position];
    }

    /**
     * @inheritDoc
     */
    public function hasChildren()
    {
        return \count($this->children) > 0;
    }

    /**
     * Returns node depth.
     *
     * @return  int
     */
    public function getDepth()
    {
        return $this->depth;<commit_msg>Add parameter/return types to PageNode<commit_after><?php

namespace wcf\data\page;

use wcf\data\DatabaseObjectDecorator;

/**
 * Represents a page node element.
 *
 * @author  <NAME>
 * @copyright   2001-2019 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\Data\Page
 * @since   3.0
 *
 * @method  Page    getDecoratedObject()
 * @mixin   Page
 */
class PageNode extends DatabaseObjectDecorator implements \Countable, \RecursiveIterator
{
    /**
     * parent node
     * @var PageNode
     */
    protected $parentNode;

    /**
     * children of this node
     * @var PageNode[]
     */
    protected $children = [];

    /**
     * node depth
     */
    protected int $depth = 0;

    /**
     * iterator position
     */
    private int $position = 0;

    /**
     * @inheritDoc
     */
    protected static $baseClass = Page::class;

    /**
     * Creates a new PageNode object.
     *
     * @param PageNode $parentNode
     */
    public function __construct($parentNode = null, ?Page $page = null, int $depth = 0)
    {
        if ($page === null) {
            $page = new Page(null, []);
        }
        parent::__construct($page);

        $this->parentNode = $parentNode;
        $this->depth = $depth;
    }

    /**
     * Sets the children of this node.
     *
     * @param PageNode[] $children
     */
    public function setChildren(array $children): void
    {
        $this->children = $children;
    }

    /**
     * Returns the parent node
     */
    public function getParentNode(): PageNode
    {
        return $this->parentNode;
    }

    /**
     * Returns the number of children.
     */
    public function count(): int
    {
        return \count($this->children);
    }

    /**
     * @inheritDoc
     */
    public function rewind(): void
    {
        $this->position = 0;
    }

    /**
     * @inheritDoc
     */
    public function valid(): bool
    {
        return isset($this->children[$this->position]);
    }

    /**
     * @inheritDoc
     */
    public function next(): void
    {
        $this->position++;
    }

    /**
     * @inheritDoc
     */
    public function current(): PageNode
    {
        return $this->children[$this->position];
    }

    /**
     * @inheritDoc
     */
    public function key(): int
    {
        return $this->position;
    }

    /**
     * @inheritDoc
     */
    public function getChildren(): PageNode
    {
        return $this->children[$this->position];
    }

    /**
     * @inheritDoc
     */
    public function hasChildren(): bool
    {
        return \count($this->children) > 0;
    }

    /**
     * Returns node depth.
     */
    public function getDepth(): int
    {
        return $this->depth;
{'fraction_non_alphanumeric': 0.13628287135749823, 'fraction_numerical': 0.005330490405117271, 'mean_word_length': 1.7606669936243255, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 41, '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': '3629059', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1667, 'n_words': 392}