From 10a014647ba105c69ff840f6634dc9d549702289 Mon Sep 17 00:00:00 2001 From: Geert Eltink Date: Sat, 24 Oct 2020 17:30:24 +0200 Subject: [PATCH] docs: add example for type hinting in docblocks Signed-off-by: Geert Eltink --- docs/book/v2/coding-style-guide.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/book/v2/coding-style-guide.md b/docs/book/v2/coding-style-guide.md index 834b747..2e6f5c7 100644 --- a/docs/book/v2/coding-style-guide.md +++ b/docs/book/v2/coding-style-guide.md @@ -1257,11 +1257,32 @@ $instance = new class extends \Foo implements > ### Additional Laminas rules > -> Code SHOULD be written so it explains itself. DocBlocks and comments -> SHOULD only be used if necessary. They MUST NOT start with `#` and MUST -> NOT be empty. They SHOULD NOT be used for already typehinted arguments, +> Code SHOULD be written so it explains itself. +> +> DocBlocks and comments SHOULD only be used if necessary. They MUST NOT start +> with `#` and MUST NOT be empty. +> +> DocBlocks and comments SHOULD NOT be used for already typehinted arguments, > except arrays. > + +```php +/** + * Sets a single-line title + * + * The string `param` and `return` tags should be omitted as they are already + * type hinted. + * + * A `param` tag should be here to describe the array. + * + * @param array $context + */ +public function setTitle(string $title, array $context): void +{ + // ... +} +``` + > The asterisks in a DocBlock should align, and there should be one > space between the asterisk and tag. >