Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpKernel] Add more parameter types #33195

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public function __construct(array $pools = [])
$this->pools = $pools;
}

public function hasPool($name)
public function hasPool(string $name)
{
return isset($this->pools[$name]);
}

public function getPool($name)
public function getPool(string $name)
{
if (!$this->hasPool($name)) {
throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name));
Expand All @@ -37,7 +37,7 @@ public function getPool($name)
return $this->pools[$name];
}

public function clearPool($name)
public function clearPool(string $name)
{
if (!isset($this->pools[$name])) {
throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
abstract class CacheWarmer implements CacheWarmerInterface
{
protected function writeCacheFile($file, $content)
protected function writeCacheFile(string $file, $content)
{
$tmpFile = @tempnam(\dirname($file), basename($file));
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function __sleep(): array
/**
* @internal
*/
public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString): ?string
public static function generateUrlFormat(UrlGeneratorInterface $router, string $routeName, string $queryString): ?string
{
try {
return $router->generate($routeName).$queryString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ExceptionListener implements EventSubscriberInterface
protected $logger;
protected $debug;

public function __construct($controller, LoggerInterface $logger = null, $debug = false)
public function __construct($controller, LoggerInterface $logger = null, bool $debug = false)
{
$this->controller = $controller;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/HttpKernel/HttpCache/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private function save(string $key, string $data): bool
return true;
}

public function getPath($key)
public function getPath(string $key)
{
return $this->root.\DIRECTORY_SEPARATOR.substr($key, 0, 2).\DIRECTORY_SEPARATOR.substr($key, 2, 2).\DIRECTORY_SEPARATOR.substr($key, 4, 2).\DIRECTORY_SEPARATOR.substr($key, 6);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class SubRequestHandler
{
public static function handle(HttpKernelInterface $kernel, Request $request, $type, $catch): Response
public static function handle(HttpKernelInterface $kernel, Request $request, int $type, bool $catch): Response
{
// save global state related to trusted headers and proxies
$trustedProxies = Request::getTrustedProxies();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function purge()
/**
* {@inheritdoc}
*/
public function read($token)
public function read(string $token)
{
if (!$token || !file_exists($file = $this->getFilename($token))) {
return null;
Expand Down Expand Up @@ -257,7 +257,7 @@ protected function readLineFromFile($file)
return '' === $line ? null : $line;
}

protected function createProfileFromData($token, $data, $parent = null)
protected function createProfileFromData(string $token, array $data, Profile $parent = null)
{
$profile = new Profile($token);
$profile->setIp($data['ip']);
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/HttpKernel/Profiler/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function getMethod()
return $this->method;
}

public function setMethod($method)
public function setMethod(string $method)
{
$this->method = $method;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class TestCacheWarmer extends CacheWarmer
{
protected $file;

public function __construct($file)
public function __construct(string $file)
{
$this->file = $file;
}

public function warmUp($cacheDir)
public function warmUp(string $cacheDir)
{
$this->writeCacheFile($this->file, 'content');
}
Expand Down
3 changes: 2 additions & 1 deletion 3 src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
Expand Down Expand Up @@ -122,7 +123,7 @@ public function getStatusCodes()
public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($expectedStatusCode)
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($expectedStatusCode) {
$dispatcher->addListener(KernelEvents::EXCEPTION, function (ExceptionEvent $event) use ($expectedStatusCode) {
$event->allowCustomResponseCode();
$event->setResponse(new Response('', $expectedStatusCode));
});
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/HttpKernel/Tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ protected function getKernel(array $methods = [], array $bundles = [])
return $kernel;
}

protected function getKernelForTest(array $methods = [], $debug = false)
protected function getKernelForTest(array $methods = [], bool $debug = false)
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
->setConstructorArgs(['test', $debug])
Expand All @@ -661,7 +661,7 @@ public function terminate()
$this->terminateCalled = true;
}

public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
public function handle(Request $request, int $type = self::MASTER_REQUEST, bool $catch = true)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ public function testChildren()
$parentProfile->setIp('127.0.0.1');
$parentProfile->setUrl('http://foo.bar/parent');
$parentProfile->setStatusCode(200);
$parentProfile->setMethod('GET');

$childProfile = new Profile('token_child');
$childProfile->setIp('127.0.0.1');
$childProfile->setUrl('http://foo.bar/child');
$childProfile->setStatusCode(200);
$childProfile->setMethod('GET');

$parentProfile->addChild($childProfile);

Expand Down Expand Up @@ -86,6 +88,7 @@ public function testStoreSpecialCharsInUrl()
$profile->setUrl('http://foo.bar/\'');
$profile->setIp('127.0.0.1');
$profile->setStatusCode(200);
$profile->setMethod('GET');

$this->storage->write($profile);
$this->assertNotFalse($this->storage->read('simple_quote'), '->write() accepts single quotes in URL');
Expand All @@ -94,6 +97,7 @@ public function testStoreSpecialCharsInUrl()
$profile->setUrl('http://foo.bar/"');
$profile->setIp('127.0.0.1');
$profile->setStatusCode(200);
$profile->setMethod('GET');

$this->storage->write($profile);
$this->assertNotFalse($this->storage->read('double_quote'), '->write() accepts double quotes in URL');
Expand All @@ -102,6 +106,7 @@ public function testStoreSpecialCharsInUrl()
$profile->setUrl('http://foo.bar/\\');
$profile->setIp('127.0.0.1');
$profile->setStatusCode(200);
$profile->setMethod('GET');

$this->storage->write($profile);
$this->assertNotFalse($this->storage->read('backslash'), '->write() accepts backslash in URL');
Expand All @@ -110,6 +115,7 @@ public function testStoreSpecialCharsInUrl()
$profile->setUrl('http://foo.bar/,');
$profile->setIp('127.0.0.1');
$profile->setStatusCode(200);
$profile->setMethod('GET');

$this->storage->write($profile);
$this->assertNotFalse($this->storage->read('comma'), '->write() accepts comma in URL');
Expand All @@ -121,6 +127,7 @@ public function testStoreDuplicateToken()
$profile->setUrl('http://example.com/');
$profile->setIp('127.0.0.1');
$profile->setStatusCode(200);
$profile->setMethod('GET');

$this->assertTrue($this->storage->write($profile), '->write() returns true when the token is unique');

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.