8000 [ErrorHandler] ignore `@return` when there is an `@template` · symfony/symfony@d1aa509 · GitHub
[go: up one dir, main page]

Skip to content

Commit d1aa509

Browse files
[ErrorHandler] ignore @return when there is an @template
1 parent 41697e7 commit d1aa509

File tree

2 files changed

+50
-58
lines changed

2 files changed

+50
-58
lines changed

.github/expected-missing-return-types.diff

Lines changed: 43 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ composer u -o
44
SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.0' php .github/patch-types.php
55
head=$(sed '/^diff /Q' .github/expected-missing-return-types.diff)
66
(echo "$head" && echo && git diff -U2 composer.json src/) > .github/expected-missing-return-types.diff
7+
git checkout composer.json src/
78

89
diff --git a/composer.json b/composer.json
9-
index 978743d34d..1f185f682c 100644
10+
index c7b7eac4c7..2b60fb6a19 100644
1011
--- a/composer.json
1112
+++ b/composer.json
1213
@@ -180,5 +180,5 @@
@@ -155,7 +156,7 @@ index 6b1c6c5fbe..bb80ed461e 100644
155156
+ public function isFresh(ResourceInterface $resource, int $timestamp): bool;
156157
}
157158
diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php
158-
index 09234f5eb5..24d995ad6d 100644
159+
index 0ed5649b8a..6c814bf82c 100644
159160
--- a/src/Symfony/Component/Console/Application.php
160161
+++ b/src/Symfony/Component/Console/Application.php
161162
@@ -218,5 +218,5 @@ class Application implements ResetInterface
@@ -208,7 +209,7 @@ index 09234f5eb5..24d995ad6d 100644
208209
{
209210
foreach ($command->getHelperSet() as $helper) {
210211
diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php
211-
index e69bae0982..3390628d0d 100644
212+
index 0bd3426c07..b38caf989e 100644
212213
--- a/src/Symfony/Component/Console/Command/Command.php
213214
+++ b/src/Symfony/Component/Console/Command/Command.php
214215
@@ -171,5 +171,5 @@ class Command
@@ -236,32 +237,32 @@ index 1d2b7bfb84..cb1f66152d 100644
236237
+ public function getName(): string;
237238
}
238239
diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php
239-
index 024da1884e..943790e875 100644
240+
index 3af991a76f..742e2508f3 100644
240241
--- a/src/Symfony/Component/Console/Input/InputInterface.php
241242
+++ b/src/Symfony/Component/Console/Input/InputInterface.php
242-
@@ -54,5 +54,5 @@ interface InputInterface
243+
@@ -57,5 +57,5 @@ interface InputInterface
243244
* @return mixed
244245
*/
245246
- public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false);
246247
+ public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed;
247248

248249
/**
249-
@@ -84,5 +84,5 @@ interface InputInterface
250+
@@ -87,5 +87,5 @@ interface InputInterface
250251
* @throws InvalidArgumentException When argument given doesn't exist
251252
*/
252253
- public function getArgument(string $name);
253254
+ public function getArgument(string $name): mixed;
254255

255256
/**
256-
@@ -112,5 +112,5 @@ interface InputInterface
257+
@@ -115,5 +115,5 @@ interface InputInterface
257258
* @throws InvalidArgumentException When option given doesn't exist
258259
*/
259260
- public function getOption(string $name);
260261
+ public function getOption(string $name): mixed;
261262

262263
/**
263264
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
264-
index e9fa5a6808..016e9d893a 100644
265+
index c2824f4578..032f5c2318 100644
265266
--- a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
266267
+++ b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
267268
@@ -71,5 +71,5 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
@@ -383,7 +384,7 @@ index 479aeef880..272954c082 100644
383384
+ public function getFunctions(): array;
384385
}
385386
diff --git a/src/Symfony/Component/Form/AbstractExtension.php b/src/Symfony/Component/Form/AbstractExtension.php
386-
index 5a077a42a6..62a234b116 100644
387+
index 79d61e8bc0..7f34d95d84 100644
387388
--- a/src/Symfony/Component/Form/AbstractExtension.php
388389
+++ b/src/Symfony/Component/Form/AbstractExtension.php
389390
@@ -114,5 +114,5 @@ abstract class AbstractExtension implements FormExtensionInterface
@@ -525,10 +526,10 @@ index 2f442cb536..d98909cfae 100644
525526
+ public function warmUp(string $cacheDir): array;
526527
}
527528
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
528-
index 1289cf0ea9..dabeec97ee 100644
529+
index 3a3be3af49..971560c07b 100644
529530
--- a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
530531
+++ b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
531-
@@ -58,5 +58,5 @@ abstract class DataCollector implements DataCollectorInterface
532+
@@ -59,5 +59,5 @@ abstract class DataCollector implements DataCollectorInterface
532533
* @return callable[] The casters to add to the cloner
533534
*/
534535
- protected function getCasters()
@@ -546,7 +547,7 @@ index 1cb865fd66..f6f4efe7a7 100644
546547
+ public function getName(): string;
547548
}
548549
diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
549-
index eeec55593f..c12df944fc 100644
550+
index cf0e243c6b..292b907ea8 100644
550551
--- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
551552
+++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
552553
@@ -448,5 +448,5 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
@@ -557,7 +558,7 @@ index eeec55593f..c12df944fc 100644
557558
{
558559
$this->surrogate?->addSurrogateCapability($request);
559560
diff --git a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php
560-
index fc70d8970d..9dde6d1f93 100644
561+
index 1557da575a..7e5a2a9859 100644
561562
--- a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php
562563
+++ b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php
563564
@@ -61,5 +61,5 @@ class HttpKernelBrowser extends AbstractBrowser
@@ -610,23 +611,6 @@ index 125b6eae50..ac327e8981 100644
610611
+ public function createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): SharedLockInterface
611612
{
612613
$lock = new Lock($key, $this->store, $ttl, $autoRelease);
613-
diff --git a/src/Symfony/Component/Messenger/Envelope.php b/src/Symfony/Component/Messenger/Envelope.php
614-
index bb1194ad1b..27731b9cb0 100644
615-
--- a/src/Symfony/Component/Messenger/Envelope.php
616-
+++ b/src/Symfony/Component/Messenger/Envelope.php
617-
@@ -13,4 +13,5 @@ namespace Symfony\Component\Messenger;
618-
619-
use Symfony\Component\Messenger\Stamp\StampInterface;
620-
+use Symfony\Component\Messenger\Stamp\StampInterface as TStamp;
621-
622-
/**
623-
@@ -101,5 +102,5 @@ final class Envelope
624-
* @return TStamp|null
625-
*/
626-
- public function last(string $stampFqcn): ?StampInterface
627-
+ public function last(string $stampFqcn): ?TStamp
628-
{
629-
return isset($this->stamps[$stampFqcn]) ? end($this->stamps[$stampFqcn]) : null;
630614
diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php
631615
index 205c15b4cd..e93e460ed1 100644
632616
--- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php
@@ -771,7 +755,7 @@ index 2dd0e5efbf..95e01d8955 100644
771755
{
772756
$name = str_replace('\\', '_', $class->name).'_'.$method->name;
773757
diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php
774-
index be653e4f00..e46300d474 100644
758+
index 83c10427a1..e113d4a194 100644
775759
--- a/src/Symfony/Component/Routing/Router.php
776760
+++ b/src/Symfony/Component/Routing/Router.php
777761
@@ -178,5 +178,5 @@ class Router implements RouterInterface, RequestMatcherInterface
@@ -813,7 +797,7 @@ index 7e401c3ff3..6b446ff376 100644
813797
+ public function vote(TokenInterface $token, mixed $subject, array $attributes): int;
814798
}
815799
diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
816-
index 9e2b02b603..c6a753f1f7 100644
800+
index 298bc78cd9..3ef4176dd8 100644
817801
--- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
818802
+++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
819803
@@ -89,5 +89,5 @@ class AuthenticationException extends RuntimeException
@@ -852,7 +836,7 @@ index 91271d14a3..100c2fb549 100644
852836
+ public function start(Request $request, AuthenticationException $authException = null): Response;
853837
}
854838
diff --git a/src/Symfony/Component/Security/Http/Firewall.php b/src/Symfony/Component/Security/Http/Firewall.php
855-
index 546b77d22f..24038d4b94 100644
839+
index 0c313f8f09..acfc9f4b88 100644
856840
--- a/src/Symfony/Component/Security/Http/Firewall.php
857841
+++ b/src/Symfony/Component/Security/Http/Firewall.php
858842
@@ -106,5 +106,5 @@ class Firewall implements EventSubscriberInterface
@@ -873,7 +857,7 @@ index 480ea8ad6b..fa43d6a6e9 100644
873857
+ public function getListeners(Request $request): array;
874858
}
875859
diff --git a/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php b/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php
876-
index 84a84ad1f3..6f66b6d32a 100644
860+
index f38069e471..0966eb3e89 100644
877861
--- a/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php
878862
+++ b/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php
879863
@@ -35,5 +35,5 @@ interface DecoderInterface
@@ -883,11 +867,11 @@ index 84a84ad1f3..6f66b6d32a 100644
883867
+ public function decode(string $data, string $format, array $context = []): mixed;
884868

885869
/**
886-
@@ -44,4 +44,4 @@ interface DecoderInterface
870+
@@ -45,4 +45,4 @@ interface DecoderInterface
887871
* @return bool
888872
*/
889-
- public function supportsDecoding(string $format);
890-
+ public function supportsDecoding(string $format): bool;
873+
- public function supportsDecoding(string $format /*, array $context = [] */);
874+
+ public function supportsDecoding(string $format /*, array $context = [] */): bool;
891875
}
892876
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
893877
index 7f86ed8d78..cf084423ec 100644
@@ -915,59 +899,60 @@ index 7f86ed8d78..cf084423ec 100644
915899
{
916900
if (null !== $object = $this->extractObjectToPopulate($class, $context, self::OBJECT_TO_POPULATE)) {
917901
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
918-
index 3e1e7edc8e..e025b2bc4a 100644
902+
index a8943113c4..2983dabd0f 100644
919903
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
920904
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
921-
@@ -136,5 +136,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
922-
* {@inheritdoc}
905+
@@ -138,5 +138,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
906+
* @param array $context
923907
*/
924-
- public function supportsNormalization(mixed $data, string $format = null)
925-
+ public function supportsNormalization(mixed $data, string $format = null): bool
908+
- public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */)
909+
+ public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
926910
{
927911
return \is_object($data) && !$data instanceof \Traversable;
928-
@@ -144,5 +144,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
912+
@@ -146,5 +146,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
929913
* {@inheritdoc}
930914
*/
931915
- public function normalize(mixed $object, string $format = null, array $context = [])
932916
+ public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
933917
{
934918
if (!isset($context['cache_key'])) {
935-
@@ -277,5 +277,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
919+
@@ -279,5 +279,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
936920
* {@inheritdoc}
937921
*/
938922
- protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
939923
+ protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null): object
940924
{
941925
if ($this->classDiscriminatorResolver && $mapping = $this->classDiscriminatorResolver->getMappingForClass($class)) {
942-
@@ -339,5 +339,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
926+
@@ -341,5 +341,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
943927
* @return string[]
944928
*/
945929
- abstract protected function extractAttributes(object $object, string $format = null, array $context = []);
946930
+ abstract protected function extractAttributes(object $object, string $format = null, array $context = []): array;
947931

948932
/**
949-
@@ -346,10 +346,10 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
933+
@@ -348,5 +348,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
950934
* @return mixed
951935
*/
952936
- abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []);
953937
+ abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []): mixed;
954938

955939
/**
956-
* {@inheritdoc}
940+
@@ -355,5 +355,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
941+
* @param array $context
957942
*/
958-
- public function supportsDenormalization(mixed $data, string $type, string $format = null)
959-
+ public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
943+
- public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */)
944+
+ public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
960945
{
961946
return class_exists($type) || (interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type));
962-
@@ -359,5 +359,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
947+
@@ -363,5 +363,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
963948
* {@inheritdoc}
964949
*/
965950
- public function denormalize(mixed $data, string $type, string $format = null, array $context = [])
966951
+ public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
967952
{
968953
if (!isset($context['cache_key'])) {
969954
diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
970-
index 5e94400b80..726d89cbb1 100644
955+
index 1c708738a1..3b6c9d5056 100644
971956
--- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
972957
+++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
973958
@@ -45,5 +45,5 @@ interface DenormalizerInterface
@@ -977,14 +962,14 @@ index 5e94400b80..726d89cbb1 100644
977962
+ public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed;
978963

979964
/**
980-
@@ -56,4 +56,4 @@ interface DenormalizerInterface
965+
@@ -57,4 +57,4 @@ interface DenormalizerInterface
981966
* @return bool
982967
*/
983-
- public function supportsDenormalization(mixed $data, string $type, string $format = null);
984-
+ public function supportsDenormalization(mixed $data, string $type, string $format = null): bool;
968+
- public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */);
969+
+ public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool;
985970
}
986971
diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
987-
index 30eeafb47b..a7a60ad2f2 100644
972+
index 741f19e50b..acf3be931b 100644
988973
--- a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
989974
+++ b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
990975
@@ -37,5 +37,5 @@ interface NormalizerInterface
@@ -994,11 +979,11 @@ index 30eeafb47b..a7a60ad2f2 100644
994979
+ public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null;
995980

996981
/**
997-
@@ -47,4 +47,4 @@ interface NormalizerInterface
982+
@@ -48,4 +48,4 @@ interface NormalizerInterface
998983
* @return bool
999984
*/
1000-
- public function supportsNormalization(mixed $data, string $format = null);
1001-
+ public function supportsNormalization(mixed $data, string $format = null): bool;
985+
- public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */);
986+
+ public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool;
1002987
}
1003988
diff --git a/src/Symfony/Component/Templating/Helper/HelperInterface.php b/src/Symfony/Component/Templating/Helper/HelperInterface.php
1004989
index 5dade65db5..db0d0a00ea 100644

src/Symfony/Component/ErrorHandler/DebugClassLoader.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,12 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
371371

372372
$parent = get_parent_class($class) ?: null;
373373
self::$returnTypes[$class] = [];
374+
$classIsTemplate = false;
374375

375376
// Detect annotations on the class
376377
if ($doc = $this->parsePhpDoc($refl)) {
378+
$classIsTemplate = isset($doc['template']);
379+
377380
foreach (['final', 'deprecated', 'internal'] as $annotation) {
378381
if (null !== $description = $doc[$annotation][0] ?? null) {
379382
self::${$annotation}[$class] = '' !== $description ? ' '.$description.(preg_match('/[.!]$/', $description) ? '' : '.') : '.';
@@ -517,6 +520,10 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
517520
// To read method annotations
518521
$doc = $this->parsePhpDoc($method);
519522

523+
if (($classIsTemplate || isset($doc['template'])) && $method->hasReturnType()) {
524+
unset($doc['return']);
525+
}
526+
520527
if (isset(self::$annotatedParameters[$class][$method->name])) {
521528
$definedParameters = [];
522529
foreach ($method->getParameters() as $parameter) {

0 commit comments

Comments
 (0)
0