Skip to content
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
36 changes: 20 additions & 16 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ public static function input(?string $prefix = null): string
* // Do not provide options but requires a valid email
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
*
* @param string $field Output "field" question
* @param list<int|string>|string $options String to a default value, array to a list of options (the first option will be the default value)
* @param array|string|null $validation Validation rules
* @param string $field Output "field" question
* @param list<int|string>|string $options String to a default value, array to a list of options (the first option will be the default value)
* @param list<string>|string|null $validation Validation rules
*
* @return string The user input
*/
Expand Down Expand Up @@ -273,10 +273,10 @@ public static function prompt(string $field, $options = null, $validation = null
/**
* prompt(), but based on the option's key
*
* @param array|string $text Output "field" text or an one or two value array where the first value is the text before listing the options
* and the second value the text before asking to select one option. Provide empty string to omit
* @param array $options A list of options (array(key => description)), the first option will be the default value
* @param array|string|null $validation Validation rules
* @param list<string>|string $text Output "field" text or an one or two value array where the first value is the text before listing the options
* and the second value the text before asking to select one option. Provide empty string to omit
* @param array<int|string, string> $options A list of options (array(key => description)), the first option will be the default value
* @param list<string>|string|null $validation Validation rules
*
* @return string The selected key of $options
*/
Expand All @@ -302,11 +302,11 @@ public static function promptByKey($text, array $options, $validation = null): s
/**
* This method is the same as promptByKey(), but this method supports multiple keys, separated by commas.
*
* @param string $text Output "field" text or an one or two value array where the first value is the text before listing the options
* and the second value the text before asking to select one option. Provide empty string to omit
* @param array $options A list of options (array(key => description)), the first option will be the default value
* @param string $text Output "field" text or an one or two value array where the first value is the text before listing the options
* and the second value the text before asking to select one option. Provide empty string to omit
* @param array<int|string, string> $options A list of options (array(key => description)), the first option will be the default value
*
* @return array The selected key(s) and value(s) of $options
* @return array<int|string, string> The selected key(s) and value(s) of $options
*/
public static function promptByMultipleKeys(string $text, array $options): array
{
Expand Down Expand Up @@ -375,6 +375,8 @@ public static function promptByMultipleKeys(string $text, array $options): array

/**
* Validation for $options in promptByKey() and promptByMultipleKeys(). Return an error if $options is an empty array.
*
* @param array<int|string, string> $options
*/
private static function isZeroOptions(array $options): void
{
Expand All @@ -385,6 +387,8 @@ private static function isZeroOptions(array $options): void

/**
* Print each key and value one by one
*
* @param array<int|string, string> $options
*/
private static function printKeysAndValues(array $options): void
{
Expand All @@ -404,9 +408,9 @@ private static function printKeysAndValues(array $options): void
/**
* Validate one prompt "field" at a time
*
* @param string $field Prompt "field" output
* @param string $value Input value
* @param array|string $rules Validation rules
* @param string $field Prompt "field" output
* @param string $value Input value
* @param list<string>|string $rules Validation rules
*/
protected static function validate(string $field, string $value, $rules): bool
{
Expand Down Expand Up @@ -1025,8 +1029,8 @@ public static function getOptionString(bool $useLongOpts = false, bool $trim = f
/**
* Returns a well formatted table
*
* @param array $tbody List of rows
* @param array $thead List of columns
* @param list<array<int|string, mixed>> $tbody List of rows
* @param list<string> $thead List of columns
*
* @return void
*/
Expand Down
2 changes: 2 additions & 0 deletions system/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public function showHeader(bool $suppress = false)
* unshift it as argument instead.
*
* @param array<int|string, string|null> $params
*
* @return array<int|string, string|null>
*/
private function parseParamsForHelpOption(array $params): array
{
Expand Down
2 changes: 1 addition & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 1837 errors
# total 1825 errors

includes:
- argument.type.neon
Expand Down
62 changes: 1 addition & 61 deletions utils/phpstan-baseline/missingType.iterableValue.neon
Original file line number Diff line number Diff line change
@@ -1,67 +1,7 @@
# total 1153 errors
# total 1141 errors

parameters:
ignoreErrors:
-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:isZeroOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:printKeysAndValues\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:promptByKey\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:promptByKey\(\) has parameter \$text with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:promptByKey\(\) has parameter \$validation with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:promptByMultipleKeys\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:promptByMultipleKeys\(\) return type has no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:prompt\(\) has parameter \$validation with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:table\(\) has parameter \$tbody with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:table\(\) has parameter \$thead with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\CLI\:\:validate\(\) has parameter \$rules with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/CLI.php

-
message: '#^Method CodeIgniter\\CLI\\Console\:\:parseParamsForHelpOption\(\) return type has no value type specified in iterable type array\.$#'
count: 1
path: ../../system/CLI/Console.php

-
message: '#^Method CodeIgniter\\CodeIgniter\:\:getPerformanceStats\(\) return type has no value type specified in iterable type array\.$#'
count: 1
Expand Down
Loading