-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Added an ArgumentResolver with clean extension point #18308
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* An ArgumentResolverInterface implementation knows how to determine the | ||
* An ArgumentResolverInterface instance knows how to determine the | ||
* arguments for a specific action. | ||
* | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
|
@@ -29,7 +29,7 @@ interface ArgumentResolverInterface | |
* | ||
* @return array An array of arguments to pass to the controller | ||
* | ||
* @throws \RuntimeException When value for argument given is not provided | ||
* @throws \RuntimeException When no value could be provided for a required argument | ||
*/ | ||
public function getArguments(Request $request, $controller); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just checked a bunch of files including the ones you mentioned and I think it's github, all files I've checked have a blank line in the end for me |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
interface ArgumentValueResolverInterface | ||
{ | ||
/** | ||
* Whether this resolver can resolve can resolve the value for the given ArgumentMetadata. | ||
* Whether this resolver can resolve the value for the given ArgumentMetadata. | ||
* | ||
* @param Request $request | ||
* @param ArgumentMetadata $argument | ||
|
@@ -34,8 +34,6 @@ public function supports(Request $request, ArgumentMetadata $argument); | |
/** | ||
* Yield the possible value(s). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically, this method is returning an iterator of the possible values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo "Yields" |
||
* | ||
* An implementation must yield at least one value. | ||
* | ||
* @param Request $request | ||
* @param ArgumentMetadata $argument | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ public function __construct(ControllerResolverInterface $resolver, Stopwatch $st | |
$this->stopwatch = $stopwatch; | ||
$this->argumentResolver = $argumentResolver; | ||
|
||
// required for BC reasons | ||
// BC | ||
if (null === $this->argumentResolver) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is for BC you should add a comment so we don't forget to remove the block in 4.0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be implied by the getArguments method deprecation but adding it just in case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
$this->argumentResolver = $resolver; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ public function createArgumentMetadata($controller) | |
} | ||
|
||
foreach ($reflection->getParameters() as $param) { | ||
$arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaulValue($param), $this->getDefaulValue($param)); | ||
$arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param)); | ||
} | ||
|
||
return $arguments; | ||
|
@@ -59,7 +59,7 @@ private function isVariadic(\ReflectionParameter $parameter) | |
* | ||
* @return bool | ||
*/ | ||
private function hasDefaulValue(\ReflectionParameter $parameter) | ||
private function hasDefaultValue(\ReflectionParameter $parameter) | ||
{ | ||
return $parameter->isDefaultValueAvailable(); | ||
} | ||
|
@@ -71,9 +71,9 @@ private function hasDefaulValue(\ReflectionParameter $parameter) | |
* | ||
* @return mixed|null | ||
*/ | ||
private function getDefaulValue(\ReflectionParameter $parameter) | ||
private function getDefaultValue(\ReflectionParameter $parameter) | ||
{ | ||
return $this->hasDefaulValue($parameter) ? $parameter->getDefaultValue() : null; | ||
return $this->hasDefaultValue($parameter) ? $parameter->getDefaultValue() : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it really necessary to throw an exception with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You lost me here for a second, what do you mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got confused because the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did it this way because of "If the parameter is not optional a ReflectionException will be thrown." |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something similar (but then removed instead of deprecated) should be added to UPGRADE-4.0.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be easier to document this in the PR where it's actually removed?