diff --git a/phpstan.neon b/phpstan.neon index e6aa6bea..634d4818 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,5 +5,3 @@ parameters: paths: - src/ ignoreErrors: - - - identifier: missingType.iterableValue diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 00000000..dfe1cdd6 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml index c8cee210..baf06305 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,13 +1,14 @@ diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index c87cd8f5..817592cc 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -168,7 +168,7 @@ protected function deleteNodeModules(): bool /** * Runs the NPM install command. * - * @param array $output The variable to write the output to. + * @param array $output The variable to write the output to. * @param int $return The variable to write the return status code to. * @param bool $useLatest Whether to install the latest minor versions. * @return void diff --git a/src/View/Helper/BreadcrumbsHelper.php b/src/View/Helper/BreadcrumbsHelper.php index 974ce7e0..dec277b0 100644 --- a/src/View/Helper/BreadcrumbsHelper.php +++ b/src/View/Helper/BreadcrumbsHelper.php @@ -25,7 +25,7 @@ class BreadcrumbsHelper extends CoreBreadcrumbsHelper /** * Default attributes for the templates * - * @var array + * @var array> */ protected array $defaultAttributes = [ 'class' => [ @@ -47,7 +47,10 @@ public function render(array $attributes = [], array $separator = []): string } /** - * @inheritDoc + * {@inheritDoc} + * + * @param array|string|null $url URL of the crumb. + * @param array $options Array of options. These options will be used as HTML attributes of the crumb. */ public function add(string $content, array|string|null $url = null, array $options = []): static { @@ -59,7 +62,10 @@ public function add(string $content, array|string|null $url = null, array $optio } /** - * @inheritDoc + * {@inheritDoc} + * + * @param array|string|null, options?: array}> $crumbs Array of crumbs to add. + * @param array $options Shared options for all crumbs. */ public function addMany(array $crumbs, array $options = []): static { @@ -79,7 +85,10 @@ public function addMany(array $crumbs, array $options = []): static } /** - * @inheritDoc + * {@inheritDoc} + * + * @param array|string|null $url URL of the crumb. + * @param array $options Array of options. These options will be used as HTML attributes of the crumb. */ public function prepend(string $content, array|string|null $url = null, array $options = []): static { @@ -91,7 +100,10 @@ public function prepend(string $content, array|string|null $url = null, array $o } /** - * @inheritDoc + * {@inheritDoc} + * + * @param array|string|null $url URL of the crumb. + * @param array $options Array of options. These options will be used as HTML attributes of the crumb. */ public function insertAt(int $index, string $content, array|string|null $url = null, array $options = []): static { diff --git a/src/View/Helper/FlashHelper.php b/src/View/Helper/FlashHelper.php index a683f5bb..92c087d2 100644 --- a/src/View/Helper/FlashHelper.php +++ b/src/View/Helper/FlashHelper.php @@ -44,7 +44,7 @@ class FlashHelper extends Helper * "BootstrapUI." is prepended to the name so that the element is used from this plugin. * * @param string $key The [Flash.]key you are rendering in the view. - * @param array $options Additional options to use for the creation of this flash message. + * @param array $options Additional options to use for the creation of this flash message. * Supports the 'params', and 'element' keys that are used in the helper. * @return string|null Rendered flash message or null if flash key does not exist * in session. diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index 4be76c21..4b3522ec 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -69,7 +69,7 @@ class FormHelper extends CoreFormHelper /** * Form alignment types. * - * @var array + * @var array */ public const ALIGN_TYPES = [self::ALIGN_DEFAULT, self::ALIGN_HORIZONTAL, self::ALIGN_INLINE]; @@ -118,7 +118,7 @@ class FormHelper extends CoreFormHelper /** * Set on `Form::create()` to tell grid type. * - * @var array|null + * @var array|null */ protected ?array $grid = null; @@ -132,7 +132,7 @@ class FormHelper extends CoreFormHelper /** * Default Bootstrap string templates. * - * @var array + * @var array */ protected array $templates = [ 'error' => @@ -221,7 +221,7 @@ class FormHelper extends CoreFormHelper /** * Templates set per alignment type * - * @var array + * @var array> */ protected array $templateSet = [ 'default' => [ @@ -317,7 +317,7 @@ class FormHelper extends CoreFormHelper /** * Default Bootstrap widgets. * - * @var array + * @var array */ protected array $widgets = [ 'button' => 'BootstrapUI\View\Widget\ButtonWidget', @@ -533,8 +533,8 @@ public function control(string $fieldName, array $options = []): string * Modify options and templates based on spacing. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function spacingOptions(string $fieldName, array $options): array { @@ -562,8 +562,8 @@ protected function spacingOptions(string $fieldName, array $options): array * Modify the options for container templates. * * @param string|null $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function containerOptions(?string $fieldName, array $options): array { @@ -602,8 +602,8 @@ protected function containerOptions(?string $fieldName, array $options): array * Modify options for checkbox controls. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function checkboxOptions(string $fieldName, array $options): array { @@ -641,8 +641,8 @@ protected function checkboxOptions(string $fieldName, array $options): array * Modify options for radio controls. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function radioOptions(string $fieldName, array $options): array { @@ -692,8 +692,8 @@ protected function radioOptions(string $fieldName, array $options): array * Modify options for select controls. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function selectOptions(string $fieldName, array $options): array { @@ -762,8 +762,8 @@ protected function selectOptions(string $fieldName, array $options): array * Modify options for range controls. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function rangeOptions(string $fieldName, array $options): array { @@ -784,8 +784,8 @@ protected function rangeOptions(string $fieldName, array $options): array * Modify the options for labels. * * @param string|null $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function labelOptions(?string $fieldName, array $options): array { @@ -823,7 +823,7 @@ protected function labelOptions(?string $fieldName, array $options): array } if ($labelClasses) { - $options['label'] = $this->injectClasses($labelClasses, (array)$options['label']); + $options['label'] = $this->injectClasses($labelClasses, $options['label']); } } @@ -834,8 +834,8 @@ protected function labelOptions(?string $fieldName, array $options): array * Modify templates based on error style. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function feedbackStyleOptions(string $fieldName, array $options): array { @@ -871,8 +871,8 @@ protected function feedbackStyleOptions(string $fieldName, array $options): arra * Modify options for aria attributes. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function ariaOptions(string $fieldName, array $options): array { @@ -921,8 +921,8 @@ protected function ariaOptions(string $fieldName, array $options): array * Modify options for placeholders. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function placeholderOptions(string $fieldName, array $options): array { @@ -955,8 +955,8 @@ protected function placeholderOptions(string $fieldName, array $options): array * Modify options for control's help. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function helpOptions(string $fieldName, array $options): array { @@ -993,8 +993,8 @@ protected function helpOptions(string $fieldName, array $options): array * Modify options for control's tooltip. * * @param string $fieldName Field name. - * @param array $options Options. See `$options` argument of `control()` method. - * @return array + * @param array $options Options. See `$options` argument of `control()` method. + * @return array */ protected function tooltipOptions(string $fieldName, array $options): array { @@ -1019,8 +1019,8 @@ protected function tooltipOptions(string $fieldName, array $options): array * * @param string $html The form element HTML. * @param string|null $fieldName The field name. - * @param array $options The element generation options (see `$options` argument for `button()`, `submit()`, and - * `control()`). + * @param array $options The element generation options (see `$options` argument for `button()`, + * `submit()`, and `control()`). * @return string * @see button() * @see submit() @@ -1070,8 +1070,8 @@ public function multiCheckbox(string $fieldName, iterable $options, array $attri /** * Set options for radio and multi checkbox inputs. * - * @param array $attributes Attributes - * @return array + * @param array $attributes Attributes + * @return array */ protected function multiInputAttributes(array $attributes): array { @@ -1094,7 +1094,7 @@ protected function multiInputAttributes(array $attributes): array * Creates a color input. * * @param string $fieldName The field name. - * @param array $options Array of options or HTML attributes. + * @param array $options Array of options or HTML attributes. * @return string */ public function color(string $fieldName, array $options = []): string @@ -1124,7 +1124,7 @@ public function end(array $secureAttributes = []): string * in a hidden input. Defaults to true. * * @param string $fieldName Name of a field, like this "modelname.fieldname" - * @param array $options Array of HTML attributes. + * @param array $options Array of HTML attributes. * @return string An HTML text input element. */ public function staticControl(string $fieldName, array $options = []): string @@ -1169,7 +1169,11 @@ public function staticControl(string $fieldName, array $options = []): string } /** - * @inheritDoc + * {@inheritDoc} + * + * @param array $options The options for the input element. + * @return array|string The generated input element, or an array of input markup if `checkbox()` + * is called with the `hiddenField` option set to `_split`. */ protected function getInput(string $fieldName, array $options): array|string { @@ -1236,8 +1240,8 @@ protected function parseOptions(string $fieldName, array $options): array * * Handles per-form scoped tasks like form alignment detection/switching. * - * @param array $options Options. - * @return array Modified options. + * @param array $options Options. + * @return array Modified options. */ protected function processFormOptions(array $options): array { @@ -1364,7 +1368,7 @@ protected function gridClass(int $columnIndex, bool $offset = false): string /** * Detects the form alignment when possible. * - * @param array $options Options. + * @param array $options Options. * @return string Form alignment type. One of `default`, `horizontal` or `inline`. */ protected function detectFormAlignment(array $options): string diff --git a/src/View/Helper/HtmlHelper.php b/src/View/Helper/HtmlHelper.php index 969476d5..cf4ffeff 100644 --- a/src/View/Helper/HtmlHelper.php +++ b/src/View/Helper/HtmlHelper.php @@ -23,7 +23,7 @@ class HtmlHelper extends CoreHtmlHelper * size `lg` class '-lg` will be added. Default null. * * @param \Cake\View\View $View The View this helper is being attached to. - * @param array $config Configuration settings for the helper. + * @param array $config Configuration settings for the helper. */ public function __construct(View $View, array $config = []) { @@ -45,7 +45,7 @@ public function __construct(View $View, array $config = []) * - `tag`: The HTML tag to use for the badge. Default `span`. * * @param string $text Text to show in badge. - * @param array $options Additional options and HTML attributes. + * @param array $options Additional options and HTML attributes. * @return string HTML badge markup. */ public function badge(string $text, array $options = []): string @@ -82,7 +82,7 @@ public function badge(string $text, array $options = []): string * for above options. * * @param string $name Name of icon (i.e. `search`, `exclamation`, etc.). - * @param array $options Additional options and HTML attributes. + * @param array $options Additional options and HTML attributes. * @return string HTML icon markup. */ public function icon(string $name, array $options = []): string diff --git a/src/View/Helper/OptionsAwareTrait.php b/src/View/Helper/OptionsAwareTrait.php index 0fc6d960..fa2ad50b 100644 --- a/src/View/Helper/OptionsAwareTrait.php +++ b/src/View/Helper/OptionsAwareTrait.php @@ -11,8 +11,8 @@ trait OptionsAwareTrait /** * Contains the logic for applying style classes for buttons. * - * @param array $data An array of HTML attributes and options. - * @return array An array of HTML attributes and options. + * @param array $data An array of HTML attributes and options. + * @return array An array of HTML attributes and options. */ public function applyButtonClasses(array $data): array { @@ -31,8 +31,8 @@ public function applyButtonClasses(array $data): array * Renames any CSS classes found in the options. * * @param string $element UI element to which the classname is applied. - * @param array $options An array of HTML attributes and options. - * @return array An array of HTML attributes and options. + * @param array $options An array of HTML attributes and options. + * @return array An array of HTML attributes and options. */ public function renameClasses(string $element, array $options): array { @@ -53,8 +53,8 @@ public function renameClasses(string $element, array $options): array /** * Checks if `$options['class']` contains any one of the class names. * - * @param array|string $classes Name of class(es) to check. - * @param array $options An array of HTML attributes and options. + * @param array|string $classes Name of class(es) to check. + * @param array $options An array of HTML attributes and options. * @return bool True if any one of the class names was found. */ public function hasAnyClass(array|string $classes, array $options): bool @@ -78,9 +78,9 @@ public function hasAnyClass(array|string $classes, array $options): bool * in `$options['skip']` then it will not be injected. This method removes `$options['skip']` before * returning. * - * @param array|string $classes Name of class(es) to inject. - * @param array $options An array of HTML attributes and options. - * @return array An array of HTML attributes and options. + * @param array|string $classes Name of class(es) to inject. + * @param array $options An array of HTML attributes and options. + * @return array An array of HTML attributes and options. */ public function injectClasses(array|string $classes, array $options): array { @@ -108,9 +108,9 @@ public function injectClasses(array|string $classes, array $options): array /** * Removes classes from `$options['class']`. * - * @param array|string $classes Name of class(es) to remove. - * @param array $options An array of HTML attributes and options. - * @return array An array of HTML attributes and options. + * @param array|string $classes Name of class(es) to remove. + * @param array $options An array of HTML attributes and options. + * @return array An array of HTML attributes and options. */ public function removeClasses(array|string $classes, array $options): array { @@ -134,8 +134,8 @@ public function removeClasses(array|string $classes, array $options): array /** * Checks if `$classes` are part of the `$options['class']`. * - * @param array|string $classes Name of class(es) to check. - * @param array $options An array of HTML attributes and options. + * @param array|string $classes Name of class(es) to check. + * @param array $options An array of HTML attributes and options. * @return bool False if one or more class(es) do not exist. */ public function checkClasses(array|string $classes, array $options): bool @@ -160,7 +160,7 @@ public function checkClasses(array|string $classes, array $options): bool * Normalizes class strings/arrays. * * @param mixed $mixed One or more classes. - * @return array Classes as array. + * @return array Classes as array. */ protected function toClassArray(mixed $mixed): array { @@ -198,7 +198,7 @@ public function genClassName(string $element, string $class): bool|string * Generates a list of all classnames of a element * * @param string $element UI element - * @return array Array of all generated and raw styles + * @return array Array of all generated and raw styles */ public function genAllClassNames(string $element): array { diff --git a/src/View/Helper/PaginatorHelper.php b/src/View/Helper/PaginatorHelper.php index f7a97495..27edce4d 100644 --- a/src/View/Helper/PaginatorHelper.php +++ b/src/View/Helper/PaginatorHelper.php @@ -19,7 +19,7 @@ class PaginatorHelper extends CorePaginatorHelper /** * Label defaults. * - * @var array + * @var array> */ protected array $labels = [ 'first' => [ @@ -44,7 +44,7 @@ class PaginatorHelper extends CorePaginatorHelper * Constructor. Overridden to merge passed args with URL options. * * @param \Cake\View\View $View The View this helper is being attached to. - * @param array $config Configuration settings for the helper. + * @param array $config Configuration settings for the helper. */ public function __construct(View $View, array $config = []) { @@ -178,7 +178,7 @@ public function next(string $content = '›', array $options = []): string * using `'size' => 'lg'` would add class `pagination-lg` to UL tag. * - `escape` Whether to escape the link text. Defaults to `true`. * - * @param array $options Options for the numbers. + * @param array $options Options for the numbers. * @return string|false Pagination controls markup, or `false` in case of an invalid `size` option. * @link http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-page-number-links */ @@ -256,8 +256,8 @@ public function links(array $options = []): string|false * Prepares label options. * * @param string $name The name of the control for which to prepare the label options. - * @param array $options The array containing the label option. - * @return array + * @param array $options The array containing the label option. + * @return array */ protected function labelOptions(string $name, array $options): array { @@ -278,8 +278,8 @@ protected function labelOptions(string $name, array $options): array * Prepares template options. * * @param string $name The name of the control for which to prepare the template options. - * @param array $options The array containing the template option. - * @return array + * @param array $options The array containing the template option. + * @return array */ protected function templateOptions(string $name, array $options): array { diff --git a/src/View/Helper/Types/Type.php b/src/View/Helper/Types/Type.php index a60d1e55..779f937f 100644 --- a/src/View/Helper/Types/Type.php +++ b/src/View/Helper/Types/Type.php @@ -13,7 +13,7 @@ abstract class Type implements TypeInterface /** * Get all constant values of a class * - * @return array + * @return list * @throws \ReflectionException */ public static function values(): array diff --git a/src/View/Helper/Types/TypeInterface.php b/src/View/Helper/Types/TypeInterface.php index 71c14b53..277e5a2b 100644 --- a/src/View/Helper/Types/TypeInterface.php +++ b/src/View/Helper/Types/TypeInterface.php @@ -16,7 +16,7 @@ interface TypeInterface * * [0 => "value1", 1 => "value2"] * - * @return array An array of all constants + * @return list An array of all constants */ public static function values(): array; } diff --git a/src/View/UIViewTrait.php b/src/View/UIViewTrait.php index fc596b12..9e8eb915 100644 --- a/src/View/UIViewTrait.php +++ b/src/View/UIViewTrait.php @@ -12,7 +12,7 @@ trait UIViewTrait /** * Initialization hook method. * - * @param array $options Associative array with valid keys: + * @param array $options Associative array with valid keys: * - `layout`: * - If not set or true will use the plugin's layout * - If a layout name passed it will be used diff --git a/src/View/Widget/BasicWidget.php b/src/View/Widget/BasicWidget.php index d9635328..e110555d 100644 --- a/src/View/Widget/BasicWidget.php +++ b/src/View/Widget/BasicWidget.php @@ -23,7 +23,7 @@ class BasicWidget extends CoreBasicWidget * * Any other keys provided in $data will be converted into HTML attributes. * - * @param array $data The data to build an input with. + * @param array $data The data to build an input with. * @param \Cake\View\Form\ContextInterface $context The current form context. * @return string */ diff --git a/src/View/Widget/ButtonWidget.php b/src/View/Widget/ButtonWidget.php index 979d86d7..91b4ecb9 100644 --- a/src/View/Widget/ButtonWidget.php +++ b/src/View/Widget/ButtonWidget.php @@ -14,7 +14,7 @@ class ButtonWidget extends CoreButtonWidget /** * Renders a button. * - * @param array $data The data to build a button with. + * @param array $data The data to build a button with. * @param \Cake\View\Form\ContextInterface $context The current form context. * @return string */ diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index c3abc711..dd58732a 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -30,7 +30,7 @@ class DateTimeWidget extends CoreDateTimeWidget * * All other keys will be converted into HTML attributes. * - * @param array $data Data to render with. + * @param array $data Data to render with. * @param \Cake\View\Form\ContextInterface $context The current form context. * @return string A generated select box. * @throws \RuntimeException when the name attribute is empty. diff --git a/src/View/Widget/InputGroupTrait.php b/src/View/Widget/InputGroupTrait.php index 3a993fa9..9193e544 100644 --- a/src/View/Widget/InputGroupTrait.php +++ b/src/View/Widget/InputGroupTrait.php @@ -25,7 +25,7 @@ trait InputGroupTrait * - `input` If set it will be used as input tag between append and prepend addons. * By default parent::render() will be called to get input tag. * - * @param array $data The data to build an input with. + * @param array $data The data to build an input with. * @param \Cake\View\Form\ContextInterface $context The current form context. * @return string */ @@ -95,8 +95,8 @@ protected function withInputGroup(array $data, ContextInterface $context): strin /** * Get addon HTML. * - * @param array $addons Addon content. - * @param array $data Widget data. + * @param array $addons Addon content. + * @param array $data Widget data. * @return string */ protected function addon(array $addons, array $data): string @@ -130,8 +130,9 @@ protected function isButton(string $html): bool /** * Checks, if prepend/append has options and formats them * - * @param array|string $attachment prepend or append element. Can be a string or array, if contains options - * @return array + * @param array|string $attachment prepend or append element. Can be a string or array, if contains + * options + * @return array{content: array, options: array} */ protected function checkForOptions(array|string $attachment): array { @@ -160,9 +161,9 @@ protected function checkForOptions(array|string $attachment): array /** * Processes options given by prepend/append and adds them to wrapping container * - * @param array $attachment prepend/append content and options - * @param array $attrs of wrapping container - * @return array attrs with classes + * @param array $attachment prepend/append content and options + * @param array $attrs of wrapping container + * @return array attrs with classes */ protected function processOptions(array $attachment, array $attrs): array { diff --git a/src/View/Widget/SelectBoxWidget.php b/src/View/Widget/SelectBoxWidget.php index 1f9e0326..bffab8bb 100644 --- a/src/View/Widget/SelectBoxWidget.php +++ b/src/View/Widget/SelectBoxWidget.php @@ -80,7 +80,7 @@ class SelectBoxWidget extends CoreSelectBoxWidget * You are free to mix each of the forms in the same option set, and * nest complex types as required. * - * @param array $data Data to render with. + * @param array $data Data to render with. * @param \Cake\View\Form\ContextInterface $context The current form context. * @return string A generated select box. * @throws \RuntimeException when the name attribute is empty. diff --git a/src/View/Widget/TextareaWidget.php b/src/View/Widget/TextareaWidget.php index 8611ef13..0be56f0a 100644 --- a/src/View/Widget/TextareaWidget.php +++ b/src/View/Widget/TextareaWidget.php @@ -29,7 +29,7 @@ class TextareaWidget extends CoreTextareaWidget * * All other keys will be converted into HTML attributes. * - * @param array $data The data to build a textarea with. + * @param array $data The data to build a textarea with. * @param \Cake\View\Form\ContextInterface $context The current form context. * @return string HTML elements. */