[HttpKernel] Add more parameter types.
This commit is contained in:
parent
90e3da4edd
commit
dbcc6cbb8f
@ -23,12 +23,12 @@ class Psr6CacheClearer implements CacheClearerInterface
|
||||
$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));
|
||||
@ -37,7 +37,7 @@ class Psr6CacheClearer implements CacheClearerInterface
|
||||
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));
|
||||
|
@ -18,7 +18,7 @@ namespace Symfony\Component\HttpKernel\CacheWarmer;
|
||||
*/
|
||||
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)) {
|
||||
|
@ -76,7 +76,7 @@ class FileLinkFormatter
|
||||
/**
|
||||
* @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;
|
||||
|
@ -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;
|
||||
|
@ -390,7 +390,7 @@ class Store implements StoreInterface
|
||||
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);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
*/
|
||||
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();
|
||||
|
@ -113,7 +113,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($token)
|
||||
public function read(string $token)
|
||||
{
|
||||
if (!$token || !file_exists($file = $this->getFilename($token))) {
|
||||
return null;
|
||||
@ -257,7 +257,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
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']);
|
||||
|
@ -114,7 +114,7 @@ class Profile
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function setMethod($method)
|
||||
public function setMethod(string $method)
|
||||
{
|
||||
$this->method = $method;
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
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;
|
||||
@ -122,7 +123,7 @@ class HttpKernelTest extends TestCase
|
||||
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));
|
||||
});
|
||||
|
@ -641,7 +641,7 @@ EOF;
|
||||
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])
|
||||
@ -661,7 +661,7 @@ class TestKernel implements HttpKernelInterface
|
||||
$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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +53,13 @@ class FileProfilerStorageTest extends TestCase
|
||||
$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);
|
||||
|
||||
@ -86,6 +88,7 @@ class FileProfilerStorageTest extends TestCase
|
||||
$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');
|
||||
@ -94,6 +97,7 @@ class FileProfilerStorageTest extends TestCase
|
||||
$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');
|
||||
@ -102,6 +106,7 @@ class FileProfilerStorageTest extends TestCase
|
||||
$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');
|
||||
@ -110,6 +115,7 @@ class FileProfilerStorageTest extends TestCase
|
||||
$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');
|
||||
@ -121,6 +127,7 @@ class FileProfilerStorageTest extends TestCase
|
||||
$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');
|
||||
|
||||
|
Reference in New Issue
Block a user