Skip to content

Commit 56e0217

Browse files
authored
Add some return type hints (#15)
This PR adds return type hints to resolve deprecation warnings issued by Symfony's DebugClassLoader in Symfony 5.4. In places where we cannot reasonably rule out that methods have been overridden, only soft (docblock-based) types are added. In case you have overwritten these methods, you should start adding _real_ return type declarations _now_.
1 parent bc7b1aa commit 56e0217

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

Integration/BootstrapFileKernelAdaptor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration;
1010

1111
use Symfony\Component\HttpFoundation\Request;
12+
use Symfony\Component\HttpFoundation\Response;
1213
use Symfony\Component\HttpKernel\HttpKernelInterface;
1314

1415
class BootstrapFileKernelAdaptor implements HttpKernelInterface
@@ -20,6 +21,9 @@ public function __construct($filename)
2021
$this->file = $filename;
2122
}
2223

24+
/**
25+
* @return Response
26+
*/
2327
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
2428
{
2529
$file = $this->file;

Integration/LegacyApplication.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ class LegacyApplication implements HttpKernelInterface
2020
/** @var HttpKernelInterface */
2121
protected $legacyKernel;
2222

23-
public function setLegacyKernel(HttpKernelInterface $kernel)
23+
public function setLegacyKernel(HttpKernelInterface $kernel): void
2424
{
2525
$this->legacyKernel = $kernel;
2626
}
2727

28+
/**
29+
* @return Response
30+
*/
2831
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
2932
{
3033
if (null === $this->response) {
@@ -35,13 +38,12 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
3538
return $this->response;
3639
}
3740

38-
public function isDispatched()
41+
public function isDispatched(): bool
3942
{
4043
return null !== $this->response;
4144
}
4245

43-
/** @return Response */
44-
public function getResponse()
46+
public function getResponse(): Response
4547
{
4648
if (null === $this->response) {
4749
throw new LegacyIntegrationException('The legacy application has not been started or has not generated a response. Maybe the @Dispatch annotation is missing for the current controller?');

Integration/LegacyCaptureResponseFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration;
1010

11+
use Symfony\Component\HttpFoundation\Response;
12+
1113
class LegacyCaptureResponseFactory
1214
{
13-
public static function create($legacyExecutionCallback)
15+
public static function create($legacyExecutionCallback): Response
1416
{
1517
// Preserve all headers that have previously been set (pre-Legacy startup)
1618
$preLegacyHeaders = headers_list();
@@ -26,7 +28,7 @@ public static function create($legacyExecutionCallback)
2628
}
2729
}
2830

29-
private static function runLegacyAndCaptureResponse($legacyExecutionCallback)
31+
private static function runLegacyAndCaptureResponse($legacyExecutionCallback): Response
3032
{
3133
ob_start();
3234
try {

Twig/Extension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Extension extends AbstractExtension implements GlobalsInterface, ServiceSu
2828
*/
2929
private $embedResult = null;
3030

31-
public static function getSubscribedServices()
31+
public static function getSubscribedServices(): array
3232
{
3333
return [
3434
LegacyApplication::class,
@@ -41,7 +41,7 @@ public function __construct(ContainerInterface $container)
4141
$this->container = $container;
4242
}
4343

44-
public function getFunctions()
44+
public function getFunctions(): array
4545
{
4646
return [
4747
new TwigFunction('webfactory_legacy_integration_embed', [$this, 'embedString']),
@@ -66,10 +66,8 @@ public function getFragmentalResponse()
6666
* Evaluate $xpath search query on the legacy content and get a string representation of matching elements.
6767
*
6868
* @param string $xpath
69-
*
70-
* @return string
7169
*/
72-
public function xpath($xpath)
70+
public function xpath($xpath): string
7371
{
7472
return $this->getXPathHelper()->getFragment($xpath);
7573
}

0 commit comments

Comments
 (0)