8000 Replace @return annotation by return type in final classes · symfony/symfony@d6204e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit d6204e8

Browse files
author
dFayet
committed
Replace @return annotation by return type in final classes
1 parent e8c2a1b commit d6204e8

File tree

74 files changed

+150
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+150
-388
lines changed

src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ public function setRepository(EntityManagerInterface $entityManager, $entityName
4747
$this->repositoryList[$repositoryHash] = $repository;
4848
}
4949

50-
/**
51-
* @return ObjectRepository
52-
*/
53-
private function createRepository(EntityManagerInterface $entityManager, $entityName)
50+
private function createRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
5451
{
5552
/* @var $metadata ClassMetadata */
5653
$metadata = $entityManager->getClassMetadata($entityName);

src/Symfony/Bridge/Twig/Extension/RoutingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getUrl($name, $parameters = [], $schemeRelative = false)
9393
*
9494
* @final
9595
*/
96-
public function isUrlGenerationSafe(Node $argsNode)
96+
public function isUrlGenerationSafe(Node $argsNode): array
9797
{
9898
// support named arguments
9999
$paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : (

src/Symfony/Bridge/Twig/Extension/TranslationExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getFilters()
7070
*
7171
* @return AbstractTokenParser[]
7272
*/
73-
public function getTokenParsers()
73+
public function getTokenParsers(): array
7474
{
7575
return [
7676
// {% trans %}Symfony is great!{% endtrans %}

src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ public function attach(string $file, string $name = null, string $contentType =
6262
}
6363
}
6464

65-
/**
66-
* @return $this
67-
*/
68-
public function setSubject(string $subject)
65+
public function setSubject(string $subject): self
6966
{
7067
$this->message->subject($subject);
7168

@@ -77,10 +74,7 @@ public function getSubject(): ?string
7774
return $this->message->getSubject();
7875
}
7976

80-
/**
81-
* @return $this
82-
*/
83-
public function setReturnPath(string $address)
77+
public function setReturnPath(string $address): self
8478
{
8579
$this->message->returnPath($address);
8680

@@ -92,10 +86,7 @@ public function getReturnPath(): string
9286
return $this->message->getReturnPath();
9387
}
9488

95-
/**
96-
* @return $this
97-
*/
98-
public function addFrom(string $address, string $name = null)
89+
public function addFrom(string $address, string $name = null): self
9990
{
10091
$this->message->addFrom($name ? new NamedAddress($address, $name) : new Address($address));
10192

@@ -110,10 +101,7 @@ public function getFrom(): array
110101
return $this->message->getFrom();
111102
}
112103

113-
/**
114-
* @return $this
115-
*/
116-
public function addReplyTo(string $address)
104+
public function addReplyTo(string $address): self
117105
{
118106
$this->message->addReplyTo($address);
119107

@@ -128,10 +116,7 @@ public function getReplyTo(): array
128116
return $this->message->getReplyTo();
129117
}
130118

131-
/**
132-
* @return $this
133-
*/
134-
public function addTo(string $address, string $name = null)
119+
public function addTo(string $address, string $name = null): self
135120
{
136121
$this->message->addTo($name ? new NamedAddress($address, $name) : new Address($address));
137122

@@ -146,10 +131,7 @@ public function getTo(): array
146131
return $this->message->getTo();
147132
}
148133

149-
/**
150-
* @return $this
151-
*/
152-
public function addCc(string $address, string $name = null)
134+
public function addCc(string $address, string $name = null): self
153135
{
154136
$this->message->addCc($name ? new NamedAddress($address, $name) : new Address($address));
155137

@@ -164,10 +146,7 @@ public function getCc(): array
164146
return $this->message->getCc();
165147
}
166148

167-
/**
168-
* @return $this
169-
*/
170-
public function addBcc(string $address, string $name = null)
149+
public function addBcc(string $address, string $name = null): self
171150
{
172151
$this->message->addBcc($name ? new NamedAddress($address, $name) : new Address($address));
173152

@@ -182,10 +161,7 @@ public function getBcc(): array
182161
return $this->message->getBcc();
183162
}
184163

185-
/**
186-
* @return $this
187-
*/
188-
public function setPriority(int $priority)
164+
public function setPriority(int $priority): self
189165
{
190166
$this->message->setPriority($priority);
191167

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function warmUp($cacheDir)
5757
*
5858
* @return bool always true
5959
*/
60-
public function isOptional()
60+
public function isOptional(): bool
6161
{
6262
return true;
6363
}

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,9 @@ protected function validateInput(InputInterface $input)
208208
/**
209209
* Loads the ContainerBuilder from the cache.
210210
*
211-
* @return ContainerBuilder
212-
*
213211
* @throws \LogicException
214212
*/
215-
protected function getContainerBuilder()
213+
protected function getContainerBuilder(): ContainerBuilder
216214
{
217215
if ($this->containerBuilder) {
218216
return $this->containerBuilder;

src/Symfony/Component/BrowserKit/Response.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(string $content = '', int $status = 200, array $head
4040
*
4141
* @return string The response with headers and content
4242
*/
43-
public function __toString()
43+
public function __toString(): string
4444
{
4545
$headers = '';
4646
foreach ($this->headers as $name => $value) {
@@ -61,7 +61,7 @@ public function __toString()
6161
*
6262
* @return string The response content
6363
*/
64-
public function getContent()
64+
public function getContent(): string
6565
{
6666
return $this->content;
6767
}
@@ -76,7 +76,7 @@ public function getStatusCode(): int
7676
*
7777
* @return array The response headers
7878
*/
79-
public function getHeaders()
79+
public function getHeaders(): array
8080
{
8181
return $this->headers;
8282
}

src/Symfony/Component/Cache/CacheItem.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,9 @@ public function getMetadata(): array
145145
*
146146
* @param string $key The key to validate
147147
*
148-
* @return string
149-
*
150148
* @throws InvalidArgumentException When $key is not valid
151149
*/
152-
public static function validateKey($key)
150+
public static function validateKey($key): string
153151
{
154152
if (!\is_string($key)) {
155153
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', \is_object($key) ? \get_class($key) : \gettype($key)));

src/Symfony/Component/Config/Resource/ClassExistenceResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __toString()
5151
/**
5252
* @return string The file path to the resource
5353
*/
54-
public function getResource()
54+
public function getResource(): string
5555
{
5656
return $this->resource;
5757
}

src/Symfony/Component/Config/Resource/DirectoryResource.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,15 @@ public function __toString()
5050
/**
5151
* @return string The file path to the resource
5252
*/
53-
public function getResource()
53+
public function getResource(): string
5454
{
5555
return $this->resource;
5656
}
5757

5858
/**
5959
* Returns the pattern to restrict monitored files.
60-
*
61-
* @return string|null
6260
*/
63-
public function getPattern()
61+
public function getPattern(): ?string
6462
{
6563
return $this->pattern;
6664
}

src/Symfony/Component/Config/Resource/FileExistenceResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __toString()
4747
/**
4848
* @return string The file path to the resource
4949
*/
50-
public function getResource()
50+
public function getResource(): string
5151
{
5252
return $this->resource;
5353
}

src/Symfony/Component/Config/Resource/FileResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __toString()
5252
/**
5353
* @return string The canonicalized, absolute path to the resource
5454
*/
55-
public function getResource()
55+
public function getResource(): string
5656
{
5757
return $this->resource;
5858
}

src/Symfony/Component/Console/Helper/ProcessHelper.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ProcessHelper extends Helper
3737
*
3838
* @return Process The process that ran
3939
*/
40-
public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
40+
public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
4141
{
4242
if ($output instanceof ConsoleOutputInterface) {
4343
$output = $output->getErrorOutput();
@@ -103,7 +103,7 @@ public function run(OutputInterface $output, $cmd, $error = null, callable $call
103103
*
104104
* @see run()
105105
*/
106-
public function mustRun(OutputInterface $output, $cmd, $error = null, callable $callback = null)
106+
public function mustRun(OutputInterface $output, $cmd, $error = null, callable $callback = null): Process
107107
{
108108
$process = $this->run($output, $cmd, $error, $callback);
109109

@@ -120,10 +120,8 @@ public function mustRun(OutputInterface $output, $cmd, $error = null, callable $
120120
* @param OutputInterface $output An OutputInterface interface
121121
* @param Process $process The Process
122122
* @param callable|null $callback A PHP callable
123-
*
124-
* @return callable
125123
*/
126-
public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null)
124+
public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable
127125
{
128126
if ($output instanceof ConsoleOutputInterface) {
129127
$output = $output->getErrorOutput();

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ErrorHandler
112112
*
113113
* @return self The registered error handler
114114
*/
115-
public static function register(self $handler = null, $replace = true)
115+
public static function register(self $handler = null, $replace = true): self
116116
{
117117
if (null === self::$reservedMemory) {
118118
self::$reservedMemory = str_repeat('x', 10240);
@@ -210,7 +210,7 @@ public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $repl
210210
*
211211
* @throws \InvalidArgumentException
212212
*/
213-
public function setLoggers(array $loggers)
213+
public function setLoggers(array $loggers): array
214214
{
215215
$prevLogged = $this->loggedErrors;
216216
$prev = $this->loggers;
@@ -261,7 +261,7 @@ public function setLoggers(array $loggers)
261261
*
262262
* @return callable|null The previous exception handler
263263
*/
264-
public function setExceptionHandler(callable $handler = null)
264+
public function setExceptionHandler(callable $handler = null): ?callable
265265
{
266266
$prev = $this->exceptionHandler;
267267
$this->exceptionHandler = $handler;
@@ -277,7 +277,7 @@ public function setExceptionHandler(callable $handler = null)
277277
*
278278
* @return int The previous value
279279
*/
280-
public function throwAt($levels, $replace = false)
280+
public function throwAt($levels, $replace = false): int
281281
{
282282
$prev = $this->thrownErrors;
283283
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
@@ -297,7 +297,7 @@ public function throwAt($levels, $replace = false)
297297
*
298298
* @return int The previous value
299299
*/
300-
public function scopeAt($levels, $replace = false)
300+
public function scopeAt($levels, $replace = false): int
301301
{
302302
$prev = $this->scopedErrors;
303303
$this->scopedErrors = (int) $levels;
@@ -316,7 +316,7 @@ public function scopeAt($levels, $replace = false)
316316
*
317317
* @return int The previous value
318318
*/
319-
public function traceAt($levels, $replace = false)
319+
public function traceAt($levels, $replace = false): int
320320
{
321321
$prev = $this->tracedErrors;
322322
$this->tracedErrors = (int) $levels;
@@ -335,7 +335,7 @@ public function traceAt($levels, $replace = false)
335335
*
336336
* @return int The previous value
337337
*/
338-
public function screamAt($levels, $replace = false)
338+
public function screamAt($levels, $replace = false): int
339339
{
340340
$prev = $this->screamedErrors;
341341
$this->screamedErrors = (int) $levels;
@@ -670,7 +670,7 @@ public static function handleFatalError(array $error = null)
670670
*
671671
* @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface
672672
*/
673-
protected function getFatalErrorHandlers()
673+
protected function getFatalErrorHandlers(): array
674674
{
675675
return [
676676
new UndefinedFunctionFatalErrorHandler(),

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static function register($debug = true, $charset = null, $fileLinkFormat
8484
*
8585
* @return callable|null The previous exception handler if any
8686
*/
87-
public function setHandler(callable $handler = null)
87+
public function setHandler(callable $handler = null): ?callable
8888
{
8989
$old = $this->handler;
9090
$this->handler = $handler;
@@ -99,7 +99,7 @@ public function setHandler(callable $handler = null)
9999
*
100100
* @return string The previous file link format
101101
*/
102-
public function setFileLinkFormat($fileLinkFormat)
102+
public function setFileLinkFormat($fileLinkFormat): string
103103
{
104104
$old = $this->fileLinkFormat;
105105
$this->fileLinkFormat = $fileLinkFormat;
@@ -196,7 +196,7 @@ public function sendPhpResponse($exception)
196196
*
197197
* @return string The HTML content as a string
198198
*/
199-
public function getHtml($exception)
199+
public function getHtml($exception): string
200200
{
201201
if (!$exception instanceof FlattenException) {
202202
$exception = FlattenException::create($exception);
@@ -210,7 +210,7 @@ public function getHtml($exception)
210210
*
211211
* @return string The content as a string
212212
*/
213-
public function getContent(FlattenException $exception)
213+
public function getContent(FlattenException $exception): string
214214
{
215215
switch ($exception->getStatusCode()) {
216216
case 404:
@@ -295,7 +295,7 @@ public function getContent(FlattenException $exception)
295295
*
296296
* @return string The stylesheet as a string
297297
*/
298-
public function getStylesheet(FlattenException $exception)
298+
public function getStylesheet(FlattenException $exception): string
299299
{
300300
if (!$this->debug) {
301301
return <<<'EOF'
@@ -415,10 +415,8 @@ private function formatPath($path, $line)
415415
* Formats an array as a string.
416416
*
417417
* @param array $args The argument array
418-
*
419-
* @return string
420418
*/
421-
private function formatArgs(array $args)
419+
private function formatArgs(array $args): string
422420
{
423421
$result = [];
424422
foreach ($args as $key => $item) {

0 commit comments

Comments
 (0)
0