minor #33279 Add return types to tests and final|internal|private methods (nicolas-grekas, derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- Add return types to tests and final|internal|private methods | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #33228 #33236 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> #33266 made me spot an issue with my logic to add return types with help from `DebugClassLoader`. Here is a completing PR, with the logic expanded to test classes. I need help to fix tests, /cc @derrabus :) Commits -------c39fd9c973
Fixed tests on the Security and Form componentsfc186bb78f
Add return types to tests and final|internal|private methods
This commit is contained in:
commit
55cd8d6f3e
@ -28,10 +28,8 @@ final class TestRepositoryFactory implements RepositoryFactory
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return ObjectRepository
|
||||
*/
|
||||
public function getRepository(EntityManagerInterface $entityManager, $entityName)
|
||||
public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
|
||||
{
|
||||
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
|
||||
|
||||
|
@ -257,10 +257,7 @@ class DoctrineExtensionTest extends TestCase
|
||||
$method->invokeArgs($this->extension, [$objectManager, $container, $cacheName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
|
||||
*/
|
||||
protected function createContainer(array $data = [])
|
||||
protected function createContainer(array $data = []): ContainerBuilder
|
||||
{
|
||||
return new ContainerBuilder(new ParameterBag(array_merge([
|
||||
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
|
||||
|
@ -24,9 +24,6 @@ class BaseUser
|
||||
|
||||
/**
|
||||
* BaseUser constructor.
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $username
|
||||
*/
|
||||
public function __construct(int $id, string $username)
|
||||
{
|
||||
@ -42,10 +39,7 @@ class BaseUser
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername()
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
@ -35,18 +35,12 @@ class CompositeObjectNoToStringIdEntity
|
||||
$this->objectTwo = $objectTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SingleIntIdNoToStringEntity
|
||||
*/
|
||||
public function getObjectOne()
|
||||
public function getObjectOne(): SingleIntIdNoToStringEntity
|
||||
{
|
||||
return $this->objectOne;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SingleIntIdNoToStringEntity
|
||||
*/
|
||||
public function getObjectTwo()
|
||||
public function getObjectTwo(): SingleIntIdNoToStringEntity
|
||||
{
|
||||
return $this->objectTwo;
|
||||
}
|
||||
|
@ -20,10 +20,7 @@ class StringWrapper
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getString()
|
||||
public function getString(): string
|
||||
{
|
||||
return $this->string;
|
||||
}
|
||||
|
@ -34,10 +34,8 @@ class StringWrapperType extends StringType
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'string_wrapper';
|
||||
}
|
||||
|
@ -35,19 +35,19 @@ class User implements UserInterface
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getRoles()
|
||||
public function getRoles(): array
|
||||
{
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
public function getPassword(): ?string
|
||||
{
|
||||
}
|
||||
|
||||
public function getSalt()
|
||||
public function getSalt(): ?string
|
||||
{
|
||||
}
|
||||
|
||||
public function getUsername()
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class TestManagerRegistry extends ManagerRegistry
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function getAliasNamespace($alias)
|
||||
public function getAliasNamespace($alias): string
|
||||
{
|
||||
return 'Foo';
|
||||
}
|
||||
|
@ -27,20 +27,16 @@ class DoctrineFooType extends Type
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return self::NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
|
||||
{
|
||||
return $platform->getClobTypeDeclarationSQL([]);
|
||||
}
|
||||
@ -80,10 +76,8 @@ class DoctrineFooType extends Type
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function requiresSQLCommentHint(AbstractPlatform $platform)
|
||||
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -26,10 +26,7 @@ class ConsoleFormatterTest extends TestCase
|
||||
self::assertSame($expectedMessage, $formatter->format($record));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerFormatTests()
|
||||
public function providerFormatTests(): array
|
||||
{
|
||||
$currentDateTime = new \DateTime();
|
||||
|
||||
|
@ -148,9 +148,9 @@ class LoggerTest extends TestCase
|
||||
|
||||
class ClassThatInheritLogger extends Logger
|
||||
{
|
||||
public function getLogs()
|
||||
public function getLogs(): array
|
||||
{
|
||||
parent::getLogs();
|
||||
return parent::getLogs();
|
||||
}
|
||||
|
||||
public function countErrors()
|
||||
|
@ -99,9 +99,9 @@ class DebugProcessorTest extends TestCase
|
||||
|
||||
class ClassThatInheritDebugProcessor extends DebugProcessor
|
||||
{
|
||||
public function getLogs()
|
||||
public function getLogs(): array
|
||||
{
|
||||
parent::getLogs();
|
||||
return parent::getLogs();
|
||||
}
|
||||
|
||||
public function countErrors()
|
||||
|
@ -173,10 +173,7 @@ EOPHP;
|
||||
$this->assertSame(123, @$foo->dynamicProp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getProxyCandidates()
|
||||
public function getProxyCandidates(): array
|
||||
{
|
||||
$definitions = [
|
||||
[new Definition(__CLASS__), true],
|
||||
|
@ -15,7 +15,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class StubTranslator implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
|
||||
{
|
||||
return '[trans]'.strtr($id, $parameters).'[/trans]';
|
||||
}
|
||||
|
@ -123,10 +123,7 @@ class TwigExtractorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function resourcesWithSyntaxErrorsProvider()
|
||||
public function resourcesWithSyntaxErrorsProvider(): array
|
||||
{
|
||||
return [
|
||||
[__DIR__.'/../Fixtures'],
|
||||
@ -157,10 +154,7 @@ class TwigExtractorTest extends TestCase
|
||||
$this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function resourceProvider()
|
||||
public function resourceProvider(): array
|
||||
{
|
||||
$directory = __DIR__.'/../Fixtures/extractor/';
|
||||
|
||||
|
@ -97,6 +97,8 @@ class TestContainer extends Container
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
|
||||
{
|
||||
|
@ -19,14 +19,14 @@ use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class TestAppKernel extends Kernel
|
||||
{
|
||||
public function registerBundles()
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getProjectDir()
|
||||
public function getProjectDir(): string
|
||||
{
|
||||
return __DIR__.'/test';
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class ExtendedCallableClass extends CallableClass
|
||||
|
||||
class RouteStub extends Route
|
||||
{
|
||||
public function compile()
|
||||
public function compile(): CompiledRoute
|
||||
{
|
||||
return new CompiledRoute('', '#PATH_REGEX#', [], [], '#HOST_REGEX#');
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class DataCollectorTranslatorPassTest extends TestCase
|
||||
|
||||
class TranslatorWithTranslatorBag implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class CustomPathBundle extends Bundle
|
||||
{
|
||||
public function getPath()
|
||||
public function getPath(): string
|
||||
{
|
||||
return __DIR__.'/..';
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
abstract class AbstractWebTestCase extends BaseWebTestCase
|
||||
{
|
||||
@ -42,14 +43,14 @@ abstract class AbstractWebTestCase extends BaseWebTestCase
|
||||
$fs->remove($dir);
|
||||
}
|
||||
|
||||
protected static function getKernelClass()
|
||||
protected static function getKernelClass(): string
|
||||
{
|
||||
require_once __DIR__.'/app/AppKernel.php';
|
||||
|
||||
return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel';
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
protected static function createKernel(array $options = []): KernelInterface
|
||||
{
|
||||
$class = self::getKernelClass();
|
||||
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundle
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
||||
|
||||
class AutowiringTypesTest extends AbstractWebTestCase
|
||||
@ -70,7 +71,7 @@ class AutowiringTypesTest extends AbstractWebTestCase
|
||||
$this->assertInstanceOf(FilesystemAdapter::class, $autowiredServices->getCachePool());
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
protected static function createKernel(array $options = []): KernelInterface
|
||||
{
|
||||
return parent::createKernel(['test_case' => 'AutowiringTypes'] + $options);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class Configuration implements ConfigurationInterface
|
||||
$this->customConfig = $customConfig;
|
||||
}
|
||||
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('test');
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
@ -42,7 +43,7 @@ class TestExtension extends Extension implements PrependExtensionInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
|
||||
{
|
||||
return new Configuration($this->customConfig);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class TransSubscriberService implements ServiceSubscriberInterface
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public static function getSubscribedServices()
|
||||
public static function getSubscribedServices(): array
|
||||
{
|
||||
return ['translator' => TranslatorInterface::class];
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
class CachePoolsTest extends AbstractWebTestCase
|
||||
{
|
||||
@ -116,7 +117,7 @@ class CachePoolsTest extends AbstractWebTestCase
|
||||
$this->assertNotInstanceof(TagAwareAdapter::class, $pool7);
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
protected static function createKernel(array $options = []): KernelInterface
|
||||
{
|
||||
return parent::createKernel(['test_case' => 'CachePools'] + $options);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class AppKernel extends Kernel
|
||||
parent::__construct($environment, $debug);
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
if (!file_exists($filename = $this->getProjectDir().'/'.$this->testCase.'/bundles.php')) {
|
||||
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
|
||||
@ -54,17 +54,17 @@ class AppKernel extends Kernel
|
||||
return include $filename;
|
||||
}
|
||||
|
||||
public function getProjectDir()
|
||||
public function getProjectDir(): string
|
||||
{
|
||||
return __DIR__;
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/logs';
|
||||
}
|
||||
@ -89,7 +89,7 @@ class AppKernel extends Kernel
|
||||
$this->__construct($this->varDir, $this->testCase, $this->rootConfig, $this->environment, $this->debug);
|
||||
}
|
||||
|
||||
protected function getKernelParameters()
|
||||
protected function getKernelParameters(): array
|
||||
{
|
||||
$parameters = parent::getKernelParameters();
|
||||
$parameters['kernel.test_case'] = $this->testCase;
|
||||
|
@ -47,19 +47,19 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface
|
||||
throw new Danger();
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return $this->cacheDir = sys_get_temp_dir().'/sf_micro_kernel';
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return $this->cacheDir;
|
||||
}
|
||||
@ -100,7 +100,7 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
KernelEvents::EXCEPTION => 'onKernelException',
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures;
|
||||
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
use Symfony\Component\Templating\TemplateReference;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
|
||||
class StubTemplateNameParser implements TemplateNameParserInterface
|
||||
{
|
||||
@ -26,7 +27,7 @@ class StubTemplateNameParser implements TemplateNameParserInterface
|
||||
$this->rootTheme = $rootTheme;
|
||||
}
|
||||
|
||||
public function parse($name)
|
||||
public function parse($name): TemplateReferenceInterface
|
||||
{
|
||||
list($bundle, $controller, $template) = explode(':', $name, 3);
|
||||
|
||||
|
@ -15,7 +15,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class StubTranslator implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
|
||||
{
|
||||
return '[trans]'.strtr($id, $parameters).'[/trans]';
|
||||
}
|
||||
|
@ -58,10 +58,8 @@ class PhpEngineTest extends TestCase
|
||||
|
||||
/**
|
||||
* Creates a Container with a Session-containing Request service.
|
||||
*
|
||||
* @return Container
|
||||
*/
|
||||
protected function getContainer()
|
||||
protected function getContainer(): Container
|
||||
{
|
||||
$container = new Container();
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
|
@ -410,7 +410,7 @@ class TranslatorWithInvalidLocale extends Translator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLocale()
|
||||
public function getLocale(): string
|
||||
{
|
||||
return 'invalid locale';
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ final class SecurityUserValueResolver implements ArgumentValueResolverInterface
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
}
|
||||
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
// only security user implementations are supported
|
||||
if (UserInterface::class !== $argument->getType()) {
|
||||
@ -55,7 +55,7 @@ final class SecurityUserValueResolver implements ArgumentValueResolverInterface
|
||||
return $user instanceof UserInterface;
|
||||
}
|
||||
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
yield $this->tokenStorage->getToken()->getUser();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
abstract class AbstractWebTestCase extends BaseWebTestCase
|
||||
{
|
||||
@ -42,14 +43,14 @@ abstract class AbstractWebTestCase extends BaseWebTestCase
|
||||
$fs->remove($dir);
|
||||
}
|
||||
|
||||
protected static function getKernelClass()
|
||||
protected static function getKernelClass(): string
|
||||
{
|
||||
require_once __DIR__.'/app/AppKernel.php';
|
||||
|
||||
return 'Symfony\Bundle\SecurityBundle\Tests\Functional\app\AppKernel';
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
protected static function createKernel(array $options = []): KernelInterface
|
||||
{
|
||||
$class = self::getKernelClass();
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
|
||||
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
|
||||
|
||||
@ -29,7 +30,7 @@ class AutowiringTypesTest extends AbstractWebTestCase
|
||||
$this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode');
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
protected static function createKernel(array $options = []): KernelInterface
|
||||
{
|
||||
return parent::createKernel(['test_case' => 'AutowiringTypes'] + $options);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class EntryPointStub implements AuthenticationEntryPointInterface
|
||||
{
|
||||
const RESPONSE_TEXT = '2be8e651259189d841a19eecdf37e771e2431741';
|
||||
|
||||
public function start(Request $request, AuthenticationException $authException = null)
|
||||
public function start(Request $request, AuthenticationException $authException = null): Response
|
||||
{
|
||||
return new Response(self::RESPONSE_TEXT);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
@ -27,7 +28,7 @@ class LocalizedFormFailureHandler implements AuthenticationFailureHandlerInterfa
|
||||
$this->router = $router;
|
||||
}
|
||||
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
|
||||
{
|
||||
return new RedirectResponse($this->router->generate('localized_login_path', [], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
@ -13,12 +13,13 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
|
||||
|
||||
class JsonAuthenticationFailureHandler implements AuthenticationFailureHandlerInterface
|
||||
{
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
|
||||
{
|
||||
return new JsonResponse(['message' => 'Something went wrong'], 500);
|
||||
}
|
||||
|
@ -13,12 +13,13 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
|
||||
|
||||
class JsonAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
|
||||
{
|
||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
|
||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token): Response
|
||||
{
|
||||
return new JsonResponse(['message' => sprintf('Good game @%s!', $token->getUsername())]);
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ class AppKernel extends Kernel
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContainerClass()
|
||||
public function getContainerClass(): string
|
||||
{
|
||||
return parent::getContainerClass().substr(md5($this->rootConfig), -16);
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
if (!is_file($filename = $this->getProjectDir().'/'.$this->testCase.'/bundles.php')) {
|
||||
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
|
||||
@ -60,17 +60,17 @@ class AppKernel extends Kernel
|
||||
return include $filename;
|
||||
}
|
||||
|
||||
public function getProjectDir()
|
||||
public function getProjectDir(): string
|
||||
{
|
||||
return __DIR__;
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/logs';
|
||||
}
|
||||
@ -91,7 +91,7 @@ class AppKernel extends Kernel
|
||||
$this->__construct($a[0], $a[1], $a[2], $a[3], $a[4]);
|
||||
}
|
||||
|
||||
protected function getKernelParameters()
|
||||
protected function getKernelParameters(): array
|
||||
{
|
||||
$parameters = parent::getKernelParameters();
|
||||
$parameters['kernel.test_case'] = $this->testCase;
|
||||
|
@ -79,12 +79,12 @@ class CacheWarmingKernel extends Kernel
|
||||
parent::__construct(($withTemplating ? 'with' : 'without').'_templating', true);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'CacheWarming';
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
return [new FrameworkBundle(), new TwigBundle()];
|
||||
}
|
||||
@ -116,17 +116,17 @@ class CacheWarmingKernel extends Kernel
|
||||
}
|
||||
}
|
||||
|
||||
public function getProjectDir()
|
||||
public function getProjectDir(): string
|
||||
{
|
||||
return __DIR__;
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/logs';
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class EmptyAppTest extends TestCase
|
||||
|
||||
class EmptyAppKernel extends Kernel
|
||||
{
|
||||
public function registerBundles()
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
return [new TwigBundle()];
|
||||
}
|
||||
@ -49,12 +49,12 @@ class EmptyAppKernel extends Kernel
|
||||
});
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/logs';
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class NoTemplatingEntryTest extends TestCase
|
||||
|
||||
class NoTemplatingEntryKernel extends Kernel
|
||||
{
|
||||
public function registerBundles()
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
return [new FrameworkBundle(), new TwigBundle()];
|
||||
}
|
||||
@ -75,12 +75,12 @@ class NoTemplatingEntryKernel extends Kernel
|
||||
});
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/logs';
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class ProfileDummy extends Profile
|
||||
parent::__construct('token');
|
||||
}
|
||||
|
||||
public function hasCollector($name)
|
||||
public function hasCollector($name): bool
|
||||
{
|
||||
switch ($name) {
|
||||
case 'foo':
|
||||
|
@ -41,6 +41,9 @@ class HttpBrowser extends AbstractBrowser
|
||||
parent::__construct([], $history, $cookieJar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
protected function doRequest($request)
|
||||
{
|
||||
$headers = $this->getHeaders($request);
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Component\BrowserKit\Client;
|
||||
use Symfony\Component\BrowserKit\CookieJar;
|
||||
use Symfony\Component\BrowserKit\History;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Symfony\Component\DomCrawler\Form as DomCrawlerForm;
|
||||
|
||||
class SpecialResponse extends Response
|
||||
@ -38,7 +39,7 @@ class TestClient extends AbstractBrowser
|
||||
$this->nextScript = $script;
|
||||
}
|
||||
|
||||
protected function doRequest($request)
|
||||
protected function doRequest($request): Response
|
||||
{
|
||||
if (null === $this->nextResponse) {
|
||||
return new Response();
|
||||
@ -50,7 +51,7 @@ class TestClient extends AbstractBrowser
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function filterResponse($response)
|
||||
protected function filterResponse($response): Response
|
||||
{
|
||||
if ($response instanceof SpecialResponse) {
|
||||
return new Response($response->getContent(), $response->getStatusCode(), $response->getHeaders());
|
||||
@ -934,7 +935,7 @@ class ClassThatInheritClient extends AbstractBrowser
|
||||
$this->nextResponse = $response;
|
||||
}
|
||||
|
||||
protected function doRequest($request)
|
||||
protected function doRequest($request): Response
|
||||
{
|
||||
if (null === $this->nextResponse) {
|
||||
return new Response();
|
||||
@ -946,7 +947,7 @@ class ClassThatInheritClient extends AbstractBrowser
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function submit(DomCrawlerForm $form, array $values = [])
|
||||
public function submit(DomCrawlerForm $form, array $values = []): Crawler
|
||||
{
|
||||
return parent::submit($form, $values);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class TestHttpClient extends HttpBrowser
|
||||
$this->nextScript = $script;
|
||||
}
|
||||
|
||||
protected function filterResponse($response)
|
||||
protected function filterResponse($response): Response
|
||||
{
|
||||
if ($response instanceof SpecialHttpResponse) {
|
||||
return new Response($response->getContent(), $response->getStatusCode(), $response->getHeaders());
|
||||
@ -67,7 +67,7 @@ class TestHttpClient extends HttpBrowser
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function doRequest($request)
|
||||
protected function doRequest($request): Response
|
||||
{
|
||||
$response = parent::doRequest($request);
|
||||
|
||||
|
@ -36,10 +36,8 @@ final class CacheItem implements ItemInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
@ -54,10 +52,8 @@ final class CacheItem implements ItemInterface
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isHit()
|
||||
public function isHit(): bool
|
||||
{
|
||||
return $this->isHit;
|
||||
}
|
||||
@ -153,11 +149,9 @@ final class CacheItem implements ItemInterface
|
||||
/**
|
||||
* Returns the list of tags bound to the value coming from the pool storage if any.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @deprecated since Symfony 4.2, use the "getMetadata()" method instead.
|
||||
*/
|
||||
public function getPreviousTags()
|
||||
public function getPreviousTags(): array
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "getMetadata()" method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
@ -169,11 +163,9 @@ final class CacheItem implements ItemInterface
|
||||
*
|
||||
* @param string $key The key to validate
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws InvalidArgumentException When $key is not valid
|
||||
*/
|
||||
public static function validateKey($key)
|
||||
public static function validateKey($key): string
|
||||
{
|
||||
if (!\is_string($key)) {
|
||||
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', \is_object($key) ? \get_class($key) : \gettype($key)));
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
|
||||
abstract class AbstractRedisAdapterTest extends AdapterTestCase
|
||||
@ -23,7 +24,7 @@ abstract class AbstractRedisAdapterTest extends AdapterTestCase
|
||||
|
||||
protected static $redis;
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\Cache\Adapter\ApcuAdapter;
|
||||
|
||||
@ -22,7 +23,7 @@ class ApcuAdapterTest extends AdapterTestCase
|
||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
||||
];
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
$this->markTestSkipped('APCu extension is required.');
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
|
||||
/**
|
||||
@ -24,7 +25,7 @@ class ArrayAdapterTest extends AdapterTestCase
|
||||
'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.',
|
||||
];
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new ArrayAdapter($defaultLifetime);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\ChainAdapter;
|
||||
@ -25,7 +26,7 @@ use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter;
|
||||
*/
|
||||
class ChainAdapterTest extends AdapterTestCase
|
||||
{
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null)
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null): CacheItemPoolInterface
|
||||
{
|
||||
if ('testGetMetadata' === $testMethod) {
|
||||
return new ChainAdapter([new FilesystemAdapter('', $defaultLifetime)], $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
|
||||
|
||||
@ -26,7 +27,7 @@ class DoctrineAdapterTest extends AdapterTestCase
|
||||
'testClearPrefix' => 'Doctrine cannot clear by prefix',
|
||||
];
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new DoctrineAdapter(new ArrayCache($defaultLifetime), '', $defaultLifetime);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
*/
|
||||
class FilesystemAdapterTest extends AdapterTestCase
|
||||
{
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new FilesystemAdapter('', $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||
|
||||
@ -21,7 +22,7 @@ class FilesystemTagAwareAdapterTest extends FilesystemAdapterTest
|
||||
{
|
||||
use TagAwareTestTrait;
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new FilesystemTagAwareAdapter('', $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
|
||||
|
||||
@ -38,7 +39,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')) : self::$client;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
||||
@ -20,7 +21,7 @@ use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
||||
*/
|
||||
class NamespacedProxyAdapterTest extends ProxyAdapterTest
|
||||
{
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null)
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null): CacheItemPoolInterface
|
||||
{
|
||||
if ('testGetMetadata' === $testMethod) {
|
||||
return new ProxyAdapter(new FilesystemAdapter(), 'foo', $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\PdoAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
||||
|
||||
@ -40,7 +41,7 @@ class PdoAdapterTest extends AdapterTestCase
|
||||
@unlink(self::$dbFile);
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\PdoAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
||||
|
||||
@ -40,7 +41,7 @@ class PdoDbalAdapterTest extends AdapterTestCase
|
||||
@unlink(self::$dbFile);
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\NullAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
||||
@ -70,7 +71,7 @@ class PhpArrayAdapterTest extends AdapterTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null)
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null): CacheItemPoolInterface
|
||||
{
|
||||
if ('testGetMetadata' === $testMethod || 'testClearPrefix' === $testMethod) {
|
||||
return new PhpArrayAdapter(self::$file, new FilesystemAdapter());
|
||||
@ -145,7 +146,7 @@ class PhpArrayAdapterWrapper extends PhpArrayAdapter
|
||||
{
|
||||
protected $data = [];
|
||||
|
||||
public function save(CacheItemInterface $item)
|
||||
public function save(CacheItemInterface $item): bool
|
||||
{
|
||||
(\Closure::bind(function () use ($item) {
|
||||
$key = $item->getKey();
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
||||
|
||||
@ -42,7 +43,7 @@ class PhpArrayAdapterWithFallbackTest extends AdapterTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new PhpArrayAdapter(self::$file, new FilesystemAdapter('php-array-fallback', $defaultLifetime));
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class PhpFilesAdapterTest extends AdapterTestCase
|
||||
'testDefaultLifeTime' => 'PhpFilesAdapter does not allow configuring a default lifetime.',
|
||||
];
|
||||
|
||||
public function createCachePool()
|
||||
public function createCachePool(): CacheItemPoolInterface
|
||||
{
|
||||
return new PhpFilesAdapter('sf-cache');
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||
|
||||
@ -24,7 +25,7 @@ class PredisTagAwareAdapterTest extends PredisAdapterTest
|
||||
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$this->assertInstanceOf(\Predis\Client::class, self::$redis);
|
||||
$adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||
|
||||
@ -24,7 +25,7 @@ class PredisTagAwareClusterAdapterTest extends PredisClusterAdapterTest
|
||||
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$this->assertInstanceOf(\Predis\Client::class, self::$redis);
|
||||
$adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||
|
||||
@ -24,7 +25,7 @@ class PredisTagAwareRedisClusterAdapterTest extends PredisRedisClusterAdapterTes
|
||||
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$this->assertInstanceOf(\Predis\Client::class, self::$redis);
|
||||
$adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
|
@ -29,10 +29,7 @@ class ProxyAdapterTest extends AdapterTestCase
|
||||
'testPrune' => 'ProxyAdapter just proxies',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return CacheItemPoolInterface
|
||||
*/
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null)
|
||||
public function createCachePool($defaultLifetime = 0, $testMethod = null): CacheItemPoolInterface
|
||||
{
|
||||
if ('testGetMetadata' === $testMethod) {
|
||||
return new ProxyAdapter(new FilesystemAdapter(), '', $defaultLifetime);
|
||||
@ -64,12 +61,12 @@ class TestingArrayAdapter extends ArrayAdapter
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
public function getItem($key)
|
||||
public function getItem($key): CacheItem
|
||||
{
|
||||
return $this->item;
|
||||
}
|
||||
|
||||
public function save(CacheItemInterface $item)
|
||||
public function save(CacheItemInterface $item): bool
|
||||
{
|
||||
if ($item === $this->item) {
|
||||
throw new \Exception('OK '.$item->get());
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\Psr16Adapter;
|
||||
@ -26,7 +27,7 @@ class Psr16AdapterTest extends AdapterTestCase
|
||||
'testClearPrefix' => 'SimpleCache cannot clear by prefix',
|
||||
];
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new Psr16Adapter(new Psr16Cache(new FilesystemAdapter()), '', $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Traits\RedisProxy;
|
||||
@ -23,7 +24,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest
|
||||
self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), ['lazy' => true]);
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$adapter = parent::createCachePool($defaultLifetime);
|
||||
$this->assertInstanceOf(RedisProxy::class, self::$redis);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
||||
@ -29,7 +30,7 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest
|
||||
self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['lazy' => true, 'redis_cluster' => true]);
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$this->assertInstanceOf(RedisClusterProxy::class, self::$redis);
|
||||
$adapter = new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||
use Symfony\Component\Cache\Traits\RedisProxy;
|
||||
@ -25,7 +26,7 @@ class RedisTagAwareAdapterTest extends RedisAdapterTest
|
||||
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$this->assertInstanceOf(RedisProxy::class, self::$redis);
|
||||
$adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||
|
||||
@ -24,7 +25,7 @@ class RedisTagAwareArrayAdapterTest extends RedisArrayAdapterTest
|
||||
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$this->assertInstanceOf(\RedisArray::class, self::$redis);
|
||||
$adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
||||
@ -25,7 +26,7 @@ class RedisTagAwareClusterAdapterTest extends RedisClusterAdapterTest
|
||||
$this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite';
|
||||
}
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
$this->assertInstanceOf(RedisClusterProxy::class, self::$redis);
|
||||
$adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
|
||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
@ -26,7 +27,7 @@ class SimpleCacheAdapterTest extends AdapterTestCase
|
||||
'testClearPrefix' => 'SimpleCache cannot clear by prefix',
|
||||
];
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
|
||||
@ -24,7 +25,7 @@ class TagAwareAdapterTest extends AdapterTestCase
|
||||
{
|
||||
use TagAwareTestTrait;
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new TagAwareAdapter(new FilesystemAdapter('', $defaultLifetime));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\TraceableAdapter;
|
||||
|
||||
@ -23,7 +24,7 @@ class TraceableAdapterTest extends AdapterTestCase
|
||||
'testPrune' => 'TraceableAdapter just proxies',
|
||||
];
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
|
||||
{
|
||||
return new TraceableAdapter(new FilesystemAdapter('', $defaultLifetime));
|
||||
}
|
||||
|
@ -13,10 +13,7 @@ class ArrayCache extends CacheProvider
|
||||
return $this->doContains($id) ? $this->data[$id][0] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doContains($id)
|
||||
protected function doContains($id): bool
|
||||
{
|
||||
if (!isset($this->data[$id])) {
|
||||
return false;
|
||||
@ -27,40 +24,28 @@ class ArrayCache extends CacheProvider
|
||||
return !$expiry || microtime(true) < $expiry || !$this->doDelete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
protected function doSave($id, $data, $lifeTime = 0): bool
|
||||
{
|
||||
$this->data[$id] = [$data, $lifeTime ? microtime(true) + $lifeTime : false];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
protected function doDelete($id): bool
|
||||
{
|
||||
unset($this->data[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function doFlush()
|
||||
protected function doFlush(): bool
|
||||
{
|
||||
$this->data = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
protected function doGetStats()
|
||||
protected function doGetStats(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -29,74 +29,47 @@ class ExternalAdapter implements CacheItemPoolInterface
|
||||
$this->cache = new ArrayAdapter($defaultLifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CacheItemInterface
|
||||
*/
|
||||
public function getItem($key)
|
||||
public function getItem($key): CacheItemInterface
|
||||
{
|
||||
return $this->cache->getItem($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable
|
||||
*/
|
||||
public function getItems(array $keys = [])
|
||||
public function getItems(array $keys = []): iterable
|
||||
{
|
||||
return $this->cache->getItems($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasItem($key)
|
||||
public function hasItem($key): bool
|
||||
{
|
||||
return $this->cache->hasItem($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): bool
|
||||
{
|
||||
return $this->cache->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItem($key)
|
||||
public function deleteItem($key): bool
|
||||
{
|
||||
return $this->cache->deleteItem($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteItems(array $keys)
|
||||
public function deleteItems(array $keys): bool
|
||||
{
|
||||
return $this->cache->deleteItems($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function save(CacheItemInterface $item)
|
||||
public function save(CacheItemInterface $item): bool
|
||||
{
|
||||
return $this->cache->save($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDeferred(CacheItemInterface $item)
|
||||
public function saveDeferred(CacheItemInterface $item): bool
|
||||
{
|
||||
return $this->cache->saveDeferred($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function commit()
|
||||
public function commit(): bool
|
||||
{
|
||||
return $this->cache->commit();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Cache\Tests;
|
||||
|
||||
use Cache\IntegrationTests\SimpleCacheTest;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\PruneableInterface;
|
||||
use Symfony\Component\Cache\Psr16Cache;
|
||||
@ -39,12 +40,12 @@ class Psr16CacheTest extends SimpleCacheTest
|
||||
}
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new Psr16Cache(new FilesystemAdapter('', $defaultLifetime));
|
||||
}
|
||||
|
||||
public static function validKeys()
|
||||
public static function validKeys(): array
|
||||
{
|
||||
return array_merge(parent::validKeys(), [["a\0b"]]);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\RedisCache;
|
||||
|
||||
/**
|
||||
@ -26,7 +27,7 @@ abstract class AbstractRedisCacheTest extends CacheTestCase
|
||||
|
||||
protected static $redis;
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\ApcuCache;
|
||||
|
||||
/**
|
||||
@ -24,7 +25,7 @@ class ApcuCacheTest extends CacheTestCase
|
||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
|
||||
$this->markTestSkipped('APCu extension is required.');
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
||||
|
||||
/**
|
||||
@ -19,7 +20,7 @@ use Symfony\Component\Cache\Simple\ArrayCache;
|
||||
*/
|
||||
class ArrayCacheTest extends CacheTestCase
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new ArrayCache($defaultLifetime);
|
||||
}
|
||||
|
@ -26,10 +26,7 @@ abstract class CacheTestCase extends SimpleCacheTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function validKeys()
|
||||
public static function validKeys(): array
|
||||
{
|
||||
return array_merge(parent::validKeys(), [["a\0b"]]);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
*/
|
||||
class ChainCacheTest extends CacheTestCase
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new ChainCache([new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)], $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\DoctrineCache;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
|
||||
|
||||
@ -25,7 +26,7 @@ class DoctrineCacheTest extends CacheTestCase
|
||||
'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new DoctrineCache(new ArrayCache($defaultLifetime), '', $defaultLifetime);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
*/
|
||||
class FilesystemCacheTest extends CacheTestCase
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new FilesystemCache('', $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Simple\MemcachedCache;
|
||||
|
||||
@ -41,7 +42,7 @@ class MemcachedCacheTest extends CacheTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
$client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]) : self::$client;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Simple\MemcachedCache;
|
||||
|
||||
@ -19,7 +20,7 @@ use Symfony\Component\Cache\Simple\MemcachedCache;
|
||||
*/
|
||||
class MemcachedCacheTextModeTest extends MemcachedCacheTest
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]);
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\PdoCache;
|
||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
||||
|
||||
@ -41,7 +42,7 @@ class PdoCacheTest extends CacheTestCase
|
||||
@unlink(self::$dbFile);
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\PdoCache;
|
||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
||||
|
||||
@ -42,7 +43,7 @@ class PdoDbalCacheTest extends CacheTestCase
|
||||
@unlink(self::$dbFile);
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\NullCache;
|
||||
use Symfony\Component\Cache\Simple\PhpArrayCache;
|
||||
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
|
||||
@ -62,7 +63,7 @@ class PhpArrayCacheTest extends CacheTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function createSimpleCache()
|
||||
public function createSimpleCache(): CacheInterface
|
||||
{
|
||||
return new PhpArrayCacheWrapper(self::$file, new NullCache());
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
use Symfony\Component\Cache\Simple\PhpArrayCache;
|
||||
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
|
||||
@ -49,7 +50,7 @@ class PhpArrayCacheWithFallbackTest extends CacheTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new PhpArrayCache(self::$file, new FilesystemCache('php-array-fallback', $defaultLifetime));
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class PhpArrayCacheWrapper extends PhpArrayCache
|
||||
{
|
||||
protected $data = [];
|
||||
|
||||
public function set($key, $value, $ttl = null)
|
||||
public function set($key, $value, $ttl = null): bool
|
||||
{
|
||||
(\Closure::bind(function () use ($key, $value) {
|
||||
$this->data[$key] = $value;
|
||||
@ -28,7 +28,7 @@ class PhpArrayCacheWrapper extends PhpArrayCache
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setMultiple($values, $ttl = null)
|
||||
public function setMultiple($values, $ttl = null): bool
|
||||
{
|
||||
if (!\is_array($values) && !$values instanceof \Traversable) {
|
||||
return parent::setMultiple($values, $ttl);
|
||||
|
@ -24,7 +24,7 @@ class PhpFilesCacheTest extends CacheTestCase
|
||||
'testDefaultLifeTime' => 'PhpFilesCache does not allow configuring a default lifetime.',
|
||||
];
|
||||
|
||||
public function createSimpleCache()
|
||||
public function createSimpleCache(): CacheInterface
|
||||
{
|
||||
return new PhpFilesCache('sf-cache');
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\Psr6Cache;
|
||||
|
||||
/**
|
||||
@ -22,7 +23,7 @@ abstract class Psr6CacheTest extends CacheTestCase
|
||||
'testPrune' => 'Psr6Cache just proxies',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new Psr6Cache($this->createCacheItemPool($defaultLifetime));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
use Symfony\Component\Cache\Simple\TraceableCache;
|
||||
|
||||
@ -24,7 +25,7 @@ class TraceableCacheTest extends CacheTestCase
|
||||
'testPrune' => 'TraceableCache just proxies',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
public function createSimpleCache($defaultLifetime = 0): CacheInterface
|
||||
{
|
||||
return new TraceableCache(new FilesystemCache('', $defaultLifetime));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Builder\ExprBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
||||
class ExprBuilderTest extends TestCase
|
||||
@ -201,10 +202,8 @@ class ExprBuilderTest extends TestCase
|
||||
|
||||
/**
|
||||
* Create a test treebuilder with a variable node, and init the validation.
|
||||
*
|
||||
* @return TreeBuilder
|
||||
*/
|
||||
protected function getTestBuilder()
|
||||
protected function getTestBuilder(): ExprBuilder
|
||||
{
|
||||
$builder = new TreeBuilder('test');
|
||||
|
||||
@ -225,7 +224,7 @@ class ExprBuilderTest extends TestCase
|
||||
*
|
||||
* @return array The finalized config values
|
||||
*/
|
||||
protected function finalizeTestBuilder($testBuilder, $config = null)
|
||||
protected function finalizeTestBuilder($testBuilder, $config = null): array
|
||||
{
|
||||
return $testBuilder
|
||||
->end()
|
||||
@ -240,10 +239,8 @@ class ExprBuilderTest extends TestCase
|
||||
* Return a closure that will return the given value.
|
||||
*
|
||||
* @param mixed $val The value that the closure must return
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function returnClosure($val)
|
||||
protected function returnClosure($val): \Closure
|
||||
{
|
||||
return function ($v) use ($val) {
|
||||
return $val;
|
||||
|
@ -12,11 +12,12 @@
|
||||
namespace Symfony\Component\Config\Tests\Fixtures\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Tests\Fixtures\BarNode;
|
||||
|
||||
class BarNodeDefinition extends NodeDefinition
|
||||
{
|
||||
protected function createNode()
|
||||
protected function createNode(): NodeInterface
|
||||
{
|
||||
return new BarNode($this->name);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class NodeBuilder extends BaseNodeBuilder
|
||||
return $this->node($name, 'bar');
|
||||
}
|
||||
|
||||
protected function getNodeClass($type)
|
||||
protected function getNodeClass($type): string
|
||||
{
|
||||
switch ($type) {
|
||||
case 'variable':
|
||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class ExampleConfiguration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('acme_root');
|
||||
|
||||
|
@ -103,7 +103,7 @@ class TestFileLoader extends FileLoader
|
||||
return $resource;
|
||||
}
|
||||
|
||||
public function supports($resource, $type = null)
|
||||
public function supports($resource, $type = null): bool
|
||||
{
|
||||
return $this->supports;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user