Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add example for type hinting in docblocks #45

Merged
merged 1 commit into from Oct 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 24 additions & 3 deletions docs/book/v2/coding-style-guide.md
Expand Up @@ -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<string,string> $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.
>
Expand Down