minor #33302 Add more return types after fixing a typo in my script (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

Add more return types after fixing a typo in my script

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

65d942010c Add more return types after fixing a typo in my script
This commit is contained in:
Nicolas Grekas 2019-08-23 14:17:32 +02:00
commit 0fa1246e30
26 changed files with 37 additions and 49 deletions

View File

@ -31,10 +31,7 @@ class BaseUser
$this->username = $username; $this->username = $username;
} }
/** public function getId(): int
* @return int
*/
public function getId()
{ {
return $this->id; return $this->id;
} }

View File

@ -153,8 +153,8 @@ class ClassThatInheritLogger extends Logger
return parent::getLogs(); return parent::getLogs();
} }
public function countErrors() public function countErrors(): int
{ {
parent::countErrors(); return parent::countErrors();
} }
} }

View File

@ -104,8 +104,8 @@ class ClassThatInheritDebugProcessor extends DebugProcessor
return parent::getLogs(); return parent::getLogs();
} }
public function countErrors() public function countErrors(): int
{ {
parent::countErrors(); return parent::countErrors();
} }
} }

View File

@ -43,7 +43,7 @@ class ServerDumpPlaceholderCommand extends Command
$this->setDescription($this->replacedCommand->getDescription()); $this->setDescription($this->replacedCommand->getDescription());
} }
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int
{ {
(new SymfonyStyle($input, $output))->getErrorStyle()->warning('In order to use the VarDumper server, set the "debug.dump_destination" config option to "tcp://%env(VAR_DUMPER_SERVER)%"'); (new SymfonyStyle($input, $output))->getErrorStyle()->warning('In order to use the VarDumper server, set the "debug.dump_destination" config option to "tcp://%env(VAR_DUMPER_SERVER)%"');

View File

@ -95,7 +95,7 @@ EOT
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int
{ {
/** @var KernelInterface $kernel */ /** @var KernelInterface $kernel */
$kernel = $this->getApplication()->getKernel(); $kernel = $this->getApplication()->getKernel();

View File

@ -74,7 +74,7 @@ EOF
* *
* @throws \LogicException * @throws \LogicException
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$errorIo = $io->getErrorStyle(); $errorIo = $io->getErrorStyle();
@ -86,7 +86,7 @@ EOF
'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)', 'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)',
]); ]);
return null; return 0;
} }
$extension = $this->findExtension($name); $extension = $this->findExtension($name);
@ -130,6 +130,6 @@ EOF
$io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path)); $io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path));
return null; return 0;
} }
} }

View File

@ -69,7 +69,7 @@ EOF
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$errorIo = $io->getErrorStyle(); $errorIo = $io->getErrorStyle();
@ -146,7 +146,7 @@ EOF
$io->newLine(); $io->newLine();
return null; return 0;
} }
private function getFileLink(string $class): string private function getFileLink(string $class): string

View File

@ -71,7 +71,7 @@ EOF
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -114,6 +114,6 @@ EOF
return 1; return 1;
} }
return null; return 0;
} }
} }

View File

@ -102,7 +102,7 @@ EOF
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$errorIo = $io->getErrorStyle(); $errorIo = $io->getErrorStyle();
@ -236,7 +236,7 @@ EOF
if (!\count($operation->getDomains())) { if (!\count($operation->getDomains())) {
$errorIo->warning('No translation messages were found.'); $errorIo->warning('No translation messages were found.');
return null; return 0;
} }
$resultMessage = 'Translation files were successfully updated'; $resultMessage = 'Translation files were successfully updated';
@ -302,7 +302,7 @@ EOF
$errorIo->success($resultMessage.'.'); $errorIo->success($resultMessage.'.');
return null; return 0;
} }
private function filterCatalogue(MessageCatalogue $catalogue, string $domain): MessageCatalogue private function filterCatalogue(MessageCatalogue $catalogue, string $domain): MessageCatalogue

View File

@ -101,7 +101,7 @@ EOF
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; $errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
@ -163,7 +163,7 @@ EOF
$errorIo->success('Password encoding succeeded'); $errorIo->success('Password encoding succeeded');
return null; return 0;
} }
/** /**

View File

@ -131,6 +131,9 @@ trait FilesystemCommonTrait
throw new \ErrorException($message, 0, $type, $file, $line); throw new \ErrorException($message, 0, $type, $file, $line);
} }
/**
* @return array
*/
public function __sleep() public function __sleep()
{ {
throw new \BadMethodCallException('Cannot serialize '.__CLASS__); throw new \BadMethodCallException('Cannot serialize '.__CLASS__);

View File

@ -150,7 +150,7 @@ class Command
* execute() method, you set the code to execute by passing * execute() method, you set the code to execute by passing
* a Closure to the setCode() method. * a Closure to the setCode() method.
* *
* @return int|null null or 0 if everything went fine, or an error code * @return int|void void or 0 if everything went fine, or an exit code
* *
* @throws LogicException When this abstract method is not implemented * @throws LogicException When this abstract method is not implemented
* *

View File

@ -53,10 +53,8 @@ class Specificity
/** /**
* Returns -1 if the object specificity is lower than the argument, * Returns -1 if the object specificity is lower than the argument,
* 0 if they are equal, and 1 if the argument is lower. * 0 if they are equal, and 1 if the argument is lower.
*
* @return int
*/ */
public function compareTo(self $specificity) public function compareTo(self $specificity): int
{ {
if ($this->a !== $specificity->a) { if ($this->a !== $specificity->a) {
return $this->a > $specificity->a ? 1 : -1; return $this->a > $specificity->a ? 1 : -1;

View File

@ -124,7 +124,7 @@ final class LegacyEventDispatcherProxy implements EventDispatcherInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getListenerPriority($eventName, $listener) public function getListenerPriority($eventName, $listener): ?int
{ {
return $this->dispatcher->getListenerPriority($eventName, $listener); return $this->dispatcher->getListenerPriority($eventName, $listener);
} }

View File

@ -137,11 +137,9 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
} }
/** /**
* @return int
*
* @internal * @internal
*/ */
public function getUsageIndex() public function getUsageIndex(): int
{ {
return $this->usageIndex; return $this->usageIndex;
} }

View File

@ -159,7 +159,7 @@ class ExceptionListenerTest extends TestCase
class TestLogger extends Logger implements DebugLoggerInterface class TestLogger extends Logger implements DebugLoggerInterface
{ {
public function countErrors() public function countErrors(): int
{ {
return \count($this->logs['critical']); return \count($this->logs['critical']);
} }

View File

@ -967,10 +967,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
abstract protected function getIntlErrorMessage(): string; abstract protected function getIntlErrorMessage(): string;
/** abstract protected function getIntlErrorCode(): int;
* @return int
*/
abstract protected function getIntlErrorCode();
/** /**
* @param int $errorCode * @param int $errorCode

View File

@ -188,7 +188,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
return IntlGlobals::getErrorMessage(); return IntlGlobals::getErrorMessage();
} }
protected function getIntlErrorCode() protected function getIntlErrorCode(): int
{ {
return IntlGlobals::getErrorCode(); return IntlGlobals::getErrorCode();
} }

View File

@ -73,7 +73,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
return intl_get_error_message(); return intl_get_error_message();
} }
protected function getIntlErrorCode() protected function getIntlErrorCode(): int
{ {
return intl_get_error_code(); return intl_get_error_code();
} }

View File

@ -842,10 +842,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
abstract protected function getIntlErrorMessage(): string; abstract protected function getIntlErrorMessage(): string;
/** abstract protected function getIntlErrorCode(): int;
* @return int
*/
abstract protected function getIntlErrorCode();
/** /**
* @param int $errorCode * @param int $errorCode

View File

@ -178,7 +178,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
return IntlGlobals::getErrorMessage(); return IntlGlobals::getErrorMessage();
} }
protected function getIntlErrorCode() protected function getIntlErrorCode(): int
{ {
return IntlGlobals::getErrorCode(); return IntlGlobals::getErrorCode();
} }

View File

@ -49,7 +49,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
return intl_get_error_message(); return intl_get_error_message();
} }
protected function getIntlErrorCode() protected function getIntlErrorCode(): int
{ {
return intl_get_error_code(); return intl_get_error_code();
} }

View File

@ -73,11 +73,9 @@ final class ConnectionOptions
* *
* @param string $name * @param string $name
* *
* @return int
*
* @throws LdapException * @throws LdapException
*/ */
public static function getOption($name) public static function getOption($name): int
{ {
// Convert // Convert
$constantName = self::getOptionName($name); $constantName = self::getOptionName($name);

View File

@ -34,7 +34,7 @@ class TraceableVoter implements VoterInterface
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher); $this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
} }
public function vote(TokenInterface $token, $subject, array $attributes) public function vote(TokenInterface $token, $subject, array $attributes): int
{ {
$result = $this->voter->vote($token, $subject, $attributes); $result = $this->voter->vote($token, $subject, $attributes);

View File

@ -31,7 +31,7 @@ class Exporter
* @param int &$objectsCount * @param int &$objectsCount
* @param bool &$valuesAreStatic * @param bool &$valuesAreStatic
* *
* @return int * @return array
* *
* @throws NotInstantiableTypeException When a value cannot be serialized * @throws NotInstantiableTypeException When a value cannot be serialized
*/ */

View File

@ -601,7 +601,7 @@ class EventDispatcherMock implements \Symfony\Component\EventDispatcher\EventDis
{ {
} }
public function getListenerPriority($eventName, $listener) public function getListenerPriority($eventName, $listener): ?int
{ {
} }