Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
111 lines
2.8 KiB
PHP
111 lines
2.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\Console\Helper;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
/**
|
|
* The TreeHelper class provides methods to display tree-like structures.
|
|
*
|
|
* @author Simon André <smn.andre@gmail.com>
|
|
*
|
|
* @implements \RecursiveIterator<int, TreeNode>
|
|
*/
|
|
final class TreeHelper implements \RecursiveIterator
|
|
{
|
|
/**
|
|
* @var \Iterator<int, TreeNode>
|
|
*/
|
|
private \Iterator $children;
|
|
|
|
private function __construct(
|
|
private readonly OutputInterface $output,
|
|
private readonly TreeNode $node,
|
|
private readonly TreeStyle $style,
|
|
) {
|
|
$this->children = new \IteratorIterator($this->node->getChildren());
|
|
$this->children->rewind();
|
|
}
|
|
|
|
public static function createTree(OutputInterface $output, string|TreeNode|null $root = null, iterable $values = [], ?TreeStyle $style = null): self
|
|
{
|
|
$node = $root instanceof TreeNode ? $root : new TreeNode($root ?? '');
|
|
|
|
return new self($output, TreeNode::fromValues($values, $node), $style ?? TreeStyle::default());
|
|
}
|
|
|
|
public function current(): TreeNode
|
|
{
|
|
return $this->children->current();
|
|
}
|
|
|
|
public function key(): int
|
|
{
|
|
return $this->children->key();
|
|
}
|
|
|
|
public function next(): void
|
|
{
|
|
$this->children->next();
|
|
}
|
|
|
|
public function rewind(): void
|
|
{
|
|
$this->children->rewind();
|
|
}
|
|
|
|
public function valid(): bool
|
|
{
|
|
return $this->children->valid();
|
|
}
|
|
|
|
public function hasChildren(): bool
|
|
{
|
|
if (null === $current = $this->current()) {
|
|
return false;
|
|
}
|
|
|
|
foreach ($current->getChildren() as $child) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function getChildren(): \RecursiveIterator
|
|
{
|
|
return new self($this->output, $this->current(), $this->style);
|
|
}
|
|
|
|
/**
|
|
* Recursively renders the tree to the output, applying the tree style.
|
|
*/
|
|
public function render(): void
|
|
{
|
|
$treeIterator = new \RecursiveTreeIterator($this);
|
|
|
|
$this->style->applyPrefixes($treeIterator);
|
|
|
|
$this->output->writeln($this->node->getValue());
|
|
|
|
$visited = new \SplObjectStorage();
|
|
foreach ($treeIterator as $node) {
|
|
$currentNode = $node instanceof TreeNode ? $node : $treeIterator->getInnerIterator()->current();
|
|
if (isset($visited[$currentNode])) {
|
|
throw new \LogicException(\sprintf('Cycle detected at node: "%s".', $currentNode->getValue()));
|
|
}
|
|
$visited[$currentNode] = true;
|
|
|
|
$this->output->writeln($node);
|
|
}
|
|
}
|
|
}
|