Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpClient][HttpFoundation][HttpKernel][Ldap][Mailer][Mime][Process][Routing][Security][Serializer][Translation][Validator] Add missing return types #50185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 196 additions & 53 deletions .github/expected-missing-return-types.diff

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/Symfony/Component/HttpClient/Response/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class StreamWrapper
/** @var resource|string|null */
private $content;

/** @var resource|null */
/** @var resource|callable|null */
private $handle;

private bool $blocking = true;
Expand Down Expand Up @@ -266,6 +266,9 @@ public function stream_seek(int $offset, int $whence = \SEEK_SET): bool
return false;
}

/**
* @return resource|false
*/
public function stream_cast(int $castAs)
{
if (\STREAM_CAST_FOR_SELECT === $castAs) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,9 @@ public function preferSafeContent(): bool
* Copyright (c) 2005-2010 Zend Technologies USA Inc. (https://www.zend.com/)
*/

/**
* @return string
*/
protected function prepareRequestUri()
{
$requestUri = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ final public function load(array $configs, ContainerBuilder $container): void

/**
* Configures the passed container according to the merged configuration.
*
* @return void
*/
abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container);
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Security/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ protected function loadUser(string $identifier, Entry $entry): UserInterface
return new LdapUser($entry, $identifier, $password, $this->defaultRoles, $extraFields);
}

private function getAttributeValue(Entry $entry, string $attribute)
private function getAttributeValue(Entry $entry, string $attribute): mixed
{
if (!$entry->hasAttribute($attribute)) {
throw new InvalidArgumentException(sprintf('Missing attribute "%s" for user "%s".', $attribute, $entry->getDn()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function getEndpoint(): ?string
return ($this->host ?: self::HOST).($this->port ? ':'.$this->port : '');
}

private function castCustomHeader(string $value, string $type)
private function castCustomHeader(string $value, string $type): mixed
{
return match ($type) {
'bool' => filter_var($value, \FILTER_VALIDATE_BOOL),
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Mime/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ public function getBody(): AbstractPart
return $this->generateBody();
}

/**
* @return void
*/
public function ensureValidity()
{
$this->ensureBodyValid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function __construct(Process $process)
$this->process = $process;
}

/**
* @return Process
*/
public function getProcess()
{
return $this->process;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function __construct(Process $process, int $timeoutType)
));
}

/**
* @return Process
*/
public function getProcess()
{
return $this->process;
Expand All @@ -59,7 +62,7 @@ public function isIdleTimeout()
return self::TYPE_IDLE === $this->timeoutType;
}

public function getExceededTimeout()
public function getExceededTimeout(): ?float
{
return match ($this->timeoutType) {
self::TYPE_GENERAL => $this->process->getTimeout(),
Expand Down
18 changes: 13 additions & 5 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ public function mustRun(callable $callback = null, array $env = []): static
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
*
* @return void
*
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running
* @throws LogicException In case a callback is provided and output has been disabled
Expand Down Expand Up @@ -1140,6 +1142,8 @@ public function setInput(mixed $input): static
* In case you run a background process (with the start method), you should
* trigger this method regularly to ensure the process timeout
*
* @return void
*
* @throws ProcessTimedOutException In case the timeout was reached
*/
public function checkTimeout()
Expand Down Expand Up @@ -1180,6 +1184,8 @@ public function getStartTime(): float
*
* Enabling the "create_new_console" option allows a subprocess to continue
* to run after the main process exited, on both Windows and *nix
*
* @return void
*/
public function setOptions(array $options)
{
Expand Down Expand Up @@ -1275,6 +1281,8 @@ protected function buildCallback(callable $callback = null): \Closure
* Updates the status of the process, reads pipes.
*
* @param bool $blocking Whether to use a blocking read call
*
* @return void
*/
protected function updateStatus(bool $blocking)
{
Expand Down Expand Up @@ -1323,7 +1331,7 @@ protected function isSigchildEnabled(): bool
*
* @throws LogicException in case output has been disabled or process is not started
*/
private function readPipesForOutput(string $caller, bool $blocking = false)
private function readPipesForOutput(string $caller, bool $blocking = false): void
{
if ($this->outputDisabled) {
throw new LogicException('Output has been disabled.');
Expand Down Expand Up @@ -1358,7 +1366,7 @@ private function validateTimeout(?float $timeout): ?float
* @param bool $blocking Whether to use blocking calls or not
* @param bool $close Whether to close file handles or not
*/
private function readPipes(bool $blocking, bool $close)
private function readPipes(bool $blocking, bool $close): void
{
$result = $this->processPipes->readAndWrite($blocking, $close);

Expand Down Expand Up @@ -1407,7 +1415,7 @@ private function close(): int
/**
* Resets data related to the latest run of the process.
*/
private function resetProcessData()
private function resetProcessData(): void
{
$this->starttime = null;
$this->callback = null;
Expand Down Expand Up @@ -1528,7 +1536,7 @@ function ($m) use (&$env, $uid) {
*
* @throws LogicException if the process has not run
*/
private function requireProcessIsStarted(string $functionName)
private function requireProcessIsStarted(string $functionName): void
{
if (!$this->isStarted()) {
throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName));
Expand All @@ -1540,7 +1548,7 @@ private function requireProcessIsStarted(string $functionName)
*
* @throws LogicException if the process is not yet terminated
*/
private function requireProcessIsTerminated(string $functionName)
private function requireProcessIsTerminated(string $functionName): void
{
if (!$this->isTerminated()) {
throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ protected function createRoute(string $path, array $defaults, array $requirement
return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
}

/**
* @return void
*/
abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot);

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Routing/Matcher/UrlMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ protected function mergeDefaults(array $params, array $defaults): array
return $defaults;
}

/**
* @return ExpressionLanguage
*/
protected function getExpressionLanguage()
{
if (null === $this->expressionLanguage) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public function getOption(string $key): mixed
return $this->options[$key];
}

/**
* @return RouteCollection
*/
public function getRouteCollection()
{
return $this->collection ??= $this->loader->load($this->resource, $this->options['resource_type']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function testImportAttributesWithPsr4Prefix(string $configFile)
$loader = new PhpFileLoader($locator),
new Psr4DirectoryLoader($locator),
new class() extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
{
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
}
Expand All @@ -337,7 +337,7 @@ public function testImportAttributesFromClass()
new LoaderResolver([
$loader = new PhpFileLoader(new FileLocator(\dirname(__DIR__).'/Fixtures')),
new class() extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
{
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private function getLoader(): DelegatingLoader
new LoaderResolver([
new Psr4DirectoryLoader($locator),
new class() extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
{
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public function testImportAttributesWithPsr4Prefix(string $configFile)
$loader = new XmlFileLoader($locator),
new Psr4DirectoryLoader($locator),
new class() extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
{
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
}
Expand All @@ -632,7 +632,7 @@ public function testImportAttributesFromClass()
new LoaderResolver([
$loader = new XmlFileLoader(new FileLocator(\dirname(__DIR__).'/Fixtures')),
new class() extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
{
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public function testImportAttributesWithPsr4Prefix(string $configFile)
$loader = new YamlFileLoader($locator),
new Psr4DirectoryLoader($locator),
new class() extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
{
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
}
Expand All @@ -498,7 +498,7 @@ public function testImportAttributesFromClass()
new LoaderResolver([
$loader = new YamlFileLoader(new FileLocator(\dirname(__DIR__).'/Fixtures')),
new class() extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot)
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
{
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function __construct(array $users = [])
/**
* Adds a new User to the provider.
*
* @return void
*
* @throws \LogicException
*/
public function createUser(UserInterface $user)
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Security/Http/Firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public function onKernelFinishRequest(FinishRequestEvent $event)
}
}

/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,17 @@ public function __construct(

/**
* @param array $context
*
* @return bool
*/
public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */)
{
return \is_object($data) && !$data instanceof \Traversable;
}

/**
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize(mixed $object, string $format = null, array $context = [])
{
if (!isset($context['cache_key'])) {
Expand Down Expand Up @@ -226,6 +231,9 @@ public function normalize(mixed $object, string $format = null, array $context =
return $data;
}

/**
* @return object
*/
protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
{
if ($this->classDiscriminatorResolver && $mapping = $this->classDiscriminatorResolver->getMappingForClass($class)) {
Expand Down Expand Up @@ -299,12 +307,17 @@ abstract protected function getAttributeValue(object $object, string $attribute,

/**
* @param array $context
*
* @return bool
*/
public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */)
{
return class_exists($type) || (interface_exists($type, false) && null !== $this->classDiscriminatorResolver?->getMappingForClass($type));
}

/**
* @return mixed
*/
public function denormalize(mixed $data, string $type, string $format = null, array $context = [])
{
if (!isset($context['cache_key'])) {
Expand Down Expand Up @@ -408,7 +421,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
}

/**
* Sets attribute value.
* @return void
*/
abstract protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ public function moveMessagesToIntlDomainsIfPossible(string $batch = self::ALL_BA
* stores the results.
*
* @param string $domain The domain which the operation will be performed for
*
* @return void
*/
abstract protected function processDomain(string $domain);
}
Loading