Skip to content

Commit b866172

Browse files
minor #33259 [5.0] Add return types on internal|final|private methods (nicolas-grekas)
This PR was merged into the 5.0-dev branch. Discussion ---------- [5.0] Add return types on internal|final|private methods | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #33228 #33236 | License | MIT | Doc PR | - I think some changes here can be backported to 4.4 Also, this fails with e.g. `Return value of Symfony\Component\Serializer\Normalizer\ArrayDenormalizer::denormalize() must be an object, array returned` Which means we need to update `DenormalizerInterface::denormalize()` with `@return object|array` in 3.4. Commits ------- 6f303b4 [5.0] Add return types on internal|final|private methods
2 parents 0fa6ef1 + 6f303b4 commit b866172

File tree

9 files changed

+10
-19
lines changed

9 files changed

+10
-19
lines changed

src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ protected function send($content, array $records): void
6363

6464
/**
6565
* {@inheritdoc}
66-
*
67-
* @return void
6866
*/
69-
public function reset()
67+
public function reset(): void
7068
{
7169
$this->flushMemorySpool();
7270
}

src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function has($id): bool
9898
/**
9999
* {@inheritdoc}
100100
*/
101-
public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
101+
public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1): ?object
102102
{
103103
return $this->getPrivateContainer()->has($id) ? $this->getPrivateContainer()->get($id) : $this->getPublicContainer()->get($id, $invalidBehavior);
104104
}

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,8 @@ public function testGetUserWithEmptyContainer()
159159

160160
/**
161161
* @param $token
162-
*
163-
* @return Container
164162
*/
165-
private function getContainerWithTokenStorage($token = null)
163+
private function getContainerWithTokenStorage($token = null): Container
166164
{
167165
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock();
168166
$tokenStorage

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,7 @@ private function checkResultCode($result)
316316
throw new CacheException(sprintf('MemcachedAdapter client error: %s.', strtolower($this->client->getResultMessage())));
317317
}
318318

319-
/**
320-
* @return \Memcached
321-
*/
322-
private function getClient()
319+
private function getClient(): \Memcached
323320
{
324321
if ($this->client) {
325322
return $this->client;

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ public static function xpathLiteral(string $s)
898898
*
899899
* @return static
900900
*/
901-
private function filterRelativeXPath(string $xpath)
901+
private function filterRelativeXPath(string $xpath): object
902902
{
903903
$prefixes = $this->findNamespacePrefixes($xpath);
904904

@@ -1140,7 +1140,7 @@ private function findNamespacePrefixes(string $xpath): array
11401140
*
11411141
* @return static
11421142
*/
1143-
private function createSubCrawler($nodes)
1143+
private function createSubCrawler($nodes): object
11441144
{
11451145
$crawler = new static($nodes, $this->uri, $this->baseHref);
11461146
$crawler->isHtml = $this->isHtml;

src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function onFinishRequest(FinishRequestEvent $event)
128128
}
129129
}
130130

131-
public static function getSubscribedEvents()
131+
public static function getSubscribedEvents(): array
132132
{
133133
return [
134134
KernelEvents::REQUEST => ['onKernelRequest', 128],

src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function onKernelResponse(ResponseEvent $event)
9797
}
9898
}
9999

100-
public static function getSubscribedEvents()
100+
public static function getSubscribedEvents(): array
101101
{
102102
return [
103103
KernelEvents::REQUEST => ['onKernelRequest', 192],

src/Symfony/Component/Mime/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ private function createDataPart(array $attachment): DataPart
515515
/**
516516
* @return $this
517517
*/
518-
private function setHeaderBody(string $type, string $name, $body)
518+
private function setHeaderBody(string $type, string $name, $body): object
519519
{
520520
$this->getHeaders()->setHeaderBody($type, $name, $body);
521521

src/Symfony/Component/Translation/Translator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,8 @@ public function setFallbackLocales(array $locales)
180180
* Gets the fallback locales.
181181
*
182182
* @internal
183-
*
184-
* @return array The fallback locales
185183
*/
186-
public function getFallbackLocales()
184+
public function getFallbackLocales(): array
187185
{
188186
return $this->fallbackLocales;
189187
}

0 commit comments

Comments
 (0)