Skip to content

Commit 02ada60

Browse files
committed
docs: fix PHPDocs View
1 parent 9d54096 commit 02ada60

File tree

5 files changed

+68
-224
lines changed

5 files changed

+68
-224
lines changed

phpstan-baseline.php

Lines changed: 1 addition & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -9006,171 +9006,21 @@
90069006
'count' => 1,
90079007
'path' => __DIR__ . '/system/View/Parser.php',
90089008
];
9009-
$ignoreErrors[] = [
9010-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:applyFilters\\(\\) has parameter \\$filters with no value type specified in iterable type array\\.$#',
9011-
'count' => 1,
9012-
'path' => __DIR__ . '/system/View/Parser.php',
9013-
];
9014-
$ignoreErrors[] = [
9015-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:objectToArray\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#',
9016-
'count' => 1,
9017-
'path' => __DIR__ . '/system/View/Parser.php',
9018-
];
9019-
$ignoreErrors[] = [
9020-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:objectToArray\\(\\) return type has no value type specified in iterable type array\\.$#',
9021-
'count' => 1,
9022-
'path' => __DIR__ . '/system/View/Parser.php',
9023-
];
9024-
$ignoreErrors[] = [
9025-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
9026-
'count' => 1,
9027-
'path' => __DIR__ . '/system/View/Parser.php',
9028-
];
9029-
$ignoreErrors[] = [
9030-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parse\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
9031-
'count' => 1,
9032-
'path' => __DIR__ . '/system/View/Parser.php',
9033-
];
9034-
$ignoreErrors[] = [
9035-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parsePair\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
9036-
'count' => 1,
9037-
'path' => __DIR__ . '/system/View/Parser.php',
9038-
];
9039-
$ignoreErrors[] = [
9040-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parsePair\\(\\) return type has no value type specified in iterable type array\\.$#',
9041-
'count' => 1,
9042-
'path' => __DIR__ . '/system/View/Parser.php',
9043-
];
9044-
$ignoreErrors[] = [
9045-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parseSingle\\(\\) return type has no value type specified in iterable type array\\.$#',
9046-
'count' => 1,
9047-
'path' => __DIR__ . '/system/View/Parser.php',
9048-
];
9049-
$ignoreErrors[] = [
9050-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:prepareReplacement\\(\\) has parameter \\$matches with no value type specified in iterable type array\\.$#',
9051-
'count' => 1,
9052-
'path' => __DIR__ . '/system/View/Parser.php',
9053-
];
9054-
$ignoreErrors[] = [
9055-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
9056-
'count' => 1,
9057-
'path' => __DIR__ . '/system/View/Parser.php',
9058-
];
9059-
$ignoreErrors[] = [
9060-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
9061-
'count' => 1,
9062-
'path' => __DIR__ . '/system/View/Parser.php',
9063-
];
90649009
$ignoreErrors[] = [
90659010
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:replaceSingle\\(\\) has parameter \\$pattern with no value type specified in iterable type array\\.$#',
90669011
'count' => 1,
90679012
'path' => __DIR__ . '/system/View/Parser.php',
90689013
];
9069-
$ignoreErrors[] = [
9070-
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
9071-
'count' => 1,
9072-
'path' => __DIR__ . '/system/View/Parser.php',
9073-
];
9074-
$ignoreErrors[] = [
9075-
'message' => '#^Property CodeIgniter\\\\View\\\\Parser\\:\\:\\$dataContexts type has no value type specified in iterable type array\\.$#',
9076-
'count' => 1,
9077-
'path' => __DIR__ . '/system/View/Parser.php',
9078-
];
9079-
$ignoreErrors[] = [
9080-
'message' => '#^Property CodeIgniter\\\\View\\\\Parser\\:\\:\\$noparseBlocks type has no value type specified in iterable type array\\.$#',
9081-
'count' => 1,
9082-
'path' => __DIR__ . '/system/View/Parser.php',
9083-
];
9084-
$ignoreErrors[] = [
9085-
'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
9086-
'count' => 1,
9087-
'path' => __DIR__ . '/system/View/RendererInterface.php',
9088-
];
9089-
$ignoreErrors[] = [
9090-
'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
9091-
'count' => 1,
9092-
'path' => __DIR__ . '/system/View/RendererInterface.php',
9093-
];
9094-
$ignoreErrors[] = [
9095-
'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
9096-
'count' => 1,
9097-
'path' => __DIR__ . '/system/View/RendererInterface.php',
9098-
];
9099-
$ignoreErrors[] = [
9100-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:__construct\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#',
9101-
'count' => 1,
9102-
'path' => __DIR__ . '/system/View/Table.php',
9103-
];
9104-
$ignoreErrors[] = [
9105-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_defaultTemplate\\(\\) return type has no value type specified in iterable type array\\.$#',
9106-
'count' => 1,
9107-
'path' => __DIR__ . '/system/View/Table.php',
9108-
];
9109-
$ignoreErrors[] = [
9110-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_prepArgs\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#',
9111-
'count' => 1,
9112-
'path' => __DIR__ . '/system/View/Table.php',
9113-
];
9114-
$ignoreErrors[] = [
9115-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_prepArgs\\(\\) return type has no value type specified in iterable type array\\.$#',
9116-
'count' => 1,
9117-
'path' => __DIR__ . '/system/View/Table.php',
9118-
];
9119-
$ignoreErrors[] = [
9120-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_setFromArray\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
9121-
'count' => 1,
9122-
'path' => __DIR__ . '/system/View/Table.php',
9123-
];
9124-
$ignoreErrors[] = [
9125-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:generate\\(\\) has parameter \\$tableData with no value type specified in iterable type array\\.$#',
9126-
'count' => 1,
9127-
'path' => __DIR__ . '/system/View/Table.php',
9128-
];
9129-
$ignoreErrors[] = [
9130-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) has parameter \\$array with no value type specified in iterable type array\\.$#',
9131-
'count' => 1,
9132-
'path' => __DIR__ . '/system/View/Table.php',
9133-
];
9134-
$ignoreErrors[] = [
9135-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) return type has no value type specified in iterable type array\\.$#',
9136-
'count' => 1,
9137-
'path' => __DIR__ . '/system/View/Table.php',
9138-
];
9139-
$ignoreErrors[] = [
9140-
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:setTemplate\\(\\) has parameter \\$template with no value type specified in iterable type array\\.$#',
9141-
'count' => 1,
9142-
'path' => __DIR__ . '/system/View/Table.php',
9143-
];
91449014
$ignoreErrors[] = [
91459015
'message' => '#^Only booleans are allowed in an if condition, string\\|null given\\.$#',
91469016
'count' => 1,
91479017
'path' => __DIR__ . '/system/View/Table.php',
91489018
];
9149-
$ignoreErrors[] = [
9150-
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$footing type has no value type specified in iterable type array\\.$#',
9151-
'count' => 1,
9152-
'path' => __DIR__ . '/system/View/Table.php',
9153-
];
91549019
$ignoreErrors[] = [
91559020
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$function type has no signature specified for callable\\.$#',
91569021
'count' => 1,
91579022
'path' => __DIR__ . '/system/View/Table.php',
91589023
];
9159-
$ignoreErrors[] = [
9160-
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$heading type has no value type specified in iterable type array\\.$#',
9161-
'count' => 1,
9162-
'path' => __DIR__ . '/system/View/Table.php',
9163-
];
9164-
$ignoreErrors[] = [
9165-
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$rows type has no value type specified in iterable type array\\.$#',
9166-
'count' => 1,
9167-
'path' => __DIR__ . '/system/View/Table.php',
9168-
];
9169-
$ignoreErrors[] = [
9170-
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$template type has no value type specified in iterable type array\\.$#',
9171-
'count' => 1,
9172-
'path' => __DIR__ . '/system/View/Table.php',
9173-
];
91749024
$ignoreErrors[] = [
91759025
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:getData\\(\\) return type has no value type specified in iterable type array\\.$#',
91769026
'count' => 1,
@@ -9186,26 +9036,6 @@
91869036
'count' => 1,
91879037
'path' => __DIR__ . '/system/View/View.php',
91889038
];
9189-
$ignoreErrors[] = [
9190-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
9191-
'count' => 1,
9192-
'path' => __DIR__ . '/system/View/View.php',
9193-
];
9194-
$ignoreErrors[] = [
9195-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
9196-
'count' => 1,
9197-
'path' => __DIR__ . '/system/View/View.php',
9198-
];
9199-
$ignoreErrors[] = [
9200-
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
9201-
'count' => 1,
9202-
'path' => __DIR__ . '/system/View/View.php',
9203-
];
9204-
$ignoreErrors[] = [
9205-
'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$data type has no value type specified in iterable type array\\.$#',
9206-
'count' => 1,
9207-
'path' => __DIR__ . '/system/View/View.php',
9208-
];
92099039
$ignoreErrors[] = [
92109040
'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$performanceData type has no value type specified in iterable type array\\.$#',
92119041
'count' => 1,
@@ -9221,11 +9051,6 @@
92219051
'count' => 1,
92229052
'path' => __DIR__ . '/system/View/View.php',
92239053
];
9224-
$ignoreErrors[] = [
9225-
'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$tempData type has no value type specified in iterable type array\\.$#',
9226-
'count' => 1,
9227-
'path' => __DIR__ . '/system/View/View.php',
9228-
];
92299054
$ignoreErrors[] = [
92309055
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
92319056
'count' => 2,
@@ -15992,15 +15817,10 @@
1599215817
'path' => __DIR__ . '/tests/system/View/TableTest.php',
1599315818
];
1599415819
$ignoreErrors[] = [
15995-
'message' => '#^Parameter \\#1 \\$array of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects array, string given\\.$#',
15820+
'message' => '#^Parameter \\#1 \\$array of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects array\\<int, string\\>, string given\\.$#',
1599615821
'count' => 1,
1599715822
'path' => __DIR__ . '/tests/system/View/TableTest.php',
1599815823
];
15999-
$ignoreErrors[] = [
16000-
'message' => '#^Parameter \\#1 \\$template of method CodeIgniter\\\\View\\\\Table\\:\\:setTemplate\\(\\) expects array, string given\\.$#',
16001-
'count' => 2,
16002-
'path' => __DIR__ . '/tests/system/View/TableTest.php',
16003-
];
1600415824
$ignoreErrors[] = [
1600515825
'message' => '#^Parameter \\#2 \\$columnLimit of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects int, string given\\.$#',
1600615826
'count' => 1,

system/View/Parser.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Parser extends View
5656
/**
5757
* Stores extracted noparse blocks.
5858
*
59-
* @var array
59+
* @var list<string>
6060
*/
6161
protected $noparseBlocks = [];
6262

@@ -72,7 +72,7 @@ class Parser extends View
7272
* Stores the context for each data element
7373
* when set by `setData` so the context is respected.
7474
*
75-
* @var array
75+
* @var array<string, mixed>
7676
*/
7777
protected $dataContexts = [];
7878

@@ -99,6 +99,10 @@ public function __construct(
9999
*
100100
* Parses pseudo-variables contained in the specified template view,
101101
* replacing them with any data that has already been set.
102+
*
103+
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
104+
* it might be needed to pass additional info
105+
* to other template engines.
102106
*/
103107
public function render(string $view, ?array $options = null, ?bool $saveData = null): string
104108
{
@@ -159,6 +163,10 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
159163
*
160164
* Parses pseudo-variables contained in the specified string,
161165
* replacing them with any data that has already been set.
166+
*
167+
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
168+
* it might be needed to pass additional info
169+
* to other template engines.
162170
*/
163171
public function renderString(string $template, ?array $options = null, ?bool $saveData = null): string
164172
{
@@ -190,6 +198,7 @@ public function renderString(string $template, ?array $options = null, ?bool $sa
190198
* so that the variable is correctly handled within the
191199
* parsing itself, and contexts (including raw) are respected.
192200
*
201+
* @param array<string, mixed> $data
193202
* @param non-empty-string|null $context The context to escape it for.
194203
* If 'raw', no escaping will happen.
195204
* @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context
@@ -222,7 +231,8 @@ public function setData(array $data = [], ?string $context = null): RendererInte
222231
* Parses pseudo-variables contained in the specified template,
223232
* replacing them with the data in the second param
224233
*
225-
* @param array $options Future options
234+
* @param array<string, mixed> $data
235+
* @param array<string, mixed> $options Future options
226236
*/
227237
protected function parse(string $template, array $data = [], ?array $options = null): string
228238
{
@@ -266,6 +276,8 @@ protected function parse(string $template, array $data = [], ?array $options = n
266276

267277
/**
268278
* Parse a single key/value, extracting it
279+
*
280+
* @return array<string, string>
269281
*/
270282
protected function parseSingle(string $key, string $val): array
271283
{
@@ -280,6 +292,10 @@ protected function parseSingle(string $key, string $val): array
280292
* Parse a tag pair
281293
*
282294
* Parses tag pairs: {some_tag} string... {/some_tag}
295+
*
296+
* @param array<string, mixed> $data
297+
*
298+
* @return array<string, string>
283299
*/
284300
protected function parsePair(string $variable, array $data, string $template): array
285301
{
@@ -533,6 +549,8 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f
533549

534550
/**
535551
* Callback used during parse() to apply any filters to the value.
552+
*
553+
* @param list<string> $matches
536554
*/
537555
protected function prepareReplacement(array $matches, string $replace, bool $escape = true): string
538556
{
@@ -586,6 +604,8 @@ public function shouldAddEscaping(string $key)
586604
/**
587605
* Given a set of filters, will apply each of the filters in turn
588606
* to $replace, and return the modified string.
607+
*
608+
* @param list<string> $filters
589609
*/
590610
protected function applyFilters(string $replace, array $filters): string
591611
{
@@ -708,9 +728,9 @@ public function removePlugin(string $alias)
708728
* Converts an object to an array, respecting any
709729
* toArray() methods on an object.
710730
*
711-
* @param array|bool|float|int|object|string|null $value
731+
* @param array<string, mixed>|bool|float|int|object|string|null $value
712732
*
713-
* @return array|bool|float|int|string|null
733+
* @return array<string, mixed>|bool|float|int|string|null
714734
*/
715735
protected function objectToArray($value)
716736
{

system/View/RendererInterface.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,29 @@ interface RendererInterface
2424
* Builds the output based upon a file name and any
2525
* data that has already been set.
2626
*
27-
* @param array|null $options Reserved for 3rd-party uses since
28-
* it might be needed to pass additional info
29-
* to other template engines.
30-
* @param bool $saveData Whether to save data for subsequent calls
27+
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
28+
* it might be needed to pass additional info
29+
* to other template engines.
30+
* @param bool $saveData Whether to save data for subsequent calls
3131
*/
3232
public function render(string $view, ?array $options = null, bool $saveData = false): string;
3333

3434
/**
3535
* Builds the output based upon a string and any
3636
* data that has already been set.
3737
*
38-
* @param string $view The view contents
39-
* @param array|null $options Reserved for 3rd-party uses since
40-
* it might be needed to pass additional info
41-
* to other template engines.
42-
* @param bool $saveData Whether to save data for subsequent calls
38+
* @param string $view The view contents
39+
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
40+
* it might be needed to pass additional info
41+
* to other template engines.
42+
* @param bool $saveData Whether to save data for subsequent calls
4343
*/
4444
public function renderString(string $view, ?array $options = null, bool $saveData = false): string;
4545

4646
/**
4747
* Sets several pieces of view data at once.
4848
*
49+
* @param array<string, mixed> $data
4950
* @param non-empty-string|null $context The context to escape it for.
5051
* If 'raw', no escaping will happen.
5152
* @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context

0 commit comments

Comments
 (0)