Skip to content

Commit

Permalink
feature #31996 [5.0] Add return types in final classes (dFayet)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.0-dev branch.

Discussion
----------

[5.0] Add return types in final classes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes/no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | #31981
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This is the first step for the issue #31981

I have some questions:

-  ~I have not added type for methods with `@inheritdoc` annotation, should I?~
- ~Don't we want to type also functions without `@return` annotation? (still in `final` classes)~
- ~If yes is the answer of the previous one, do we also want the `void` return type?~
- ~I have also added the return type in the `DependencyInjection` PhpDumper, but is it also wanted? (if yes, I will clean a bit the code changed)~
- ~Should we update the documentation's code samples when they display `final` classes?~

Todo:
- [x] Adjust the PR, following the answers of the questions
- [x] Add return type also when there is no `@return`, or with `@inheritdoc`
- [x] [src/Symfony/Component/Debug/ErrorHandler.php#L383](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/ErrorHandler.php#L383) `@return` annotation is not correct according to the return, investigate and adjust if needed
- [x] [src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php#L50](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php#L50) `@return` annotation is not correct according to the return, investigate and adjust if needed
- [x] Do a PR on documentation to add return type on code snippets with final classes => unneeded as they were already typed

Commits
-------

ca5ae1989e Replace @return annotation by return type in final classes
  • Loading branch information
Tobion committed Jun 23, 2019
2 parents 19bc449 + c0cb08f commit 246d62d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MarkingStore/MethodMarkingStore.php
Expand Up @@ -46,7 +46,7 @@ public function __construct(bool $singleState = false, string $property = 'marki
/**
* {@inheritdoc}
*/
public function getMarking($subject)
public function getMarking($subject): Marking
{
$method = 'get'.ucfirst($this->property);

Expand Down
2 changes: 1 addition & 1 deletion TransitionBlockerList.php
Expand Up @@ -63,7 +63,7 @@ public function isEmpty(): bool
*
* @return \ArrayIterator|TransitionBlocker[]
*/
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->blockers);
}
Expand Down

0 comments on commit 246d62d

Please sign in to comment.