Add more return types after fixing a typo in my script

This commit is contained in:
Nicolas Grekas 2019-08-23 14:04:07 +02:00
parent 3456446de5
commit 65d942010c
26 changed files with 37 additions and 49 deletions

View File

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

View File

@ -153,8 +153,8 @@ class ClassThatInheritLogger extends Logger
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();
}
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());
}
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)%"');

View File

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

View File

@ -74,7 +74,7 @@ EOF
*
* @throws \LogicException
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$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)',
]);
return null;
return 0;
}
$extension = $this->findExtension($name);
@ -130,6 +130,6 @@ EOF
$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}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$errorIo = $io->getErrorStyle();
@ -146,7 +146,7 @@ EOF
$io->newLine();
return null;
return 0;
}
private function getFileLink(string $class): string

View File

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

View File

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

View File

@ -101,7 +101,7 @@ EOF
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
@ -163,7 +163,7 @@ EOF
$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);
}
/**
* @return array
*/
public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);

View File

@ -150,7 +150,7 @@ class Command
* execute() method, you set the code to execute by passing
* 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
*

View File

@ -53,10 +53,8 @@ class Specificity
/**
* Returns -1 if the object specificity is lower than the argument,
* 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) {
return $this->a > $specificity->a ? 1 : -1;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ class TraceableVoter implements VoterInterface
$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);

View File

@ -31,7 +31,7 @@ class Exporter
* @param int &$objectsCount
* @param bool &$valuesAreStatic
*
* @return int
* @return array
*
* @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
{
}