Update functionality of code examples#8336
Conversation
|
We might even want to use type declarations here, WDYT? |
|
@greg0ire I've added types to the methods. Do you think I should add those to properties too? It looks weitd that |
greg0ire
left a comment
There was a problem hiding this comment.
Do you think I should add those to properties too?
Yes, I think we should promote modern code.
|
|
||
| namespace Bank\Entities; | ||
|
|
||
| use use Doctrine\ORM\Mapping as ORM; |
There was a problem hiding this comment.
| use use Doctrine\ORM\Mapping as ORM; | |
| use Doctrine\ORM\Mapping as ORM; |
| class Account | ||
| { | ||
| public function addEntry($amount) | ||
| public function addEntry(int $amount): Entry |
There was a problem hiding this comment.
That does look weird, not sure where it comes from.
There was a problem hiding this comment.
I don't see any usage of the return value so I removed it.
What about adding types to properties? |
|
I can add those too. PHP 7.3 is close to the end of bugfix support and adding property types would have been part of another PR for all docs, but sure: why not start now? |
| } | ||
|
|
||
| public function getAmount() | ||
| public function getAmount(): Amount |
There was a problem hiding this comment.
the return value should be int instead of Amount
No description provided.