Skip to content

Commit

Permalink
chore: style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Dec 8, 2023
1 parent c3adf32 commit e534f66
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Components/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract class Element
final public function __construct(
protected OutputInterface $output,
protected array|string $content,
Styles $styles = null
?Styles $styles = null
) {
$this->styles = $styles ?? new Styles(defaultStyles: static::$defaultStyles);
$this->styles->setElement($this);
Expand Down
4 changes: 2 additions & 2 deletions src/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function renderUsing(?OutputInterface $renderer): void
*
* @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);
}
Expand Down Expand Up @@ -58,7 +58,7 @@ function terminal(): Terminal
*
* @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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Question
*/
private SymfonyQuestionHelper $helper;

public function __construct(SymfonyQuestionHelper $helper = null)
public function __construct(?SymfonyQuestionHelper $helper = null)
{
$this->helper = $helper ?? new QuestionHelper();
}
Expand All @@ -53,7 +53,7 @@ public static function getStreamableInput(): StreamableInputInterface
*
* @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();

Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class Styles
*
* @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
Expand Down
2 changes: 1 addition & 1 deletion src/Terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Termwind.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public static function getRenderer(): OutputInterface
* @param array<int, string|Element>|string $elements
* @return array<int, string|Element>
*/
private static function prepareElements($elements, string $styles = '', Closure $callback = null): array
private static function prepareElements($elements, string $styles = '', ?Closure $callback = null): array
{
if ($callback === null) {
$callback = static fn ($element): string|Element => $element;
Expand Down
2 changes: 1 addition & 1 deletion src/ValueObjects/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ private function applyStyling(string $content): string
/**
* 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,
Expand Down

0 comments on commit e534f66

Please sign in to comment.