Skip to content

Commit

Permalink
[Components] Convert to native return types
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj authored and nicolas-grekas committed Jul 5, 2023
1 parent 47bf7f3 commit a250774
Show file tree
Hide file tree
Showing 717 changed files with 1,716 additions and 20,028 deletions.
14,199 changes: 27 additions & 14,172 deletions .github/expected-missing-return-types.diff

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions .github/patch-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'):
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionUnionTypeWithIntersectionFixture.php'):
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Internal'):
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Tests/Fixtures/LazyGhost/ReadOnlyClass.php'):
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Tests/Fixtures/LazyProxy/ReadOnlyClass.php'):
case false !== strpos($file, '/src/Symfony/Component/VarExporter/Tests/Fixtures/'):
case false !== strpos($file, '/src/Symfony/Component/Cache/Traits/RelayProxy.php'):
case false !== strpos($file, '/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php'):
case false !== strpos($file, '/src/Symfony/Contracts/Service/Test/ServiceLocatorTestCase.php'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde
$this->prepareContainer($containerBuilder);

return $containerBuilder;
}, $kernel, \get_class($kernel));
}, $kernel, $kernel::class);
$container = $buildContainer();
(new XmlFileLoader($container, new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
$locatorPass = new ServiceLocatorTagPass();
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Contracts\Service\ResetInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver;
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ContainerAwareController;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __sleep(): array
return ['varDir', 'testCase', 'rootConfig', 'environment', 'debug'];
}

public function __wakeup()
public function __wakeup(): void
{
foreach ($this as $k => $v) {
if (\is_object($v)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken;

use Jose\Component\Core\Algorithm;
use Jose\Component\Core\JWK;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public function searchBarAction(Request $request): Response

$this->cspHandler?->disableCsp();


$session = null;
if ($request->attributes->getBoolean('_stateless') && $request->hasSession()) {
$session = $request->getSession();
Expand Down
10 changes: 2 additions & 8 deletions src/Symfony/Component/Asset/Packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ public function __construct(PackageInterface $defaultPackage = null, iterable $p
}
}

/**
* @return void
*/
public function setDefaultPackage(PackageInterface $defaultPackage)
public function setDefaultPackage(PackageInterface $defaultPackage): void
{
$this->defaultPackage = $defaultPackage;
}

/**
* @return void
*/
public function addPackage(string $name, PackageInterface $package)
public function addPackage(string $name, PackageInterface $package): void
{
$this->packages[$name] = $package;
}
Expand Down
48 changes: 12 additions & 36 deletions src/Symfony/Component/BrowserKit/AbstractBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,16 @@ public function __construct(array $server = [], History $history = null, CookieJ

/**
* Sets whether to automatically follow redirects or not.
*
* @return void
*/
public function followRedirects(bool $followRedirects = true)
public function followRedirects(bool $followRedirects = true): void
{
$this->followRedirects = $followRedirects;
}

/**
* Sets whether to automatically follow meta refresh redirects or not.
*
* @return void
*/
public function followMetaRefresh(bool $followMetaRefresh = true)
public function followMetaRefresh(bool $followMetaRefresh = true): void
{
$this->followMetaRefresh = $followMetaRefresh;
}
Expand All @@ -91,10 +87,8 @@ public function isFollowingRedirects(): bool

/**
* Sets the maximum number of redirects that crawler can follow.
*
* @return void
*/
public function setMaxRedirects(int $maxRedirects)
public function setMaxRedirects(int $maxRedirects): void
{
$this->maxRedirects = $maxRedirects < 0 ? -1 : $maxRedirects;
$this->followRedirects = -1 !== $this->maxRedirects;
Expand All @@ -111,11 +105,9 @@ public function getMaxRedirects(): int
/**
* Sets the insulated flag.
*
* @return void
*
* @throws LogicException When Symfony Process Component is not installed
*/
public function insulate(bool $insulated = true)
public function insulate(bool $insulated = true): void
{
if ($insulated && !class_exists(\Symfony\Component\Process\Process::class)) {
throw new LogicException('Unable to isolate requests as the Symfony Process Component is not installed. Try running "composer require symfony/process".');
Expand All @@ -126,10 +118,8 @@ public function insulate(bool $insulated = true)

/**
* Sets server parameters.
*
* @return void
*/
public function setServerParameters(array $server)
public function setServerParameters(array $server): void
{
$this->server = array_merge([
'HTTP_USER_AGENT' => 'Symfony BrowserKit',
Expand All @@ -138,10 +128,8 @@ public function setServerParameters(array $server)

/**
* Sets single server parameter.
*
* @return void
*/
public function setServerParameter(string $key, string $value)
public function setServerParameter(string $key, string $value): void
{
$this->server[$key] = $value;
}
Expand Down Expand Up @@ -436,11 +424,9 @@ public function request(string $method, string $uri, array $parameters = [], arr
/**
* Makes a request in another process.
*
* @return object
*
* @throws \RuntimeException When processing returns exit code
*/
protected function doRequestInProcess(object $request)
protected function doRequestInProcess(object $request): object
{
$deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec');
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile);
Expand Down Expand Up @@ -470,41 +456,33 @@ protected function doRequestInProcess(object $request)

/**
* Makes a request.
*
* @return object
*/
abstract protected function doRequest(object $request);
abstract protected function doRequest(object $request): object;

/**
* Returns the script to execute when the request must be insulated.
*
* @param object $request An origin request instance
*
* @return string
*
* @throws LogicException When this abstract class is not implemented
*/
protected function getScript(object $request)
protected function getScript(object $request): string
{
throw new LogicException('To insulate requests, you need to override the getScript() method.');
}

/**
* Filters the BrowserKit request to the origin one.
*
* @return object
*/
protected function filterRequest(Request $request)
protected function filterRequest(Request $request): object
{
return $request;
}

/**
* Filters the origin response to the BrowserKit one.
*
* @return Response
*/
protected function filterResponse(object $response)
protected function filterResponse(object $response): Response
{
return $response;
}
Expand Down Expand Up @@ -626,10 +604,8 @@ private function getMetaRefreshUrl(): ?string
* Restarts the client.
*
* It flushes history and all cookies.
*
* @return void
*/
public function restart()
public function restart(): void
{
$this->cookieJar->clear();
$this->history->clear();
Expand Down
25 changes: 6 additions & 19 deletions src/Symfony/Component/BrowserKit/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ class CookieJar
{
protected $cookieJar = [];

/**
* @return void
*/
public function set(Cookie $cookie)
public function set(Cookie $cookie): void
{
$this->cookieJar[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie;
}
Expand Down Expand Up @@ -69,10 +66,8 @@ public function get(string $name, string $path = '/', string $domain = null): ?C
* You should never use an empty domain, but if you do so,
* all cookies for the given name/path expire (this behavior
* ensures a BC behavior with previous versions of Symfony).
*
* @return void
*/
public function expire(string $name, ?string $path = '/', string $domain = null)
public function expire(string $name, ?string $path = '/', string $domain = null): void
{
$path ??= '/';

Expand All @@ -99,10 +94,8 @@ public function expire(string $name, ?string $path = '/', string $domain = null)

/**
* Removes all the cookies from the jar.
*
* @return void
*/
public function clear()
public function clear(): void
{
$this->cookieJar = [];
}
Expand All @@ -111,10 +104,8 @@ public function clear()
* Updates the cookie jar from a response Set-Cookie headers.
*
* @param string[] $setCookies Set-Cookie headers from an HTTP response
*
* @return void
*/
public function updateFromSetCookie(array $setCookies, string $uri = null)
public function updateFromSetCookie(array $setCookies, string $uri = null): void
{
$cookies = [];

Expand All @@ -139,10 +130,8 @@ public function updateFromSetCookie(array $setCookies, string $uri = null)

/**
* Updates the cookie jar from a Response object.
*
* @return void
*/
public function updateFromResponse(Response $response, string $uri = null)
public function updateFromResponse(Response $response, string $uri = null): void
{
$this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri);
}
Expand Down Expand Up @@ -213,10 +202,8 @@ public function allRawValues(string $uri): array

/**
* Removes all expired cookies.
*
* @return void
*/
public function flushExpiredCookies()
public function flushExpiredCookies(): void
{
foreach ($this->cookieJar as $domain => $pathCookies) {
foreach ($pathCookies as $path => $namedCookies) {
Expand Down
8 changes: 2 additions & 6 deletions src/Symfony/Component/BrowserKit/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,17 @@ class History

/**
* Clears the history.
*
* @return void
*/
public function clear()
public function clear(): void
{
$this->stack = [];
$this->position = -1;
}

/**
* Adds a Request to the history.
*
* @return void
*/
public function add(Request $request)
public function add(Request $request): void
{
$this->stack = \array_slice($this->stack, 0, $this->position + 1);
$this->stack[] = clone $request;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Tests/TestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function doRequest(object $request): Response
return $response;
}

protected function getScript(object $request)
protected function getScript(object $request): string
{
$r = new \ReflectionClass(Response::class);
$path = $r->getFileName();
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Tests/TestHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function doRequest(object $request): Response
return $response;
}

protected function getScript(object $request)
protected function getScript(object $request): string
{
$r = new \ReflectionClass(Response::class);
$path = $r->getFileName();
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Component/Cache/Adapter/ApcuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ public function __construct(string $namespace = '', int $defaultLifetime = 0, st
$this->marshaller = $marshaller;
}

/**
* @return bool
*/
public static function isSupported()
public static function isSupported(): bool
{
return \function_exists('apcu_fetch') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,7 @@ public function getValues(): array
return $values;
}

/**
* @return void
*/
public function reset()
public function reset(): void
{
$this->clear();
}
Expand Down
Loading

0 comments on commit a250774

Please sign in to comment.