8000 Add types to private and final methods. · symfony/symfony@349108f · GitHub
[go: up one dir, main page]

Skip to content

Commit 349108f

Browse files
committed
Add types to private and final methods.
1 parent ff63bb3 commit 349108f

File tree

14 files changed

+29
-22
lines changed
  • Messenger
  • PropertyAccess
  • Security/Http/RememberMe
  • Translation/Command
  • Validator/Constraints
  • Workflow
  • 14 files changed

    +29
    -22
    lines changed

    src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -119,7 +119,7 @@ public function getName()
    119119
    return 'db';
    120120
    }
    121121

    122-
    private function sanitizeQueries(string $connectionName, array $queries)
    122+
    private function sanitizeQueries(string $connectionName, array $queries): array
    123123
    {
    124124
    foreach ($queries as $i => $query) {
    125125
    $queries[$i] = $this->sanitizeQuery($connectionName, $query);
    @@ -128,7 +128,7 @@ private function sanitizeQueries(string $connectionName, array $queries)
    128128
    return $queries;
    129129
    }
    130130

    131-
    private function sanitizeQuery(string $connectionName, $query)
    131+
    private function sanitizeQuery(string $connectionName, array $query): array
    132132
    {
    133133
    $query['explainable'] = true;
    134134
    if (null === $query['params']) {

    src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -180,7 +180,7 @@ private function replacePlaceHolder(array $record)
    180180
    return $record;
    181181
    }
    182182

    183-
    private function dumpData($data, $colors = null)
    183+
    private function dumpData($data, bool $colors = null): string
    184184
    {
    185185
    if (null === $this->dumper) {
    186186
    return '';

    src/Symfony/Bridge/Twig/Command/LintCommand.php

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -118,13 +118,13 @@ protected function findFiles($filename)
    118118
    throw new RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
    119119
    }
    120120

    121-
    private function validate(string $template, $file)
    121+
    private function validate(string $template, string $file): array
    122122
    {
    123123
    $realLoader = $this->twig->getLoader();
    124124
    try {
    125-
    $temporaryLoader = new ArrayLoader([(string) $file => $template]);
    125+
    $temporaryLoader = new ArrayLoader([$file => $template]);
    126126
    $this->twig->setLoader($temporaryLoader);
    127-
    $nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file)));
    127+
    $nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, $file)));
    128128
    $this->twig->compile($nodeTree);
    129129
    $this->twig->setLoader($realLoader);
    130130
    } catch (Error $e) {

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

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -72,7 +72,7 @@ protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array
    7272
    /**
    7373
    * @internal
    7474
    */
    75-
    final protected function ignoreAutoloadException($class, \Exception $exception)
    75+
    final protected function ignoreAutoloadException(string $class, \Exception $exception): void
    7676
    {
    7777
    try {
    7878
    ClassExistenceResource::throwOnRequiredClass($class, $exception);

    src/Symfony/Component/BrowserKit/Cookie.php

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -199,7 +199,7 @@ public static function fromString($cookie, $url = null)
    199199
    );
    200200
    }
    201201

    202-
    private static function parseDate($dateValue)
    202+
    private static function parseDate(string $dateValue): ?string
    203203
    {
    204204
    // trim single quotes around date if present
    205205
    if (($length = \strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) {
    @@ -216,6 +216,8 @@ private static function parseDate($dateValue)
    216216
    if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
    217217
    return $date->format('U');
    218218
    }
    219+
    220+
    return null;
    219221
    }
    220222

    221223
    /**

    src/Symfony/Component/Filesystem/Filesystem.php

    Lines changed: 4 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -740,7 +740,10 @@ private function getSchemeAndHierarchy(string $filename): array
    740740
    return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
    741741
    }
    742742

    743-
    private static function box($func)
    743+
    /**
    744+
    * @return mixed
    745+
    */
    746+
    private static function box(callable $func)
    744747
    {
    745748
    self::$lastError = null;
    746749
    set_error_handler(__CLASS__.'::handleError');

    src/Symfony/Component/Form/Extension/Core/Type/FileType.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -246,8 +246,8 @@ private function factorizeSizes(int $size, int $limit)
    246246
    /**
    247247
    * This method should be kept in sync with Symfony\Component\Validator\Constraints\FileValidator::moreDecimalsThan().
    248248
    */
    249-
    private static function moreDecimalsThan($double, $numberOfDecimals)
    249+
    private static function moreDecimalsThan(string $double, int $numberOfDecimals): bool
    250250
    {
    251-
    return \strlen((string) $double) > \strlen(round($double, $numberOfDecimals));
    251+
    return \strlen($double) > \strlen(round($double, $numberOfDecimals));
    252252
    }
    253253
    }

    src/Symfony/Component/Form/FormFactoryBuilder.php

    Lines changed: 1 addition & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -47,10 +47,7 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface
    4747
    */
    4848
    private $typeGuessers = [];
    4949

    50-
    /**
    51-
    * @param bool $forceCoreExtension
    52-
    */
    53-
    public function __construct($forceCoreExtension = false)
    50+
    public function __construct(bool $forceCoreExtension = false)
    5451
    {
    5552
    $this->forceCoreExtension = $forceCoreExtension;
    5653
    }

    src/Symfony/Component/Messenger/MessageBus.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -39,7 +39,7 @@ public function __construct(iterable $middlewareHandlers = [])
    3939
    private $middlewareHandlers;
    4040
    private $cachedIterator;
    4141

    42-
    public function __construct($middlewareHandlers)
    42+
    public function __construct(\Traversable $middlewareHandlers)
    4343
    {
    4444
    $this->middlewareHandlers = $middlewareHandlers;
    4545
    }

    src/Symfony/Component/PropertyAccess/PropertyAccessor.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -181,7 +181,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
    181181
    }
    182182
    }
    183183

    184-
    private static function throwInvalidArgumentException($message, $trace, $i, $propertyPath)
    184+
    private static function throwInvalidArgumentException(string $message, array $trace, int $i, $propertyPath): void
    185185
    {
    186186
    // the type mismatch is not caused by invalid arguments (but e.g. by an incompatible return type hint of the writer method)
    187187
    if (0 !== strpos($message, 'Argument ')) {

    src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -22,6 +22,7 @@
    2222
    use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
    2323
    use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
    2424
    use Symfony\Component\Security\Core\User\UserInterface;
    25+
    use Symfony\Component\Security\Core\User\UserProviderInterface;
    2526
    use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
    2627
    use Symfony\Component\Security\Http\ParameterBagUtils;
    2728

    @@ -221,7 +222,7 @@ protected function onLoginFail(Request $request, \Exception $exception = null)
    221222
    */
    222223
    abstract protected function onLoginSuccess(Request $request, Response $response, TokenInterface $token);
    223224

    224-
    final protected function getUserProvider($class)
    225+
    final protected function getUserProvider(string $class): UserProviderInterface
    225226
    {
    226227
    foreach ($this->userProviders as $provider) {
    227228
    if ($provider->supportsClass($class)) {

    src/Symfony/Component/Translation/Command/XliffLintCommand.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
    106106
    return $this->display($io, $filesInfo);
    107107
    }
    108108

    109-
    private function validate(string $content, $file = null)
    109+
    private function validate(string $content, string $file = null): array
    110110
    {
    111111
    $errors = [];
    112112

    src/Symfony/Component/Validator/Constraints/FileValidator.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -199,9 +199,9 @@ public function validate($value, Constraint $constraint)
    199199
    }
    200200
    }
    201201

    202-
    private static function moreDecimalsThan($double, $numberOfDecimals)
    202+
    private static function moreDecimalsThan(string $double, int $numberOfDecimals): bool
    203203
    {
    204-
    return \strlen((string) $double) > \strlen(round($double, $numberOfDecimals));
    204+
    return \strlen($double) > \strlen(round($double, $numberOfDecimals));
    205205
    }
    206206

    207207
    /**

    src/Symfony/Component/Workflow/Registry.php

    Lines changed: 5 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -82,7 +82,11 @@ public function all($subject): array
    8282
    return $matched;
    8383
    }
    8484

    85-
    private function supports(WorkflowInterface $workflow, $supportStrategy, $subject, $workflowName): bool
    85+
    /**
    86+
    * @param WorkflowSupportStrategyInterface $supportStrategy
    87+
    * @param object $subject
    88+
    */
    89+
    private function supports(WorkflowInterface $workflow, $supportStrategy, $subject, ?string $workflowName): bool
    8690
    {
    8791
    if (null !== $workflowName && $workflowName !== $workflow->getName()) {
    8892
    return false;

    0 commit comments

    Comments
     (0)
    0