From fc186bb78fcc73e48883dc9ebee4e84101034762 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 21 Aug 2019 15:30:43 +0200 Subject: [PATCH 1/2] Add return types to tests and final|internal|private methods --- .../Doctrine/Test/TestRepositoryFactory.php | 4 +- .../DoctrineExtensionTest.php | 5 +-- .../Doctrine/Tests/Fixtures/BaseUser.php | 8 +--- .../CompositeObjectNoToStringIdEntity.php | 10 +---- .../Tests/Fixtures/Type/StringWrapper.php | 5 +-- .../Tests/Fixtures/Type/StringWrapperType.php | 4 +- .../Bridge/Doctrine/Tests/Fixtures/User.php | 6 +-- .../Doctrine/Tests/ManagerRegistryTest.php | 2 +- .../PropertyInfo/Fixtures/DoctrineFooType.php | 12 ++--- .../Tests/Formatter/ConsoleFormatterTest.php | 5 +-- .../Bridge/Monolog/Tests/LoggerTest.php | 4 +- .../Tests/Processor/DebugProcessorTest.php | 4 +- .../LazyProxy/PhpDumper/ProxyDumperTest.php | 5 +-- .../Extension/Fixtures/StubTranslator.php | 2 +- .../Tests/Translation/TwigExtractorTest.php | 10 +---- .../FrameworkBundle/Test/TestContainer.php | 2 + .../Fixture/TestAppKernel.php | 4 +- .../Console/Descriptor/ObjectsProvider.php | 2 +- .../DataCollectorTranslatorPassTest.php | 2 +- .../CustomPathBundle/src/CustomPathBundle.php | 2 +- .../Tests/Functional/AbstractWebTestCase.php | 5 ++- .../Tests/Functional/AutowiringTypesTest.php | 3 +- .../DependencyInjection/Configuration.php | 2 +- .../DependencyInjection/TestExtension.php | 3 +- .../TransDebug/TransSubscriberService.php | 2 +- .../Tests/Functional/CachePoolsTest.php | 3 +- .../Tests/Functional/app/AppKernel.php | 10 ++--- .../Tests/Kernel/ConcreteMicroKernel.php | 8 ++-- .../Fixtures/StubTemplateNameParser.php | 3 +- .../Helper/Fixtures/StubTranslator.php | 2 +- .../Tests/Templating/PhpEngineTest.php | 4 +- .../Tests/Translation/TranslatorTest.php | 2 +- .../SecurityUserValueResolver.php | 4 +- .../Tests/Functional/AbstractWebTestCase.php | 5 ++- .../Tests/Functional/AutowiringTypesTest.php | 3 +- .../Security/EntryPointStub.php | 2 +- .../Security/LocalizedFormFailureHandler.php | 3 +- .../Http/JsonAuthenticationFailureHandler.php | 3 +- .../Http/JsonAuthenticationSuccessHandler.php | 3 +- .../Tests/Functional/app/AppKernel.php | 12 ++--- .../Tests/Functional/CacheWarmingTest.php | 10 ++--- .../Tests/Functional/EmptyAppTest.php | 6 +-- .../Functional/NoTemplatingEntryTest.php | 6 +-- .../Tests/Profiler/TemplateManagerTest.php | 2 +- .../Component/BrowserKit/HttpBrowser.php | 3 ++ .../BrowserKit/Tests/AbstractBrowserTest.php | 11 ++++- .../BrowserKit/Tests/HttpBrowserTest.php | 5 ++- src/Symfony/Component/Cache/CacheItem.php | 16 ++----- .../Adapter/AbstractRedisAdapterTest.php | 3 +- .../Cache/Tests/Adapter/ApcuAdapterTest.php | 3 +- .../Cache/Tests/Adapter/ArrayAdapterTest.php | 3 +- .../Cache/Tests/Adapter/ChainAdapterTest.php | 3 +- .../Tests/Adapter/DoctrineAdapterTest.php | 3 +- .../Tests/Adapter/FilesystemAdapterTest.php | 2 +- .../Adapter/FilesystemTagAwareAdapterTest.php | 3 +- .../Tests/Adapter/MemcachedAdapterTest.php | 3 +- .../Adapter/NamespacedProxyAdapterTest.php | 3 +- .../Cache/Tests/Adapter/PdoAdapterTest.php | 3 +- .../Tests/Adapter/PdoDbalAdapterTest.php | 3 +- .../Tests/Adapter/PhpArrayAdapterTest.php | 5 ++- .../PhpArrayAdapterWithFallbackTest.php | 3 +- .../Tests/Adapter/PhpFilesAdapterTest.php | 2 +- .../Adapter/PredisTagAwareAdapterTest.php | 3 +- .../PredisTagAwareClusterAdapterTest.php | 3 +- .../PredisTagAwareRedisClusterAdapterTest.php | 3 +- .../Cache/Tests/Adapter/ProxyAdapterTest.php | 9 ++-- .../Cache/Tests/Adapter/Psr16AdapterTest.php | 3 +- .../Cache/Tests/Adapter/RedisAdapterTest.php | 3 +- .../Tests/Adapter/RedisClusterAdapterTest.php | 3 +- .../Adapter/RedisTagAwareAdapterTest.php | 3 +- .../Adapter/RedisTagAwareArrayAdapterTest.php | 3 +- .../RedisTagAwareClusterAdapterTest.php | 3 +- .../Tests/Adapter/SimpleCacheAdapterTest.php | 3 +- .../Tests/Adapter/TagAwareAdapterTest.php | 3 +- .../Tests/Adapter/TraceableAdapterTest.php | 3 +- .../Cache/Tests/Fixtures/ArrayCache.php | 25 +++-------- .../Cache/Tests/Fixtures/ExternalAdapter.php | 45 ++++--------------- .../Component/Cache/Tests/Psr16CacheTest.php | 5 ++- .../Tests/Simple/AbstractRedisCacheTest.php | 3 +- .../Cache/Tests/Simple/ApcuCacheTest.php | 3 +- .../Cache/Tests/Simple/ArrayCacheTest.php | 3 +- .../Cache/Tests/Simple/CacheTestCase.php | 5 +-- .../Cache/Tests/Simple/ChainCacheTest.php | 2 +- .../Cache/Tests/Simple/DoctrineCacheTest.php | 3 +- .../Tests/Simple/FilesystemCacheTest.php | 2 +- .../Cache/Tests/Simple/MemcachedCacheTest.php | 3 +- .../Simple/MemcachedCacheTextModeTest.php | 3 +- .../Cache/Tests/Simple/PdoCacheTest.php | 3 +- .../Cache/Tests/Simple/PdoDbalCacheTest.php | 3 +- .../Cache/Tests/Simple/PhpArrayCacheTest.php | 3 +- .../Simple/PhpArrayCacheWithFallbackTest.php | 3 +- .../Tests/Simple/PhpArrayCacheWrapper.php | 4 +- .../Cache/Tests/Simple/PhpFilesCacheTest.php | 2 +- .../Cache/Tests/Simple/Psr6CacheTest.php | 3 +- .../Cache/Tests/Simple/TraceableCacheTest.php | 3 +- .../Definition/Builder/ExprBuilderTest.php | 11 ++--- .../Fixtures/Builder/BarNodeDefinition.php | 3 +- .../Tests/Fixtures/Builder/NodeBuilder.php | 2 +- .../Configuration/ExampleConfiguration.php | 2 +- .../Config/Tests/Loader/FileLoaderTest.php | 2 +- .../Config/Tests/Loader/LoaderTest.php | 2 +- .../Resource/ReflectionClassResourceTest.php | 4 +- .../Config/Tests/Resource/ResourceStub.php | 4 +- .../Console/Tests/ApplicationTest.php | 6 +-- .../Tests/EventListener/ErrorListenerTest.php | 4 +- .../Console/Tests/Fixtures/DummyOutput.php | 5 +-- .../Console/Tests/Helper/ProgressBarTest.php | 4 +- .../Tests/Helper/ProgressIndicatorTest.php | 4 +- .../Tests/Logger/ConsoleLoggerTest.php | 7 +-- .../Debug/Tests/Fixtures/FinalClasses.php | 1 - .../Fixtures/LoggerThatSetAnErrorHandler.php | 2 +- .../Argument/BoundArgument.php | 2 +- .../Compiler/ServiceLocatorTagPass.php | 4 +- .../Compiler/ExtensionCompilerPassTest.php | 2 +- .../Tests/Compiler/IntegrationTest.php | 2 +- .../MergeExtensionConfigurationPassTest.php | 10 ++--- .../RegisterEnvVarProcessorsPassTest.php | 4 +- .../ValidateEnvPlaceholdersPassTest.php | 10 ++--- .../Tests/Dumper/PhpDumperTest.php | 2 +- .../Tests/Extension/ExtensionTest.php | 2 +- .../Tests/Fixtures/BarFactory.php | 2 +- .../Tests/Fixtures/ScalarFactory.php | 3 -- .../Tests/Fixtures/TestServiceSubscriber.php | 2 +- .../Fixtures/TestServiceSubscriberChild.php | 3 +- .../Tests/Fixtures/config/services9.php | 2 +- .../Tests/Fixtures/containers/container9.php | 4 +- .../Tests/Loader/FileLoaderTest.php | 2 +- .../Tests/ServiceLocatorTest.php | 2 +- .../DomCrawler/Tests/AbstractCrawlerTest.php | 3 ++ .../LegacyEventDispatcherProxy.php | 6 ++- .../EventDispatcher/LegacyEventProxy.php | 2 +- .../Debug/TraceableEventDispatcherTest.php | 2 +- .../RegisterListenersPassTest.php | 2 +- .../Tests/EventDispatcherTest.php | 6 +-- .../Tests/LegacyEventDispatcherTest.php | 3 ++ .../Tests/Fixtures/TestProvider.php | 2 +- .../Tests/Fixtures/MockStream/MockStream.php | 6 +-- .../Component/Finder/Tests/FinderTest.php | 3 ++ .../Component/Finder/Tests/GitignoreTest.php | 2 +- .../MultiplePcreFilterIteratorTest.php | 4 +- ...DateTimeImmutableToDateTimeTransformer.php | 4 +- .../Form/Tests/AbstractExtensionTest.php | 5 ++- .../ChoiceList/AbstractChoiceListTest.php | 5 +-- .../Tests/ChoiceList/ArrayChoiceListTest.php | 3 +- .../DependencyInjection/FormPassTest.php | 5 +-- .../DataMapper/PropertyPathMapperTest.php | 4 +- .../EventListener/ValidationListenerTest.php | 21 +++++---- .../Type/UploadValidatorExtensionTest.php | 2 +- .../Validator/Util/ServerParamsTest.php | 2 +- .../ViolationMapper/ViolationMapperTest.php | 9 +--- .../Form/Tests/Fixtures/ChoiceSubType.php | 2 +- .../Tests/Fixtures/FixedFilterListener.php | 2 +- .../Form/Tests/Fixtures/FooSubType.php | 2 +- .../Component/Form/Tests/Fixtures/FooType.php | 2 +- .../Tests/Fixtures/FormWithSameParentType.php | 2 +- .../Tests/Fixtures/RecursiveFormTypeBar.php | 2 +- .../Tests/Fixtures/RecursiveFormTypeBaz.php | 2 +- .../Tests/Fixtures/RecursiveFormTypeFoo.php | 2 +- .../Form/Tests/Fixtures/TestExtension.php | 10 ++--- .../Storage/NativeSessionStorageTest.php | 5 +-- .../Storage/PhpBridgeSessionStorageTest.php | 5 +-- .../Controller/ArgumentResolver.php | 2 +- .../ArgumentResolver/DefaultValueResolver.php | 4 +- .../NotTaggedControllerValueResolver.php | 2 +- .../RequestAttributeValueResolver.php | 4 +- .../ArgumentResolver/RequestValueResolver.php | 4 +- .../ArgumentResolver/ServiceValueResolver.php | 4 +- .../ArgumentResolver/SessionValueResolver.php | 4 +- .../VariadicValueResolver.php | 4 +- .../ArgumentMetadataFactory.php | 2 +- .../Tests/CacheWarmer/CacheWarmerTest.php | 2 +- .../TraceableValueResolverTest.php | 4 +- .../DataCollector/ConfigDataCollectorTest.php | 4 +- .../FragmentRendererPassTest.php | 5 ++- .../Tests/EventListener/DumpListenerTest.php | 2 +- .../EventListener/ExceptionListenerTest.php | 4 +- .../DataCollector/CloneVarDataCollector.php | 2 +- .../Tests/Fixtures/KernelForOverrideName.php | 3 +- .../Tests/Fixtures/KernelForTest.php | 7 +-- .../Tests/Fixtures/KernelWithoutBundles.php | 5 ++- .../HttpKernel/Tests/Fixtures/TestClient.php | 2 +- .../Tests/HttpCache/HttpCacheTest.php | 2 +- .../Tests/HttpCache/SubRequestHandlerTest.php | 2 +- .../Tests/HttpCache/TestHttpKernel.php | 4 +- .../HttpCache/TestMultipleHttpKernel.php | 4 +- .../Component/HttpKernel/Tests/KernelTest.php | 17 +++---- .../HttpKernel/Tests/Log/LoggerTest.php | 2 +- .../Component/HttpKernel/Tests/Logger.php | 45 ++++--------------- .../HttpKernel/Tests/TestHttpKernel.php | 2 +- src/Symfony/Component/Intl/Intl.php | 18 ++++---- .../Tests/Collator/AbstractCollatorTest.php | 6 +-- .../Intl/Tests/Collator/CollatorTest.php | 2 +- .../Collator/Verification/CollatorTest.php | 2 +- .../Provider/AbstractDataProviderTest.php | 10 +---- .../Json/JsonCurrencyDataProviderTest.php | 5 +-- .../Json/JsonLanguageDataProviderTest.php | 5 +-- .../Json/JsonLocaleDataProviderTest.php | 5 +-- .../Json/JsonRegionDataProviderTest.php | 5 +-- .../Json/JsonScriptDataProviderTest.php | 5 +-- .../AbstractIntlDateFormatterTest.php | 9 +--- .../DateFormatter/IntlDateFormatterTest.php | 4 +- .../Verification/IntlDateFormatterTest.php | 4 +- .../AbstractNumberFormatterTest.php | 17 ++----- .../NumberFormatter/NumberFormatterTest.php | 6 +-- .../Verification/NumberFormatterTest.php | 6 +-- src/Symfony/Component/Ldap/Ldap.php | 8 ++-- src/Symfony/Component/Ldap/Tests/LdapTest.php | 3 ++ src/Symfony/Component/Lock/Key.php | 7 +-- src/Symfony/Component/Lock/Lock.php | 8 ++-- src/Symfony/Component/Lock/Tests/LockTest.php | 34 ++++++++++++-- .../Tests/Store/AbstractRedisStoreTest.php | 3 +- .../Lock/Tests/Store/AbstractStoreTest.php | 5 +-- .../Lock/Tests/Store/CombinedStoreTest.php | 2 +- .../Lock/Tests/Store/FlockStoreTest.php | 3 +- .../Lock/Tests/Store/MemcachedStoreTest.php | 3 +- .../Lock/Tests/Store/PdoDbalStoreTest.php | 3 +- .../Lock/Tests/Store/PdoStoreTest.php | 3 +- .../Tests/Store/RetryTillSaveStoreTest.php | 3 +- .../Lock/Tests/Store/SemaphoreStoreTest.php | 3 +- .../Lock/Tests/Store/ZookeeperStoreTest.php | 6 ++- .../Component/Mime/Header/DateHeader.php | 5 +-- .../Mime/Header/IdentificationHeader.php | 5 +-- .../Component/Mime/Header/MailboxHeader.php | 4 +- .../Mime/Header/MailboxListHeader.php | 2 +- .../Component/Mime/Header/PathHeader.php | 5 +-- .../Component/Process/Pipes/AbstractPipes.php | 2 - src/Symfony/Component/Process/Process.php | 2 +- .../Fixtures/TestSingularAndPluralProps.php | 10 +---- .../Tests/Fixtures/TypeHinted.php | 8 +--- .../Tests/Fixtures/CustomRouteCompiler.php | 3 +- .../Tests/Fixtures/CustomXmlFileLoader.php | 2 +- .../Tests/Fixtures/RedirectableUrlMatcher.php | 2 +- .../Tests/Fixtures/TestObjectRouteLoader.php | 3 ++ .../Routing/Tests/Loader/ObjectLoaderTest.php | 5 ++- .../CompiledRedirectableUrlMatcherTest.php | 2 +- .../DumpedRedirectableUrlMatcherTest.php | 2 +- .../Dumper/CompiledUrlMatcherDumperTest.php | 2 +- .../Matcher/Dumper/PhpMatcherDumperTest.php | 2 +- .../TraceableAccessDecisionManager.php | 6 --- .../Core/Encoder/MigratingPasswordEncoder.php | 4 +- .../Core/Encoder/NativePasswordEncoder.php | 2 +- .../Core/Encoder/SodiumPasswordEncoder.php | 4 +- .../Component/Security/Core/Security.php | 5 +-- .../AuthenticationTrustResolverTest.php | 12 ++--- .../Tests/Authorization/Voter/VoterTest.php | 4 +- .../Tests/Encoder/BasePasswordEncoderTest.php | 4 +- .../Core/Tests/Encoder/EncoderFactoryTest.php | 8 ++-- .../Tests/User/InMemoryUserProviderTest.php | 5 +-- .../Component/Security/Core/User/User.php | 16 +++---- .../FormLoginAuthenticatorTest.php | 19 ++++---- .../Http/Controller/UserValueResolver.php | 4 +- .../Tests/Firewall/ContextListenerTest.php | 12 ++--- .../MetadataAwareNameConverter.php | 4 +- .../Normalizer/AbstractNormalizer.php | 4 +- .../Normalizer/AbstractObjectNormalizer.php | 2 +- .../DeserializeNestedArrayOfObjectsTest.php | 9 ++-- .../Tests/Encoder/ChainEncoderTest.php | 2 +- .../Fixtures/AbstractNormalizerDummy.php | 4 +- .../Fixtures/StaticConstructorNormalizer.php | 2 +- .../AbstractObjectNormalizerTest.php | 28 ++++++++---- .../Tests/Normalizer/ObjectNormalizerTest.php | 2 +- .../Tests/Normalizer/TestDenormalizer.php | 2 +- .../Tests/Normalizer/TestNormalizer.php | 2 +- .../Templating/Tests/DelegatingEngineTest.php | 6 +-- .../Tests/Fixtures/SimpleHelper.php | 2 +- .../Templating/Tests/Helper/HelperTest.php | 2 +- .../Tests/Loader/CacheLoaderTest.php | 2 +- .../Tests/Loader/FilesystemLoaderTest.php | 2 +- .../Templating/Tests/Loader/LoaderTest.php | 2 +- .../Templating/Tests/PhpEngineTest.php | 5 ++- .../Templating/Tests/Storage/StorageTest.php | 2 +- .../fixtures/ServiceSubscriber.php | 2 +- .../Tests/Dumper/FileDumperTest.php | 4 +- .../Tests/PluralizationRulesTest.php | 6 +-- .../Translation/Tests/TranslatorCacheTest.php | 4 +- .../Mapping/Loader/PropertyInfoLoader.php | 2 +- .../AbstractComparisonValidatorTestCase.php | 34 +++----------- .../Tests/Constraints/CompositeTest.php | 4 +- .../Constraints/DivisibleByValidatorTest.php | 11 ++--- .../Constraints/EqualToValidatorTest.php | 11 ++--- .../GreaterThanOrEqualValidatorTest.php | 11 ++--- ...idatorWithPositiveOrZeroConstraintTest.php | 7 +-- .../Constraints/GreaterThanValidatorTest.php | 11 ++--- ...hanValidatorWithPositiveConstraintTest.php | 7 +-- .../Constraints/IdenticalToValidatorTest.php | 13 +++--- .../LessThanOrEqualValidatorTest.php | 11 ++--- ...idatorWithNegativeOrZeroConstraintTest.php | 7 +-- .../Constraints/LessThanValidatorTest.php | 11 ++--- ...hanValidatorWithNegativeConstraintTest.php | 7 +-- .../Constraints/NotEqualToValidatorTest.php | 11 ++--- .../NotIdenticalToValidatorTest.php | 13 +++--- ...ontainerConstraintValidatorFactoryTest.php | 2 +- .../Validator/Tests/Fixtures/ConstraintA.php | 2 +- .../Validator/Tests/Fixtures/ConstraintC.php | 2 +- .../Tests/Fixtures/ConstraintWithValue.php | 2 +- .../Fixtures/ConstraintWithValueAsDefault.php | 2 +- .../Tests/Fixtures/FakeMetadataFactory.php | 6 +-- .../Validator/Tests/Fixtures/FilesLoader.php | 2 +- .../LazyLoadingMetadataFactoryTest.php | 4 +- .../Tests/Validator/AbstractTest.php | 5 +-- .../Validator/RecursiveValidatorTest.php | 3 +- .../Component/VarDumper/Caster/Caster.php | 4 +- .../WebLink/HttpHeaderSerializer.php | 4 +- src/Symfony/Component/Workflow/Definition.php | 4 +- .../MarkingStore/MethodMarkingStore.php | 2 +- .../ClassInstanceSupportStrategy.php | 7 +-- .../EventListener/AuditTrailListenerTest.php | 2 +- .../Component/Workflow/Tests/WorkflowTest.php | 9 +++- .../Yaml/Tests/Command/LintCommandTest.php | 5 +-- .../Contracts/Tests/Cache/CacheTraitTest.php | 18 ++++---- 310 files changed, 733 insertions(+), 855 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php index afc49ed575bf..5f161358cf9c 100644 --- a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php +++ b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php @@ -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); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 1efdf31abf09..0c1a67967d11 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -257,10 +257,7 @@ protected function invokeLoadCacheDriver(array $objectManager, ContainerBuilder $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'], diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php index 50b5845581ce..49c13e0d310e 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php @@ -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 @@ public function getId() return $this->id; } - /** - * @return string - */ - public function getUsername() + public function getUsername(): string { return $this->username; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeObjectNoToStringIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeObjectNoToStringIdEntity.php index ac97367094bd..82811b89ed8c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeObjectNoToStringIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeObjectNoToStringIdEntity.php @@ -35,18 +35,12 @@ public function __construct(SingleIntIdNoToStringEntity $objectOne, SingleIntIdN $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; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php index d46798aa84bb..941ab3ed48ee 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php @@ -20,10 +20,7 @@ public function __construct(string $string = null) $this->string = $string; } - /** - * @return string - */ - public function getString() + public function getString(): string { return $this->string; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php index 9e1cd621fe2a..d3c93d195688 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php @@ -34,10 +34,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} - * - * @return string */ - public function getName() + public function getName(): string { return 'string_wrapper'; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php index c2ad425b61ea..097f11d4f6db 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php @@ -39,15 +39,15 @@ public function getRoles() { } - public function getPassword() + public function getPassword(): ?string { } - public function getSalt() + public function getSalt(): ?string { } - public function getUsername() + public function getUsername(): string { return $this->name; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index 624e5a5a3469..81f197f93c53 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -51,7 +51,7 @@ public function setTestContainer($container) $this->container = $container; } - public function getAliasNamespace($alias) + public function getAliasNamespace($alias): string { return 'Foo'; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php index 1249bd5193e0..a66339649313 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php @@ -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 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} - * - * @return bool */ - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php b/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php index c09597e916cf..89d5bee45454 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php @@ -26,10 +26,7 @@ public function testFormat(array $record, $expectedMessage) self::assertSame($expectedMessage, $formatter->format($record)); } - /** - * @return array - */ - public function providerFormatTests() + public function providerFormatTests(): array { $currentDateTime = new \DateTime(); diff --git a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php index 143200f6c571..be4781d67f90 100644 --- a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php @@ -148,9 +148,9 @@ public function testInheritedClassCallCountErrorsWithoutArgument() class ClassThatInheritLogger extends Logger { - public function getLogs() + public function getLogs(): array { - parent::getLogs(); + return parent::getLogs(); } public function countErrors() diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php index 9aceb9337e40..ef859df0cdc2 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php @@ -99,9 +99,9 @@ private function getRecord($level = Logger::WARNING, $message = 'test') class ClassThatInheritDebugProcessor extends DebugProcessor { - public function getLogs() + public function getLogs(): array { - parent::getLogs(); + return parent::getLogs(); } public function countErrors() diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index da653a7b4d85..33ea1cdcecde 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -173,10 +173,7 @@ protected function createProxy(\$class, \Closure \$factory) $this->assertSame(123, @$foo->dynamicProp); } - /** - * @return array - */ - public function getProxyCandidates() + public function getProxyCandidates(): array { $definitions = [ [new Definition(__CLASS__), true], diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php index 9abd707b40e0..2c8c7db10d86 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php @@ -15,7 +15,7 @@ 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]'; } diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 80d93c058109..5cbf43688bdc 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -123,10 +123,7 @@ public function testExtractSyntaxError($resources) } } - /** - * @return array - */ - public function resourcesWithSyntaxErrorsProvider() + public function resourcesWithSyntaxErrorsProvider(): array { return [ [__DIR__.'/../Fixtures'], @@ -157,10 +154,7 @@ public function testExtractWithFiles($resource) $this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages')); } - /** - * @return array - */ - public function resourceProvider() + public function resourceProvider(): array { $directory = __DIR__.'/../Fixtures/extractor/'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php b/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php index f0fcb38ee184..ee97ad0a695c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php @@ -97,6 +97,8 @@ public function has($id): bool /** * {@inheritdoc} + * + * @return object|null */ public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php index cf9ca2f7e5aa..678d573586f3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php @@ -19,14 +19,14 @@ class TestAppKernel extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { return [ new FrameworkBundle(), ]; } - public function getProjectDir() + public function getProjectDir(): string { return __DIR__.'/test'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php index d5491e8e345c..2b8bb343172d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php @@ -202,7 +202,7 @@ public static function staticMethod() class RouteStub extends Route { - public function compile() + public function compile(): CompiledRoute { return new CompiledRoute('', '#PATH_REGEX#', [], [], '#HOST_REGEX#'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php index d78e0c24924e..138a0e4bbc27 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php @@ -108,7 +108,7 @@ public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames() 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 { } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php index 166b606a459e..ad7194de97b0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php @@ -15,7 +15,7 @@ class CustomPathBundle extends Bundle { - public function getPath() + public function getPath(): string { return __DIR__.'/..'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractWebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractWebTestCase.php index 7e8b50f36739..0b1cc7e65fd5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractWebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractWebTestCase.php @@ -13,6 +13,7 @@ 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 @@ protected static function deleteTmpDir() $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(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php index e0bf9e34dfea..f6149ea874f8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php @@ -17,6 +17,7 @@ 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 @@ public function testCacheAutowiring() $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); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Configuration.php index 9022bc24c26d..fb70137ff7b2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Configuration.php @@ -23,7 +23,7 @@ public function __construct($customConfig = null) $this->customConfig = $customConfig; } - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('test'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php index 59670fdd19a2..b9b22e90b41e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php @@ -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 @@ public function prepend(ContainerBuilder $container) /** * {@inheritdoc} */ - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { return new Configuration($this->customConfig); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TransDebug/TransSubscriberService.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TransDebug/TransSubscriberService.php index 449b35f5e945..5738ab094b34 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TransDebug/TransSubscriberService.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TransDebug/TransSubscriberService.php @@ -24,7 +24,7 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return ['translator' => TranslatorInterface::class]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php index ea1ce9f3266d..2adf5b1dd56e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php @@ -15,6 +15,7 @@ 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 @@ private function doTestCachePools($options, $adapterClass) $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); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php index 0c4d03bfc11a..0ea364b19694 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php @@ -45,7 +45,7 @@ public function __construct($varDir, $testCase, $rootConfig, $environment, $debu 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 @@ public function registerBundles() 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 @@ public function __wakeup() $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; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php index e765c6c23b3c..7e6bb3481064 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php @@ -47,19 +47,19 @@ public function dangerousAction() 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 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::EXCEPTION => 'onKernelException', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php index 9835bc2a228e..e6b8105806c7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php @@ -13,6 +13,7 @@ use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReference; +use Symfony\Component\Templating\TemplateReferenceInterface; class StubTemplateNameParser implements TemplateNameParserInterface { @@ -26,7 +27,7 @@ public function __construct($root, $rootTheme) $this->rootTheme = $rootTheme; } - public function parse($name) + public function parse($name): TemplateReferenceInterface { list($bundle, $controller, $template) = explode(':', $name, 3); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php index 402b3a886c74..2f051f035e54 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php @@ -15,7 +15,7 @@ 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]'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php index 62062018ca81..77cbeb59980b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php @@ -58,10 +58,8 @@ public function testGetInvalidHelper() /** * 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()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 10265acd5ed5..0c243222ae05 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -410,7 +410,7 @@ class TranslatorWithInvalidLocale extends Translator /** * {@inheritdoc} */ - public function getLocale() + public function getLocale(): string { return 'invalid locale'; } diff --git a/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php b/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php index 476e24ee4e45..25a9244f2fc3 100644 --- a/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php +++ b/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php @@ -37,7 +37,7 @@ public function __construct(TokenStorageInterface $tokenStorage) $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 @@ public function supports(Request $request, ArgumentMetadata $argument) return $user instanceof UserInterface; } - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield $this->tokenStorage->getToken()->getUser(); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AbstractWebTestCase.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AbstractWebTestCase.php index 61d0081200b7..010b6219d8f9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AbstractWebTestCase.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AbstractWebTestCase.php @@ -13,6 +13,7 @@ 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 @@ protected static function deleteTmpDir() $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(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AutowiringTypesTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AutowiringTypesTest.php index d0a6e0674802..9d17b13a10b6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AutowiringTypesTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AutowiringTypesTest.php @@ -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 @@ public function testAccessDecisionManagerAutowiring() $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); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php index e1d3280570d8..816457bdc804 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php @@ -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); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php index f8f1c450d396..afb4648d36c6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php @@ -13,6 +13,7 @@ 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 @@ public function __construct(RouterInterface $router) $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)); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php index 737c5a5abec0..26ba36e3d3dd 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php @@ -13,12 +13,13 @@ 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); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php index 0390eb8e35eb..a0300d4d7838 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php @@ -13,12 +13,13 @@ 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())]); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index f5b85e0c059e..8e622282c2c1 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -46,12 +46,12 @@ public function __construct($varDir, $testCase, $rootConfig, $environment, $debu /** * {@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 @@ public function registerBundles() 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 @@ public function unserialize($str) $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; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php index 6ecc0c3b89b4..b397d3abace1 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php @@ -79,12 +79,12 @@ public function __construct($withTemplating) 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 @@ public function registerContainerConfiguration(LoaderInterface $loader) } } - 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'; } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php index d2a3ab68f9d7..e9063f94652c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php @@ -32,7 +32,7 @@ public function testBootEmptyApp() class EmptyAppKernel extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { return [new TwigBundle()]; } @@ -49,12 +49,12 @@ public function registerContainerConfiguration(LoaderInterface $loader) }); } - 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'; } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php index 25dc8c8736ab..75bc4297b1cb 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php @@ -53,7 +53,7 @@ protected function deleteTempDir() class NoTemplatingEntryKernel extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { return [new FrameworkBundle(), new TwigBundle()]; } @@ -75,12 +75,12 @@ public function registerContainerConfiguration(LoaderInterface $loader) }); } - 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'; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 2c39dc73e843..5cdc50224c1c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -130,7 +130,7 @@ public function __construct() parent::__construct('token'); } - public function hasCollector($name) + public function hasCollector($name): bool { switch ($name) { case 'foo': diff --git a/src/Symfony/Component/BrowserKit/HttpBrowser.php b/src/Symfony/Component/BrowserKit/HttpBrowser.php index 7492e58907cb..47f3de907e56 100644 --- a/src/Symfony/Component/BrowserKit/HttpBrowser.php +++ b/src/Symfony/Component/BrowserKit/HttpBrowser.php @@ -41,6 +41,9 @@ public function __construct(HttpClientInterface $client = null, History $history parent::__construct([], $history, $cookieJar); } + /** + * @return Response + */ protected function doRequest($request) { $headers = $this->getHeaders($request); diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index 0d492e92344d..4abde0e97bb1 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -17,6 +17,7 @@ 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,6 +39,9 @@ public function setNextScript($script) $this->nextScript = $script; } + /** + * @return object + */ protected function doRequest($request) { if (null === $this->nextResponse) { @@ -50,7 +54,7 @@ protected function doRequest($request) 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,6 +938,9 @@ public function setNextResponse(Response $response) $this->nextResponse = $response; } + /** + * @return object + */ protected function doRequest($request) { if (null === $this->nextResponse) { @@ -946,7 +953,7 @@ protected function doRequest($request) return $response; } - public function submit(DomCrawlerForm $form, array $values = []) + public function submit(DomCrawlerForm $form, array $values = []): Crawler { return parent::submit($form, $values); } diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index ae9f143cad2b..7e171035dbca 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -58,7 +58,7 @@ public function setNextScript($script) $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,6 +67,9 @@ protected function filterResponse($response) return $response; } + /** + * @return object + */ protected function doRequest($request) { $response = parent::doRequest($request); diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 0c761fd1fac0..fe7d717fca75 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -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 @@ public function get() /** * {@inheritdoc} - * - * @return bool */ - public function isHit() + public function isHit(): bool { return $this->isHit; } @@ -153,11 +149,9 @@ public function getMetadata(): array /** * 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 @@ public function getPreviousTags() * * @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))); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php index 2d1024069de5..9b77e926d495 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php index 5cca73f56189..a4673f12a21b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php @@ -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.'); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php index 5c72dc6e0bc3..81f8e1470202 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index ac9200640452..02fe61480abe 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -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 @@ */ 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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php index b5644cbc84b9..dda3019c69ff 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php index b7a69cb4472a..5dbedcd444d8 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemAdapterTest.php @@ -19,7 +19,7 @@ */ class FilesystemAdapterTest extends AdapterTestCase { - public function createCachePool($defaultLifetime = 0) + public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface { return new FilesystemAdapter('', $defaultLifetime); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php index 83a7ea52ddad..76c9a5817c4c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index 0aebb0e16217..8238eaea056c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -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 @@ public static function setUpBeforeClass(): void } } - public function createCachePool($defaultLifetime = 0) + public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface { $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')) : self::$client; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php index f1ffcbb823fb..460ca0bc8216 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/NamespacedProxyAdapterTest.php @@ -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 @@ */ 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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php index cd4b95cf0e2f..4a09e851797c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php @@ -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 @@ public static function tearDownAfterClass(): void @unlink(self::$dbFile); } - public function createCachePool($defaultLifetime = 0) + public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface { return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php index 573a1b1d0139..d4fa558411b3 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -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 @@ public static function tearDownAfterClass(): void @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); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php index b6d5c29881a3..ed5023b0786f 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php @@ -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 @@ protected function tearDown(): void } } - 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(); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php index d8e20179883d..32f52bae9bcc 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php @@ -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 @@ protected function tearDown(): void } } - public function createCachePool($defaultLifetime = 0) + public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface { return new PhpArrayAdapter(self::$file, new FilesystemAdapter('php-array-fallback', $defaultLifetime)); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php index dec63a62a0dc..3e636174473d 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php @@ -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'); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php index e685d7608388..390a73da5f78 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php @@ -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 @@ protected function setUp(): void $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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php index 8c604c1ca6bf..8339367593d0 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php @@ -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 @@ protected function setUp(): void $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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareRedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareRedisClusterAdapterTest.php index e8d2ea654f31..813d52471587 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareRedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareRedisClusterAdapterTest.php @@ -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 @@ protected function setUp(): void $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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php index 13e5aedad044..6436428e7424 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php @@ -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 @@ public function __construct(CacheItemInterface $item) $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()); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php index 1647a6d4cb9b..7d5f2423989b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php index b039289cdcd1..216d1373dbd0 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php @@ -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 @@ public static function setUpBeforeClass(): void 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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php index 34dfae19de36..821259b78fdc 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php @@ -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 @@ public static function setUpBeforeClass(): void 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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php index ef140818575d..b88af7b7335e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php @@ -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 @@ protected function setUp(): void $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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php index 7c9802040864..5fcf781cd9f8 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php @@ -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 @@ protected function setUp(): void $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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php index 7b7d6801940f..3deb0c264a85 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php @@ -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 @@ protected function setUp(): void $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); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php index c4ec9bf62e8e..626ba4733141 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index 490e50339a32..27731deb2bea 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -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)); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php index 35eba7d77bec..3d531f5caf16 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php @@ -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)); } diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php index c00a3aef05ae..724e605e58d3 100644 --- a/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php @@ -13,10 +13,7 @@ protected function doFetch($id) 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 @@ protected function doContains($id) 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; } diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php index 0481b16bcd85..2d2a4b1593a3 100644 --- a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php @@ -29,74 +29,47 @@ public function __construct(int $defaultLifetime = 0) $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(); } diff --git a/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php b/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php index 7774e1ddd588..f3a027cbfbe8 100644 --- a/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php @@ -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 @@ protected function setUp(): void } } - 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"]]); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php index 81718970c419..b9bc266ab538 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php index b3220946038c..03e3f262a6de 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php @@ -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.'); diff --git a/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php index 587304a5db1c..15fb83975dbc 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Simple; +use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Simple\ArrayCache; /** @@ -19,7 +20,7 @@ */ class ArrayCacheTest extends CacheTestCase { - public function createSimpleCache($defaultLifetime = 0) + public function createSimpleCache($defaultLifetime = 0): CacheInterface { return new ArrayCache($defaultLifetime); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php b/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php index 5cad7858be85..5d7e30f27afb 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php @@ -26,10 +26,7 @@ protected function setUp(): void } } - /** - * @return array - */ - public static function validKeys() + public static function validKeys(): array { return array_merge(parent::validKeys(), [["a\0b"]]); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php index 3ec828c1506c..38b4bb8dd471 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php @@ -24,7 +24,7 @@ */ 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); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php index 5d78c00cac84..150c1f6abb08 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php index 9f423ba641c9..31eacdbdb4e1 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php @@ -20,7 +20,7 @@ */ class FilesystemCacheTest extends CacheTestCase { - public function createSimpleCache($defaultLifetime = 0) + public function createSimpleCache($defaultLifetime = 0): CacheInterface { return new FilesystemCache('', $defaultLifetime); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php index 3a7b27b6c08f..c07f9f10ff08 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php @@ -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 @@ public static function setUpBeforeClass(): void } } - public function createSimpleCache($defaultLifetime = 0) + public function createSimpleCache($defaultLifetime = 0): CacheInterface { $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]) : self::$client; diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php index d68131a1db7b..1e749ba72e80 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php @@ -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 @@ */ 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]); diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php index c326d387d541..cac5373c9edb 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php @@ -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 @@ public static function tearDownAfterClass(): void @unlink(self::$dbFile); } - public function createSimpleCache($defaultLifetime = 0) + public function createSimpleCache($defaultLifetime = 0): CacheInterface { return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php index 2893fee99615..80c868b5cabb 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php @@ -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 @@ public static function tearDownAfterClass(): void @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); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php index c1d4ab2d7705..36dd116dcd2c 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php @@ -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 @@ protected function tearDown(): void } } - public function createSimpleCache() + public function createSimpleCache(): CacheInterface { return new PhpArrayCacheWrapper(self::$file, new NullCache()); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php index 7ae814a98a0d..08a8459c62c4 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php @@ -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 @@ protected function tearDown(): void } } - public function createSimpleCache($defaultLifetime = 0) + public function createSimpleCache($defaultLifetime = 0): CacheInterface { return new PhpArrayCache(self::$file, new FilesystemCache('php-array-fallback', $defaultLifetime)); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.php index 1e102fe1ff2e..4dfb2236d5c3 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.php @@ -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 @@ public function set($key, $value, $ttl = null) 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); diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php index 7e40df7de5fb..2ee25a536ea4 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php @@ -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'); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php index 9fff36e402de..365147d1d390 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php @@ -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)); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php index c2e8a477b477..21bd1eadbb18 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php @@ -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)); } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index c4921f6c2834..311c41ec66b6 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -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 @@ public function testEndThenPartNotSpecified() /** * 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 @@ protected function getTestBuilder() * * @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 @@ protected function finalizeTestBuilder($testBuilder, $config = null) * 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; diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Builder/BarNodeDefinition.php b/src/Symfony/Component/Config/Tests/Fixtures/Builder/BarNodeDefinition.php index b9c62e53771c..03d7ceba921a 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Builder/BarNodeDefinition.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Builder/BarNodeDefinition.php @@ -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); } diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php index 22b8b32fb6de..26323e9805d6 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php @@ -20,7 +20,7 @@ public function barNode($name) return $this->node($name, 'bar'); } - protected function getNodeClass($type) + protected function getNodeClass($type): string { switch ($type) { case 'variable': diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php index bfa43d964d18..21b2345ea01a 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php @@ -16,7 +16,7 @@ class ExampleConfiguration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('acme_root'); diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index 0b2e3fb6b9a5..f2f88184204c 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -103,7 +103,7 @@ public function load($resource, $type = null) return $resource; } - public function supports($resource, $type = null) + public function supports($resource, $type = null): bool { return $this->supports; } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index b26796b278b9..6c582ca8d575 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -105,7 +105,7 @@ public function load($resource, $type = null) { } - public function supports($resource, $type = null) + public function supports($resource, $type = null): bool { return \is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION); } diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php index 5dc9634f04f6..6ffb461a457b 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -204,7 +204,7 @@ class TestEventSubscriber implements EventSubscriberInterface { public static $subscribedEvents = []; - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return self::$subscribedEvents; } @@ -228,7 +228,7 @@ class TestServiceSubscriber implements ServiceSubscriberInterface { public static $subscribedServices = []; - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return self::$subscribedServices; } diff --git a/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php b/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php index b01729cbff85..959b00290ed6 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php +++ b/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php @@ -22,12 +22,12 @@ public function setFresh($isFresh) $this->fresh = $isFresh; } - public function __toString() + public function __toString(): string { return 'stub'; } - public function isFresh($timestamp) + public function isFresh($timestamp): bool { return $this->fresh; } diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index ad08aa2e3460..19b3c34b8c32 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -1758,7 +1758,7 @@ class CustomApplication extends Application * * @return InputDefinition An InputDefinition instance */ - protected function getDefaultInputDefinition() + protected function getDefaultInputDefinition(): InputDefinition { return new InputDefinition([new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.')]); } @@ -1768,7 +1768,7 @@ protected function getDefaultInputDefinition() * * @return HelperSet A HelperSet instance */ - protected function getDefaultHelperSet() + protected function getDefaultHelperSet(): HelperSet { return new HelperSet([new FormatterHelper()]); } @@ -1799,7 +1799,7 @@ public function execute(InputInterface $input, OutputInterface $output) class DisabledCommand extends Command { - public function isEnabled() + public function isEnabled(): bool { return false; } diff --git a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php index 39766db3d805..68b4b3a3e165 100644 --- a/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/Console/Tests/EventListener/ErrorListenerTest.php @@ -138,11 +138,11 @@ private function getOutput() class NonStringInput extends Input { - public function getFirstArgument() + public function getFirstArgument(): ?string { } - public function hasParameterOption($values, $onlyParams = false) + public function hasParameterOption($values, $onlyParams = false): bool { } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php b/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php index e9cf6ce7dae8..96de7e7189d6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php @@ -20,10 +20,7 @@ */ class DummyOutput extends BufferedOutput { - /** - * @return array - */ - public function getLogs() + public function getLogs(): array { $logs = []; foreach (explode(PHP_EOL, trim($this->fetch())) as $message) { diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index d007a5782ce1..877b1dfd197b 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -867,10 +867,8 @@ public function testFormatsWithoutMax($format) /** * Provides each defined format. - * - * @return array */ - public function provideFormat() + public function provideFormat(): array { return [ ['normal'], diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php index 6d803fc251ef..d51d9f72b462 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php @@ -148,10 +148,8 @@ public function testFormats($format) /** * Provides each defined format. - * - * @return array */ - public function provideFormat() + public function provideFormat(): array { return [ ['normal'], diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index f1bbb61c5ff9..ef115767efcc 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -32,10 +32,7 @@ class ConsoleLoggerTest extends TestCase */ protected $output; - /** - * @return LoggerInterface - */ - public function getLogger() + public function getLogger(): LoggerInterface { $this->output = new DummyOutput(OutputInterface::VERBOSITY_VERBOSE); @@ -56,7 +53,7 @@ public function getLogger() * * @return string[] */ - public function getLogs() + public function getLogs(): array { return $this->output->getLogs(); } diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/FinalClasses.php b/src/Symfony/Component/Debug/Tests/Fixtures/FinalClasses.php index 4c2b0aaf351f..e85c36a1ec0e 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/FinalClasses.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/FinalClasses.php @@ -41,7 +41,6 @@ class FinalClass4 /** * @author John Doe * - * * @final multiline * comment */ diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/LoggerThatSetAnErrorHandler.php b/src/Symfony/Component/Debug/Tests/Fixtures/LoggerThatSetAnErrorHandler.php index dd8563627a1f..068e8208d9e9 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/LoggerThatSetAnErrorHandler.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/LoggerThatSetAnErrorHandler.php @@ -6,7 +6,7 @@ class LoggerThatSetAnErrorHandler extends BufferingLogger { - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { set_error_handler('is_string'); parent::log($level, $message, $context); diff --git a/src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php b/src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php index 4a0054e20bff..60059267beea 100644 --- a/src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php +++ b/src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php @@ -43,7 +43,7 @@ public function __construct($value, bool $trackUsage = true, int $type = 0, stri /** * {@inheritdoc} */ - public function getValues() + public function getValues(): array { return [$this->value, $this->identifier, $this->used, $this->type, $this->file]; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php index 96d4bbe0f4a5..dea70174b884 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php @@ -89,10 +89,8 @@ protected function processValue($value, $isRoot = false) /** * @param Reference[] $refMap * @param string|null $callerId - * - * @return Reference */ - public static function register(ContainerBuilder $container, array $refMap, $callerId = null) + public static function register(ContainerBuilder $container, array $refMap, $callerId = null): Reference { foreach ($refMap as $id => $ref) { if (!$ref instanceof Reference) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php index 034841e8036f..fb23f570162c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php @@ -61,7 +61,7 @@ public function __construct($alias) $this->alias = $alias; } - public function getAlias() + public function getAlias(): string { return $this->alias; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php index 83d3e23d3ba5..73c284f806a1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php @@ -406,7 +406,7 @@ public function testTaggedServiceLocatorWithDefaultIndex() class ServiceSubscriberStub implements ServiceSubscriberInterface { - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return []; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php index c98275144e74..d5db48cc3064 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -132,7 +132,7 @@ public function testThrowingExtensionsGetMergedBag() class FooConfiguration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('foo'); $treeBuilder->getRootNode() @@ -147,12 +147,12 @@ public function getConfigTreeBuilder() class FooExtension extends Extension { - public function getAlias() + public function getAlias(): string { return 'foo'; } - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { return new FooConfiguration(); } @@ -179,12 +179,12 @@ public function load(array $configs, ContainerBuilder $container) class ThrowingExtension extends Extension { - public function getAlias() + public function getAlias(): string { return 'throwing'; } - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { return new FooConfiguration(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php index 49832451e578..4686f483a7d6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php @@ -78,7 +78,7 @@ public function getEnv($prefix, $name, \Closure $getEnv) return $getEnv($name); } - public static function getProvidedTypes() + public static function getProvidedTypes(): array { return ['foo' => 'string']; } @@ -86,7 +86,7 @@ public static function getProvidedTypes() class BadProcessor extends SimpleProcessor { - public static function getProvidedTypes() + public static function getProvidedTypes(): array { return ['foo' => 'string|foo']; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index 1c1fbdb764f3..3a89b11c8c8a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -313,7 +313,7 @@ private function doProcess(ContainerBuilder $container): void class EnvConfiguration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('env_extension'); $treeBuilder->getRootNode() @@ -376,7 +376,7 @@ public function getConfigTreeBuilder() class EnvConfigurationWithoutRootNode implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { return new TreeBuilder(); } @@ -384,7 +384,7 @@ public function getConfigTreeBuilder() class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('env_extension'); $treeBuilder->getRootNode() @@ -410,12 +410,12 @@ public function __construct(ConfigurationInterface $configuration = null) $this->configuration = $configuration ?? new EnvConfiguration(); } - public function getAlias() + public function getAlias(): string { return 'env_extension'; } - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { return $this->configuration; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index d6b20071be5d..9460e27bbdf9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -1328,7 +1328,7 @@ public function getEnv($prefix, $name, \Closure $getEnv) return str_rot13($getEnv($name)); } - public static function getProvidedTypes() + public static function getProvidedTypes(): array { return ['rot13' => 'string']; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php index 9f35b4a4193d..16a1d39e2940 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -50,7 +50,7 @@ public function load(array $configs, ContainerBuilder $container) { } - public function isConfigEnabled(ContainerBuilder $container, array $config) + public function isConfigEnabled(ContainerBuilder $container, array $config): bool { return parent::isConfigEnabled($container, $config); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/BarFactory.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/BarFactory.php index 305b206c88b8..6c2c0f099664 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/BarFactory.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/BarFactory.php @@ -11,7 +11,7 @@ class BarFactory public function __construct(iterable $bars) { - $this->bars = \iterator_to_array($bars); + $this->bars = iterator_to_array($bars); } public function getDefaultBar(): BarInterface diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ScalarFactory.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ScalarFactory.php index 72f6f918075a..393e24139458 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ScalarFactory.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ScalarFactory.php @@ -4,9 +4,6 @@ final class ScalarFactory { - /** - * @return string - */ public static function getSomeValue(): string { return 'some value'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php index 7fc3842af3a4..968ff85f0444 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriber.php @@ -10,7 +10,7 @@ public function __construct($container) { } - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return [ __CLASS__, diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriberChild.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriberChild.php index efd89e3285ef..c585a6643be3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriberChild.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/TestServiceSubscriberChild.php @@ -6,7 +6,8 @@ class TestServiceSubscriberChild extends TestServiceSubscriberParent { - use ServiceSubscriberTrait, TestServiceSubscriberTrait; + use ServiceSubscriberTrait; + use TestServiceSubscriberTrait; private function testDefinition2(): TestDefinition2 { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php index 04f5858e6b54..7c070ef64f45 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php @@ -4,8 +4,8 @@ use Bar\FooClass; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Parameter; +use Symfony\Component\DependencyInjection\Reference; require_once __DIR__.'/../includes/classes.php'; require_once __DIR__.'/../includes/foo.php'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php index 520f235b2236..6ae7f7161ab7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php @@ -5,10 +5,10 @@ use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Parameter; +use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\ExpressionLanguage\Expression; $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php index b5a6911254d4..4e70a0814cde 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -248,7 +248,7 @@ public function load($resource, $type = null) return $resource; } - public function supports($resource, $type = null) + public function supports($resource, $type = null): bool { return false; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php b/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php index e5ff2841261e..025691d74aa7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php @@ -104,7 +104,7 @@ public function getFoo() return $this->container->get('foo'); } - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return ['bar' => 'stdClass']; } diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php index 7a8196b9f1ac..c17ac333f3cb 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php @@ -1241,6 +1241,9 @@ protected function createNodeList() class ClassThatInheritCrawler extends Crawler { + /** + * @return static + */ public function children() { parent::children(); diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php index afa3e988d005..a3efdf31c6f0 100644 --- a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php +++ b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php @@ -50,6 +50,8 @@ public static function decorate(?ContractsEventDispatcherInterface $dispatcher): * {@inheritdoc} * * @param string|null $eventName + * + * @return Event */ public function dispatch($event/*, string $eventName = null*/) { @@ -114,7 +116,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function getListeners($eventName = null) + public function getListeners($eventName = null): array { return $this->dispatcher->getListeners($eventName); } @@ -130,7 +132,7 @@ public function getListenerPriority($eventName, $listener) /** * {@inheritdoc} */ - public function hasListeners($eventName = null) + public function hasListeners($eventName = null): bool { return $this->dispatcher->hasListeners($eventName); } diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventProxy.php index cad8cfaedb72..45ee251d6a98 100644 --- a/src/Symfony/Component/EventDispatcher/LegacyEventProxy.php +++ b/src/Symfony/Component/EventDispatcher/LegacyEventProxy.php @@ -37,7 +37,7 @@ public function getEvent() return $this->event; } - public function isPropagationStopped() + public function isPropagationStopped(): bool { if (!$this->event instanceof ContractsEvent && !$this->event instanceof StoppableEventInterface) { return false; diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index ea476eee04c8..6a208a666251 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -312,7 +312,7 @@ public function testClearOrphanedEvents() class EventSubscriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return ['foo' => 'call']; } diff --git a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php index 2e238bc5ef9e..1cc54a40b9c6 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -179,7 +179,7 @@ public function testInvokableEventListener() class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'event' => 'onEvent', diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index 83d10a89be74..bc2287303d63 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -482,7 +482,7 @@ public function foo($e, $name, $dispatcher) class TestEventSubscriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return ['pre.foo' => 'preFoo', 'post.foo' => 'postFoo']; } @@ -490,7 +490,7 @@ public static function getSubscribedEvents() class TestEventSubscriberWithPriorities implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'pre.foo' => ['preFoo', 10], @@ -501,7 +501,7 @@ public static function getSubscribedEvents() class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return ['pre.foo' => [ ['preFoo1'], diff --git a/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php index 30bd0c33463b..4cf203f4dada 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php @@ -56,6 +56,9 @@ protected function createEventDispatcher() class TestLegacyEventDispatcher extends EventDispatcher { + /** + * @return object + */ public function dispatch($eventName, Event $event = null) { return parent::dispatch($event, $eventName); diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/Fixtures/TestProvider.php b/src/Symfony/Component/ExpressionLanguage/Tests/Fixtures/TestProvider.php index 8405d4f97585..6f7c32d7a417 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/Fixtures/TestProvider.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/Fixtures/TestProvider.php @@ -17,7 +17,7 @@ class TestProvider implements ExpressionFunctionProviderInterface { - public function getFunctions() + public function getFunctions(): array { return [ new ExpressionFunction('identity', function ($input) { diff --git a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php index 3d80a90582ce..a1d410b1987b 100644 --- a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php +++ b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php @@ -25,10 +25,8 @@ class MockStream * @param int $options Holds additional flags set by the streams API * @param string $opened_path If the path is opened successfully, and STREAM_USE_PATH is set in options, * opened_path should be set to the full path of the file/resource that was actually opened - * - * @return bool */ - public function stream_open($path, $mode, $options, &$opened_path) + public function stream_open($path, $mode, $options, &$opened_path): bool { return true; } @@ -39,7 +37,7 @@ public function stream_open($path, $mode, $options, &$opened_path) * * @return array File stats */ - public function url_stat($path, $flags) + public function url_stat($path, $flags): array { return []; } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 19b1909e8791..48ef921a866a 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -1438,6 +1438,9 @@ protected function buildFinder() class ClassThatInheritFinder extends Finder { + /** + * @return $this + */ public function sortByName() { parent::sortByName(); diff --git a/src/Symfony/Component/Finder/Tests/GitignoreTest.php b/src/Symfony/Component/Finder/Tests/GitignoreTest.php index ad0ce0b50700..c043df8c0be6 100644 --- a/src/Symfony/Component/Finder/Tests/GitignoreTest.php +++ b/src/Symfony/Component/Finder/Tests/GitignoreTest.php @@ -41,7 +41,7 @@ public function testCases(string $patterns, array $matchingCases, array $nonMatc * ], * ] */ - public function provider() + public function provider(): array { return [ [ diff --git a/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php index 955677695ba0..15e069b9f81c 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php @@ -59,12 +59,12 @@ public function accept() throw new \BadFunctionCallException('Not implemented'); } - public function isRegex($str) + public function isRegex($str): bool { return parent::isRegex($str); } - public function toRegex($str) + public function toRegex($str): string { throw new \BadFunctionCallException('Not implemented'); } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformer.php index b0737393e4e3..ce23fbde42f7 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformer.php @@ -30,7 +30,7 @@ final class DateTimeImmutableToDateTimeTransformer implements DataTransformerInt * * @throws TransformationFailedException If the given value is not a \DateTimeImmutable */ - public function transform($value) + public function transform($value): ?\DateTime { if (null === $value) { return null; @@ -52,7 +52,7 @@ public function transform($value) * * @throws TransformationFailedException If the given value is not a \DateTime */ - public function reverseTransform($value) + public function reverseTransform($value): ?\DateTimeImmutable { if (null === $value) { return null; diff --git a/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php b/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php index c3fa1b6cf9f3..ce3e63416e3c 100644 --- a/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Form\AbstractExtension; +use Symfony\Component\Form\FormTypeGuesserInterface; use Symfony\Component\Form\Tests\Fixtures\FooType; class AbstractExtensionTest extends TestCase @@ -33,12 +34,12 @@ public function testGetType() class ConcreteExtension extends AbstractExtension { - protected function loadTypes() + protected function loadTypes(): array { return [new FooType()]; } - protected function loadTypeGuesser() + protected function loadTypeGuesser(): ?FormTypeGuesserInterface { } } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php index ea615b559a68..8dcbd2e64f13 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php @@ -218,10 +218,7 @@ public function testGetChoicesForValuesWithNull() $this->assertNotEmpty($this->list->getChoicesForValues($values)); } - /** - * @return \Symfony\Component\Form\ChoiceList\ChoiceListInterface - */ - abstract protected function createChoiceList(); + abstract protected function createChoiceList(): \Symfony\Component\Form\ChoiceList\ChoiceListInterface; abstract protected function getChoices(); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index d9c4ea16a27b..ce5f2e933f00 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Tests\ChoiceList; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; +use Symfony\Component\Form\ChoiceList\ChoiceListInterface; /** * @author Bernhard Schussek @@ -27,7 +28,7 @@ protected function setUp(): void parent::setUp(); } - protected function createChoiceList() + protected function createChoiceList(): ChoiceListInterface { return new ArrayChoiceList($this->getChoices()); } diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php index 7988bb986b45..15fdd85ff665 100644 --- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php +++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php @@ -238,10 +238,7 @@ public function testAddLegacyTaggedTypeExtensions(array $extensions, array $expe $this->assertEquals($expectedRegisteredExtensions, $extDefinition->getArgument(1)); } - /** - * @return array - */ - public function addLegacyTaggedTypeExtensionsDataProvider() + public function addLegacyTaggedTypeExtensionsDataProvider(): array { return [ [ diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php index ffabfadb74b3..5890ebb8f474 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php @@ -333,7 +333,7 @@ public function provideDate() class SubmittedForm extends Form { - public function isSubmitted() + public function isSubmitted(): bool { return true; } @@ -341,7 +341,7 @@ public function isSubmitted() class NotSynchronizedForm extends Form { - public function isSynchronized() + public function isSynchronized(): bool { return false; } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php index de3eb2717f02..f8fbabd92a01 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php @@ -27,8 +27,11 @@ use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Mapping\MetadataInterface; use Symfony\Component\Validator\Validation; +use Symfony\Component\Validator\Validator\ContextualValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; class ValidationListenerTest extends TestCase @@ -137,12 +140,12 @@ public function testValidateWithEmptyViolationList() class SubmittedNotSynchronizedForm extends Form { - public function isSubmitted() + public function isSubmitted(): bool { return true; } - public function isSynchronized() + public function isSynchronized(): bool { return false; } @@ -157,32 +160,32 @@ public function __construct(ConstraintViolationInterface $violation) $this->violation = $violation; } - public function getMetadataFor($value) + public function getMetadataFor($value): MetadataInterface { } - public function hasMetadataFor($value) + public function hasMetadataFor($value): bool { } - public function validate($value, $constraints = null, $groups = null) + public function validate($value, $constraints = null, $groups = null): ConstraintViolationListInterface { return new ConstraintViolationList([$this->violation]); } - public function validateProperty($object, $propertyName, $groups = null) + public function validateProperty($object, $propertyName, $groups = null): ConstraintViolationListInterface { } - public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) + public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null): ConstraintViolationListInterface { } - public function startContext() + public function startContext(): ContextualValidatorInterface { } - public function inContext(ExecutionContextInterface $context) + public function inContext(ExecutionContextInterface $context): ContextualValidatorInterface { } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php index 34ff556d1530..d1af4d7d2178 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php @@ -40,7 +40,7 @@ public function testPostMaxSizeTranslation() class DummyTranslator implements TranslatorInterface { - public function trans($id, array $parameters = [], $domain = null, $locale = null) + public function trans($id, array $parameters = [], $domain = null, $locale = null): string { return 'translated max {{ max }}!'; } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php index 049876246c50..8d3b5f6fa00f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php @@ -79,7 +79,7 @@ public function __construct($size) $this->size = $size; } - public function getNormalizedIniPostMaxSize() + public function getNormalizedIniPostMaxSize(): string { return $this->size; } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index bcd9ea420eda..be875fb322b2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -93,18 +93,13 @@ function () { throw new TransformationFailedException(); } /** * @param $propertyPath - * - * @return ConstraintViolation */ - protected function getConstraintViolation($propertyPath) + protected function getConstraintViolation($propertyPath): ConstraintViolation { return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, $propertyPath, null); } - /** - * @return FormError - */ - protected function getFormError(ConstraintViolationInterface $violation, FormInterface $form) + protected function getFormError(ConstraintViolationInterface $violation, FormInterface $form): FormError { $error = new FormError($this->message, $this->messageTemplate, $this->params, null, $violation); $error->setOrigin($form); diff --git a/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php index 580e21570869..ceb25f5559e9 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php @@ -36,7 +36,7 @@ public function configureOptions(OptionsResolver $resolver) /** * {@inheritdoc} */ - public function getParent() + public function getParent(): ?string { return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php b/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php index 7ca0187c643a..ece653e87b87 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php @@ -55,7 +55,7 @@ public function preSetData(FormEvent $event) } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ FormEvents::PRE_SUBMIT => 'preSubmit', diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php b/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php index e4a4f3612e19..9ce8b5e66e5f 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php @@ -15,7 +15,7 @@ class FooSubType extends AbstractType { - public function getParent() + public function getParent(): ?string { return __NAMESPACE__.'\FooType'; } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooType.php b/src/Symfony/Component/Form/Tests/Fixtures/FooType.php index 3a9517228532..c5ca46597f59 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FooType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FooType.php @@ -15,7 +15,7 @@ class FooType extends AbstractType { - public function getParent() + public function getParent(): ?string { return null; } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FormWithSameParentType.php b/src/Symfony/Component/Form/Tests/Fixtures/FormWithSameParentType.php index 098f9a2a2b70..79544d4c0983 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FormWithSameParentType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FormWithSameParentType.php @@ -15,7 +15,7 @@ class FormWithSameParentType extends AbstractType { - public function getParent() + public function getParent(): ?string { return self::class; } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBar.php b/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBar.php index a7b0d4df35b0..7836a5399737 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBar.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBar.php @@ -15,7 +15,7 @@ class RecursiveFormTypeBar extends AbstractType { - public function getParent() + public function getParent(): ?string { return RecursiveFormTypeBaz::class; } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBaz.php b/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBaz.php index 63f62e757f93..dda34803f67c 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBaz.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeBaz.php @@ -15,7 +15,7 @@ class RecursiveFormTypeBaz extends AbstractType { - public function getParent() + public function getParent(): ?string { return RecursiveFormTypeFoo::class; } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeFoo.php b/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeFoo.php index a41f63ee0b9c..00ac0e70a846 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeFoo.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/RecursiveFormTypeFoo.php @@ -15,7 +15,7 @@ class RecursiveFormTypeFoo extends AbstractType { - public function getParent() + public function getParent(): ?string { return RecursiveFormTypeBar::class; } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php b/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php index 578db1242c5d..335e5c4c7e04 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php @@ -34,12 +34,12 @@ public function addType(FormTypeInterface $type) $this->types[\get_class($type)] = $type; } - public function getType($name) + public function getType($name): FormTypeInterface { return isset($this->types[$name]) ? $this->types[$name] : null; } - public function hasType($name) + public function hasType($name): bool { return isset($this->types[$name]); } @@ -55,17 +55,17 @@ public function addTypeExtension(FormTypeExtensionInterface $extension) } } - public function getTypeExtensions($name) + public function getTypeExtensions($name): array { return isset($this->extensions[$name]) ? $this->extensions[$name] : []; } - public function hasTypeExtensions($name) + public function hasTypeExtensions($name): bool { return isset($this->extensions[$name]); } - public function getTypeGuesser() + public function getTypeGuesser(): ?FormTypeGuesserInterface { return $this->guesser; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 17f46bef5e1a..b04e0611273e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -53,10 +53,7 @@ protected function tearDown(): void $this->savePath = null; } - /** - * @return NativeSessionStorage - */ - protected function getStorage(array $options = []) + protected function getStorage(array $options = []): NativeSessionStorage { $storage = new NativeSessionStorage($options); $storage->registerBag(new AttributeBag()); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index 7d6827079893..206ff48777e9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -49,10 +49,7 @@ protected function tearDown(): void $this->savePath = null; } - /** - * @return PhpBridgeSessionStorage - */ - protected function getStorage() + protected function getStorage(): PhpBridgeSessionStorage { $storage = new PhpBridgeSessionStorage(); $storage->registerBag(new AttributeBag()); diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php index 0a5f618de07f..89154ece716f 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php @@ -43,7 +43,7 @@ public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFa /** * {@inheritdoc} */ - public function getArguments(Request $request, $controller) + public function getArguments(Request $request, $controller): array { $arguments = []; diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php index e58fd3ab2bed..32a0e071d688 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php @@ -25,7 +25,7 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface /** * {@inheritdoc} */ - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic()); } @@ -33,7 +33,7 @@ public function supports(Request $request, ArgumentMetadata $argument) /** * {@inheritdoc} */ - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield $argument->hasDefaultValue() ? $argument->getDefaultValue() : null; } diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php index 7dac296c0c7d..d4971cc1a507 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php @@ -34,7 +34,7 @@ public function __construct(ContainerInterface $container) /** * {@inheritdoc} */ - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { $controller = $request->attributes->get('_controller'); diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php index 05be372d8459..c62d327b65a2 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php @@ -25,7 +25,7 @@ final class RequestAttributeValueResolver implements ArgumentValueResolverInterf /** * {@inheritdoc} */ - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { return !$argument->isVariadic() && $request->attributes->has($argument->getName()); } @@ -33,7 +33,7 @@ public function supports(Request $request, ArgumentMetadata $argument) /** * {@inheritdoc} */ - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield $request->attributes->get($argument->getName()); } diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestValueResolver.php index 2a5060a61268..75cbd97edbbf 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestValueResolver.php @@ -25,7 +25,7 @@ final class RequestValueResolver implements ArgumentValueResolverInterface /** * {@inheritdoc} */ - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class); } @@ -33,7 +33,7 @@ public function supports(Request $request, ArgumentMetadata $argument) /** * {@inheritdoc} */ - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield $request; } diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php index e7df546b6680..4ffb8c99eb4b 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php @@ -34,7 +34,7 @@ public function __construct(ContainerInterface $container) /** * {@inheritdoc} */ - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { $controller = $request->attributes->get('_controller'); @@ -58,7 +58,7 @@ public function supports(Request $request, ArgumentMetadata $argument) /** * {@inheritdoc} */ - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { if (\is_array($controller = $request->attributes->get('_controller'))) { $controller = $controller[0].'::'.$controller[1]; diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/SessionValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/SessionValueResolver.php index 276d65461caa..a1e6b431595c 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/SessionValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/SessionValueResolver.php @@ -26,7 +26,7 @@ final class SessionValueResolver implements ArgumentValueResolverInterface /** * {@inheritdoc} */ - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { if (!$request->hasSession()) { return false; @@ -43,7 +43,7 @@ public function supports(Request $request, ArgumentMetadata $argument) /** * {@inheritdoc} */ - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield $request->getSession(); } diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php index a388bd823d44..ed61420e6779 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php @@ -25,7 +25,7 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface /** * {@inheritdoc} */ - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { return $argument->isVariadic() && $request->attributes->has($argument->getName()); } @@ -33,7 +33,7 @@ public function supports(Request $request, ArgumentMetadata $argument) /** * {@inheritdoc} */ - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { $values = $request->attributes->get($argument->getName()); diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php index 527a6a8a3646..9370174c253a 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php @@ -21,7 +21,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface /** * {@inheritdoc} */ - public function createArgumentMetadata($controller) + public function createArgumentMetadata($controller): array { $arguments = []; diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php index b5acb1261849..8359d99f5fad 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php @@ -59,7 +59,7 @@ public function warmUp($cacheDir) $this->writeCacheFile($this->file, 'content'); } - public function isOptional() + public function isOptional(): bool { return false; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php index 3c2cc3f70040..91446c45ab73 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php @@ -63,12 +63,12 @@ public function testTimingsInResolve() class ResolverStub implements ArgumentValueResolverInterface { - public function supports(Request $request, ArgumentMetadata $argument) + public function supports(Request $request, ArgumentMetadata $argument): bool { return true; } - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield 'first'; yield 'second'; diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 18269d28e733..f698571f2a6f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -62,11 +62,11 @@ public function testLegacy() class KernelForTest extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { } - public function getBundles() + public function getBundles(): array { return []; } diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php index 1d521368e1df..49567d40be6c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass; use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface; @@ -59,11 +60,11 @@ public function testValidContentRenderer() class RendererService implements FragmentRendererInterface { - public function render($uri, Request $request = null, array $options = []) + public function render($uri, Request $request = null, array $options = []): Response { } - public function getName() + public function getName(): string { return 'test'; } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php index b86a7552f85e..440c3faabc89 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php @@ -66,7 +66,7 @@ public function testConfigure() class MockCloner implements ClonerInterface { - public function cloneVar($var) + public function cloneVar($var): Data { return new Data([[$var.'-']]); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index 2048fdd01cc1..7c2cb9d192ca 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -167,7 +167,7 @@ public function countErrors() class TestKernel implements HttpKernelInterface { - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) + public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response { return new Response('foo'); } @@ -175,7 +175,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = class TestKernelThatThrowsException implements HttpKernelInterface { - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) + public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response { throw new \RuntimeException('bar'); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php index 4f5de182fd17..168267b45629 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php @@ -39,7 +39,7 @@ public function getData() return $this->data; } - public function getName() + public function getName(): string { return 'clone_var'; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php index f7baaa6325fb..16cc47ce9b63 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php @@ -12,13 +12,14 @@ namespace Symfony\Component\HttpKernel\Tests\Fixtures; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel; class KernelForOverrideName extends Kernel { protected $name = 'overridden'; - public function registerBundles() + public function registerBundles(): iterable { } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php index 868094a596d5..5ba41ce03827 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\Fixtures; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel; class KernelForTest extends Kernel @@ -21,7 +22,7 @@ public function getBundleMap() return $this->bundleMap; } - public function registerBundles() + public function registerBundles(): iterable { return []; } @@ -35,12 +36,12 @@ public function isBooted() return $this->booted; } - public function getCacheDir() + public function getCacheDir(): string { return $this->getProjectDir().'/Tests/Fixtures/cache.'.$this->environment; } - public function getLogDir() + public function getLogDir(): string { return $this->getProjectDir().'/Tests/Fixtures/logs'; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelWithoutBundles.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelWithoutBundles.php index 2391557362f0..074ccc3276b7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelWithoutBundles.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelWithoutBundles.php @@ -13,11 +13,12 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel; class KernelWithoutBundles extends Kernel { - public function registerBundles() + public function registerBundles(): iterable { return []; } @@ -26,7 +27,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) { } - public function getProjectDir() + public function getProjectDir(): string { return __DIR__; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php index 140cbfbf51f4..b56e725afbea 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php @@ -15,7 +15,7 @@ class TestClient extends HttpKernelBrowser { - protected function getScript($request) + protected function getScript($request): string { $script = parent::getScript($request); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 1bf66fdc97b2..3ba144958035 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -1555,7 +1555,7 @@ public function terminate(Request $request, Response $response) $this->terminateCalled = true; } - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) + public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response { } } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php index 61e6beded580..ea2d2b7a12c4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php @@ -143,7 +143,7 @@ public function __construct(\Closure $assertCallback) $this->assertCallback = $assertCallback; } - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) + public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response { $assertCallback = $this->assertCallback; $assertCallback($request, $type, $catch); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php index 304ff9d9e43e..5b204d82698b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php @@ -54,7 +54,7 @@ public function assert(\Closure $callback) } } - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false): Response { $this->catch = $catch; $this->backendRequest = [Request::getTrustedProxies(), Request::getTrustedHeaderSet(), $request]; @@ -72,7 +72,7 @@ public function getController(Request $request) return [$this, 'callController']; } - public function getArguments(Request $request, $controller) + public function getArguments(Request $request, $controller): array { return [$request]; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php index 010bee86895a..8ce3cfb8bb2b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php @@ -43,7 +43,7 @@ public function getBackendRequest() return $this->backendRequest; } - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false): Response { $this->backendRequest = $request; @@ -55,7 +55,7 @@ public function getController(Request $request) return [$this, 'callController']; } - public function getArguments(Request $request, $controller) + public function getArguments(Request $request, $controller): array { return [$request]; } diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 12827c33d9a6..35304bc982ef 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -21,6 +21,7 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; +use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; @@ -620,10 +621,8 @@ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() /** * Returns a mock for the BundleInterface. - * - * @return BundleInterface */ - protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null) + protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null): BundleInterface { $bundle = $this ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') @@ -669,10 +668,8 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu * * @param array $methods Additional methods to mock (besides the abstract ones) * @param array $bundles Bundles to register - * - * @return Kernel */ - protected function getKernel(array $methods = [], array $bundles = []) + protected function getKernel(array $methods = [], array $bundles = []): Kernel { $methods[] = 'registerBundles'; @@ -716,7 +713,7 @@ public function terminate() $this->terminateCalled = true; } - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) + public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response { } } @@ -735,7 +732,7 @@ public function __construct(\Closure $buildContainer = null, HttpKernelInterface $this->httpKernel = $httpKernel; } - public function registerBundles() + public function registerBundles(): iterable { return []; } @@ -744,7 +741,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) { } - public function getProjectDir() + public function getProjectDir(): string { return __DIR__.'/Fixtures'; } @@ -756,7 +753,7 @@ protected function build(ContainerBuilder $container) } } - protected function getHttpKernel() + protected function getHttpKernel(): HttpKernelInterface { return $this->httpKernel; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php index 79b79cc69cb9..c89146aff5c1 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php @@ -57,7 +57,7 @@ public static function assertLogsMatch(array $expected, array $given) * * @return string[] */ - public function getLogs() + public function getLogs(): array { return file($this->tmpFile, FILE_IGNORE_NEW_LINES); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Logger.php b/src/Symfony/Component/HttpKernel/Tests/Logger.php index 1f80e48ae9e7..d15e79a6c0f6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Logger.php +++ b/src/Symfony/Component/HttpKernel/Tests/Logger.php @@ -41,74 +41,47 @@ public function clear() ]; } - /** - * @return void - */ - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { $this->logs[$level][] = $message; } - /** - * @return void - */ - public function emergency($message, array $context = []) + public function emergency($message, array $context = []): void { $this->log('emergency', $message, $context); } - /** - * @return void - */ - public function alert($message, array $context = []) + public function alert($message, array $context = []): void { $this->log('alert', $message, $context); } - /** - * @return void - */ - public function critical($message, array $context = []) + public function critical($message, array $context = []): void { $this->log('critical', $message, $context); } - /** - * @return void - */ - public function error($message, array $context = []) + public function error($message, array $context = []): void { $this->log('error', $message, $context); } - /** - * @return void - */ - public function warning($message, array $context = []) + public function warning($message, array $context = []): void { $this->log('warning', $message, $context); } - /** - * @return void - */ - public function notice($message, array $context = []) + public function notice($message, array $context = []): void { $this->log('notice', $message, $context); } - /** - * @return void - */ - public function info($message, array $context = []) + public function info($message, array $context = []): void { $this->log('info', $message, $context); } - /** - * @return void - */ - public function debug($message, array $context = []) + public function debug($message, array $context = []): void { $this->log('debug', $message, $context); } diff --git a/src/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php index 27ba2d6f8949..b01807509d62 100644 --- a/src/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php @@ -30,7 +30,7 @@ public function getController(Request $request) return [$this, 'callController']; } - public function getArguments(Request $request, $controller) + public function getArguments(Request $request, $controller): array { return [$request]; } diff --git a/src/Symfony/Component/Intl/Intl.php b/src/Symfony/Component/Intl/Intl.php index 5d87df7f9b69..7c885e4e3883 100644 --- a/src/Symfony/Component/Intl/Intl.php +++ b/src/Symfony/Component/Intl/Intl.php @@ -109,7 +109,7 @@ final class Intl * * @return bool Returns true if the intl extension is installed, false otherwise */ - public static function isExtensionLoaded() + public static function isExtensionLoaded(): bool { return class_exists('\ResourceBundle'); } @@ -121,7 +121,7 @@ public static function isExtensionLoaded() * * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Currencies} instead. */ - public static function getCurrencyBundle() + public static function getCurrencyBundle(): CurrencyBundleInterface { @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Currencies::class), E_USER_DEPRECATED); @@ -143,7 +143,7 @@ public static function getCurrencyBundle() * * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Languages} or {@see Scripts} instead. */ - public static function getLanguageBundle() + public static function getLanguageBundle(): LanguageBundleInterface { @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" or "%s" instead.', __METHOD__, Languages::class, Scripts::class), E_USER_DEPRECATED); @@ -169,7 +169,7 @@ public static function getLanguageBundle() * * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Locales} instead. */ - public static function getLocaleBundle() + public static function getLocaleBundle(): LocaleBundleInterface { @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Locales::class), E_USER_DEPRECATED); @@ -190,7 +190,7 @@ public static function getLocaleBundle() * * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Countries} instead. */ - public static function getRegionBundle() + public static function getRegionBundle(): RegionBundleInterface { @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Countries::class), E_USER_DEPRECATED); @@ -210,7 +210,7 @@ public static function getRegionBundle() * * @return string|null The ICU version or NULL if it could not be determined */ - public static function getIcuVersion() + public static function getIcuVersion(): ?string { if (false === self::$icuVersion) { if (!self::isExtensionLoaded()) { @@ -240,7 +240,7 @@ public static function getIcuVersion() * * @return string The version of the installed ICU data */ - public static function getIcuDataVersion() + public static function getIcuDataVersion(): string { if (false === self::$icuDataVersion) { self::$icuDataVersion = trim(file_get_contents(self::getDataDirectory().'/version.txt')); @@ -254,7 +254,7 @@ public static function getIcuDataVersion() * * @return string The ICU version of the stub classes */ - public static function getIcuStubVersion() + public static function getIcuStubVersion(): string { return '64.2'; } @@ -264,7 +264,7 @@ public static function getIcuStubVersion() * * @return string The absolute path to the data directory */ - public static function getDataDirectory() + public static function getDataDirectory(): string { return __DIR__.'/Resources/data'; } diff --git a/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php index 28eb37d7cc05..b2931f65e111 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php @@ -54,9 +54,7 @@ public function asortProvider() } /** - * @param string $locale - * - * @return \Collator + * @return Collator|\Collator */ - abstract protected function getCollator($locale); + abstract protected function getCollator(string $locale); } diff --git a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php index 21349088fa86..0964e31e34c1 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php @@ -95,7 +95,7 @@ public function testStaticCreate() $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator); } - protected function getCollator($locale) + protected function getCollator(?string $locale): Collator { return new class($locale) extends Collator { }; diff --git a/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php index 3f06b2c25f10..bb376e504e13 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php @@ -29,7 +29,7 @@ protected function setUp(): void parent::setUp(); } - protected function getCollator($locale) + protected function getCollator(?string $locale): \Collator { return new \Collator($locale); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php index eed2db8c7572..6e9071fbaa78 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php @@ -756,10 +756,7 @@ protected function getRootLocales() return self::$rootLocales; } - /** - * @return BundleEntryReader - */ - protected function createEntryReader() + protected function createEntryReader(): BundleEntryReader { $entryReader = new BundleEntryReader($this->createBundleReader()); $entryReader->setLocaleAliases($this->getLocaleAliases()); @@ -767,8 +764,5 @@ protected function createEntryReader() return $entryReader; } - /** - * @return BundleReaderInterface - */ - abstract protected function createBundleReader(); + abstract protected function createBundleReader(): BundleReaderInterface; } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php index ff12edb44126..b770f8b0cfd6 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php @@ -28,10 +28,7 @@ protected function getDataDirectory() return Intl::getDataDirectory(); } - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() + protected function createBundleReader(): BundleReaderInterface { return new JsonBundleReader(); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php index 74049ab53e13..0626872a3bd8 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php @@ -28,10 +28,7 @@ protected function getDataDirectory() return Intl::getDataDirectory(); } - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() + protected function createBundleReader(): BundleReaderInterface { return new JsonBundleReader(); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php index ba00439bdcea..2a1b53bf59f8 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php @@ -28,10 +28,7 @@ protected function getDataDirectory() return Intl::getDataDirectory(); } - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() + protected function createBundleReader(): BundleReaderInterface { return new JsonBundleReader(); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php index 9bb3bba48917..f5f5266e388d 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php @@ -28,10 +28,7 @@ protected function getDataDirectory() return Intl::getDataDirectory(); } - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() + protected function createBundleReader(): BundleReaderInterface { return new JsonBundleReader(); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php index 9648cbaca306..c9888047771b 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php @@ -28,10 +28,7 @@ protected function getDataDirectory() return Intl::getDataDirectory(); } - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() + protected function createBundleReader(): BundleReaderInterface { return new JsonBundleReader(); } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index b8f4b5eebe68..cf7a563b2590 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -965,10 +965,7 @@ protected function assertIsIntlSuccess($formatter, $errorMessage, $errorCode) */ abstract protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null); - /** - * @return string - */ - abstract protected function getIntlErrorMessage(); + abstract protected function getIntlErrorMessage(): string; /** * @return int @@ -977,8 +974,6 @@ abstract protected function getIntlErrorCode(); /** * @param int $errorCode - * - * @return bool */ - abstract protected function isIntlFailure($errorCode); + abstract protected function isIntlFailure($errorCode): bool; } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 5b5adca6a581..2c043e235fdc 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -183,7 +183,7 @@ protected function getDateFormatter($locale, $datetype, $timetype, $timezone = n }; } - protected function getIntlErrorMessage() + protected function getIntlErrorMessage(): string { return IntlGlobals::getErrorMessage(); } @@ -193,7 +193,7 @@ protected function getIntlErrorCode() return IntlGlobals::getErrorCode(); } - protected function isIntlFailure($errorCode) + protected function isIntlFailure($errorCode): bool { return IntlGlobals::isFailure($errorCode); } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php index 863d3409c878..a993ace5cb10 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php @@ -68,7 +68,7 @@ protected function getDateFormatter($locale, $datetype, $timetype, $timezone = n return $formatter; } - protected function getIntlErrorMessage() + protected function getIntlErrorMessage(): string { return intl_get_error_message(); } @@ -78,7 +78,7 @@ protected function getIntlErrorCode() return intl_get_error_code(); } - protected function isIntlFailure($errorCode) + protected function isIntlFailure($errorCode): bool { return intl_is_failure($errorCode); } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index f64131a61b8c..6a6e4ef628d8 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -836,18 +836,11 @@ public function testParseWithNotNullPositionValue() } /** - * @param string $locale - * @param null $style - * @param null $pattern - * - * @return \NumberFormatter + * @return NumberFormatter|\NumberFormatter */ - abstract protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null); + abstract protected function getNumberFormatter(string $locale = 'en', string $style = null, string $pattern = null); - /** - * @return string - */ - abstract protected function getIntlErrorMessage(); + abstract protected function getIntlErrorMessage(): string; /** * @return int @@ -856,8 +849,6 @@ abstract protected function getIntlErrorCode(); /** * @param int $errorCode - * - * @return bool */ - abstract protected function isIntlFailure($errorCode); + abstract protected function isIntlFailure($errorCode): bool; } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php index 1f002aa77bc4..8faca56818b8 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php @@ -167,13 +167,13 @@ public function testSetTextAttribute() $formatter->setTextAttribute(null, null); } - protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null) + protected function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): NumberFormatter { return new class($locale, $style, $pattern) extends NumberFormatter { }; } - protected function getIntlErrorMessage() + protected function getIntlErrorMessage(): string { return IntlGlobals::getErrorMessage(); } @@ -183,7 +183,7 @@ protected function getIntlErrorCode() return IntlGlobals::getErrorCode(); } - protected function isIntlFailure($errorCode) + protected function isIntlFailure($errorCode): bool { return IntlGlobals::isFailure($errorCode); } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php index 106e666967a1..1209180e8963 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php @@ -39,12 +39,12 @@ public function testGetTextAttribute() parent::testGetTextAttribute(); } - protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null) + protected function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): \NumberFormatter { return new \NumberFormatter($locale, $style, $pattern); } - protected function getIntlErrorMessage() + protected function getIntlErrorMessage(): string { return intl_get_error_message(); } @@ -54,7 +54,7 @@ protected function getIntlErrorCode() return intl_get_error_code(); } - protected function isIntlFailure($errorCode) + protected function isIntlFailure($errorCode): bool { return intl_is_failure($errorCode); } diff --git a/src/Symfony/Component/Ldap/Ldap.php b/src/Symfony/Component/Ldap/Ldap.php index 615dbcfda383..dc7d3ae304ae 100644 --- a/src/Symfony/Component/Ldap/Ldap.php +++ b/src/Symfony/Component/Ldap/Ldap.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Ldap; use Symfony\Component\Ldap\Adapter\AdapterInterface; +use Symfony\Component\Ldap\Adapter\EntryManagerInterface; +use Symfony\Component\Ldap\Adapter\QueryInterface; use Symfony\Component\Ldap\Exception\DriverNotFoundException; /** @@ -41,7 +43,7 @@ public function bind($dn = null, $password = null) /** * {@inheritdoc} */ - public function query($dn, $query, array $options = []) + public function query($dn, $query, array $options = []): QueryInterface { return $this->adapter->createQuery($dn, $query, $options); } @@ -49,7 +51,7 @@ public function query($dn, $query, array $options = []) /** * {@inheritdoc} */ - public function getEntryManager() + public function getEntryManager(): EntryManagerInterface { return $this->adapter->getEntryManager(); } @@ -57,7 +59,7 @@ public function getEntryManager() /** * {@inheritdoc} */ - public function escape($subject, $ignore = '', $flags = 0) + public function escape($subject, $ignore = '', $flags = 0): string { return $this->adapter->escape($subject, $ignore, $flags); } diff --git a/src/Symfony/Component/Ldap/Tests/LdapTest.php b/src/Symfony/Component/Ldap/Tests/LdapTest.php index 09975378fc46..68e9da245113 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Ldap\Adapter\AdapterInterface; use Symfony\Component\Ldap\Adapter\ConnectionInterface; +use Symfony\Component\Ldap\Adapter\QueryInterface; use Symfony\Component\Ldap\Exception\DriverNotFoundException; use Symfony\Component\Ldap\Ldap; @@ -54,6 +55,7 @@ public function testLdapEscape() ->expects($this->once()) ->method('escape') ->with('foo', 'bar', 'baz') + ->willReturn(''); ; $this->ldap->escape('foo', 'bar', 'baz'); } @@ -64,6 +66,7 @@ public function testLdapQuery() ->expects($this->once()) ->method('createQuery') ->with('foo', 'bar', ['baz']) + ->willReturn($this->createMock(QueryInterface::class)) ; $this->ldap->query('foo', 'bar', ['baz']); } diff --git a/src/Symfony/Component/Lock/Key.php b/src/Symfony/Component/Lock/Key.php index e20fbd9c8058..798e571d008d 100644 --- a/src/Symfony/Component/Lock/Key.php +++ b/src/Symfony/Component/Lock/Key.php @@ -74,15 +74,12 @@ public function reduceLifetime($ttl) * * @return float|null Remaining lifetime in seconds. Null when the key won't expire. */ - public function getRemainingLifetime() + public function getRemainingLifetime(): ?float { return null === $this->expiringTime ? null : $this->expiringTime - microtime(true); } - /** - * @return bool - */ - public function isExpired() + public function isExpired(): bool { return null !== $this->expiringTime && $this->expiringTime <= microtime(true); } diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php index 8a61bf6f7b8e..41af54727a6c 100644 --- a/src/Symfony/Component/Lock/Lock.php +++ b/src/Symfony/Component/Lock/Lock.php @@ -65,7 +65,7 @@ public function __destruct() /** * {@inheritdoc} */ - public function acquire($blocking = false) + public function acquire($blocking = false): bool { try { if ($blocking) { @@ -149,7 +149,7 @@ public function refresh($ttl = null) /** * {@inheritdoc} */ - public function isAcquired() + public function isAcquired(): bool { return $this->dirty = $this->store->exists($this->key); } @@ -181,7 +181,7 @@ public function release() /** * {@inheritdoc} */ - public function isExpired() + public function isExpired(): bool { return $this->key->isExpired(); } @@ -189,7 +189,7 @@ public function isExpired() /** * {@inheritdoc} */ - public function getRemainingLifetime() + public function getRemainingLifetime(): ?float { return $this->key->getRemainingLifetime(); } diff --git a/src/Symfony/Component/Lock/Tests/LockTest.php b/src/Symfony/Component/Lock/Tests/LockTest.php index aae7a7671d48..d31a6d58aaf6 100644 --- a/src/Symfony/Component/Lock/Tests/LockTest.php +++ b/src/Symfony/Component/Lock/Tests/LockTest.php @@ -34,6 +34,9 @@ public function testAcquireNoBlocking() $store ->expects($this->once()) ->method('save'); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $this->assertTrue($lock->acquire(false)); } @@ -47,6 +50,9 @@ public function testAcquireNoBlockingStoreInterface() $store ->expects($this->once()) ->method('save'); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $this->assertTrue($lock->acquire(false)); } @@ -63,6 +69,9 @@ public function testPassingOldStoreInterface() $store ->expects($this->once()) ->method('save'); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $this->assertTrue($lock->acquire(false)); } @@ -77,6 +86,9 @@ public function testAcquireReturnsFalse() ->expects($this->once()) ->method('save') ->willThrowException(new LockConflictedException()); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $this->assertFalse($lock->acquire(false)); } @@ -91,6 +103,9 @@ public function testAcquireReturnsFalseStoreInterface() ->expects($this->once()) ->method('save') ->willThrowException(new LockConflictedException()); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $this->assertFalse($lock->acquire(false)); } @@ -107,6 +122,9 @@ public function testAcquireBlocking() $store ->expects($this->once()) ->method('waitAndSave'); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $this->assertTrue($lock->acquire(true)); } @@ -124,6 +142,9 @@ public function testAcquireSetsTtl() ->expects($this->once()) ->method('putOffExpiration') ->with($key, 10); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $lock->acquire(); } @@ -138,6 +159,9 @@ public function testRefresh() ->expects($this->once()) ->method('putOffExpiration') ->with($key, 10); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $lock->refresh(); } @@ -152,6 +176,9 @@ public function testRefreshCustom() ->expects($this->once()) ->method('putOffExpiration') ->with($key, 20); + $store + ->method('exists') + ->willReturnOnConsecutiveCalls(true, false); $lock->refresh(20); } @@ -163,10 +190,9 @@ public function testIsAquired() $lock = new Lock($key, $store, 10); $store - ->expects($this->any()) ->method('exists') ->with($key) - ->will($this->onConsecutiveCalls(true, false)); + ->willReturnOnConsecutiveCalls(true, false); $this->assertTrue($lock->isAcquired()); } @@ -219,7 +245,7 @@ public function testReleaseOnDestruction() $store ->method('exists') - ->willReturnOnConsecutiveCalls([true, false]) + ->willReturnOnConsecutiveCalls(true, false) ; $store ->expects($this->once()) @@ -238,7 +264,7 @@ public function testNoAutoReleaseWhenNotConfigured() $store ->method('exists') - ->willReturnOnConsecutiveCalls([true, false]) + ->willReturnOnConsecutiveCalls(true, false) ; $store ->expects($this->never()) diff --git a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php index 4b9c81bd8e8c..e05b7d4c3ffc 100644 --- a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Lock\Tests\Store; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\RedisStore; /** @@ -38,7 +39,7 @@ abstract protected function getRedisConnection(); /** * {@inheritdoc} */ - public function getStore() + public function getStore(): PersistingStoreInterface { return new RedisStore($this->getRedisConnection()); } diff --git a/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php index 8159cd7f760e..2868e6032ec7 100644 --- a/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php @@ -21,10 +21,7 @@ */ abstract class AbstractStoreTest extends TestCase { - /** - * @return PersistingStoreInterface - */ - abstract protected function getStore(); + abstract protected function getStore(): PersistingStoreInterface; public function testSave() { diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php index 35e2110396be..c8da617fae61 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -39,7 +39,7 @@ protected function getClockDelay() /** * {@inheritdoc} */ - public function getStore() + public function getStore(): PersistingStoreInterface { $redis = new \Predis\Client('tcp://'.getenv('REDIS_HOST').':6379'); try { diff --git a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php index 769082ddf933..1b1b49835871 100644 --- a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Lock\Tests\Store; use Symfony\Component\Lock\Key; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\FlockStore; /** @@ -24,7 +25,7 @@ class FlockStoreTest extends AbstractStoreTest /** * {@inheritdoc} */ - protected function getStore() + protected function getStore(): PersistingStoreInterface { return new FlockStore(); } diff --git a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php index c13f6723daa6..64fac4923770 100644 --- a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Lock\Tests\Store; use Symfony\Component\Lock\Key; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\MemcachedStore; /** @@ -46,7 +47,7 @@ protected function getClockDelay() /** * {@inheritdoc} */ - public function getStore() + public function getStore(): PersistingStoreInterface { $memcached = new \Memcached(); $memcached->addServer(getenv('MEMCACHED_HOST'), 11211); diff --git a/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php index 2a8ec082a113..264c99829c98 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PdoDbalStoreTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Lock\Tests\Store; use Doctrine\DBAL\DriverManager; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\PdoStore; /** @@ -49,7 +50,7 @@ protected function getClockDelay() /** * {@inheritdoc} */ - public function getStore() + public function getStore(): PersistingStoreInterface { return new PdoStore(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); } diff --git a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php index 27a458c99b15..eb24cb1de4a8 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Lock\Tests\Store; use Symfony\Component\Lock\Key; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\PdoStore; /** @@ -49,7 +50,7 @@ protected function getClockDelay() /** * {@inheritdoc} */ - public function getStore() + public function getStore(): PersistingStoreInterface { return new PdoStore('sqlite:'.self::$dbFile); } diff --git a/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php index febd48f279fc..12d7d7a1494f 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Lock\Tests\Store; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\RedisStore; use Symfony\Component\Lock\Store\RetryTillSaveStore; @@ -21,7 +22,7 @@ class RetryTillSaveStoreTest extends AbstractStoreTest { use BlockingStoreTestTrait; - public function getStore() + public function getStore(): PersistingStoreInterface { $redis = new \Predis\Client('tcp://'.getenv('REDIS_HOST').':6379'); try { diff --git a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php index 6c265b98bdb4..8ea1e717c6ee 100644 --- a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Lock\Tests\Store; use Symfony\Component\Lock\Key; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\SemaphoreStore; /** @@ -26,7 +27,7 @@ class SemaphoreStoreTest extends AbstractStoreTest /** * {@inheritdoc} */ - protected function getStore() + protected function getStore(): PersistingStoreInterface { return new SemaphoreStore(); } diff --git a/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php index 0ba6d73b9f37..981b62c6a0d7 100644 --- a/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/ZookeeperStoreTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Lock\Tests\Store; use Symfony\Component\Lock\Key; +use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\StoreFactory; use Symfony\Component\Lock\Store\ZookeeperStore; @@ -22,7 +23,10 @@ */ class ZookeeperStoreTest extends AbstractStoreTest { - public function getStore(): ZookeeperStore + /** + * @return ZookeeperStore + */ + public function getStore(): PersistingStoreInterface { $zookeeper_server = getenv('ZOOKEEPER_HOST').':2181'; diff --git a/src/Symfony/Component/Mime/Header/DateHeader.php b/src/Symfony/Component/Mime/Header/DateHeader.php index fdc146447430..a7385d4ce21a 100644 --- a/src/Symfony/Component/Mime/Header/DateHeader.php +++ b/src/Symfony/Component/Mime/Header/DateHeader.php @@ -35,10 +35,7 @@ public function setBody($body) $this->setDateTime($body); } - /** - * @return \DateTimeImmutable - */ - public function getBody() + public function getBody(): \DateTimeImmutable { return $this->getDateTime(); } diff --git a/src/Symfony/Component/Mime/Header/IdentificationHeader.php b/src/Symfony/Component/Mime/Header/IdentificationHeader.php index 91facf72d5af..8a94574e5c64 100644 --- a/src/Symfony/Component/Mime/Header/IdentificationHeader.php +++ b/src/Symfony/Component/Mime/Header/IdentificationHeader.php @@ -44,10 +44,7 @@ public function setBody($body) $this->setId($body); } - /** - * @return array - */ - public function getBody() + public function getBody(): array { return $this->getIds(); } diff --git a/src/Symfony/Component/Mime/Header/MailboxHeader.php b/src/Symfony/Component/Mime/Header/MailboxHeader.php index 25dea2b16977..b58c8252fd7c 100644 --- a/src/Symfony/Component/Mime/Header/MailboxHeader.php +++ b/src/Symfony/Component/Mime/Header/MailboxHeader.php @@ -42,10 +42,8 @@ public function setBody($body) /** * @throws RfcComplianceException - * - * @return Address */ - public function getBody() + public function getBody(): Address { return $this->getAddress(); } diff --git a/src/Symfony/Component/Mime/Header/MailboxListHeader.php b/src/Symfony/Component/Mime/Header/MailboxListHeader.php index e58d9d4f0b4a..1d00fdb12c3d 100644 --- a/src/Symfony/Component/Mime/Header/MailboxListHeader.php +++ b/src/Symfony/Component/Mime/Header/MailboxListHeader.php @@ -48,7 +48,7 @@ public function setBody($body) * * @return Address[] */ - public function getBody() + public function getBody(): array { return $this->getAddresses(); } diff --git a/src/Symfony/Component/Mime/Header/PathHeader.php b/src/Symfony/Component/Mime/Header/PathHeader.php index cc450d6dd505..5101ad0f9f41 100644 --- a/src/Symfony/Component/Mime/Header/PathHeader.php +++ b/src/Symfony/Component/Mime/Header/PathHeader.php @@ -40,10 +40,7 @@ public function setBody($body) $this->setAddress($body); } - /** - * @return Address - */ - public function getBody() + public function getBody(): Address { return $this->getAddress(); } diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index 69b0b3bb50e2..54a622138287 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -86,8 +86,6 @@ protected function unblock() /** * Writes input to stdin. * - * @return array|null - * * @throws InvalidArgumentException When an input iterator yields a non supported value */ protected function write(): ?array diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index c268a8dd571e..d0c2e084c5b2 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -955,7 +955,7 @@ public function addErrorOutput(string $line) } /** - * Gets the last output time in seconds + * Gets the last output time in seconds. * * @return float|null The last output time in seconds or null if it isn't started */ diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestSingularAndPluralProps.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestSingularAndPluralProps.php index d8a8c7648314..128ba33cb605 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestSingularAndPluralProps.php +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestSingularAndPluralProps.php @@ -23,10 +23,7 @@ class TestSingularAndPluralProps /** @var array */ private $emails = []; - /** - * @return string|null - */ - public function getEmail() + public function getEmail(): ?string { return $this->email; } @@ -39,10 +36,7 @@ public function setEmail($email) $this->email = $email; } - /** - * @return array - */ - public function getEmails() + public function getEmails(): array { return $this->emails; } diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TypeHinted.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TypeHinted.php index ce0f3d89aaa3..c9a83c45e44f 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TypeHinted.php +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TypeHinted.php @@ -33,17 +33,11 @@ public function getDate() return $this->date; } - /** - * @return \Countable - */ - public function getCountable() + public function getCountable(): \Countable { return $this->countable; } - /** - * @param \Countable $countable - */ public function setCountable(\Countable $countable) { $this->countable = $countable; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/CustomRouteCompiler.php b/src/Symfony/Component/Routing/Tests/Fixtures/CustomRouteCompiler.php index 22b942d7bc87..57c07c3140f7 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/CustomRouteCompiler.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/CustomRouteCompiler.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Routing\Tests\Fixtures; +use Symfony\Component\Routing\CompiledRoute; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCompiler; @@ -19,7 +20,7 @@ class CustomRouteCompiler extends RouteCompiler /** * {@inheritdoc} */ - public static function compile(Route $route) + public static function compile(Route $route): CompiledRoute { return new CustomCompiledRoute('', '', [], []); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php b/src/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php index b7a02b60b0ae..8757e0c3532c 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php @@ -19,7 +19,7 @@ */ class CustomXmlFileLoader extends XmlFileLoader { - protected function loadFile($file) + protected function loadFile($file): \DOMDocument { return XmlUtils::loadFile($file, function () { return true; }); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php b/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php index 79ae1cce54ca..c2a5ba3c2a87 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php @@ -19,7 +19,7 @@ */ class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect($path, $route, $scheme = null): array { return [ '_controller' => 'Some controller reference...', diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/TestObjectRouteLoader.php b/src/Symfony/Component/Routing/Tests/Fixtures/TestObjectRouteLoader.php index d272196dd6f1..fd9a6cda958e 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/TestObjectRouteLoader.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/TestObjectRouteLoader.php @@ -17,6 +17,9 @@ class TestObjectRouteLoader extends ObjectRouteLoader { public $loaderMap = []; + /** + * @return object + */ protected function getServiceObject($id) { return $this->loaderMap[$id] ?? null; diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php index bf94ef34ae3a..6c93facefe69 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php @@ -98,11 +98,14 @@ class TestObjectLoader extends ObjectLoader { public $loaderMap = []; - public function supports($resource, $type = null) + public function supports($resource, $type = null): bool { return 'service'; } + /** + * @return object + */ protected function getObject(string $id) { return $this->loaderMap[$id] ?? null; diff --git a/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php index 7fb7dfef9e97..30773fa59499 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php @@ -33,7 +33,7 @@ protected function getUrlMatcher(RouteCollection $routes, RequestContext $contex class TestCompiledRedirectableUrlMatcher extends CompiledUrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect($path, $route, $scheme = null): array { return []; } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php index aed006f710c0..3b35ac4de5ff 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php @@ -39,7 +39,7 @@ protected function getUrlMatcher(RouteCollection $routes, RequestContext $contex class TestDumpedRedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect($path, $route, $scheme = null): array { return []; } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php index 744229b3ef9a..4581fa89f197 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php @@ -487,7 +487,7 @@ public function testGenerateDumperMatcherWithObject() class TestCompiledUrlMatcher extends CompiledUrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect($path, $route, $scheme = null): array { return []; } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 4c15451209b0..6f7a610324b6 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -505,7 +505,7 @@ public function testGenerateDumperMatcherWithObject() abstract class RedirectableUrlMatcherStub extends UrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect($path, $route, $scheme = null): array { } } diff --git a/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php index 1115f9dddbf9..7690b3e2264b 100644 --- a/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php @@ -83,9 +83,6 @@ public function addVoterVote(VoterInterface $voter, array $attributes, int $vote ]; } - /** - * @return string - */ public function getStrategy(): string { // The $strategy property is misleading because it stores the name of its @@ -102,9 +99,6 @@ public function getVoters(): iterable return $this->voters; } - /** - * @return array - */ public function getDecisionLog(): array { return $this->decisionLog; diff --git a/src/Symfony/Component/Security/Core/Encoder/MigratingPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/MigratingPasswordEncoder.php index 77e6726808f9..2c8a6f72ce9a 100644 --- a/src/Symfony/Component/Security/Core/Encoder/MigratingPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/MigratingPasswordEncoder.php @@ -34,7 +34,7 @@ public function __construct(PasswordEncoderInterface $bestEncoder, PasswordEncod /** * {@inheritdoc} */ - public function encodePassword($raw, $salt) + public function encodePassword($raw, $salt): string { return $this->bestEncoder->encodePassword($raw, $salt); } @@ -42,7 +42,7 @@ public function encodePassword($raw, $salt) /** * {@inheritdoc} */ - public function isPasswordValid($encoded, $raw, $salt) + public function isPasswordValid($encoded, $raw, $salt): bool { if ($this->bestEncoder->isPasswordValid($encoded, $raw, $salt)) { return true; diff --git a/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php index 351943764d3b..bc900427afac 100644 --- a/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php @@ -78,7 +78,7 @@ public function encodePassword($raw, $salt): string /** * {@inheritdoc} */ - public function isPasswordValid($encoded, $raw, $salt) + public function isPasswordValid($encoded, $raw, $salt): bool { if (72 < \strlen($raw) && 0 === strpos($encoded, '$2')) { // BCrypt encodes only the first 72 chars diff --git a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php index 98e9110dca4d..616e502b5a61 100644 --- a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php @@ -54,7 +54,7 @@ public static function isSupported(): bool /** * {@inheritdoc} */ - public function encodePassword($raw, $salt) + public function encodePassword($raw, $salt): string { if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) { throw new BadCredentialsException('Invalid password.'); @@ -74,7 +74,7 @@ public function encodePassword($raw, $salt) /** * {@inheritdoc} */ - public function isPasswordValid($encoded, $raw, $salt) + public function isPasswordValid($encoded, $raw, $salt): bool { if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) { return false; diff --git a/src/Symfony/Component/Security/Core/Security.php b/src/Symfony/Component/Security/Core/Security.php index 334fbd8d283a..094cc424d200 100644 --- a/src/Symfony/Component/Security/Core/Security.php +++ b/src/Symfony/Component/Security/Core/Security.php @@ -34,10 +34,7 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - /** - * @return UserInterface|null - */ - public function getUser() + public function getUser(): ?UserInterface { if (!$token = $this->getToken()) { return null; diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php index 940dcaffaa95..3556f4afeafc 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -164,11 +164,11 @@ public function unserialize($serialized) { } - public function __toString() + public function __toString(): string { } - public function getRoles() + public function getRoles(): array { } @@ -184,11 +184,11 @@ public function setUser($user) { } - public function getUsername() + public function getUsername(): string { } - public function isAuthenticated() + public function isAuthenticated(): bool { } @@ -200,7 +200,7 @@ public function eraseCredentials() { } - public function getAttributes() + public function getAttributes(): array { } @@ -208,7 +208,7 @@ public function setAttributes(array $attributes) { } - public function hasAttribute($name) + public function hasAttribute($name): bool { } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php index 25d22975eb3d..63d4fb8b8377 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php @@ -59,12 +59,12 @@ public function testVote(array $attributes, $expectedVote, $object, $message) class VoterTest_Voter extends Voter { - protected function voteOnAttribute($attribute, $object, TokenInterface $token) + protected function voteOnAttribute($attribute, $object, TokenInterface $token): bool { return 'EDIT' === $attribute; } - protected function supports($attribute, $object) + protected function supports($attribute, $object): bool { return $object instanceof \stdClass && \in_array($attribute, ['EDIT', 'CREATE']); } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php index c808d0552267..22d1881d6588 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php @@ -16,11 +16,11 @@ class PasswordEncoder extends BasePasswordEncoder { - public function encodePassword($raw, $salt) + public function encodePassword($raw, $salt): string { } - public function isPasswordValid($encoded, $raw, $salt) + public function isPasswordValid($encoded, $raw, $salt): bool { } } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php index 0b2c36c72de4..1243d88b77a4 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php @@ -139,15 +139,15 @@ public function getRoles() { } - public function getPassword() + public function getPassword(): ?string { } - public function getSalt() + public function getSalt(): ?string { } - public function getUsername() + public function getUsername(): string { } @@ -164,7 +164,7 @@ class EncAwareUser extends SomeUser implements EncoderAwareInterface { public $encoderName = 'encoder_name'; - public function getEncoderName() + public function getEncoderName(): string { return $this->encoderName; } diff --git a/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php index ce697e4ae933..bec73072341a 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php @@ -40,10 +40,7 @@ public function testRefresh() $this->assertFalse($refreshedUser->isCredentialsNonExpired()); } - /** - * @return InMemoryUserProvider - */ - protected function createProvider() + protected function createProvider(): InMemoryUserProvider { return new InMemoryUserProvider([ 'fabien' => [ diff --git a/src/Symfony/Component/Security/Core/User/User.php b/src/Symfony/Component/Security/Core/User/User.php index 0233faf13102..cd763821c839 100644 --- a/src/Symfony/Component/Security/Core/User/User.php +++ b/src/Symfony/Component/Security/Core/User/User.php @@ -61,7 +61,7 @@ public function getRoles() /** * {@inheritdoc} */ - public function getPassword() + public function getPassword(): ?string { return $this->password; } @@ -69,7 +69,7 @@ public function getPassword() /** * {@inheritdoc} */ - public function getSalt() + public function getSalt(): ?string { return null; } @@ -77,7 +77,7 @@ public function getSalt() /** * {@inheritdoc} */ - public function getUsername() + public function getUsername(): string { return $this->username; } @@ -85,7 +85,7 @@ public function getUsername() /** * {@inheritdoc} */ - public function isAccountNonExpired() + public function isAccountNonExpired(): bool { return $this->accountNonExpired; } @@ -93,7 +93,7 @@ public function isAccountNonExpired() /** * {@inheritdoc} */ - public function isAccountNonLocked() + public function isAccountNonLocked(): bool { return $this->accountNonLocked; } @@ -101,7 +101,7 @@ public function isAccountNonLocked() /** * {@inheritdoc} */ - public function isCredentialsNonExpired() + public function isCredentialsNonExpired(): bool { return $this->credentialsNonExpired; } @@ -109,7 +109,7 @@ public function isCredentialsNonExpired() /** * {@inheritdoc} */ - public function isEnabled() + public function isEnabled(): bool { return $this->enabled; } @@ -129,7 +129,7 @@ public function getExtraFields(): array /** * {@inheritdoc} */ - public function isEqualTo(UserInterface $user) + public function isEqualTo(UserInterface $user): bool { if (!$user instanceof self) { return false; diff --git a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php index cb889617b15c..56ee7f39197b 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\User\UserInterface; @@ -98,21 +99,19 @@ class TestFormLoginAuthenticator extends AbstractFormLoginAuthenticator private $loginUrl; private $defaultSuccessRedirectUrl; - public function supports(Request $request) + public function supports(Request $request): bool { return true; } - public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) + public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response { } /** * @param mixed $defaultSuccessRedirectUrl - * - * @return TestFormLoginAuthenticator */ - public function setDefaultSuccessRedirectUrl($defaultSuccessRedirectUrl) + public function setDefaultSuccessRedirectUrl($defaultSuccessRedirectUrl): TestFormLoginAuthenticator { $this->defaultSuccessRedirectUrl = $defaultSuccessRedirectUrl; @@ -121,10 +120,8 @@ public function setDefaultSuccessRedirectUrl($defaultSuccessRedirectUrl) /** * @param mixed $loginUrl - * - * @return TestFormLoginAuthenticator */ - public function setLoginUrl($loginUrl) + public function setLoginUrl($loginUrl): TestFormLoginAuthenticator { $this->loginUrl = $loginUrl; @@ -134,7 +131,7 @@ public function setLoginUrl($loginUrl) /** * {@inheritdoc} */ - protected function getLoginUrl() + protected function getLoginUrl(): string { return $this->loginUrl; } @@ -158,7 +155,7 @@ public function getCredentials(Request $request) /** * {@inheritdoc} */ - public function getUser($credentials, UserProviderInterface $userProvider) + public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface { return $userProvider->loadUserByUsername($credentials); } @@ -166,7 +163,7 @@ public function getUser($credentials, UserProviderInterface $userProvider) /** * {@inheritdoc} */ - public function checkCredentials($credentials, UserInterface $user) + public function checkCredentials($credentials, UserInterface $user): bool { return true; } diff --git a/src/Symfony/Component/Security/Http/Controller/UserValueResolver.php b/src/Symfony/Component/Security/Http/Controller/UserValueResolver.php index 221d8d8eada5..7774e7b4a255 100644 --- a/src/Symfony/Component/Security/Http/Controller/UserValueResolver.php +++ b/src/Symfony/Component/Security/Http/Controller/UserValueResolver.php @@ -32,7 +32,7 @@ public function __construct(TokenStorageInterface $tokenStorage) $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()) { @@ -50,7 +50,7 @@ public function supports(Request $request, ArgumentMetadata $argument) return $user instanceof UserInterface; } - public function resolve(Request $request, ArgumentMetadata $argument) + public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield $this->tokenStorage->getToken()->getUser(); } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index 07626cdad8e0..6801f951b9dd 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -380,17 +380,17 @@ private function handleEventWithPreviousSession(TokenStorageInterface $tokenStor class NotSupportingUserProvider implements UserProviderInterface { - public function loadUserByUsername($username) + public function loadUserByUsername($username): UserInterface { throw new UsernameNotFoundException(); } - public function refreshUser(UserInterface $user) + public function refreshUser(UserInterface $user): UserInterface { throw new UnsupportedUserException(); } - public function supportsClass($class) + public function supportsClass($class): bool { return false; } @@ -405,11 +405,11 @@ public function __construct(User $refreshedUser = null) $this->refreshedUser = $refreshedUser; } - public function loadUserByUsername($username) + public function loadUserByUsername($username): UserInterface { } - public function refreshUser(UserInterface $user) + public function refreshUser(UserInterface $user): UserInterface { if (!$user instanceof User) { throw new UnsupportedUserException(); @@ -422,7 +422,7 @@ public function refreshUser(UserInterface $user) return $this->refreshedUser; } - public function supportsClass($class) + public function supportsClass($class): bool { return 'Symfony\Component\Security\Core\User\User' === $class; } diff --git a/src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php b/src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php index a94bf70b58fd..3565106f951a 100644 --- a/src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php +++ b/src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php @@ -40,7 +40,7 @@ public function __construct(ClassMetadataFactoryInterface $metadataFactory, Name /** * {@inheritdoc} */ - public function normalize($propertyName, string $class = null, string $format = null, array $context = []) + public function normalize($propertyName, string $class = null, string $format = null, array $context = []): string { if (null === $class) { return $this->normalizeFallback($propertyName, $class, $format, $context); @@ -56,7 +56,7 @@ public function normalize($propertyName, string $class = null, string $format = /** * {@inheritdoc} */ - public function denormalize($propertyName, string $class = null, string $format = null, array $context = []) + public function denormalize($propertyName, string $class = null, string $format = null, array $context = []): string { if (null === $class) { return $this->denormalizeFallback($propertyName, $class, $format, $context); diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 5f165b56ac77..0711f180004d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -544,11 +544,9 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara /** * @param string $attribute Attribute name * - * @return array - * * @internal */ - protected function createChildContext(array $parentContext, $attribute/*, ?string $format */) + protected function createChildContext(array $parentContext, $attribute/*, ?string $format */): array { if (\func_num_args() < 3) { @trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index a0da6b9e55f7..a04da80f7d94 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -567,7 +567,7 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str * * @internal */ - protected function createChildContext(array $parentContext, $attribute/*, ?string $format */) + protected function createChildContext(array $parentContext, $attribute/*, ?string $format */): array { if (\func_num_args() >= 3) { $format = func_get_arg(2); diff --git a/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php b/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php index ffdae811bb51..654a6c6e9071 100644 --- a/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php +++ b/src/Symfony/Component/Serializer/Tests/DeserializeNestedArrayOfObjectsTest.php @@ -64,7 +64,7 @@ class Zoo /** * @return Animal[] */ - public function getAnimals() + public function getAnimals(): array { return $this->animals; } @@ -94,7 +94,7 @@ public function __construct(array $animals = []) /** * @return Animal[] */ - public function getAnimals() + public function getAnimals(): array { return $this->animals; } @@ -110,10 +110,7 @@ public function __construct() echo ''; } - /** - * @return string|null - */ - public function getName() + public function getName(): ?string { return $this->name; } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php index 2294b2afec51..4b97fdf53491 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php @@ -124,7 +124,7 @@ class ChainNormalizationAwareEncoder extends ChainEncoder implements Normalizati class NormalizationAwareEncoder implements EncoderInterface, NormalizationAwareInterface { - public function supportsEncoding($format) + public function supportsEncoding($format): bool { return true; } diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php index 94a5e895c6c4..617c4e52fcfd 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php @@ -38,7 +38,7 @@ public function normalize($object, $format = null, array $context = []) /** * {@inheritdoc} */ - public function supportsNormalization($data, $format = null) + public function supportsNormalization($data, $format = null): bool { return true; } @@ -53,7 +53,7 @@ public function denormalize($data, $type, $format = null, array $context = []) /** * {@inheritdoc} */ - public function supportsDenormalization($data, $type, $format = null) + public function supportsDenormalization($data, $type, $format = null): bool { return true; } diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/StaticConstructorNormalizer.php b/src/Symfony/Component/Serializer/Tests/Fixtures/StaticConstructorNormalizer.php index 67304831f892..1b660b5337ae 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/StaticConstructorNormalizer.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/StaticConstructorNormalizer.php @@ -21,7 +21,7 @@ class StaticConstructorNormalizer extends ObjectNormalizer /** * {@inheritdoc} */ - protected function getConstructor(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes) + protected function getConstructor(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes): ?\ReflectionMethod { if (is_a($class, StaticConstructorDummy::class, true)) { return new \ReflectionMethod($class, 'create'); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index 68b912e42f08..dd8fcaf6e8fd 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -214,7 +214,7 @@ public function testNormalizeEmptyObject() class AbstractObjectNormalizerDummy extends AbstractObjectNormalizer { - protected function extractAttributes($object, $format = null, array $context = []) + protected function extractAttributes($object, $format = null, array $context = []): array { return []; } @@ -228,11 +228,14 @@ protected function setAttributeValue($object, $attribute, $value, $format = null $object->$attribute = $value; } - protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = []) + protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = []): bool { return \in_array($attribute, ['foo', 'baz', 'quux', 'value']); } + /** + * @return object + */ public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null) { return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes, $format); @@ -257,7 +260,7 @@ public function __construct() parent::__construct(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()))); } - protected function extractAttributes($object, $format = null, array $context = []) + protected function extractAttributes($object, $format = null, array $context = []): array { } @@ -294,14 +297,20 @@ public function __construct($normalizers) $this->normalizers = $normalizers; } - public function serialize($data, $format, array $context = []) + public function serialize($data, $format, array $context = []): string { } + /** + * @return object + */ public function deserialize($data, $type, $format, array $context = []) { } + /** + * @return object + */ public function denormalize($data, $type, $format = null, array $context = []) { foreach ($this->normalizers as $normalizer) { @@ -313,7 +322,7 @@ public function denormalize($data, $type, $format = null, array $context = []) return null; } - public function supportsDenormalization($data, $type, $format = null) + public function supportsDenormalization($data, $type, $format = null): bool { return true; } @@ -321,7 +330,7 @@ public function supportsDenormalization($data, $type, $format = null) class AbstractObjectNormalizerCollectionDummy extends AbstractObjectNormalizer { - protected function extractAttributes($object, $format = null, array $context = []) + protected function extractAttributes($object, $format = null, array $context = []): array { } @@ -334,11 +343,14 @@ protected function setAttributeValue($object, $attribute, $value, $format = null $object->$attribute = $value; } - protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = []) + protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = []): bool { return true; } + /** + * @return object + */ public function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null) { return parent::instantiateObject($data, $class, $context, $reflectionClass, $allowedAttributes, $format); @@ -380,7 +392,7 @@ public function denormalize($data, $type, $format = null, array $context = []) /** * {@inheritdoc} */ - public function supportsDenormalization($data, $type, $format = null, array $context = []) + public function supportsDenormalization($data, $type, $format = null, array $context = []): bool { return '[]' === substr($type, -2) && $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 577db7086f1d..3ef803db8e34 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -1004,7 +1004,7 @@ class ObjectInner class FormatAndContextAwareNormalizer extends ObjectNormalizer { - protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = []) + protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = []): bool { if (\in_array($attribute, ['foo', 'bar']) && 'foo_and_bar_included' === $format) { return true; diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php b/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php index eefef12d4518..abf1bcc3076d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php @@ -30,7 +30,7 @@ public function denormalize($data, $type, $format = null, array $context = []) /** * {@inheritdoc} */ - public function supportsDenormalization($data, $type, $format = null) + public function supportsDenormalization($data, $type, $format = null): bool { return true; } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php b/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php index ea57d2dfff54..5d1d102a247c 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php @@ -30,7 +30,7 @@ public function normalize($object, $format = null, array $context = []) /** * {@inheritdoc} */ - public function supportsNormalization($data, $format = null) + public function supportsNormalization($data, $format = null): bool { return true; } diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php index 30e6795a9b4a..862b0f04d4b1 100644 --- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php @@ -150,15 +150,15 @@ interface MyStreamingEngine extends StreamingEngineInterface, EngineInterface class TestEngine implements EngineInterface { - public function render($name, array $parameters = []) + public function render($name, array $parameters = []): string { } - public function exists($name) + public function exists($name): bool { } - public function supports($name) + public function supports($name): bool { return true; } diff --git a/src/Symfony/Component/Templating/Tests/Fixtures/SimpleHelper.php b/src/Symfony/Component/Templating/Tests/Fixtures/SimpleHelper.php index 06efe71b2740..9538fcc313b5 100644 --- a/src/Symfony/Component/Templating/Tests/Fixtures/SimpleHelper.php +++ b/src/Symfony/Component/Templating/Tests/Fixtures/SimpleHelper.php @@ -27,7 +27,7 @@ public function __toString() return $this->value; } - public function getName() + public function getName(): string { return 'foo'; } diff --git a/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php b/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php index dec9082efc30..e60ffc5e8261 100644 --- a/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php +++ b/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php @@ -26,7 +26,7 @@ public function testGetSetCharset() class ProjectTemplateHelper extends Helper { - public function getName() + public function getName(): string { return 'foo'; } diff --git a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php index e66d62398a89..651c8e3b63d6 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php @@ -87,7 +87,7 @@ public function load(TemplateReferenceInterface $template) return false; } - public function isFresh(TemplateReferenceInterface $template, $time) + public function isFresh(TemplateReferenceInterface $template, $time): bool { return false; } diff --git a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php index 36a63bce3b67..1511156c0478 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php @@ -79,7 +79,7 @@ public function getTemplatePathPatterns() return $this->templatePathPatterns; } - public static function isAbsolutePath($path) + public static function isAbsolutePath($path): bool { return parent::isAbsolutePath($path); } diff --git a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php index da8c04caa4c9..4bebc5dce88b 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php @@ -42,7 +42,7 @@ public function getDebugger() return $this->debugger; } - public function isFresh(TemplateReferenceInterface $template, $time) + public function isFresh(TemplateReferenceInterface $template, $time): bool { return false; } diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php index fc62a97dc26a..70b8be1689be 100644 --- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Templating\Helper\SlotsHelper; use Symfony\Component\Templating\Loader\Loader; +use Symfony\Component\Templating\Loader\LoaderInterface; use Symfony\Component\Templating\PhpEngine; use Symfony\Component\Templating\Storage\StringStorage; use Symfony\Component\Templating\TemplateNameParser; @@ -194,7 +195,7 @@ public function testGetLoader() class ProjectTemplateEngine extends PhpEngine { - public function getLoader() + public function getLoader(): LoaderInterface { return $this->loader; } @@ -219,7 +220,7 @@ public function load(TemplateReferenceInterface $template) return false; } - public function isFresh(TemplateReferenceInterface $template, $time) + public function isFresh(TemplateReferenceInterface $template, $time): bool { return false; } diff --git a/src/Symfony/Component/Templating/Tests/Storage/StorageTest.php b/src/Symfony/Component/Templating/Tests/Storage/StorageTest.php index 3aac21dd7b66..8734886ac993 100644 --- a/src/Symfony/Component/Templating/Tests/Storage/StorageTest.php +++ b/src/Symfony/Component/Templating/Tests/Storage/StorageTest.php @@ -25,7 +25,7 @@ public function testMagicToString() class TestStorage extends Storage { - public function getContent() + public function getContent(): string { } } diff --git a/src/Symfony/Component/Translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php b/src/Symfony/Component/Translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php index 65b60d6fee60..c7d8820e7cae 100644 --- a/src/Symfony/Component/Translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php +++ b/src/Symfony/Component/Translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php @@ -12,7 +12,7 @@ public function __construct(ContainerInterface $container) { } - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return ['translator' => TranslatorInterface::class]; } diff --git a/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php index 20fa918bd69e..6e42b1e5683e 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php @@ -78,12 +78,12 @@ public function testDumpCreatesNestedDirectoriesAndFile() class ConcreteFileDumper extends FileDumper { - public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) + public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []): string { return http_build_query($messages->all($domain), '', '&'); } - protected function getExtension() + protected function getExtension(): string { return 'concrete'; } diff --git a/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php b/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php index 696c92b2dd82..4b8bdffa237b 100644 --- a/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php +++ b/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php @@ -57,10 +57,8 @@ public function testLangcodes($nplural, $langCodes) * This array should contain all currently known langcodes. * * As it is impossible to have this ever complete we should try as hard as possible to have it almost complete. - * - * @return array */ - public function successLangcodes() + public function successLangcodes(): array { return [ ['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']], @@ -79,7 +77,7 @@ public function successLangcodes() * * @return array with nplural together with langcodes */ - public function failingLangcodes() + public function failingLangcodes(): array { return [ ['1', ['fa']], diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 22f37346c3f9..149a15fce22d 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -300,7 +300,7 @@ private function createFailingLoader(): LoaderInterface class StaleResource implements SelfCheckingResourceInterface { - public function isFresh($timestamp) + public function isFresh($timestamp): bool { return false; } @@ -309,7 +309,7 @@ public function getResource() { } - public function __toString() + public function __toString(): string { return ''; } diff --git a/src/Symfony/Component/Validator/Mapping/Loader/PropertyInfoLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/PropertyInfoLoader.php index 7ddd53427529..379210b54bc3 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/PropertyInfoLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/PropertyInfoLoader.php @@ -44,7 +44,7 @@ public function __construct(PropertyListExtractorInterface $listExtractor, Prope /** * {@inheritdoc} */ - public function loadClassMetadata(ClassMetadata $metadata) + public function loadClassMetadata(ClassMetadata $metadata): bool { $className = $metadata->getClassName(); if (null !== $this->classValidatorRegexp && !preg_match($this->classValidatorRegexp, $className)) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 1b92dc8c906a..486901bfc31c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -114,10 +114,7 @@ public function testValidComparisonToValue($dirtyValue, $comparisonValue) $this->assertNoViolation(); } - /** - * @return array - */ - public function provideAllValidComparisons() + public function provideAllValidComparisons(): array { // The provider runs before setUp(), so we need to manually fix // the default timezone @@ -171,15 +168,9 @@ public function testInvalidValuePath() $this->validator->validate(5, $constraint); } - /** - * @return array - */ - abstract public function provideValidComparisons(); + abstract public function provideValidComparisons(): array; - /** - * @return array - */ - abstract public function provideValidComparisonsToPropertyPath(); + abstract public function provideValidComparisonsToPropertyPath(): array; /** * @dataProvider provideAllInvalidComparisons @@ -233,10 +224,7 @@ public function testInvalidComparisonToPropertyPathAddsPathAsParameter() ->assertRaised(); } - /** - * @return array - */ - public function provideAllInvalidComparisons() + public function provideAllInvalidComparisons(): array { // The provider runs before setUp(), so we need to manually fix // the default timezone @@ -249,22 +237,14 @@ public function provideAllInvalidComparisons() return $comparisons; } - /** - * @return array - */ - abstract public function provideInvalidComparisons(); + abstract public function provideInvalidComparisons(): array; /** * @param array|null $options Options for the constraint - * - * @return Constraint */ - abstract protected function createConstraint(array $options = null); + abstract protected function createConstraint(array $options = null): Constraint; - /** - * @return string|null - */ - protected function getErrorCode() + protected function getErrorCode(): ?string { return null; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php index 2d42807821bb..c14c1be6b326 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php @@ -21,12 +21,12 @@ class ConcreteComposite extends Composite { public $constraints; - protected function getCompositeOption() + protected function getCompositeOption(): string { return 'constraints'; } - public function getDefaultOption() + public function getDefaultOption(): ?string { return 'constraints'; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php index e2d50574a710..f11fdce97bc3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\DivisibleBy; use Symfony\Component\Validator\Constraints\DivisibleByValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new DivisibleByValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new DivisibleBy($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return DivisibleBy::NOT_DIVISIBLE_BY; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [-7, 1], @@ -54,7 +55,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [25], @@ -64,7 +65,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php index c1eb2f93ad75..6253b3c38422 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\EqualTo; use Symfony\Component\Validator\Constraints\EqualToValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new EqualToValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new EqualTo($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return EqualTo::NOT_EQUAL_ERROR; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [3, 3], @@ -54,7 +55,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [5], @@ -64,7 +65,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index d8d8eab8bdee..8cbfc269e2c9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new GreaterThanOrEqualValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new GreaterThanOrEqual($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return GreaterThanOrEqual::TOO_LOW_ERROR; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [3, 2], @@ -57,7 +58,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [5], @@ -68,7 +69,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php index 36ebb4de3276..6eab44d1a0f5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\PositiveOrZero; /** @@ -18,7 +19,7 @@ */ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends GreaterThanOrEqualValidatorTest { - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new PositiveOrZero(); } @@ -26,7 +27,7 @@ protected function createConstraint(array $options = null) /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [0, 0], @@ -42,7 +43,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [-1, '-1', 0, '0', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index e678496c41e6..8259d3a9bd62 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\GreaterThan; use Symfony\Component\Validator\Constraints\GreaterThanValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new GreaterThanValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new GreaterThan($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return GreaterThan::TOO_LOW_ERROR; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [2, 1], @@ -53,7 +54,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [6], @@ -63,7 +64,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php index 639efffd2d56..4ea65a5fc51a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Positive; /** @@ -18,7 +19,7 @@ */ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidatorTest { - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new Positive(); } @@ -26,7 +27,7 @@ protected function createConstraint(array $options = null) /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [2, 0], @@ -39,7 +40,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [0, '0', 0, '0', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index c96ac16a9193..edcaac358923 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\IdenticalTo; use Symfony\Component\Validator\Constraints\IdenticalToValidator; @@ -24,17 +25,17 @@ protected function createValidator() return new IdenticalToValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new IdenticalTo($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return IdenticalTo::NOT_IDENTICAL_ERROR; } - public function provideAllValidComparisons() + public function provideAllValidComparisons(): array { $this->setDefaultTimezone('UTC'); @@ -50,7 +51,7 @@ public function provideAllValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { $date = new \DateTime('2000-01-01'); $object = new ComparisonTest_Class(2); @@ -72,7 +73,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [5], @@ -82,7 +83,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [1, '1', 2, '2', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index b77deff6163d..625b996931d5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\LessThanOrEqual; use Symfony\Component\Validator\Constraints\LessThanOrEqualValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new LessThanOrEqualValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new LessThanOrEqual($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return LessThanOrEqual::TOO_HIGH_ERROR; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [1, 2], @@ -59,7 +60,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [4], @@ -70,7 +71,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [2, '2', 1, '1', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php index 47b9484808a7..3bb1c6ea243d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\NegativeOrZero; /** @@ -18,7 +19,7 @@ */ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanOrEqualValidatorTest { - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new NegativeOrZero(); } @@ -26,7 +27,7 @@ protected function createConstraint(array $options = null) /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [0, 0], @@ -40,7 +41,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [2, '2', 0, '0', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php index 7d209ed5d471..747a7dcd79d2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\LessThan; use Symfony\Component\Validator\Constraints\LessThanValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new LessThanValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new LessThan($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return LessThan::TOO_HIGH_ERROR; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [1, 2], @@ -53,7 +54,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [4], @@ -63,7 +64,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [3, '3', 2, '2', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php index 8809355c35ba..3203adabb98c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Negative; /** @@ -18,7 +19,7 @@ */ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest { - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new Negative(); } @@ -26,7 +27,7 @@ protected function createConstraint(array $options = null) /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [-1, 0], @@ -39,7 +40,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [0, '0', 0, '0', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php index 810f7a175f10..e92d22d664aa 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\NotEqualTo; use Symfony\Component\Validator\Constraints\NotEqualToValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new NotEqualToValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new NotEqualTo($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return NotEqualTo::IS_EQUAL_ERROR; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [1, 2], @@ -53,7 +54,7 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [0], @@ -63,7 +64,7 @@ public function provideValidComparisonsToPropertyPath() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { return [ [3, '3', 3, '3', 'integer'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 0cb9ec543114..93befafe8573 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\NotIdenticalTo; use Symfony\Component\Validator\Constraints\NotIdenticalToValidator; @@ -24,12 +25,12 @@ protected function createValidator() return new NotIdenticalToValidator(); } - protected function createConstraint(array $options = null) + protected function createConstraint(array $options = null): Constraint { return new NotIdenticalTo($options); } - protected function getErrorCode() + protected function getErrorCode(): ?string { return NotIdenticalTo::IS_IDENTICAL_ERROR; } @@ -37,7 +38,7 @@ protected function getErrorCode() /** * {@inheritdoc} */ - public function provideValidComparisons() + public function provideValidComparisons(): array { return [ [1, 2], @@ -56,14 +57,14 @@ public function provideValidComparisons() /** * {@inheritdoc} */ - public function provideValidComparisonsToPropertyPath() + public function provideValidComparisonsToPropertyPath(): array { return [ [0], ]; } - public function provideAllInvalidComparisons() + public function provideAllInvalidComparisons(): array { $this->setDefaultTimezone('UTC'); @@ -79,7 +80,7 @@ public function provideAllInvalidComparisons() /** * {@inheritdoc} */ - public function provideInvalidComparisons() + public function provideInvalidComparisons(): array { $date = new \DateTime('2000-01-01'); $object = new ComparisonTest_Class(2); diff --git a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php index adc292b213d8..12176c45a31f 100644 --- a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php @@ -61,7 +61,7 @@ public function testGetInstanceInvalidValidatorClass() class DummyConstraint extends Constraint { - public function validatedBy() + public function validatedBy(): string { return DummyConstraintValidator::class; } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintA.php b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintA.php index 17ba03673d5d..7c2fea8751c2 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintA.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintA.php @@ -19,7 +19,7 @@ class ConstraintA extends Constraint public $property1; public $property2; - public function getDefaultOption() + public function getDefaultOption(): ?string { return 'property2'; } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintC.php b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintC.php index 675066ef020f..14cf65cf2521 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintC.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintC.php @@ -18,7 +18,7 @@ class ConstraintC extends Constraint { public $option1; - public function getRequiredOptions() + public function getRequiredOptions(): array { return ['option1']; } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValue.php b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValue.php index b3fbd7083cfd..72c99cc060a0 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValue.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValue.php @@ -19,7 +19,7 @@ class ConstraintWithValue extends Constraint public $property; public $value; - public function getDefaultOption() + public function getDefaultOption(): ?string { return 'property'; } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValueAsDefault.php b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValueAsDefault.php index 618cca74df04..87b685e075ad 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValueAsDefault.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValueAsDefault.php @@ -19,7 +19,7 @@ class ConstraintWithValueAsDefault extends Constraint public $property; public $value; - public function getDefaultOption() + public function getDefaultOption(): ?string { return 'value'; } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php index 5e34929be35e..0f8f765b1bfa 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php @@ -13,13 +13,13 @@ use Symfony\Component\Validator\Exception\NoSuchMetadataException; use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; -use Symfony\Component\Validator\MetadataInterface; +use Symfony\Component\Validator\Mapping\MetadataInterface; class FakeMetadataFactory implements MetadataFactoryInterface { protected $metadatas = []; - public function getMetadataFor($class) + public function getMetadataFor($class): MetadataInterface { $hash = null; @@ -43,7 +43,7 @@ public function getMetadataFor($class) return $this->metadatas[$class]; } - public function hasMetadataFor($class) + public function hasMetadataFor($class): bool { $hash = null; diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/FilesLoader.php b/src/Symfony/Component/Validator/Tests/Fixtures/FilesLoader.php index a4d6a6ab474a..80364acfe093 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/FilesLoader.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/FilesLoader.php @@ -25,7 +25,7 @@ public function __construct(array $paths, LoaderInterface $loader) parent::__construct($paths); } - protected function getFileLoaderInstance($file) + protected function getFileLoaderInstance($file): LoaderInterface { ++$this->timesCalled; diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index f3332b8ff9dd..a4f1385cee88 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -209,8 +209,10 @@ public function testGroupsFromParent() class TestLoader implements LoaderInterface { - public function loadClassMetadata(ClassMetadata $metadata) + public function loadClassMetadata(ClassMetadata $metadata): bool { $metadata->addConstraint(new ConstraintA()); + + return true; } } diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php index c727e43931d7..4cb354ec4e6d 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php @@ -38,10 +38,7 @@ abstract class AbstractTest extends AbstractValidatorTest */ protected $validator; - /** - * @return ValidatorInterface - */ - abstract protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = []); + abstract protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = []): ValidatorInterface; protected function setUp(): void { diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php index c0c7c3e96d7c..c2838792421d 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -23,10 +23,11 @@ use Symfony\Component\Validator\Tests\Constraints\Fixtures\ChildB; use Symfony\Component\Validator\Tests\Fixtures\Entity; use Symfony\Component\Validator\Validator\RecursiveValidator; +use Symfony\Component\Validator\Validator\ValidatorInterface; class RecursiveValidatorTest extends AbstractTest { - protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = []) + protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = []): ValidatorInterface { $translator = new IdentityTranslator(); $translator->setLocale('en'); diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php index 884e84de9b89..2dc71b66b2da 100644 --- a/src/Symfony/Component/VarDumper/Caster/Caster.php +++ b/src/Symfony/Component/VarDumper/Caster/Caster.php @@ -46,7 +46,7 @@ class Caster * * @return array The array-cast of the object, with prefixed dynamic properties */ - public static function castObject($obj, $class, $hasDebugInfo = false) + public static function castObject($obj, $class, $hasDebugInfo = false): array { $a = $obj instanceof \Closure ? [] : (array) $obj; @@ -110,7 +110,7 @@ public static function castObject($obj, $class, $hasDebugInfo = false) * * @return array The filtered array */ - public static function filter(array $a, $filter, array $listedProperties = [], &$count = 0) + public static function filter(array $a, $filter, array $listedProperties = [], &$count = 0): array { $count = 0; diff --git a/src/Symfony/Component/WebLink/HttpHeaderSerializer.php b/src/Symfony/Component/WebLink/HttpHeaderSerializer.php index 6c7a039326ce..d80d96ec3b5c 100644 --- a/src/Symfony/Component/WebLink/HttpHeaderSerializer.php +++ b/src/Symfony/Component/WebLink/HttpHeaderSerializer.php @@ -26,10 +26,8 @@ final class HttpHeaderSerializer * Builds the value of the "Link" HTTP header. * * @param LinkInterface[]|\Traversable $links - * - * @return string|null */ - public function serialize(iterable $links) + public function serialize(iterable $links): ?string { $elements = []; foreach ($links as $link) { diff --git a/src/Symfony/Component/Workflow/Definition.php b/src/Symfony/Component/Workflow/Definition.php index 8a6e94206d49..dd907948906f 100644 --- a/src/Symfony/Component/Workflow/Definition.php +++ b/src/Symfony/Component/Workflow/Definition.php @@ -49,10 +49,8 @@ public function __construct(array $places, array $transitions, $initialPlaces = /** * @deprecated since Symfony 4.3. Use getInitialPlaces() instead. - * - * @return string|null */ - public function getInitialPlace() + public function getInitialPlace(): ?string { @trigger_error(sprintf('Calling %s::getInitialPlace() is deprecated since Symfony 4.3. Call getInitialPlaces() instead.', __CLASS__), E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php index a2341aadbd2e..df1a6a24ab09 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php @@ -46,7 +46,7 @@ public function __construct(bool $singleState = false, string $property = 'marki /** * {@inheritdoc} */ - public function getMarking($subject) + public function getMarking($subject): Marking { $method = 'get'.ucfirst($this->property); diff --git a/src/Symfony/Component/Workflow/SupportStrategy/ClassInstanceSupportStrategy.php b/src/Symfony/Component/Workflow/SupportStrategy/ClassInstanceSupportStrategy.php index fb08b2c27833..c50c687fa46e 100644 --- a/src/Symfony/Component/Workflow/SupportStrategy/ClassInstanceSupportStrategy.php +++ b/src/Symfony/Component/Workflow/SupportStrategy/ClassInstanceSupportStrategy.php @@ -32,15 +32,12 @@ public function __construct(string $className) /** * {@inheritdoc} */ - public function supports(Workflow $workflow, $subject) + public function supports(Workflow $workflow, $subject): bool { return $subject instanceof $this->className; } - /** - * @return string - */ - public function getClassName() + public function getClassName(): string { return $this->className; } diff --git a/src/Symfony/Component/Workflow/Tests/EventListener/AuditTrailListenerTest.php b/src/Symfony/Component/Workflow/Tests/EventListener/AuditTrailListenerTest.php index 9ebe6f4fb604..0416e7a9db83 100644 --- a/src/Symfony/Component/Workflow/Tests/EventListener/AuditTrailListenerTest.php +++ b/src/Symfony/Component/Workflow/Tests/EventListener/AuditTrailListenerTest.php @@ -44,7 +44,7 @@ class Logger extends AbstractLogger { public $logs = []; - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { $this->logs[] = $message; } diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 1cfb5fc5eb49..aec6a822319f 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -574,9 +574,14 @@ class EventDispatcherMock implements \Symfony\Component\EventDispatcher\EventDis { public $dispatchedEvents = []; + /** + * @return object + */ public function dispatch($event, string $eventName = null) { $this->dispatchedEvents[] = $eventName; + + return $event; } public function addListener($eventName, $listener, $priority = 0) @@ -595,7 +600,7 @@ public function removeSubscriber(\Symfony\Component\EventDispatcher\EventSubscri { } - public function getListeners($eventName = null) + public function getListeners($eventName = null): array { } @@ -603,7 +608,7 @@ public function getListenerPriority($eventName, $listener) { } - public function hasListeners($eventName = null) + public function hasListeners($eventName = null): bool { } } diff --git a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php index b90eef2e9e24..f18ea3e571de 100644 --- a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php @@ -110,10 +110,7 @@ private function createFile($content): string return $filename; } - /** - * @return CommandTester - */ - protected function createCommandTester() + protected function createCommandTester(): CommandTester { $application = new Application(); $application->add(new LintCommand()); diff --git a/src/Symfony/Contracts/Tests/Cache/CacheTraitTest.php b/src/Symfony/Contracts/Tests/Cache/CacheTraitTest.php index f77d103c9353..9d803c34d4fe 100644 --- a/src/Symfony/Contracts/Tests/Cache/CacheTraitTest.php +++ b/src/Symfony/Contracts/Tests/Cache/CacheTraitTest.php @@ -127,39 +127,39 @@ class TestPool implements CacheItemPoolInterface { use CacheTrait; - public function hasItem($key) + public function hasItem($key): bool { } - public function deleteItem($key) + public function deleteItem($key): bool { } - public function deleteItems(array $keys = []) + public function deleteItems(array $keys = []): bool { } - public function getItem($key) + public function getItem($key): CacheItemInterface { } - public function getItems(array $key = []) + public function getItems(array $key = []): iterable { } - public function saveDeferred(CacheItemInterface $item) + public function saveDeferred(CacheItemInterface $item): bool { } - public function save(CacheItemInterface $item) + public function save(CacheItemInterface $item): bool { } - public function commit() + public function commit(): bool { } - public function clear() + public function clear(): bool { } } From c39fd9c973deeb2945f5ba23e528f1cc730bf287 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 21 Aug 2019 16:29:27 +0200 Subject: [PATCH 2/2] Fixed tests on the Security and Form components --- src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php | 2 +- .../Component/BrowserKit/Tests/AbstractBrowserTest.php | 10 ++-------- .../Component/BrowserKit/Tests/HttpBrowserTest.php | 5 +---- .../Tests/LegacyEventDispatcherTest.php | 5 +---- src/Symfony/Component/Security/Core/Security.php | 5 ++++- .../Security/Core/Tests/Encoder/EncoderFactoryTest.php | 4 ++-- .../Tests/Normalizer/AbstractObjectNormalizerTest.php | 6 ------ src/Symfony/Component/Workflow/Tests/WorkflowTest.php | 5 +---- 8 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php index 097f11d4f6db..c5cbc662fc1d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php @@ -35,7 +35,7 @@ public function __construct($id1, $id2, $name) $this->name = $name; } - public function getRoles() + public function getRoles(): array { } diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index 4abde0e97bb1..518ff37af6ac 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -39,10 +39,7 @@ public function setNextScript($script) $this->nextScript = $script; } - /** - * @return object - */ - protected function doRequest($request) + protected function doRequest($request): Response { if (null === $this->nextResponse) { return new Response(); @@ -938,10 +935,7 @@ public function setNextResponse(Response $response) $this->nextResponse = $response; } - /** - * @return object - */ - protected function doRequest($request) + protected function doRequest($request): Response { if (null === $this->nextResponse) { return new Response(); diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index 7e171035dbca..3d9db8e31bdc 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -67,10 +67,7 @@ protected function filterResponse($response): Response return $response; } - /** - * @return object - */ - protected function doRequest($request) + protected function doRequest($request): Response { $response = parent::doRequest($request); diff --git a/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php index 4cf203f4dada..f510609d72fd 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php @@ -56,10 +56,7 @@ protected function createEventDispatcher() class TestLegacyEventDispatcher extends EventDispatcher { - /** - * @return object - */ - public function dispatch($eventName, Event $event = null) + public function dispatch($eventName, Event $event = null): Event { return parent::dispatch($event, $eventName); } diff --git a/src/Symfony/Component/Security/Core/Security.php b/src/Symfony/Component/Security/Core/Security.php index 094cc424d200..334fbd8d283a 100644 --- a/src/Symfony/Component/Security/Core/Security.php +++ b/src/Symfony/Component/Security/Core/Security.php @@ -34,7 +34,10 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - public function getUser(): ?UserInterface + /** + * @return UserInterface|null + */ + public function getUser() { if (!$token = $this->getToken()) { return null; diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php index 1243d88b77a4..f2ad94e88478 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php @@ -135,7 +135,7 @@ public function testGetEncoderForEncoderAwareWithClassName() class SomeUser implements UserInterface { - public function getRoles() + public function getRoles(): array { } @@ -164,7 +164,7 @@ class EncAwareUser extends SomeUser implements EncoderAwareInterface { public $encoderName = 'encoder_name'; - public function getEncoderName(): string + public function getEncoderName(): ?string { return $this->encoderName; } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index dd8fcaf6e8fd..f6ad1a39558e 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -301,16 +301,10 @@ public function serialize($data, $format, array $context = []): string { } - /** - * @return object - */ public function deserialize($data, $type, $format, array $context = []) { } - /** - * @return object - */ public function denormalize($data, $type, $format = null, array $context = []) { foreach ($this->normalizers as $normalizer) { diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index aec6a822319f..26f58a1fa5ca 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -574,10 +574,7 @@ class EventDispatcherMock implements \Symfony\Component\EventDispatcher\EventDis { public $dispatchedEvents = []; - /** - * @return object - */ - public function dispatch($event, string $eventName = null) + public function dispatch($event, string $eventName = null): Event { $this->dispatchedEvents[] = $eventName;