Skip to content

Commit

Permalink
Replace @return annotation by return type in final classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dFayet committed Jun 20, 2019
1 parent e8c2a1b commit f84d094
Show file tree
Hide file tree
Showing 147 changed files with 325 additions and 397 deletions.
9 changes: 3 additions & 6 deletions src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php
Expand Up @@ -29,7 +29,7 @@ final class TestRepositoryFactory implements RepositoryFactory
/**
* {@inheritdoc}
*/
public function getRepository(EntityManagerInterface $entityManager, $entityName)
public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
{
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);

Expand All @@ -47,10 +47,7 @@ public function setRepository(EntityManagerInterface $entityManager, $entityName
$this->repositoryList[$repositoryHash] = $repository;
}

/**
* @return ObjectRepository
*/
private function createRepository(EntityManagerInterface $entityManager, $entityName)
private function createRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
{
/* @var $metadata ClassMetadata */
$metadata = $entityManager->getClassMetadata($entityName);
Expand All @@ -59,7 +56,7 @@ private function createRepository(EntityManagerInterface $entityManager, $entity
return new $repositoryClassName($entityManager, $metadata);
}

private function getRepositoryHash(EntityManagerInterface $entityManager, $entityName)
private function getRepositoryHash(EntityManagerInterface $entityManager, $entityName): string
{
return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php
Expand Up @@ -73,7 +73,7 @@ protected function sendHeader($header, $content)
/**
* Override default behavior since we check it in onKernelResponse.
*/
protected function headersAccepted()
protected function headersAccepted(): bool
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php
Expand Up @@ -75,7 +75,7 @@ protected function sendHeader($header, $content)
/**
* Override default behavior since we check the user agent in onKernelResponse.
*/
protected function headersAccepted()
protected function headersAccepted(): bool
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php
Expand Up @@ -35,7 +35,7 @@ public function __construct(bool $includeParams = true)
$this->reset();
}

public function __invoke(array $records)
public function __invoke(array $records): array
{
if ($this->routeData && !isset($records['extra']['requests'])) {
$records['extra']['requests'] = array_values($this->routeData);
Expand Down Expand Up @@ -78,7 +78,7 @@ public function removeRouteData(FinishRequestEvent $event)
unset($this->routeData[$requestId]);
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => ['addRouteData', 1],
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/Processor/WebProcessor.php
Expand Up @@ -39,7 +39,7 @@ public function onKernelRequest(ResponseEvent $event)
}
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => ['onKernelRequest', 4096],
Expand Down
Expand Up @@ -40,15 +40,15 @@ public function __construct(string $salt = '')
/**
* {@inheritdoc}
*/
public function isProxyCandidate(Definition $definition)
public function isProxyCandidate(Definition $definition): bool
{
return ($definition->isLazy() || $definition->hasTag('proxy')) && $this->proxyGenerator->getProxifiedClass($definition);
}

/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null)
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string
{
$instantiation = 'return';

Expand Down Expand Up @@ -82,7 +82,7 @@ public function getProxyFactoryCode(Definition $definition, $id, $factoryCode =
/**
* {@inheritdoc}
*/
public function getProxyCode(Definition $definition)
public function getProxyCode(Definition $definition): string
{
$code = $this->classGenerator->generate($this->generateProxyClass($definition));

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Extension/RoutingExtension.php
Expand Up @@ -93,7 +93,7 @@ public function getUrl($name, $parameters = [], $schemeRelative = false)
*
* @final
*/
public function isUrlGenerationSafe(Node $argsNode)
public function isUrlGenerationSafe(Node $argsNode): array
{
// support named arguments
$paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : (
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
Expand Up @@ -58,7 +58,7 @@ public function getTranslator(): ?TranslatorInterface
/**
* {@inheritdoc}
*/
public function getFilters()
public function getFilters(): array
{
return [
new TwigFilter('trans', [$this, 'trans']),
Expand All @@ -70,7 +70,7 @@ public function getFilters()
*
* @return AbstractTokenParser[]
*/
public function getTokenParsers()
public function getTokenParsers(): array
{
return [
// {% trans %}Symfony is great!{% endtrans %}
Expand All @@ -84,17 +84,17 @@ public function getTokenParsers()
/**
* {@inheritdoc}
*/
public function getNodeVisitors()
public function getNodeVisitors(): array
{
return [$this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()];
}

public function getTranslationNodeVisitor()
public function getTranslationNodeVisitor(): TranslationNodeVisitor
{
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor();
}

public function trans($message, array $arguments = [], $domain = null, $locale = null, $count = null)
public function trans($message, array $arguments = [], $domain = null, $locale = null, $count = null): string
{
if (null !== $count) {
$arguments['%count%'] = $count;
Expand All @@ -106,7 +106,7 @@ public function trans($message, array $arguments = [], $domain = null, $locale =
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'translator';
}
Expand Down
16 changes: 8 additions & 8 deletions src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php
Expand Up @@ -65,7 +65,7 @@ public function attach(string $file, string $name = null, string $contentType =
/**
* @return $this
*/
public function setSubject(string $subject)
public function setSubject(string $subject): object
{
$this->message->subject($subject);

Expand All @@ -80,7 +80,7 @@ public function getSubject(): ?string
/**
* @return $this
*/
public function setReturnPath(string $address)
public function setReturnPath(string $address): object
{
$this->message->returnPath($address);

Expand All @@ -95,7 +95,7 @@ public function getReturnPath(): string
/**
* @return $this
*/
public function addFrom(string $address, string $name = null)
public function addFrom(string $address, string $name = null): object
{
$this->message->addFrom($name ? new NamedAddress($address, $name) : new Address($address));

Expand All @@ -113,7 +113,7 @@ public function getFrom(): array
/**
* @return $this
*/
public function addReplyTo(string $address)
public function addReplyTo(string $address): object
{
$this->message->addReplyTo($address);

Expand All @@ -131,7 +131,7 @@ public function getReplyTo(): array
/**
* @return $this
*/
public function addTo(string $address, string $name = null)
public function addTo(string $address, string $name = null): object
{
$this->message->addTo($name ? new NamedAddress($address, $name) : new Address($address));

Expand All @@ -149,7 +149,7 @@ public function getTo(): array
/**
* @return $this
*/
public function addCc(string $address, string $name = null)
public function addCc(string $address, string $name = null): object
{
$this->message->addCc($name ? new NamedAddress($address, $name) : new Address($address));

Expand All @@ -167,7 +167,7 @@ public function getCc(): array
/**
* @return $this
*/
public function addBcc(string $address, string $name = null)
public function addBcc(string $address, string $name = null): object
{
$this->message->addBcc($name ? new NamedAddress($address, $name) : new Address($address));

Expand All @@ -185,7 +185,7 @@ public function getBcc(): array
/**
* @return $this
*/
public function setPriority(int $priority)
public function setPriority(int $priority): object
{
$this->message->setPriority($priority);

Expand Down
Expand Up @@ -57,15 +57,15 @@ public function warmUp($cacheDir)
*
* @return bool always true
*/
public function isOptional()
public function isOptional(): bool
{
return true;
}

/**
* {@inheritdoc}
*/
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
'router' => RouterInterface::class,
Expand Down
Expand Up @@ -258,7 +258,7 @@ private function hardCopy(string $originDir, string $targetDir): string
return self::METHOD_COPY;
}

private function getPublicDirectory(ContainerInterface $container)
private function getPublicDirectory(ContainerInterface $container): string
{
$defaultPublicDir = 'public';

Expand Down
Expand Up @@ -208,11 +208,9 @@ protected function validateInput(InputInterface $input)
/**
* Loads the ContainerBuilder from the cache.
*
* @return ContainerBuilder
*
* @throws \LogicException
*/
protected function getContainerBuilder()
protected function getContainerBuilder(): ContainerBuilder
{
if ($this->containerBuilder) {
return $this->containerBuilder;
Expand Down
Expand Up @@ -24,12 +24,12 @@ class ControllerResolver extends ContainerControllerResolver
/**
* {@inheritdoc}
*/
protected function instantiateController($class)
protected function instantiateController($class): object
{
return $this->configureController(parent::instantiateController($class), $class);
}

private function configureController($controller, string $class)
private function configureController($controller, string $class): object
{
if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container);
Expand Down
Expand Up @@ -180,7 +180,7 @@ private function createPasswordQuestion(): Question
})->setHidden(true)->setMaxAttempts(20);
}

private function generateSalt()
private function generateSalt(): string
{
return base64_encode(random_bytes(30));
}
Expand Down
Expand Up @@ -54,7 +54,7 @@ public function __call($method, $arguments)
return $this->listener->{$method}(...$arguments);
}

public function getWrappedListener()
public function getWrappedListener(): callable
{
return $this->listener;
}
Expand Down
Expand Up @@ -55,7 +55,7 @@ public function __construct(Environment $twig, bool $interceptRedirects = false,
$this->cspHandler = $cspHandler;
}

public function isEnabled()
public function isEnabled(): bool
{
return self::DISABLED !== $this->mode;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ protected function injectToolbar(Response $response, Request $request, array $no
}
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
KernelEvents::RESPONSE => ['onKernelResponse', -128],
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/HttpBrowser.php
Expand Up @@ -41,7 +41,7 @@ public function __construct(HttpClientInterface $client = null, History $history
parent::__construct([], $history, $cookieJar);
}

protected function doRequest($request)
protected function doRequest($request): Response
{
$headers = $this->getHeaders($request);
[$body, $extraHeaders] = $this->getBodyAndExtraHeaders($request);
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/BrowserKit/Response.php
Expand Up @@ -40,7 +40,7 @@ public function __construct(string $content = '', int $status = 200, array $head
*
* @return string The response with headers and content
*/
public function __toString()
public function __toString(): string
{
$headers = '';
foreach ($this->headers as $name => $value) {
Expand All @@ -61,7 +61,7 @@ public function __toString()
*
* @return string The response content
*/
public function getContent()
public function getContent(): string
{
return $this->content;
}
Expand All @@ -76,7 +76,7 @@ public function getStatusCode(): int
*
* @return array The response headers
*/
public function getHeaders()
public function getHeaders(): array
{
return $this->headers;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
Expand Up @@ -59,7 +59,7 @@ protected function filterResponse($response)
return $response;
}

protected function doRequest($request)
protected function doRequest($request): Response
{
$response = parent::doRequest($request);

Expand Down
8 changes: 3 additions & 5 deletions src/Symfony/Component/Cache/CacheItem.php
Expand Up @@ -37,7 +37,7 @@ final class CacheItem implements ItemInterface
/**
* {@inheritdoc}
*/
public function getKey()
public function getKey(): string
{
return $this->key;
}
Expand All @@ -53,7 +53,7 @@ public function get()
/**
* {@inheritdoc}
*/
public function isHit()
public function isHit(): bool
{
return $this->isHit;
}
Expand Down Expand Up @@ -145,11 +145,9 @@ public function getMetadata(): array
*
* @param string $key The key to validate
*
* @return string
*
* @throws InvalidArgumentException When $key is not valid
*/
public static function validateKey($key)
public static function validateKey($key): string
{
if (!\is_string($key)) {
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', \is_object($key) ? \get_class($key) : \gettype($key)));
Expand Down

0 comments on commit f84d094

Please sign in to comment.