This commit is contained in:
2025-05-12 14:25:25 +02:00
parent ab2db755ef
commit 9e378ca2b7
2719 changed files with 46505 additions and 60181 deletions

0
vendor/nunomaduro/termwind/LICENSE.md vendored Normal file → Executable file
View File

View File

@@ -1,33 +0,0 @@
# Well documented Makefiles
DEFAULT_GOAL := help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ [Docker]
start: ## Spin up the container
docker-compose up -d
stop: ## Shut down the containers
docker-compose down
build: ## Build all docker images
docker-compose build
##@ [Application]
composer: ## Run composer commands. Specify the command e.g. via "make composer ARGS="install|update|require <dependency>"
docker-compose run --rm app composer $(ARGS)
lint: ## Run the Linter
docker-compose run --rm app ./vendor/bin/pint -v
test-lint: ## Run the Linter Test
docker-compose run --rm app ./vendor/bin/pint --test -v
test-types: ## Run the PHPStan analysis
docker-compose run --rm app ./vendor/bin/phpstan analyse --ansi
test-unit: ## Run the Pest Test Suite
docker-compose run --rm app ./vendor/bin/pest --colors=always
test: ## Run the tests. Apply arguments via make test ARGS="--init"
make test-lint && make test-types && make test-unit

View File

@@ -10,20 +10,19 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-mbstring": "*",
"symfony/console": "^5.3.0|^6.0.0"
"symfony/console": "^6.4.15"
},
"require-dev": {
"ergebnis/phpstan-rules": "^1.0.",
"illuminate/console": "^8.0|^9.0",
"illuminate/support": "^8.0|^9.0",
"laravel/pint": "^1.0.0",
"pestphp/pest": "^1.21.0",
"pestphp/pest-plugin-mock": "^1.0",
"phpstan/phpstan": "^1.4.6",
"phpstan/phpstan-strict-rules": "^1.1.0",
"symfony/var-dumper": "^5.2.7|^6.0.0",
"illuminate/console": "^10.48.24",
"illuminate/support": "^10.48.24",
"laravel/pint": "^1.18.2",
"pestphp/pest": "^2.36.0",
"pestphp/pest-plugin-mock": "2.0.0",
"phpstan/phpstan": "^1.12.11",
"phpstan/phpstan-strict-rules": "^1.6.1",
"symfony/var-dumper": "^6.4.15",
"thecodingmachine/phpstan-strict-rules": "^1.0.0"
},
"autoload": {

View File

@@ -1,13 +0,0 @@
version: '3'
services:
app:
image: termwind-docker
container_name: termwind-docker
stdin_open: true
tty: true
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/usr/src/app

View File

@@ -1,11 +0,0 @@
FROM php:8.2-cli-alpine
# INSTALL AND UPDATE COMPOSER
COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN composer self-update
WORKDIR /usr/src/app
COPY . .
# INSTALL YOUR DEPENDENCIES
RUN composer install --prefer-dist

7
vendor/nunomaduro/termwind/pint.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"rules": {
"yoda_style": false,
"nullable_type_declaration": false,
"nullable_type_declaration_for_default_null_value": false
}
}

View File

@@ -5,10 +5,18 @@ require_once __DIR__.'/vendor/autoload.php';
use function Termwind\render;
render(<<<'HTML'
<div class="mx-2 my-1">
<div class="flex space-x-1">
<span class="flex-1 truncate">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Sunt illo et nisi omnis porro at, mollitia harum quas esse, aperiam dolorem ab recusandae fugiat nesciunt doloribus rem eaque nostrum itaque.</span>
<span class="text-green">DONE</span>
</div>
<div class="ml-2">
<pre>
──, ──,
/ \ / / / / \─│/ /
│─/\─/│─/ \─/│─/│──/\─/│─/\─/ │──/│──/
</pre>
<div class="px-1 bg-green-300 text-black">by ⚙️ Configured</div>
<div class="px-1 mt-1 bg-blue-300 text-black">{{ $version }}</div>
<em class="ml-1">
Create portable PHP CLI applications w/ PHP Micro
</em>
</div>
HTML);

View File

@@ -59,8 +59,6 @@ final class StyleToMethod
/**
* Converts the given style to a method name.
*
* @return Styles
*/
public function __invoke(string|int ...$arguments): Styles
{
@@ -98,6 +96,7 @@ final class StyleToMethod
return $this->__invoke(...$arguments);
}
// @phpstan-ignore-next-line
return $this->styles
->setStyle($this->style)
->$methodName(...array_reverse($arguments));

View File

@@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Termwind\Components;
final class Anchor extends Element
{
}
final class Anchor extends Element {}

View File

@@ -70,7 +70,7 @@ abstract class Element
public function toString(): string
{
if (is_array($this->content)) {
$inheritance = new InheritStyles();
$inheritance = new InheritStyles;
$this->content = implode('', $inheritance($this->content, $this->styles));
}
@@ -83,6 +83,7 @@ abstract class Element
public function __call(string $name, array $arguments): mixed
{
if (method_exists($this->styles, $name)) {
// @phpstan-ignore-next-line
$result = $this->styles->{$name}(...$arguments);
if (str_starts_with($name, 'get') || str_starts_with($name, 'has')) {

View File

@@ -9,6 +9,4 @@ use InvalidArgumentException;
/**
* @internal
*/
final class ColorNotFound extends InvalidArgumentException
{
}
final class ColorNotFound extends InvalidArgumentException {}

View File

@@ -9,6 +9,4 @@ use InvalidArgumentException;
/**
* @internal
*/
final class InvalidChild extends InvalidArgumentException
{
}
final class InvalidChild extends InvalidArgumentException {}

View File

@@ -9,6 +9,4 @@ use InvalidArgumentException;
/**
* @internal
*/
final class InvalidColor extends InvalidArgumentException
{
}
final class InvalidColor extends InvalidArgumentException {}

View File

@@ -9,6 +9,4 @@ use InvalidArgumentException;
/**
* @internal
*/
final class InvalidStyle extends InvalidArgumentException
{
}
final class InvalidStyle extends InvalidArgumentException {}

View File

@@ -14,7 +14,7 @@ if (! function_exists('Termwind\renderUsing')) {
/**
* Sets the renderer implementation.
*/
function renderUsing(OutputInterface|null $renderer): void
function renderUsing(?OutputInterface $renderer): void
{
Termwind::renderUsing($renderer);
}
@@ -24,9 +24,9 @@ if (! function_exists('Termwind\style')) {
/**
* Creates a new style.
*
* @param (Closure(Styles $renderable, string|int ...$arguments): Styles)|null $callback
* @param (Closure(Styles $renderable, string|int ...$arguments): Styles)|null $callback
*/
function style(string $name, Closure $callback = null): Style
function style(string $name, ?Closure $callback = null): Style
{
return StyleRepository::create($name, $callback);
}
@@ -58,7 +58,7 @@ if (! function_exists('Termwind\ask')) {
*
* @param iterable<array-key, string>|null $autocomplete
*/
function ask(string $question, iterable $autocomplete = null): mixed
function ask(string $question, ?iterable $autocomplete = null): mixed
{
return (new Question)->ask($question, $autocomplete);
}

View File

@@ -173,7 +173,6 @@ final class CodeRenderer
* Splits tokens into lines.
*
* @param array<int, array{0: string, 1: string}> $tokens
* @param int $startLine
* @return array<int, array<int, array{0: string, 1: non-empty-string}>>
*/
private function splitToLines(array $tokens, int $startLine): array
@@ -228,8 +227,6 @@ final class CodeRenderer
* Prepends line numbers into lines.
*
* @param array<int, string> $lines
* @param int $markLine
* @return string
*/
private function lineNumbers(array $lines, int $markLine): string
{

View File

@@ -122,7 +122,7 @@ final class TableRenderer
if ($child->isName('tr')) {
$rows = iterator_to_array($this->parseRow($child));
if (count($rows) > 0) {
$this->table->addRow(new TableSeparator());
$this->table->addRow(new TableSeparator);
$this->table->addRows($rows);
}
}
@@ -203,7 +203,7 @@ final class TableRenderer
$border = (int) $node->getAttribute('border');
for ($i = $border; $i--; $i > 0) {
yield new TableSeparator();
yield new TableSeparator;
}
}

View File

@@ -29,7 +29,7 @@ final class HtmlRenderer
*/
public function parse(string $html): Components\Element
{
$dom = new DOMDocument();
$dom = new DOMDocument;
if (strip_tags($html) === $html) {
return Termwind::span($html);

View File

@@ -27,9 +27,9 @@ final class Question
*/
private SymfonyQuestionHelper $helper;
public function __construct(SymfonyQuestionHelper $helper = null)
public function __construct(?SymfonyQuestionHelper $helper = null)
{
$this->helper = $helper ?? new QuestionHelper();
$this->helper = $helper ?? new QuestionHelper;
}
/**
@@ -37,7 +37,7 @@ final class Question
*/
public static function setStreamableInput(StreamableInputInterface|null $streamableInput): void
{
self::$streamableInput = $streamableInput ?? new ArgvInput();
self::$streamableInput = $streamableInput ?? new ArgvInput;
}
/**
@@ -45,7 +45,7 @@ final class Question
*/
public static function getStreamableInput(): StreamableInputInterface
{
return self::$streamableInput ??= new ArgvInput();
return self::$streamableInput ??= new ArgvInput;
}
/**
@@ -53,7 +53,7 @@ final class Question
*
* @param iterable<array-key, string>|null $autocomplete
*/
public function ask(string $question, iterable $autocomplete = null): mixed
public function ask(string $question, ?iterable $autocomplete = null): mixed
{
$html = (new HtmlRenderer)->parse($question)->toString();
@@ -73,7 +73,7 @@ final class Question
$currentHelper = $property->isInitialized($output)
? $property->getValue($output)
: new SymfonyQuestionHelper();
: new SymfonyQuestionHelper;
$property->setValue($output, new QuestionHelper);

View File

@@ -21,10 +21,9 @@ final class Styles
/**
* Creates a new style from the given arguments.
*
* @param (Closure(StylesValueObject $element, string|int ...$arguments): StylesValueObject)|null $callback
* @return Style
* @param (Closure(StylesValueObject $element, string|int ...$arguments): StylesValueObject)|null $callback
*/
public static function create(string $name, Closure $callback = null): Style
public static function create(string $name, ?Closure $callback = null): Style
{
self::$storage[$name] = $style = new Style(
$callback ?? static fn (StylesValueObject $styles) => $styles

View File

@@ -19,9 +19,9 @@ final class Terminal
/**
* Creates a new terminal instance.
*/
public function __construct(ConsoleTerminal $terminal = null)
public function __construct(?ConsoleTerminal $terminal = null)
{
$this->terminal = $terminal ?? new ConsoleTerminal();
$this->terminal = $terminal ?? new ConsoleTerminal;
}
/**

View File

@@ -25,7 +25,7 @@ final class Termwind
*/
public static function renderUsing(OutputInterface|null $renderer): void
{
self::$renderer = $renderer ?? new ConsoleOutput();
self::$renderer = $renderer ?? new ConsoleOutput;
}
/**
@@ -278,7 +278,7 @@ final class Termwind
*/
public static function getRenderer(): OutputInterface
{
return self::$renderer ??= new ConsoleOutput();
return self::$renderer ??= new ConsoleOutput;
}
/**

View File

@@ -14,9 +14,7 @@ final class Node
/**
* A value object with helper methods for working with DOM node.
*/
public function __construct(private \DOMNode $node)
{
}
public function __construct(private \DOMNode $node) {}
/**
* Gets the value of the node.
@@ -34,7 +32,7 @@ final class Node
public function getChildNodes(): Generator
{
foreach ($this->node->childNodes as $node) {
yield new static($node);
yield new self($node);
}
}
@@ -106,7 +104,7 @@ final class Node
$node = $this->node;
while ($node = $node->previousSibling) {
$node = new static($node);
$node = new self($node);
if ($node->isEmpty()) {
$node = $node->node;
@@ -121,7 +119,7 @@ final class Node
$node = $node->node;
}
return is_null($node) ? null : new static($node);
return is_null($node) ? null : new self($node);
}
/**
@@ -132,7 +130,7 @@ final class Node
$node = $this->node;
while ($node = $node->nextSibling) {
$node = new static($node);
$node = new self($node);
if ($node->isEmpty()) {
$node = $node->node;
@@ -147,7 +145,7 @@ final class Node
$node = $node->node;
}
return is_null($node) ? null : new static($node);
return is_null($node) ? null : new self($node);
}
/**

View File

@@ -16,7 +16,7 @@ final class Style
/**
* Creates a new value object instance.
*
* @param Closure(Styles $styles, string|int ...$argument): Styles $callback
* @param Closure(Styles $styles, string|int ...$argument): Styles $callback
*/
public function __construct(private Closure $callback, private string $color = '')
{

View File

@@ -15,6 +15,7 @@ use Termwind\Enums\Color;
use Termwind\Exceptions\ColorNotFound;
use Termwind\Exceptions\InvalidStyle;
use Termwind\Repositories\Styles as StyleRepository;
use function Termwind\terminal;
/**
@@ -49,11 +50,9 @@ final class Styles
private array $textModifiers = [],
private array $styleModifiers = [],
private array $defaultStyles = []
) {
}
) {}
/**
* @param Element $element
* @return $this
*/
public function setElement(Element $element): self
@@ -854,7 +853,7 @@ final class Styles
preg_match_all("/\n+/", $content, $matches);
$width *= count($matches[0] ?? []) + 1;
$width *= count($matches[0] ?? []) + 1; // @phpstan-ignore-line
$width += mb_strlen($matches[0][0] ?? '', 'UTF-8');
if ($length <= $width) {
@@ -940,7 +939,7 @@ final class Styles
/**
* Get the length of the text provided without the styling tags.
*/
public function getLength(string $text = null): int
public function getLength(?string $text = null): int
{
return mb_strlen(preg_replace(
self::STYLING_REGEX,
@@ -998,7 +997,6 @@ final class Styles
throw new InvalidStyle(sprintf('Style [%s] is invalid.', "w-$fraction"));
}
/** @@phpstan-ignore-next-line */
$width = (int) floor($width * $matches[1] / $matches[2]);
$width -= ($styles['ml'] ?? 0) + ($styles['mr'] ?? 0);
@@ -1030,7 +1028,7 @@ final class Styles
$width = count($matches) !== 3
? (int) $parentWidth
: (int) floor($width * $matches[1] / $matches[2]); //@phpstan-ignore-line
: (int) floor($width * $matches[1] / $matches[2]);
if ($maxWidth > 0) {
$width = min($maxWidth, $width);
@@ -1052,6 +1050,7 @@ final class Styles
preg_match_all(self::STYLING_REGEX, $text, $matches, PREG_OFFSET_CAPTURE);
$text = rtrim(mb_strimwidth(preg_replace(self::STYLING_REGEX, '', $text) ?? '', 0, $width, '', 'UTF-8'));
// @phpstan-ignore-next-line
foreach ($matches[0] ?? [] as [$part, $index]) {
$text = substr($text, 0, $index).$part.substr($text, $index, null);
}