8000 feature #23262 Add scalar typehints/return types (chalasr, xabbuh) · symfony/http-kernel@ccda657 · GitHub
[go: up one dir, main page]

Skip to content

Commit ccda657

Browse files
committed
feature #23262 Add scalar typehints/return types (chalasr, xabbuh)
This PR was merged into the 4.0-dev branch. Discussion ---------- Add scalar typehints/return types | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no (final, already breaks if doc not respected) | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#23242 (comment) | License | MIT | Doc PR | n/a Commits ------- 7b1715b [Yaml] use scalar type hints where possible 6ce70e4 Add scalar typehints/return types on final/internal/private code
2 parents 038c4de + 85f2fd2 commit ccda657

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

Controller/ArgumentResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
3434
*/
3535
private $argumentValueResolvers;
3636

37-
public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, $argumentValueResolvers = array())
37+
public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = array())
3838
{
3939
$this->argumentMetadataFactory = $argumentMetadataFactory ?: new ArgumentMetadataFactory();
4040
$this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers();
@@ -81,7 +81,7 @@ public function getArguments(Request $request, $controller)
8181
return $arguments;
8282
}
8383

84-
public static function getDefaultArgumentValueResolvers()
84+
public static function getDefaultArgumentValueResolvers(): iterable
8585
{
8686
return array(
8787
new RequestAttributeValueResolver(),

Fragment/AbstractSurrogateFragmentRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function render($uri, Request $request, array $options = array())
8585
return new Response($tag);
8686
}
8787

88-
private function generateSignedFragmentUri($uri, Request $request)
88+
private function generateSignedFragmentUri($uri, Request $request): string
8989
{
9090
if (null === $this->signer) {
9191
throw new \LogicException('You must use a URI when using the ESI rendering strategy or set a URL signer.');
@@ -97,7 +97,7 @@ private function generateSignedFragmentUri($uri, Request $request)
9797
return substr($fragmentUri, strlen($request->getSchemeAndHttpHost()));
9898
}
9999

100-
private function containsNonScalars(array $values)
100+
private function containsNonScalars(array $values): bool
101101
{
102102
foreach ($values as $value) {
103103
if (is_array($value) && $this->containsNonScalars($value)) {

Fragment/HIncludeFragmentRenderer.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,7 @@ public function render($uri, Request $request, array $options = array())
123123
return new Response(sprintf('<hx:include src="%s"%s>%s</hx:include>', $uri, $renderedAttributes, $content));
124124
}
125125

126-
/**
127-
* @param string $template
128-
*
129-
* @return bool
130-
*/
131-
private function templateExists($template)
126+
private function templateExists(string $template): bool
132127
{
133128
if ($this->templating instanceof EngineInterface) {
134129
try {

HttpKernel.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function terminateWithException(\Exception $exception)
118118
* @throws \LogicException If one of the listener does not behave as expected
119119
* @throws NotFoundHttpException When controller cannot be found
120120
*/
121-
private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
121+
private function handleRaw(Request $request, int $type = self::MASTER_REQUEST)
122122
{
123123
$this->requestStack->push($request);
124124

@@ -184,7 +184,7 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
184184
*
185185
* @throws \RuntimeException if the passed object is not a Response instance
186186
*/
187-
private function filterResponse(Response $response, Request $request, $type)
187+
private function filterResponse(Response $response, Request $request, int $type)
188188
{
189189
$event = new FilterResponseEvent($this, $request, $type, $response);
190190

@@ -205,7 +205,7 @@ private function filterResponse(Response $response, Request $request, $type)
205205
* @param Request $request
206206
* @param int $type
207207
*/
208-
private function finishRequest(Request $request, $type)
208+
private function finishRequest(Request $request, int $type)
209209
{
210210
$this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this, $request, $type));
211211
$this->requestStack->pop();
@@ -222,7 +222,7 @@ private function finishRequest(Request $request, $type)
222222
*
223223
* @throws \Exception
224224
*/
225-
private function handleException(\Exception $e, $request, $type)
225+
private function handleException(\Exception $e, Request $request, int $type)
226226
{
227227
$event = new GetResponseForExceptionEvent($this, $request, $type, $e);
228228
$this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event);
@@ -257,7 +257,7 @@ private function handleException(\Exception $e, $request, $type)
257257
}
258258
}
259259

260-
private function varToString($var)
260+
private function varToString($var): string
261261
{
262262
if (is_object($var)) {
263263
return sprintf('Object(%s)', get_class($var));

0 commit comments

Comments
 (0)
0