Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9834707

Browse filesBrowse files
committed
minor #16421 Add return types in docs to avoid generating more legacy code (Seldaek)
This PR was merged into the 4.4 branch. Discussion ---------- Add return types in docs to avoid generating more legacy code I am not entirely sure if this goes against a policy or not, but I wanted to fix this and also use it to raise the point in case it wasn't raised yet. While copy-pasting this code from the docs to get started on an arg value resolver, I then instantly got `Method "Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface::supports()" might add "bool" as a native return type declaration in the future. Do the same in implementation "App\ArgumentResolver\PackageResolver" now to avoid errors or add an explicit `@return` annotation to suppress this message.` in my deprecation log. This feature was added in Symfony 5.x IIRC which means PHP 7.2+ support, so return types including iterable are fully supported, no reason to advise anyone to not use them as far as I can tell :) Commits ------- c666459 Add return types in docs to avoid generating more legacy code
2 parents 885d082 + c666459 commit 9834707
Copy full SHA for 9834707

File tree

1 file changed

+2
-2
lines changed
Filter options

1 file changed

+2
-2
lines changed

‎controller/argument_value_resolver.rst

Copy file name to clipboardExpand all lines: controller/argument_value_resolver.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ retrieved from the token storage::
170170
$this->security = $security;
171171
}
172172

173-
public function supports(Request $request, ArgumentMetadata $argument)
173+
public function supports(Request $request, ArgumentMetadata $argument): bool
174174
{
175175
if (User::class !== $argument->getType()) {
176176
return false;
@@ -179,7 +179,7 @@ retrieved from the token storage::
179179
return $this->security->getUser() instanceof User;
180180
}
181181

182-
public function resolve(Request $request, ArgumentMetadata $argument)
182+
public function resolve(Request $request, ArgumentMetadata $argument): iterable
183183
{
184184
yield $this->security->getUser();
185185
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.