Skip to content

Commit d16f4d8

Browse files
Merge branch '3.4' into 4.3
* 3.4: (21 commits) [SecurityBundle] fix return type declarations [BrowserKit] fix return type declarations [PropertyInfo] fix return type declarations [Bridge/Doctrine] fix return type declarations [Form] fix return type declarations [Console] fix return type declarations [Intl] fix return type declarations [Templating] fix return type declarations [DomCrawler] fix return type declarations [Validator] fix return type declarations [Process] fix return type declarations [Workflow] fix return type declarations [Cache] fix return type declarations [Serializer] fix return type declarations [Translation] fix return type declarations [DI] fix return type declarations [Config] fix return type declarations [HttpKernel] Fix return type declarations [Security] Fix return type declarations [Routing] Fix return type declarations ...
2 parents aef79fc + 23fb04a commit d16f4d8

17 files changed

+51
-28
lines changed

Controller/ControllerResolver.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ public function getController(Request $request)
8282
return $controller;
8383
}
8484

85-
$callable = $this->createController($controller);
85+
try {
86+
$callable = $this->createController($controller);
87+
} catch (\InvalidArgumentException $e) {
88+
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage()));
89+
}
8690

8791
if (!\is_callable($callable)) {
8892
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable)));
@@ -97,17 +101,25 @@ public function getController(Request $request)
97101
* @param string $controller A Controller string
98102
*
99103
* @return callable A PHP callable
104+
*
105+
* @throws \InvalidArgumentException When the controller cannot be created
100106
*/
101107
protected function createController($controller)
102108
{
103109
if (false === strpos($controller, '::')) {
104-
return $this->instantiateController($controller);
110+
$controller = $this->instantiateController($controller);
111+
112+
if (!\is_callable($controller)) {
113+
throw new \InvalidArgumentException($this->getControllerError($controller));
114+
}
115+
116+
return $controller;
105117
}
106118

107119
list($class, $method) = explode('::', $controller, 2);
108120

109121
try {
110-
return [$this->instantiateController($class), $method];
122+
$controller = [$this->instantiateController($class), $method];
111123
} catch (\Error | \LogicException $e) {
112124
try {
113125
if ((new \ReflectionMethod($class, $method))->isStatic()) {
@@ -119,6 +131,12 @@ protected function createController($controller)
119131

120132
throw $e;
121133
}
134+
135+
if (!\is_callable($controller)) {
136+
throw new \InvalidArgumentException($this->getControllerError($controller));
137+
}
138+
139+
return $controller;
122140
}
123141

124142
/**

ControllerMetadata/ArgumentMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getName()
5050
*
5151
* The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
5252
*
53-
* @return string
53+
* @return string|null
5454
*/
5555
public function getType()
5656
{

DataCollector/ConfigDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function getApplicationVersion()
131131
/**
132132
* Gets the token.
133133
*
134-
* @return string The token
134+
* @return string|null The token
135135
*/
136136
public function getToken()
137137
{

DataCollector/ExceptionDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function hasException()
5555
/**
5656
* Gets the exception.
5757
*
58-
* @return \Exception The exception
58+
* @return \Exception|FlattenException
5959
*/
6060
public function getException()
6161
{

DataCollector/LoggerDataCollector.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ public function lateCollect()
7575
$this->currentRequest = null;
7676
}
7777

78-
/**
79-
* Gets the logs.
80-
*
81-
* @return array An array of logs
82-
*/
8378
public function getLogs()
8479
{
8580
return isset($this->data['logs']) ? $this->data['logs'] : [];

DataCollector/TimeDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getInitTime()
132132
/**
133133
* Gets the request time.
134134
*
135-
* @return int The time
135+
* @return float
136136
*/
137137
public function getStartTime()
138138
{

HttpCache/AbstractSurrogate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors)
110110
}
111111
}
112112

113-
return null;
113+
return '';
114114
}
115115

116116
/**

HttpCache/Ssi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ public function process(Request $request, Response $response)
9595
// remove SSI/1.0 from the Surrogate-Control header
9696
$this->removeFromControl($response);
9797

98-
return null;
98+
return $response;
9999
}
100100
}

Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
204204
/**
205205
* Gets a HTTP kernel from the container.
206206
*
207-
* @return HttpKernel
207+
* @return HttpKernelInterface
208208
*/
209209
protected function getHttpKernel()
210210
{
@@ -377,7 +377,7 @@ public function setAnnotatedClassCache(array $annotatedClasses)
377377
*/
378378
public function getStartTime()
379379
{
380-
return $this->debug ? $this->startTime : -INF;
380+
return $this->debug && null !== $this->startTime ? $this->startTime : -INF;
381381
}
382382

383383
/**

KernelInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getContainer();
140140
/**
141141
* Gets the request start time (not available if debug is disabled).
142142
*
143-
* @return int The request start timestamp
143+
* @return float The request start timestamp
144144
*/
145145
public function getStartTime();
146146

0 commit comments

Comments
 (0)