Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore new PHPStan error #103

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"symfony/console": "^6.2|^7.0"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^1.11",
"pestphp/pest": "^2.3",
"mockery/mockery": "^1.5",
"phpstan/phpstan-mockery": "^1.1"
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/Scrolling.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait Scrolling
/**
* Initialize scrolling.
*/
protected function initializeScrolling(int $highlighted = null): void
protected function initializeScrolling(?int $highlighted = null): void
{
$this->highlighted = $highlighted;

Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ trait Themes
*
* @throws \InvalidArgumentException
*/
public static function theme(string $name = null): string
public static function theme(?string $name = null): string
{
if ($name === null) {
return static::$theme;
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/TypedValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait TypedValue
/**
* Track the value as the user types.
*/
protected function trackTypedValue(string $default = '', bool $submit = true, callable $ignore = null): void
protected function trackTypedValue(string $default = '', bool $submit = true, ?callable $ignore = null): void
{
$this->typedValue = $default;

Expand Down
2 changes: 1 addition & 1 deletion src/Progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Progress extends Prompt
*/
public function __construct(public string $label, public iterable|int $steps, public string $hint = '')
{
$this->total = match (true) {
$this->total = match (true) { // @phpstan-ignore assign.propertyType
is_int($this->steps) => $this->steps,
is_countable($this->steps) => count($this->steps),
is_iterable($this->steps) => iterator_count($this->steps),
Expand Down
2 changes: 1 addition & 1 deletion src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Table extends Prompt
*
* @phpstan-param ($rows is null ? list<list<string>>|Collection<int, list<string>> : list<string|list<string>>|Collection<int, string|list<string>>) $headers
*/
public function __construct(array|Collection $headers = [], array|Collection $rows = null)
public function __construct(array|Collection $headers = [], array|Collection|null $rows = null)
{
if ($rows === null) {
$rows = $headers;
Expand Down
2 changes: 1 addition & 1 deletion src/Themes/Default/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function hint(string $message): self
*
* @return $this
*/
protected function when(mixed $value, callable $callback, callable $default = null): self
protected function when(mixed $value, callable $callback, ?callable $default = null): self
{
if ($value) {
$callback($this);
Expand Down
22 changes: 11 additions & 11 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
/**
* Prompt the user for text input.
*/
function text(string $label, string $placeholder = '', string $default = '', bool|string $required = false, Closure $validate = null, string $hint = ''): string
function text(string $label, string $placeholder = '', string $default = '', bool|string $required = false, ?Closure $validate = null, string $hint = ''): string
{
return (new TextPrompt($label, $placeholder, $default, $required, $validate, $hint))->prompt();
}

/**
* Prompt the user for input, hiding the value.
*/
function password(string $label, string $placeholder = '', bool|string $required = false, Closure $validate = null, string $hint = ''): string
function password(string $label, string $placeholder = '', bool|string $required = false, ?Closure $validate = null, string $hint = ''): string
{
return (new PasswordPrompt($label, $placeholder, $required, $validate, $hint))->prompt();
}
Expand All @@ -27,7 +27,7 @@ function password(string $label, string $placeholder = '', bool|string $required
* @param array<int|string, string>|Collection<int|string, string> $options
* @param true|string $required
*/
function select(string $label, array|Collection $options, int|string $default = null, int $scroll = 5, Closure $validate = null, string $hint = '', bool|string $required = true): int|string
function select(string $label, array|Collection $options, int|string|null $default = null, int $scroll = 5, ?Closure $validate = null, string $hint = '', bool|string $required = true): int|string
{
return (new SelectPrompt($label, $options, $default, $scroll, $validate, $hint, $required))->prompt();
}
Expand All @@ -39,15 +39,15 @@ function select(string $label, array|Collection $options, int|string $default =
* @param array<int|string>|Collection<int, int|string> $default
* @return array<int|string>
*/
function multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 5, bool|string $required = false, Closure $validate = null, string $hint = 'Use the space bar to select options.'): array
function multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 5, bool|string $required = false, ?Closure $validate = null, string $hint = 'Use the space bar to select options.'): array
{
return (new MultiSelectPrompt($label, $options, $default, $scroll, $required, $validate, $hint))->prompt();
}

/**
* Prompt the user to confirm an action.
*/
function confirm(string $label, bool $default = true, string $yes = 'Yes', string $no = 'No', bool|string $required = false, Closure $validate = null, string $hint = ''): bool
function confirm(string $label, bool $default = true, string $yes = 'Yes', string $no = 'No', bool|string $required = false, ?Closure $validate = null, string $hint = ''): bool
{
return (new ConfirmPrompt($label, $default, $yes, $no, $required, $validate, $hint))->prompt();
}
Expand All @@ -57,7 +57,7 @@ function confirm(string $label, bool $default = true, string $yes = 'Yes', strin
*
* @param array<string>|Collection<int, string>|Closure(string): array<string> $options
*/
function suggest(string $label, array|Collection|Closure $options, string $placeholder = '', string $default = '', int $scroll = 5, bool|string $required = false, Closure $validate = null, string $hint = ''): string
function suggest(string $label, array|Collection|Closure $options, string $placeholder = '', string $default = '', int $scroll = 5, bool|string $required = false, ?Closure $validate = null, string $hint = ''): string
{
return (new SuggestPrompt($label, $options, $placeholder, $default, $scroll, $required, $validate, $hint))->prompt();
}
Expand All @@ -68,7 +68,7 @@ function suggest(string $label, array|Collection|Closure $options, string $place
* @param Closure(string): array<int|string, string> $options
* @param true|string $required
*/
function search(string $label, Closure $options, string $placeholder = '', int $scroll = 5, Closure $validate = null, string $hint = '', bool|string $required = true): int|string
function search(string $label, Closure $options, string $placeholder = '', int $scroll = 5, ?Closure $validate = null, string $hint = '', bool|string $required = true): int|string
{
return (new SearchPrompt($label, $options, $placeholder, $scroll, $validate, $hint, $required))->prompt();
}
Expand All @@ -79,7 +79,7 @@ function search(string $label, Closure $options, string $placeholder = '', int $
* @param Closure(string): array<int|string, string> $options
* @return array<int|string>
*/
function multisearch(string $label, Closure $options, string $placeholder = '', int $scroll = 5, bool|string $required = false, Closure $validate = null, string $hint = 'Use the space bar to select options.'): array
function multisearch(string $label, Closure $options, string $placeholder = '', int $scroll = 5, bool|string $required = false, ?Closure $validate = null, string $hint = 'Use the space bar to select options.'): array
{
return (new MultiSearchPrompt($label, $options, $placeholder, $scroll, $required, $validate, $hint))->prompt();
}
Expand All @@ -100,7 +100,7 @@ function spin(Closure $callback, string $message = ''): mixed
/**
* Display a note.
*/
function note(string $message, string $type = null): void
function note(string $message, ?string $type = null): void
{
(new Note($message, $type))->display();
}
Expand Down Expand Up @@ -159,7 +159,7 @@ function outro(string $message): void
* @param array<int, string|array<int, string>>|Collection<int, string|array<int, string>> $headers
* @param array<int, array<int, string>>|Collection<int, array<int, string>> $rows
*/
function table(array|Collection $headers = [], array|Collection $rows = null): void
function table(array|Collection $headers = [], array|Collection|null $rows = null): void
{
(new Table($headers, $rows))->display();
}
Expand All @@ -174,7 +174,7 @@ function table(array|Collection $headers = [], array|Collection $rows = null): v
* @param ?Closure((TSteps is int ? int : value-of<TSteps>), Progress<TSteps>): TReturn $callback
* @return ($callback is null ? Progress<TSteps> : array<TReturn>)
*/
function progress(string $label, iterable|int $steps, Closure $callback = null, string $hint = ''): array|Progress
function progress(string $label, iterable|int $steps, ?Closure $callback = null, string $hint = ''): array|Progress
{
$progress = new Progress($label, $steps, $hint);

Expand Down