docs: fix PHPDocs View

This commit is contained in:
Denny Septian Panggabean 2024-05-02 15:28:51 +07:00
parent 9d54096efa
commit 02ada60fb3
No known key found for this signature in database
GPG Key ID: 73E560439FD2054F
5 changed files with 68 additions and 224 deletions

View File

@ -9006,171 +9006,21 @@ $ignoreErrors[] = [
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:applyFilters\\(\\) has parameter \\$filters with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:objectToArray\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:objectToArray\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parse\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parsePair\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parsePair\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parseSingle\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:prepareReplacement\\(\\) has parameter \\$matches with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:replaceSingle\\(\\) has parameter \\$pattern with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Parser\\:\\:\\$dataContexts type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Parser\\:\\:\\$noparseBlocks type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/RendererInterface.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/RendererInterface.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/RendererInterface.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:__construct\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_defaultTemplate\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_prepArgs\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_prepArgs\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_setFromArray\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:generate\\(\\) has parameter \\$tableData with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) has parameter \\$array with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:setTemplate\\(\\) has parameter \\$template with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in an if condition, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$footing type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$function type has no signature specified for callable\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$heading type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$rows type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$template type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:getData\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
@ -9186,26 +9036,6 @@ $ignoreErrors[] = [
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$data type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$performanceData type has no value type specified in iterable type array\\.$#',
'count' => 1,
@ -9221,11 +9051,6 @@ $ignoreErrors[] = [
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$tempData type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/View.php',
];
$ignoreErrors[] = [
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
'count' => 2,
@ -15992,15 +15817,10 @@ $ignoreErrors[] = [
'path' => __DIR__ . '/tests/system/View/TableTest.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$array of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects array, string given\\.$#',
'message' => '#^Parameter \\#1 \\$array of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects array\\<int, string\\>, string given\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/View/TableTest.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$template of method CodeIgniter\\\\View\\\\Table\\:\\:setTemplate\\(\\) expects array, string given\\.$#',
'count' => 2,
'path' => __DIR__ . '/tests/system/View/TableTest.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#2 \\$columnLimit of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects int, string given\\.$#',
'count' => 1,

View File

@ -56,7 +56,7 @@ class Parser extends View
/**
* Stores extracted noparse blocks.
*
* @var array
* @var list<string>
*/
protected $noparseBlocks = [];
@ -72,7 +72,7 @@ class Parser extends View
* Stores the context for each data element
* when set by `setData` so the context is respected.
*
* @var array
* @var array<string, mixed>
*/
protected $dataContexts = [];
@ -99,6 +99,10 @@ class Parser extends View
*
* Parses pseudo-variables contained in the specified template view,
* replacing them with any data that has already been set.
*
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
*/
public function render(string $view, ?array $options = null, ?bool $saveData = null): string
{
@ -159,6 +163,10 @@ class Parser extends View
*
* Parses pseudo-variables contained in the specified string,
* replacing them with any data that has already been set.
*
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
*/
public function renderString(string $template, ?array $options = null, ?bool $saveData = null): string
{
@ -190,6 +198,7 @@ class Parser extends View
* so that the variable is correctly handled within the
* parsing itself, and contexts (including raw) are respected.
*
* @param array<string, mixed> $data
* @param non-empty-string|null $context The context to escape it for.
* If 'raw', no escaping will happen.
* @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context
@ -222,7 +231,8 @@ class Parser extends View
* Parses pseudo-variables contained in the specified template,
* replacing them with the data in the second param
*
* @param array $options Future options
* @param array<string, mixed> $data
* @param array<string, mixed> $options Future options
*/
protected function parse(string $template, array $data = [], ?array $options = null): string
{
@ -266,6 +276,8 @@ class Parser extends View
/**
* Parse a single key/value, extracting it
*
* @return array<string, string>
*/
protected function parseSingle(string $key, string $val): array
{
@ -280,6 +292,10 @@ class Parser extends View
* Parse a tag pair
*
* Parses tag pairs: {some_tag} string... {/some_tag}
*
* @param array<string, mixed> $data
*
* @return array<string, string>
*/
protected function parsePair(string $variable, array $data, string $template): array
{
@ -533,6 +549,8 @@ class Parser extends View
/**
* Callback used during parse() to apply any filters to the value.
*
* @param list<string> $matches
*/
protected function prepareReplacement(array $matches, string $replace, bool $escape = true): string
{
@ -586,6 +604,8 @@ class Parser extends View
/**
* Given a set of filters, will apply each of the filters in turn
* to $replace, and return the modified string.
*
* @param list<string> $filters
*/
protected function applyFilters(string $replace, array $filters): string
{
@ -708,9 +728,9 @@ class Parser extends View
* Converts an object to an array, respecting any
* toArray() methods on an object.
*
* @param array|bool|float|int|object|string|null $value
* @param array<string, mixed>|bool|float|int|object|string|null $value
*
* @return array|bool|float|int|string|null
* @return array<string, mixed>|bool|float|int|string|null
*/
protected function objectToArray($value)
{

View File

@ -24,10 +24,10 @@ interface RendererInterface
* Builds the output based upon a file name and any
* data that has already been set.
*
* @param array|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool $saveData Whether to save data for subsequent calls
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool $saveData Whether to save data for subsequent calls
*/
public function render(string $view, ?array $options = null, bool $saveData = false): string;
@ -35,17 +35,18 @@ interface RendererInterface
* Builds the output based upon a string and any
* data that has already been set.
*
* @param string $view The view contents
* @param array|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool $saveData Whether to save data for subsequent calls
* @param string $view The view contents
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool $saveData Whether to save data for subsequent calls
*/
public function renderString(string $view, ?array $options = null, bool $saveData = false): string;
/**
* Sets several pieces of view data at once.
*
* @param array<string, mixed> $data
* @param non-empty-string|null $context The context to escape it for.
* If 'raw', no escaping will happen.
* @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context

View File

@ -27,21 +27,21 @@ class Table
/**
* Data for table rows
*
* @var list<array>|list<list<array>>
* @var list<array<string, string>>|list<list<array<string, string>>>
*/
public $rows = [];
/**
* Data for table heading
*
* @var array
* @var array<int, mixed>
*/
public $heading = [];
/**
* Data for table footing
*
* @var array
* @var array<int, mixed>
*/
public $footing = [];
@ -62,7 +62,7 @@ class Table
/**
* Table layout template
*
* @var array
* @var array<string, string>
*/
public $template;
@ -95,7 +95,7 @@ class Table
/**
* Set the template from the table config file if it exists
*
* @param array $config (default: array())
* @param array<string, string> $config (default: array())
*/
public function __construct($config = [])
{
@ -108,7 +108,8 @@ class Table
/**
* Set the template
*
* @param array $template
* @param array<string, string> $template
* @phpstan-param array<string, string>|string $template
*
* @return bool
*/
@ -157,10 +158,10 @@ class Table
* columns. This allows a single array with many elements to be
* displayed in a table that has a fixed column count.
*
* @param array $array
* @param int $columnLimit
* @param list<string> $array
* @param int $columnLimit
*
* @return array|false
* @return array<int, mixed>|false
*/
public function makeColumns($array = [], $columnLimit = 0)
{
@ -260,7 +261,9 @@ class Table
*
* Ensures a standard associative array format for all cell data
*
* @return array<string, array>|list<array>
* @param array<int, mixed> $args
*
* @return array<string, array<string, mixed>>|list<array<string, mixed>>
*/
protected function _prepArgs(array $args)
{
@ -297,7 +300,7 @@ class Table
/**
* Generate the table
*
* @param array|BaseResult|null $tableData
* @param array<int, mixed>|BaseResult|null $tableData
*
* @return string
*/
@ -472,7 +475,7 @@ class Table
/**
* Set table data from an array
*
* @param array $data
* @param array<int, mixed> $data
*
* @return void
*/
@ -510,7 +513,7 @@ class Table
/**
* Default Template
*
* @return array
* @return array<string, string>
*/
protected function _defaultTemplate()
{

View File

@ -34,14 +34,14 @@ class View implements RendererInterface
/**
* Saved Data.
*
* @var array
* @var array<string, mixed>
*/
protected $data = [];
/**
* Data for the variables that are available in the Views.
*
* @var array|null
* @var array<string, mixed>|null
*/
protected $tempData;
@ -165,13 +165,13 @@ class View implements RendererInterface
* - cache Number of seconds to cache for
* - cache_name Name to use for cache
*
* @param string $view File name of the view source
* @param array|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool|null $saveData If true, saves data for subsequent calls,
* if false, cleans the data after displaying,
* if null, uses the config setting.
* @param string $view File name of the view source
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool|null $saveData If true, saves data for subsequent calls,
* if false, cleans the data after displaying,
* if null, uses the config setting.
*/
public function render(string $view, ?array $options = null, ?bool $saveData = null): string
{
@ -306,13 +306,13 @@ class View implements RendererInterface
* data that has already been set.
* Cache does not apply, because there is no "key".
*
* @param string $view The view contents
* @param array|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool|null $saveData If true, saves data for subsequent calls,
* if false, cleans the data after displaying,
* if null, uses the config setting.
* @param string $view The view contents
* @param array<string, mixed>|null $options Reserved for 3rd-party uses since
* it might be needed to pass additional info
* to other template engines.
* @param bool|null $saveData If true, saves data for subsequent calls,
* if false, cleans the data after displaying,
* if null, uses the config setting.
*/
public function renderString(string $view, ?array $options = null, ?bool $saveData = null): string
{