Skip to content

Commit 8b8c9e4

Browse files
authored
refactor: use array-key as the benevolent union of int|string in array shapes (#10396)
1 parent f9c71a7 commit 8b8c9e4

46 files changed

Lines changed: 85 additions & 112 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎system/API/TransformerInterface.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function transform(array|object|null $resource): array;
4343
/**
4444
* Transforms a collection of resources using $this->transform() on each item.
4545
*
46-
* @param array<int|string, mixed> $resources
46+
* @param array<array-key, mixed> $resources
4747
*
4848
* @return array<int, array<string, mixed>>
4949
*/

‎system/BaseModel.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ protected function objectToRawArray($object, bool $onlyChanged = true, bool $rec
18551855
*
18561856
* @param object|row_array|null $row
18571857
*
1858-
* @return array<int|string, mixed>
1858+
* @return array<array-key, mixed>
18591859
*
18601860
* @throws DataException
18611861
* @throws InvalidArgumentException
@@ -1947,7 +1947,7 @@ public function __isset(string $name): bool
19471947
/**
19481948
* Provides direct access to method in the database connection.
19491949
*
1950-
* @param array<int|string, mixed> $params
1950+
* @param array<array-key, mixed> $params
19511951
*
19521952
* @return mixed
19531953
*/

‎system/CLI/BaseCommand.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function __construct(LoggerInterface $logger, Commands $commands)
9999
/**
100100
* Actually execute a command.
101101
*
102-
* @param array<int|string, string|null> $params
102+
* @param array<array-key, string|null> $params
103103
*
104104
* @return int|void
105105
*/
@@ -108,7 +108,7 @@ abstract public function run(array $params);
108108
/**
109109
* Can be used by a command to run other commands.
110110
*
111-
* @param array<int|string, string|null> $params
111+
* @param array<array-key, string|null> $params
112112
*
113113
* @return int|void
114114
*

‎system/CLI/CLI.php‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ public static function prompt(string $field, $options = null, $validation = null
273273
/**
274274
* prompt(), but based on the option's key
275275
*
276-
* @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
277-
* and the second value the text before asking to select one option. Provide empty string to omit
278-
* @param array<int|string, string> $options A list of options (array(key => description)), the first option will be the default value
279-
* @param list<string>|string|null $validation Validation rules
276+
* @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
277+
* and the second value the text before asking to select one option. Provide empty string to omit
278+
* @param array<array-key, string> $options A list of options (array(key => description)), the first option will be the default value
279+
* @param list<string>|string|null $validation Validation rules
280280
*
281281
* @return string The selected key of $options
282282
*/
@@ -302,11 +302,11 @@ public static function promptByKey($text, array $options, $validation = null): s
302302
/**
303303
* This method is the same as promptByKey(), but this method supports multiple keys, separated by commas.
304304
*
305-
* @param string $text Output "field" text or an one or two value array where the first value is the text before listing the options
306-
* and the second value the text before asking to select one option. Provide empty string to omit
307-
* @param array<int|string, string> $options A list of options (array(key => description)), the first option will be the default value
305+
* @param string $text Output "field" text or an one or two value array where the first value is the text before listing the options
306+
* and the second value the text before asking to select one option. Provide empty string to omit
307+
* @param array<array-key, string> $options A list of options (array(key => description)), the first option will be the default value
308308
*
309-
* @return array<int|string, string> The selected key(s) and value(s) of $options
309+
* @return array<array-key, string> The selected key(s) and value(s) of $options
310310
*/
311311
public static function promptByMultipleKeys(string $text, array $options): array
312312
{
@@ -376,7 +376,7 @@ public static function promptByMultipleKeys(string $text, array $options): array
376376
/**
377377
* Validation for $options in promptByKey() and promptByMultipleKeys(). Return an error if $options is an empty array.
378378
*
379-
* @param array<int|string, string> $options
379+
* @param array<array-key, string> $options
380380
*/
381381
private static function isZeroOptions(array $options): void
382382
{
@@ -388,7 +388,7 @@ private static function isZeroOptions(array $options): void
388388
/**
389389
* Print each key and value one by one
390390
*
391-
* @param array<int|string, string> $options
391+
* @param array<array-key, string> $options
392392
*/
393393
private static function printKeysAndValues(array $options): void
394394
{
@@ -1029,8 +1029,8 @@ public static function getOptionString(bool $useLongOpts = false, bool $trim = f
10291029
/**
10301030
* Returns a well formatted table
10311031
*
1032-
* @param list<array<int|string, mixed>> $tbody List of rows
1033-
* @param list<string> $thead List of columns
1032+
* @param list<array<array-key, mixed>> $tbody List of rows
1033+
* @param list<string> $thead List of columns
10341034
*
10351035
* @return void
10361036
*/

‎system/CLI/Commands.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct($logger = null)
5454
/**
5555
* Runs a command given
5656
*
57-
* @param array<int|string, string|null> $params
57+
* @param array<array-key, string|null> $params
5858
*
5959
* @return int Exit code
6060
*/

‎system/CLI/Console.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public function showHeader(bool $suppress = false)
7474
* We'll remove that as an option from `$params` and
7575
* unshift it as argument instead.
7676
*
77-
* @param array<int|string, string|null> $params
77+
* @param array<array-key, string|null> $params
7878
*
79-
* @return array<int|string, string|null>
79+
* @return array<array-key, string|null>
8080
*/
8181
private function parseParamsForHelpOption(array $params): array
8282
{

‎system/CLI/GeneratorTrait.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ trait GeneratorTrait
9696
*
9797
* @internal
9898
*
99-
* @var array<int|string, string|null>
99+
* @var array<array-key, string|null>
100100
*/
101101
private $params = [];
102102

103103
/**
104104
* Execute the command.
105105
*
106-
* @param array<int|string, string|null> $params
106+
* @param array<array-key, string|null> $params
107107
*
108108
* @deprecated use generateClass() instead
109109
*/
@@ -115,7 +115,7 @@ protected function execute(array $params): void
115115
/**
116116
* Generates a class file from an existing template.
117117
*
118-
* @param array<int|string, string|null> $params
118+
* @param array<array-key, string|null> $params
119119
*/
120120
protected function generateClass(array $params): void
121121
{
@@ -138,8 +138,8 @@ protected function generateClass(array $params): void
138138
/**
139139
* Generate a view file from an existing template.
140140
*
141-
* @param string $view namespaced view name that is generated
142-
* @param array<int|string, string|null> $params
141+
* @param string $view namespaced view name that is generated
142+
* @param array<array-key, string|null> $params
143143
*/
144144
protected function generateView(string $view, array $params): void
145145
{

‎system/Commands/Database/MigrateRefresh.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class MigrateRefresh extends BaseCommand
7272
*/
7373
public function run(array $params)
7474
{
75-
$params['b'] = 0;
75+
$params['b'] = '0';
7676

7777
if (ENVIRONMENT === 'production') {
7878
// @codeCoverageIgnoreStart

‎system/Commands/Database/MigrateStatus.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ class MigrateStatus extends BaseCommand
7777

7878
/**
7979
* Displays a list of all migrations and whether they've been run or not.
80-
*
81-
* @param array<string, mixed> $params
8280
*/
8381
public function run(array $params)
8482
{

‎system/Commands/Encryption/GenerateKey.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function generateRandomKey(string $prefix, int $length): string
127127
/**
128128
* Sets the new encryption key in your .env file.
129129
*
130-
* @param array<int|string, string|null> $params
130+
* @param array<array-key, string|null> $params
131131
*/
132132
protected function setNewEncryptionKey(string $key, array $params): bool
133133
{
@@ -144,7 +144,7 @@ protected function setNewEncryptionKey(string $key, array $params): bool
144144
/**
145145
* Checks whether to overwrite existing encryption key.
146146
*
147-
* @param array<int|string, string|null> $params
147+
* @param array<array-key, string|null> $params
148148
*/
149149
protected function confirmOverwrite(array $params): bool
150150
{

0 commit comments

Comments
 (0)