From a7e15b08a64d4f6fb64b4c3b58bd6a710f71050e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:22:00 +0100 Subject: [PATCH] cs: Update PHP-CS-Fixer rules (#1150) --- .php-cs-fixer.dist.php | 97 +-- .../Bridge/Symfony/Application/AppKernel.php | 8 +- fixtures/Definition/FakeMethodCall.php | 12 +- fixtures/Definition/Fixture/DummyFixture.php | 10 +- fixtures/Definition/Fixture/FakeFixture.php | 10 +- .../Definition/Fixture/MutableFixture.php | 10 +- fixtures/Definition/Flag/ElementFlag.php | 2 +- .../Flag/ElementWithToStringFlag.php | 2 +- .../Definition/MethodCall/DummyMethodCall.php | 12 +- .../Definition/MethodCall/IdentityFactory.php | 2 +- .../MethodCall/MutableMethodCall.php | 19 +- .../Object/ImmutableByCloneObject.php | 8 +- .../Definition/Object/ImmutableObject.php | 8 +- .../ServiceReference/FakeReference.php | 2 +- .../ServiceReference/MutableReference.php | 2 +- .../Definition/SpecificationBagFactory.php | 8 +- fixtures/Definition/Value/DummyValue.php | 4 +- fixtures/Definition/Value/FakeObject.php | 6 +- fixtures/Definition/Value/FakeValue.php | 4 +- fixtures/Definition/Value/MutableValue.php | 4 +- fixtures/Entity/Caller/Dummy.php | 4 +- fixtures/Entity/Caller/StaticService.php | 2 +- fixtures/Entity/StdClassFactory.php | 2 +- fixtures/FileLocator/DummyFileLocator.php | 2 +- fixtures/FileLocator/FakeFileLocator.php | 4 +- .../Denormalizer/FakeDenormalizer.php | 2 +- .../DummyChainableParserAwareDenormalizer.php | 12 +- .../Chainable/FakeChainableDenormalizer.php | 4 +- ...ChainableDenormalizerAwareDenormalizer.php | 4 +- .../Fixture/FakeFixtureBagDenormalizer.php | 2 +- .../Fixture/FakeFixtureDenormalizer.php | 2 +- .../Arguments/FakeArgumentsDenormalizer.php | 2 +- .../Calls/FakeCallsDenormalizer.php | 2 +- .../FakeConstructorDenormalizer.php | 2 +- .../DummySpecificationBagDenormalizer.php | 2 +- .../FakeSpecificationBagDenormalizer.php | 2 +- .../Property/FakePropertyDenormalizer.php | 2 +- .../Value/FakeValueDenormalizer.php | 4 +- .../Chainable/FakeChainableFlagParser.php | 4 +- .../FlagParser/DummyFlagParser.php | 2 +- .../FlagParser/FakeFlagParser.php | 2 +- .../FakeParameterBagDenormalizer.php | 2 +- .../ExpressionLanguage/Lexer/DummyLexer.php | 2 +- .../ExpressionLanguage/Lexer/FakeLexer.php | 2 +- .../Lexer/IsolatedSymfonyBuiltInLexer.php | 4 +- .../ExpressionLanguage/Parser/FakeParser.php | 2 +- .../Parser/IsolatedSymfonyBuiltInParser.php | 4 +- .../DummyChainableTokenParserAware.php | 6 +- .../Chainable/FakeChainableTokenParser.php | 4 +- .../ImpartialChainableParserAwareParser.php | 2 +- .../ProphecyChainableTokenParserAware.php | 6 +- .../Parser/TokenParser/FakeTokenParser.php | 2 +- .../FixtureBuilder/FakeFixtureBuilder.php | 2 +- fixtures/FixtureSetFactory.php | 10 +- .../Generator/Caller/FakeCallProcessor.php | 2 +- fixtures/Generator/Caller/FakeCaller.php | 2 +- fixtures/Generator/FakeGenerator.php | 2 +- fixtures/Generator/FakeObjectGenerator.php | 2 +- fixtures/Generator/Hydrator/FakeHydrator.php | 2 +- .../Hydrator/FakePropertyHydrator.php | 2 +- .../Chainable/DummyChainableInstantiator.php | 2 +- .../ProphecyChainableInstantiator.php | 4 +- .../Instantiator/FakeInstantiator.php | 2 +- .../Generator/ResolvedFixtureSetFactory.php | 4 +- .../Resolver/FakeFixtureBagResolver.php | 2 +- .../Resolver/FakeParameterBagResolver.php | 4 +- .../Resolver/FakeParameterResolver.php | 2 +- ...hainableParameterResolverAwareResolver.php | 8 +- .../FakeChainableParameterResolver.php | 4 +- .../IsolatedSymfonyParameterBagResolver.php | 6 +- .../Value/FakeChainableValueResolver.php | 4 +- fixtures/Loader/FakeDataLoader.php | 2 +- fixtures/Loader/IsolatedLoader.php | 4 +- fixtures/Loader/IsolatedSymfonyLoader.php | 10 +- fixtures/Loader/NonIsolatedSymfonyLoader.php | 6 +- fixtures/NotCallableTrait.php | 4 +- fixtures/ObjectSetFactory.php | 4 +- fixtures/Parser/FakeParser.php | 2 +- .../Parser/files/php/named_parameters.php | 28 +- fixtures/Symfony/KernelFactory.php | 6 +- .../PropertyAccess/FakePropertyAccessor.php | 8 +- fixtures/User.php | 4 +- fixtures/UserDetail.php | 4 +- profiling/scenario0/blackfire.php | 16 +- profiling/scenario1/blackfire_immutable.php | 6 +- profiling/scenario1/blackfire_mutable.php | 6 +- profiling/scenario1/blackfire_public.php | 6 +- profiling/scenario1/blackfire_stdClass.php | 6 +- profiling/scenario2/blackfire.php | 6 +- profiling/scenario3/blackfire.php | 6 +- .../Compiler/RegisterFakerProvidersPass.php | 2 +- .../Compiler/RegisterTagServicesPass.php | 2 +- .../DependencyInjection/Configuration.php | 119 ++-- .../NelmioAliceExtension.php | 8 +- src/Bridge/Symfony/NelmioAliceBundle.php | 36 +- src/DataLoaderInterface.php | 6 +- src/Definition/Fixture/FixtureId.php | 2 +- src/Definition/Fixture/SimpleFixture.php | 10 +- .../Fixture/SimpleFixtureWithFlags.php | 14 +- src/Definition/Fixture/TemplatingFixture.php | 14 +- src/Definition/Flag/OptionalFlag.php | 2 +- src/Definition/FlagBag.php | 18 +- .../MethodCall/ConfiguratorMethodCall.php | 12 +- .../MethodCall/MethodCallWithReference.php | 14 +- src/Definition/MethodCall/NoMethodCall.php | 10 +- .../MethodCall/OptionalMethodCall.php | 12 +- .../MethodCall/SimpleMethodCall.php | 14 +- src/Definition/MethodCallBag.php | 4 +- src/Definition/MethodCallInterface.php | 6 +- src/Definition/Object/CompleteObject.php | 6 +- src/Definition/Object/SimpleObject.php | 6 +- src/Definition/Property.php | 3 +- src/Definition/PropertyBag.php | 8 +- src/Definition/RangeName.php | 4 +- .../ServiceReference/StaticReference.php | 2 +- src/Definition/SpecificationBag.php | 16 +- src/Definition/Value/ArrayValue.php | 4 +- src/Definition/Value/DynamicArrayValue.php | 4 +- src/Definition/Value/EvaluatedValue.php | 2 +- .../Value/FixtureMethodCallValue.php | 8 +- src/Definition/Value/FixturePropertyValue.php | 4 +- .../Value/FixtureReferenceValue.php | 2 +- src/Definition/Value/FunctionCallValue.php | 6 +- src/Definition/Value/ListValue.php | 4 +- src/Definition/Value/NestedValue.php | 2 +- src/Definition/Value/OptionalValue.php | 8 +- src/Definition/Value/ParameterValue.php | 6 +- .../Value/ResolvedFunctionCallValue.php | 4 +- src/Definition/Value/UniqueValue.php | 12 +- src/Definition/Value/ValueForCurrentValue.php | 2 +- src/Definition/Value/VariableValue.php | 4 +- src/Faker/GeneratorFactory.php | 2 +- src/Faker/Provider/AliceProvider.php | 1 + src/FileLocator/DefaultFileLocator.php | 15 +- src/FileLocatorInterface.php | 2 +- src/FilesLoaderInterface.php | 2 +- src/FixtureBag.php | 4 +- src/FixtureBuilder/BareFixtureSet.php | 6 +- ...ectionDenormalizerWithTemporaryFixture.php | 30 +- .../Chainable/NullListNameDenormalizer.php | 10 +- .../Chainable/NullRangeNameDenormalizer.php | 4 +- .../ReferenceRangeNameDenormalizer.php | 26 +- .../SimpleCollectionDenormalizer.php | 28 +- .../Fixture/Chainable/SimpleDenormalizer.php | 24 +- .../Fixture/FixtureDenormalizerInterface.php | 6 +- .../Fixture/FixtureDenormalizerRegistry.php | 8 +- .../Fixture/SimpleFixtureBagDenormalizer.php | 6 +- .../Arguments/SimpleArgumentsDenormalizer.php | 2 +- .../ArgumentsDenormalizerInterface.php | 1 - .../Calls/CallsWithFlagsDenormalizer.php | 8 +- .../Calls/FunctionDenormalizer.php | 8 +- .../ConfiguratorFlagHandler.php | 5 +- .../MethodFlagHandler/OptionalFlagHandler.php | 5 +- .../CallsDenormalizerInterface.php | 2 +- .../Constructor/ConstructorDenormalizer.php | 2 +- .../Constructor/FactoryDenormalizer.php | 8 +- .../LegacyConstructorDenormalizer.php | 2 +- .../ConstructorDenormalizerInterface.php | 1 - .../Property/SimplePropertyDenormalizer.php | 2 +- .../PropertyDenormalizerInterface.php | 1 + .../SimpleSpecificationsDenormalizer.php | 13 +- .../Value/SimpleValueDenormalizer.php | 4 +- .../Value/UniqueValueDenormalizer.php | 9 +- .../ValueDenormalizerInterface.php | 3 +- .../Fixture/TolerantFixtureDenormalizer.php | 10 +- .../Chainable/ConfiguratorFlagParser.php | 4 +- .../FlagParser/Chainable/ExtendFlagParser.php | 8 +- .../Chainable/OptionalFlagParser.php | 8 +- .../Chainable/TemplateFlagParser.php | 4 +- .../FlagParser/Chainable/UniqueFlagParser.php | 4 +- .../FlagParser/ElementFlagParser.php | 6 +- .../FlagParser/FlagParserRegistry.php | 6 +- .../Denormalizer/SimpleDenormalizer.php | 2 +- .../Lexer/EmptyValueLexer.php | 2 +- .../Lexer/FunctionLexer.php | 2 +- .../Lexer/FunctionTokenizer.php | 11 +- .../Lexer/FunctionTreeTokenizer.php | 23 +- .../Lexer/GlobalPatternsLexer.php | 2 +- .../Lexer/ReferenceLexer.php | 6 +- .../Lexer/StringThenReferenceLexer.php | 16 +- .../Lexer/SubPatternsLexer.php | 10 +- .../ExpressionLanguage/LexerInterface.php | 1 - .../Parser/FunctionFixtureReferenceParser.php | 9 +- .../Parser/SimpleParser.php | 17 +- .../Parser/StringMergerParser.php | 7 +- .../AbstractChainableParserAwareParser.php | 4 +- .../Chainable/DynamicArrayTokenParser.php | 10 +- .../Chainable/EscapedValueTokenParser.php | 4 +- .../FixtureListReferenceTokenParser.php | 10 +- .../FixtureMethodReferenceTokenParser.php | 6 +- .../FixtureRangeReferenceTokenParser.php | 6 +- .../Chainable/FunctionTokenParser.php | 28 +- .../Chainable/IdentityTokenParser.php | 12 +- .../Chainable/MethodReferenceTokenParser.php | 10 +- .../Chainable/OptionalTokenParser.php | 8 +- .../Chainable/ParameterTokenParser.php | 4 +- .../PropertyReferenceTokenParser.php | 8 +- .../Chainable/SimpleReferenceTokenParser.php | 4 +- .../Chainable/StringArrayTokenParser.php | 4 +- .../Chainable/StringTokenParser.php | 6 +- .../Chainable/TolerantFunctionTokenParser.php | 14 +- .../VariableReferenceTokenParser.php | 12 +- .../Chainable/VariableTokenParser.php | 8 +- .../WildcardReferenceTokenParser.php | 6 +- .../TokenParser/TokenParserRegistry.php | 11 +- .../ExpressionLanguage/ParserInterface.php | 1 - .../ExpressionLanguage/Token.php | 8 +- .../ExpressionLanguage/TokenType.php | 36 +- src/FixtureBuilder/SimpleBuilder.php | 6 +- src/FixtureInterface.php | 1 - src/FixtureSet.php | 6 +- .../Caller/CallProcessorRegistry.php | 8 +- .../ConfiguratorMethodCallProcessor.php | 12 +- .../MethodCallWithReferenceProcessor.php | 9 +- .../Chainable/OptionalMethodCallProcessor.php | 10 +- .../Chainable/SimpleMethodCallProcessor.php | 6 +- src/Generator/Caller/SimpleCaller.php | 10 +- src/Generator/CallerInterface.php | 2 +- src/Generator/ConfiguratorInterface.php | 2 +- src/Generator/DoublePassGenerator.php | 2 +- src/Generator/FixtureSetResolverInterface.php | 1 - .../SymfonyPropertyAccessorHydrator.php | 6 +- src/Generator/Hydrator/SimpleHydrator.php | 8 +- src/Generator/HydratorInterface.php | 2 +- .../AbstractChainableInstantiator.php | 4 +- .../NoCallerMethodCallInstantiator.php | 8 +- .../Chainable/NoMethodCallInstantiator.php | 2 +- .../Chainable/NullConstructorInstantiator.php | 2 +- .../Chainable/StaticFactoryInstantiator.php | 8 +- .../ExistingInstanceInstantiator.php | 8 +- .../Instantiator/InstantiatorRegistry.php | 11 +- .../Instantiator/InstantiatorResolver.php | 12 +- src/Generator/InstantiatorInterface.php | 1 - src/Generator/NamedArgumentsResolver.php | 8 +- .../CompleteObjectGenerator.php | 9 +- .../ObjectGenerator/SimpleObjectGenerator.php | 19 +- src/Generator/ResolvedValueWithFixtureSet.php | 6 +- .../Fixture/TemplateFixtureBagResolver.php | 6 +- .../Fixture/TemplateFixtureResolver.php | 12 +- .../Resolver/FixtureBagResolverInterface.php | 1 - .../FixtureSet/FakeFixtureSetResolver.php | 2 +- .../RemoveConflictingObjectsResolver.php | 2 +- .../FixtureSet/SimpleFixtureSetResolver.php | 4 +- .../Chainable/ArrayParameterResolver.php | 20 +- .../Chainable/RecursiveParameterResolver.php | 12 +- .../Chainable/StaticParameterResolver.php | 2 +- .../Chainable/StringParameterResolver.php | 24 +- .../Parameter/ParameterResolverRegistry.php | 6 +- ...flictingParametersParameterBagResolver.php | 4 +- .../Parameter/SimpleParameterBagResolver.php | 6 +- .../ParameterBagResolverInterface.php | 3 +- .../Resolver/ParameterResolverInterface.php | 2 +- src/Generator/Resolver/ResolvingContext.php | 7 +- .../Value/Chainable/ArrayValueResolver.php | 6 +- .../Chainable/DynamicArrayValueResolver.php | 8 +- .../Chainable/EvaluatedValueResolver.php | 6 +- .../FakerFunctionCallValueResolver.php | 6 +- .../FixtureMethodCallReferenceResolver.php | 10 +- .../FixturePropertyReferenceResolver.php | 10 +- .../Chainable/FixtureReferenceResolver.php | 14 +- .../FixtureWildcardReferenceResolver.php | 18 +- .../FunctionCallArgumentResolver.php | 8 +- .../Value/Chainable/ListValueResolver.php | 8 +- .../Value/Chainable/OptionalValueResolver.php | 13 +- .../Chainable/ParameterValueResolver.php | 4 +- .../PhpFunctionCallValueResolver.php | 8 +- .../SelfFixtureReferenceResolver.php | 14 +- .../Value/Chainable/UniqueValueResolver.php | 8 +- .../UnresolvedFixtureReferenceIdResolver.php | 18 +- .../ValueForCurrentValueResolver.php | 6 +- .../Value/Chainable/VariableValueResolver.php | 4 +- .../Resolver/Value/ValueResolverRegistry.php | 6 +- src/Generator/ValueResolverInterface.php | 4 +- src/GeneratorInterface.php | 1 - src/Loader/NativeLoader.php | 184 +++--- src/Loader/SimpleDataLoader.php | 2 +- src/Loader/SimpleFileLoader.php | 2 +- src/Loader/SimpleFilesLoader.php | 4 +- src/ObjectBag.php | 13 +- src/Parameter.php | 9 +- src/ParameterBag.php | 8 +- src/Parser/Chainable/JsonParser.php | 2 +- src/Parser/Chainable/PhpParser.php | 4 +- src/Parser/Chainable/YamlParser.php | 4 +- .../DefaultIncludeProcessor.php | 6 +- .../IncludeProcessor/IncludeDataMerger.php | 3 +- src/Parser/ParserRegistry.php | 4 +- src/Parser/RuntimeCacheParser.php | 2 +- .../ReflectionPropertyAccessor.php | 24 +- src/PropertyAccess/StdPropertyAccessor.php | 20 +- src/Throwable/Error/TypeErrorFactory.php | 56 +- .../BadMethodCallExceptionFactory.php | 4 +- .../FileLocator/FileNotFoundException.php | 4 +- .../DenormalizerExceptionFactory.php | 16 +- .../FlagParser/FlagParserExceptionFactory.php | 8 +- .../ExpressionLanguageExceptionFactory.php | 22 +- .../FixtureNotFoundExceptionFactory.php | 8 +- .../Caller/CallProcessorExceptionFactory.php | 4 +- .../Generator/Context/CachedValueNotFound.php | 4 +- .../Hydrator/HydrationExceptionFactory.php | 22 +- .../InstantiationExceptionFactory.php | 26 +- ...bjectGeneratorNotFoundExceptionFactory.php | 4 +- .../CircularReferenceExceptionFactory.php | 4 +- .../FixtureNotFoundExceptionFactory.php | 4 +- .../Resolver/NoSuchMethodExceptionFactory.php | 6 +- .../NoSuchPropertyExceptionFactory.php | 6 +- .../RecursionLimitReachedExceptionFactory.php | 4 +- .../ResolverNotFoundExceptionFactory.php | 12 +- ...GenerationLimitReachedExceptionFactory.php | 4 +- ...eValueDuringGenerationExceptionFactory.php | 2 +- .../UnresolvableValueExceptionFactory.php | 44 +- .../InvalidArgumentExceptionFactory.php | 86 +-- .../Exception/LogicExceptionFactory.php | 10 +- .../NoValueForCurrentExceptionFactory.php | 4 +- .../ObjectNotFoundExceptionFactory.php | 4 +- .../ParameterNotFoundExceptionFactory.php | 8 +- .../Parser/ParseExceptionFactory.php | 22 +- .../NoSuchPropertyExceptionFactory.php | 4 +- src/deep_clone.php | 1 + .../CheckBundleDependenciesPassTest.php | 1 + .../DependencyInjection/ConfigurationTest.php | 43 +- .../DynamicServicesConfigurationTest.php | 17 +- .../Lexer/LexerIntegrationTest.php | 1 + .../Parser/ParserIntegrationTest.php | 1 + .../ParameterResolverIntegrationTest.php | 1 + .../Symfony/Loader/LoaderIntegrationTest.php | 9 +- tests/DeepCloneTest.php | 18 +- tests/Definition/Fixture/FixtureIdTest.php | 5 +- .../Definition/Fixture/SimpleFixtureTest.php | 35 +- .../Fixture/SimpleFixtureWithFlagsTest.php | 25 +- .../Fixture/TemplatingFixtureTest.php | 32 +- tests/Definition/Fixture/TemplatingTest.php | 33 +- .../Definition/Flag/ConfiguratorFlagTest.php | 5 +- tests/Definition/Flag/ExtendFlagTest.php | 7 +- tests/Definition/Flag/OptionalFlagTest.php | 17 +- tests/Definition/Flag/TemplateFlagTest.php | 5 +- tests/Definition/Flag/UniqueFlagTest.php | 5 +- tests/Definition/FlagBagTest.php | 125 ++-- .../MethodCall/ConfiguratorMethodCallTest.php | 33 +- .../MethodCallWithReferenceTest.php | 65 +- .../MethodCall/NoMethodCallTest.php | 5 +- .../MethodCall/OptionalMethodCallTest.php | 65 +- .../MethodCall/SimpleMethodCallTest.php | 63 +- tests/Definition/MethodCallBagTest.php | 51 +- .../Definition/Object/CompleteObjectTest.php | 29 +- tests/Definition/Object/SimpleObjectTest.php | 15 +- tests/Definition/PropertyBagTest.php | 48 +- tests/Definition/PropertyTest.php | 15 +- tests/Definition/RangeNameTest.php | 13 +- .../ServiceReference/FixtureReferenceTest.php | 7 +- .../InstantiatedReferenceTest.php | 9 +- .../ServiceReference/StaticReferenceTest.php | 9 +- tests/Definition/SpecificationBagTest.php | 67 +- tests/Definition/Value/ArrayValueTest.php | 15 +- .../Value/DynamicArrayValueTest.php | 61 +- tests/Definition/Value/EvaluatedValueTest.php | 7 +- .../Value/FixtureMatchReferenceValueTest.php | 15 +- .../Value/FixtureMethodCallValueTest.php | 23 +- .../Value/FixturePropertyValueTest.php | 17 +- .../Value/FixtureReferenceValueTest.php | 41 +- .../Value/FunctionCallValueTest.php | 21 +- tests/Definition/Value/ListValueTest.php | 13 +- tests/Definition/Value/NestedValueTest.php | 11 +- tests/Definition/Value/OptionalValueTest.php | 53 +- tests/Definition/Value/ParameterValueTest.php | 23 +- .../Value/ResolvedFunctionCallValueTest.php | 25 +- tests/Definition/Value/UniqueValueTest.php | 32 +- .../Value/ValueForCurrentValueTest.php | 7 +- tests/Definition/Value/VariableValueTest.php | 7 +- tests/Faker/GeneratorFactoryTest.php | 21 +- tests/Faker/Provider/AliceProviderTest.php | 17 +- tests/FileLocator/DefaultFileLocatorTest.php | 20 +- tests/FixtureBagTest.php | 63 +- tests/FixtureBuilder/BareFixtureSetTest.php | 13 +- .../Chainable/ChainableDenormalizerTest.php | 21 +- .../NullListNameDenormalizerTest.php | 41 +- .../NullRangeNameDenormalizerTest.php | 54 +- .../ReferenceRangeNameDenormalizerTest.php | 83 +-- .../Chainable/SimpleDenormalizerTest.php | 58 +- .../FixtureDenormalizerRegistryTest.php | 35 +- .../Denormalizer/Fixture/Reference.php | 10 +- .../SimpleFixtureBagDenormalizerTest.php | 46 +- .../SimpleArgumentsDenormalizerTest.php | 27 +- .../Calls/CallsWithFlagsDenormalizerTest.php | 89 ++- .../Calls/FunctionDenormalizerTest.php | 24 +- .../ConfiguratorFlagHandlerTest.php | 7 +- .../OptionalFlagHandlerTest.php | 7 +- .../ConstructorDenormalizerTest.php | 10 +- .../Constructor/FactoryDenormalizerTest.php | 40 +- .../LLegacyConstructorDenormalizerTest.php | 18 +- .../SimplePropertyDenormalizerTest.php | 5 +- .../SimpleSpecificationsDenormalizerTest.php | 108 ++-- .../Value/SimpleValueDenormalizerTest.php | 26 +- .../Value/UniqueValueDenormalizerTest.php | 52 +- .../Chainable/ConfiguratorFlagParserTest.php | 5 +- .../Chainable/ExtendFlagParserTest.php | 5 +- .../Chainable/OptionalFlagParserTest.php | 5 +- .../Chainable/TemplateFlagParserTest.php | 5 +- .../Chainable/UniqueFlagParserTest.php | 5 +- .../FlagParser/ElementFlagParserTest.php | 28 +- .../FlagParser/FlagParserRegistryTest.php | 7 +- .../FlagParser/FlagParserTestCase.php | 44 +- .../Denormalizer/FlagParser/Reference.php | 6 +- .../SimpleParameterBagDenormalizerTest.php | 17 +- .../Denormalizer/SimpleDenormalizerTest.php | 17 +- .../Lexer/EmptyValueLexerTest.php | 13 +- .../Lexer/FunctionLexerTest.php | 25 +- .../Lexer/FunctionTokenizerTest.php | 13 +- .../Lexer/GlobalPatternsLexerTest.php | 13 +- .../Lexer/LexerIntegrationTest.php | 36 +- .../Lexer/ReferenceEscaperLexerTest.php | 11 +- .../Lexer/ReferenceLexerTest.php | 13 +- .../Lexer/StringThenReferenceLexerTest.php | 14 +- .../Lexer/SubPatternsLexerTest.php | 23 +- .../LexerParserSynchronizationTest.php | 5 +- .../FunctionFixtureReferenceParserTest.php | 33 +- .../Parser/ParserIntegrationTest.php | 229 +++---- .../Parser/SimpleParserTest.php | 26 +- .../Parser/StringMergerParserTest.php | 27 +- ...AbstractChainableParserAwareParserTest.php | 11 +- .../Chainable/DynamicArrayTokenParserTest.php | 13 +- .../Chainable/EscapedValueTokenParserTest.php | 13 +- .../FixtureListReferenceTokenParserTest.php | 11 +- .../FixtureMethodReferenceTokenParserTest.php | 24 +- .../FixtureRangeReferenceTokenParserTest.php | 14 +- .../Chainable/IdentityTokenParserTest.php | 23 +- .../MethodReferenceTokenParserTest.php | 29 +- .../Chainable/OptionalTokenParserTest.php | 13 +- .../Chainable/ParameterTokenParserTest.php | 21 +- .../PropertyReferenceTokenParserTest.php | 11 +- .../SimpleReferenceTokenParserTest.php | 21 +- .../Chainable/StringArrayTokenParserTest.php | 25 +- .../Chainable/StringTokenParserTest.php | 11 +- .../Chainable/VariableTokenParserTest.php | 21 +- .../TokenParser/TokenParserRegistryTest.php | 29 +- .../ExpressionLanguage/TokenTest.php | 21 +- .../ExpressionLanguage/TokenTypeTest.php | 11 +- tests/FixtureBuilder/SimpleBuilderTest.php | 9 +- tests/FixtureSetTest.php | 9 +- tests/Generator/Caller/SimpleCallerTest.php | 130 ++-- tests/Generator/DoublePassGeneratorTest.php | 31 +- tests/Generator/GenerationContextTest.php | 53 +- .../SymfonyPropertyAccessorHydratorTest.php | 66 +- .../AbstractChainableInstantiatorTest.php | 23 +- .../NoCallerMethodCallInstantiatorTest.php | 35 +- .../NoMethodCallInstantiatorTest.php | 29 +- .../NullConstructorInstantiatorTest.php | 21 +- .../StaticFactoryInstantiatorTest.php | 79 +-- .../ExistingInstanceInstantiatorTest.php | 28 +- .../Instantiator/InstantiatorRegistryTest.php | 34 +- .../Instantiator/InstantiatorResolverTest.php | 61 +- .../Generator/NamedArgumentsResolverTest.php | 21 +- .../CompleteObjectGeneratorTest.php | 183 +++--- .../SimpleObjectGeneratorTest.php | 30 +- tests/Generator/ResolvedFixtureSetTest.php | 31 +- .../ResolvedValueWithFixtureSetTest.php | 5 +- .../TemplateFixtureBagResolverTest.php | 171 +++-- .../Fixture/TemplateFixtureResolverTest.php | 3 +- .../Fixture/TemplatingFixtureBagTest.php | 53 +- .../RemoveConflictingObjectsResolverTest.php | 16 +- .../SimpleFixtureSetResolverTest.php | 19 +- .../Chainable/ArrayParameterResolverTest.php | 86 ++- .../RecursiveParameterResolverTest.php | 130 ++-- .../Chainable/StringParameterResolverTest.php | 87 ++- .../ParameterResolverRegistryTest.php | 17 +- ...tingParametersParameterBagResolverTest.php | 25 +- .../SimpleParameterBagResolverTest.php | 49 +- .../Parameter/StaticParameterResolverTest.php | 23 +- .../ParameterResolverIntegrationTest.php | 43 +- .../Resolver/ResolvingContextTest.php | 31 +- .../Generator/Resolver/SimpleResolverTest.php | 5 +- .../Resolver/UniqueValuesPoolTest.php | 32 +- .../DynamicArrayValueResolverTest.php | 48 +- .../Chainable/EvaluatedValueResolverTest.php | 65 +- ...akerFunctionCallValueResolverValueTest.php | 15 +- ...FixtureMethodCallReferenceResolverTest.php | 74 +-- .../FixturePropertyReferenceResolverTest.php | 80 ++- .../FixtureReferenceResolverTest.php | 61 +- .../FixtureWildcardReferenceResolverTest.php | 52 +- .../FunctionCallArgumentResolverTest.php | 51 +- .../Value/Chainable/ListValueResolverTest.php | 31 +- .../Chainable/OptionalValueResolverTest.php | 19 +- .../Chainable/ParameterValueResolverTest.php | 13 +- .../PhpFunctionCallValueResolverTest.php | 33 +- .../SelfFixtureReferenceResolverTest.php | 60 +- .../Chainable/UniqueValueResolverTest.php | 68 +- ...resolvedFixtureReferenceIdResolverTest.php | 119 ++-- .../Chainable/VariableValueResolverTest.php | 13 +- .../Value/ValueResolverRegistryTest.php | 15 +- tests/IsAServiceTraitTest.php | 21 +- tests/Loader/LoaderIntegrationTest.php | 608 +++++++++--------- tests/Loader/NativeLoaderTest.php | 3 +- tests/Loader/SimpleDataLoaderTest.php | 7 +- tests/Loader/SimpleFileLoaderTest.php | 7 +- tests/Loader/SimpleFilesLoaderTest.php | 31 +- tests/ObjectBagTest.php | 87 +-- tests/ObjectSetTest.php | 13 +- tests/ParameterBagTest.php | 57 +- tests/ParameterTest.php | 16 +- tests/Parser/Chainable/JsonParserTest.php | 31 +- tests/Parser/Chainable/PhpParserTest.php | 31 +- tests/Parser/Chainable/YamlParserTest.php | 89 +-- tests/Parser/FilesReference.php | 2 +- .../DefaultIncludeProcessorTest.php | 29 +- .../IncludeDataMergerTest.php | 17 +- tests/Parser/ParserRegistryTest.php | 15 +- tests/Parser/RuntimeCacheParserTest.php | 54 +- .../ReflectionPropertyAccessorTest.php | 102 ++- .../StdPropertyAccessorTest.php | 45 +- tests/Throwable/BuildThrowableTest.php | 3 +- .../DenormalizationThrowableTest.php | 3 +- .../Throwable/Error/TypeErrorFactoryTest.php | 194 +++--- .../BadMethodCallExceptionFactoryTest.php | 9 +- .../FileLocator/FileNotFoundExceptionTest.php | 21 +- .../DenormalizerExceptionFactoryTest.php | 49 +- .../DenormalizerNotFoundExceptionTest.php | 7 +- .../FlagParserExceptionFactoryTest.php | 17 +- .../FlagParserNotFoundExceptionTest.php | 7 +- .../InvalidScopeExceptionTest.php | 7 +- .../UnexpectedValueExceptionTest.php | 7 +- ...ExpressionLanguageExceptionFactoryTest.php | 50 +- .../ExpressionLanguage/LexExceptionTest.php | 7 +- .../MalformedFunctionExceptionTest.php | 7 +- .../ExpressionLanguage/ParseExceptionTest.php | 7 +- .../ParserNotFoundExceptionTest.php | 7 +- .../FixtureNotFoundExceptionFactoryTest.php | 9 +- .../FixtureNotFoundExceptionTest.php | 5 +- .../CallProcessorExceptionFactoryTest.php | 9 +- .../Caller/ProcessorNotFoundExceptionTest.php | 7 +- .../Context/CachedValueNotFoundTest.php | 9 +- .../HydrationExceptionFactoryTest.php | 60 +- .../Hydrator/HydrationExceptionTest.php | 7 +- .../InaccessiblePropertyExceptionTest.php | 7 +- .../Hydrator/InvalidArgumentExceptionTest.php | 7 +- .../Hydrator/NoSuchPropertyExceptionTest.php | 7 +- .../InstantiationExceptionFactoryTest.php | 59 +- .../InstantiationExceptionTest.php | 7 +- .../InstantiatorNotFoundExceptionTest.php | 7 +- ...tGeneratorNotFoundExceptionFactoryTest.php | 9 +- .../ObjectGeneratorNotFoundExceptionTest.php | 7 +- .../CircularReferenceExceptionFactoryTest.php | 9 +- .../CircularReferenceExceptionTest.php | 7 +- .../FixtureNotFoundExceptionFactoryTest.php | 9 +- .../Resolver/FixtureNotFoundExceptionTest.php | 7 +- .../NoSuchMethodExceptionFactoryTest.php | 20 +- .../NoSuchPropertyExceptionFactoryTest.php | 18 +- .../Resolver/NoSuchPropertyExceptionTest.php | 9 +- ...ursionLimitReachedExceptionFactoryTest.php | 9 +- .../RecursionLimitReachedExceptionTest.php | 7 +- .../ResolverNotFoundExceptionFactoryTest.php | 25 +- .../ResolverNotFoundExceptionTest.php | 7 +- ...rationLimitReachedExceptionFactoryTest.php | 11 +- ...lueGenerationLimitReachedExceptionTest.php | 7 +- ...ueDuringGenerationExceptionFactoryTest.php | 9 +- ...ableValueDuringGenerationExceptionTest.php | 9 +- .../UnresolvableValueExceptionFactoryTest.php | 131 ++-- .../UnresolvableValueExceptionTest.php | 7 +- .../InvalidArgumentExceptionFactoryTest.php | 186 +++--- .../Exception/LogicExceptionFactoryTest.php | 25 +- .../NoValueForCurrentExceptionFactoryTest.php | 9 +- .../NoValueForCurrentExceptionTest.php | 5 +- .../ObjectNotFoundExceptionFactoryTest.php | 9 +- .../Exception/ObjectNotFoundExceptionTest.php | 5 +- .../ParameterNotFoundExceptionFactoryTest.php | 21 +- .../ParameterNotFoundExceptionTest.php | 5 +- .../Parser/ParseExceptionFactoryTest.php | 43 +- .../Parser/ParserNotFoundExceptionTest.php | 7 +- .../Parser/UnparsableFileExceptionTest.php | 7 +- .../NoSuchPropertyExceptionFactoryTest.php | 9 +- .../ExpressionLanguageParseThrowableTest.php | 3 +- tests/Throwable/GenerationThrowableTest.php | 3 +- .../Throwable/InstantiationThrowableTest.php | 3 +- tests/Throwable/ParseThrowableTest.php | 3 +- tests/Throwable/ResolutionThrowableTest.php | 3 +- vendor-bin/php-cs-fixer/composer.json | 3 +- 575 files changed, 5382 insertions(+), 5484 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 477e3a641..3559091ce 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,7 +11,7 @@ declare(strict_types=1); -use PhpCsFixer\Config; +use Fidry\PhpCsFixerConfig\FidryConfig; use PhpCsFixer\Finder; $finder = Finder::create() @@ -28,77 +28,26 @@ 'fixtures/Parser/files/php', 'Bridge/Symfony/Application/var', 'fixtures/Bridge/Symfony/Application/cache', - ]) -; + ]); -return (new Config()) - ->setRiskyAllowed(true) - ->setRules([ - '@PSR2' => true, - 'blank_line_after_opening_tag' => true, - 'blank_line_before_statement' => true, - 'cast_spaces' => true, - 'combine_consecutive_unsets' => true, - 'declare_equal_normalize' => true, - 'declare_strict_types' => true, - 'heredoc_to_nowdoc' => true, - 'include' => true, - 'header_comment' => [ - 'location' => 'after_open', - 'header' => <<<'LICENSE' - This file is part of the Alice package. - - (c) Nelmio - - For the full copyright and license information, please view the LICENSE - file that was distributed with this source code. - LICENSE, - ], - 'lowercase_cast' => true, - 'general_phpdoc_annotation_remove' => true, - 'global_namespace_import' => [ - 'import_classes' => true, - 'import_constants' => true, - 'import_functions' => true, - ], - 'modernize_types_casting' => true, - 'native_function_casing' => true, - 'new_with_braces' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_short_bool_cast' => true, - 'no_spaces_around_offset' => true, - 'no_superfluous_phpdoc_tags' => [ - 'remove_inheritdoc' => true, - ], - 'no_unused_imports' => true, - 'ordered_imports' => true, - 'phpdoc_no_empty_return' => true, - 'phpdoc_order' => true, - 'phpdoc_order_by_value' => true, - 'phpdoc_scalar' => true, - 'phpdoc_separation' => true, - 'phpdoc_trim' => true, - 'php_unit_construct' => true, - 'php_unit_dedicate_assert' => true, - 'php_unit_dedicate_assert_internal_type' => true, - 'php_unit_expectation' => true, - 'php_unit_fqcn_annotation' => true, - 'php_unit_namespaced' => true, - 'php_unit_test_case_static_method_calls' => true, - 'php_unit_test_class_requires_covers' => true, - 'single_quote' => true, - 'space_after_semicolon' => true, - 'standardize_not_equals' => true, - 'trim_array_spaces' => true, - 'void_return' => true, - 'whitespace_after_comma_in_array' => true, - ]) - ->setFinder($finder) -; +$config = new FidryConfig( + <<<'EOF' + This file is part of the Alice package. + + (c) Nelmio + + For the full copyright and license information, please view the LICENSE + file that was distributed with this source code. + EOF, + 74_000, +); + +$config->addRules([ + 'php_unit_method_casing' => ['case' => 'camel_case'], + 'phpdoc_no_empty_return' => false, +]); + +$config->setFinder($finder); +$config->setCacheFile(__DIR__.'/dist/.php-cs-fixer.cache'); + +return $config; diff --git a/fixtures/Bridge/Symfony/Application/AppKernel.php b/fixtures/Bridge/Symfony/Application/AppKernel.php index 2321f0176..ec94432bf 100644 --- a/fixtures/Bridge/Symfony/Application/AppKernel.php +++ b/fixtures/Bridge/Symfony/Application/AppKernel.php @@ -27,12 +27,12 @@ class AppKernel extends Kernel * @var string|null */ private $config; - + public function __construct($environment, $debug) { parent::__construct($environment, $debug); } - + public function registerBundles(): array { return [ @@ -40,12 +40,12 @@ public function registerBundles(): array new NelmioAliceBundle(), ]; } - + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load($this->config ?? __DIR__.'/config.yml'); } - + public function build(ContainerBuilder $container): void { $container->addCompilerPass(new class() implements CompilerPassInterface { diff --git a/fixtures/Definition/FakeMethodCall.php b/fixtures/Definition/FakeMethodCall.php index 405488092..e003fb0bf 100644 --- a/fixtures/Definition/FakeMethodCall.php +++ b/fixtures/Definition/FakeMethodCall.php @@ -18,27 +18,27 @@ class FakeMethodCall implements MethodCallInterface { use NotCallableTrait; - - public function withArguments(array $arguments = null): void + + public function withArguments(?array $arguments = null): void { $this->__call(__METHOD__, func_get_args()); } - + public function getCaller(): void { $this->__call(__METHOD__, func_get_args()); } - + public function getMethod(): string { $this->__call(__METHOD__, func_get_args()); } - + public function getArguments(): array { $this->__call(__METHOD__, func_get_args()); } - + public function __toString(): string { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Definition/Fixture/DummyFixture.php b/fixtures/Definition/Fixture/DummyFixture.php index 86aeed613..6cfb9246a 100644 --- a/fixtures/Definition/Fixture/DummyFixture.php +++ b/fixtures/Definition/Fixture/DummyFixture.php @@ -30,27 +30,27 @@ public function __construct(string $id) { $this->id = $id; } - + public function getId(): string { return $this->id; } - + public function getClassName(): string { $this->__call(__METHOD__, func_get_args()); } - + public function getSpecs(): SpecificationBag { $this->__call(__METHOD__, func_get_args()); } - + public function getValueForCurrent(): void { $this->__call(__METHOD__, func_get_args()); } - + public function withSpecs(SpecificationBag $specs): void { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Definition/Fixture/FakeFixture.php b/fixtures/Definition/Fixture/FakeFixture.php index eec38e1b6..0b7eda005 100644 --- a/fixtures/Definition/Fixture/FakeFixture.php +++ b/fixtures/Definition/Fixture/FakeFixture.php @@ -20,27 +20,27 @@ class FakeFixture implements FixtureInterface { use NotCallableTrait; - + public function getId(): string { $this->__call(__METHOD__, func_get_args()); } - + public function getClassName(): string { $this->__call(__METHOD__, func_get_args()); } - + public function getSpecs(): SpecificationBag { $this->__call(__METHOD__, func_get_args()); } - + public function getValueForCurrent(): void { $this->__call(__METHOD__, func_get_args()); } - + public function withSpecs(SpecificationBag $specs): void { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Definition/Fixture/MutableFixture.php b/fixtures/Definition/Fixture/MutableFixture.php index 184627bf7..bf61402ce 100644 --- a/fixtures/Definition/Fixture/MutableFixture.php +++ b/fixtures/Definition/Fixture/MutableFixture.php @@ -42,17 +42,17 @@ public function __construct(string $id, string $className, SpecificationBag $spe $this->className = $className; $this->specs = $specs; } - + public function getId(): string { return $this->id; } - + public function getClassName(): string { return $this->className; } - + public function getSpecs(): SpecificationBag { return $this->specs; @@ -62,12 +62,12 @@ public function setSpecs(SpecificationBag $specs): void { $this->specs = $specs; } - + public function getValueForCurrent(): void { $this->__call(__METHOD__, func_get_args()); } - + public function withSpecs(SpecificationBag $specs): void { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Definition/Flag/ElementFlag.php b/fixtures/Definition/Flag/ElementFlag.php index 60b35c53e..02ab67649 100644 --- a/fixtures/Definition/Flag/ElementFlag.php +++ b/fixtures/Definition/Flag/ElementFlag.php @@ -26,7 +26,7 @@ public function __construct(string $element) { $this->element = $element; } - + public function __toString(): string { return $this->element; diff --git a/fixtures/Definition/Flag/ElementWithToStringFlag.php b/fixtures/Definition/Flag/ElementWithToStringFlag.php index 641dc5004..529e0289c 100644 --- a/fixtures/Definition/Flag/ElementWithToStringFlag.php +++ b/fixtures/Definition/Flag/ElementWithToStringFlag.php @@ -32,7 +32,7 @@ public function __construct(string $element, string $toString) $this->element = $element; $this->toString = $toString; } - + public function __toString(): string { return $this->toString; diff --git a/fixtures/Definition/MethodCall/DummyMethodCall.php b/fixtures/Definition/MethodCall/DummyMethodCall.php index 30e327e92..58025bdd4 100644 --- a/fixtures/Definition/MethodCall/DummyMethodCall.php +++ b/fixtures/Definition/MethodCall/DummyMethodCall.php @@ -35,27 +35,27 @@ public function __construct(string $toString) $this->token = uniqid(); $this->toString = $toString; } - - public function withArguments(array $arguments = null): self + + public function withArguments(?array $arguments = null): self { $this->__call(__METHOD__, func_get_args()); } - + public function getCaller(): void { $this->__call(__METHOD__, func_get_args()); } - + public function getMethod(): string { $this->__call(__METHOD__, func_get_args()); } - + public function getArguments(): array { $this->__call(__METHOD__, func_get_args()); } - + public function __toString(): string { return $this->toString; diff --git a/fixtures/Definition/MethodCall/IdentityFactory.php b/fixtures/Definition/MethodCall/IdentityFactory.php index 061529fea..0b20b5aad 100644 --- a/fixtures/Definition/MethodCall/IdentityFactory.php +++ b/fixtures/Definition/MethodCall/IdentityFactory.php @@ -22,7 +22,7 @@ public static function create(string $expression): FunctionCallValue { return new FunctionCallValue( 'identity', - [new EvaluatedValue($expression)] + [new EvaluatedValue($expression)], ); } } diff --git a/fixtures/Definition/MethodCall/MutableMethodCall.php b/fixtures/Definition/MethodCall/MutableMethodCall.php index 8c9c63eaf..b1bd117e7 100644 --- a/fixtures/Definition/MethodCall/MutableMethodCall.php +++ b/fixtures/Definition/MethodCall/MutableMethodCall.php @@ -26,7 +26,6 @@ class MutableMethodCall implements MethodCallInterface */ private $caller; - private $method; /** @@ -34,28 +33,28 @@ class MutableMethodCall implements MethodCallInterface */ private $arguments; - public function __construct(ServiceReferenceInterface $caller = null, $method, array $arguments = null) + public function __construct(?ServiceReferenceInterface $caller = null, $method, ?array $arguments = null) { $this->caller = $caller; $this->method = $method; $this->arguments = $arguments; } - - public function withArguments(array $arguments = null): void + + public function withArguments(?array $arguments = null): void { $this->__call(__METHOD__, func_get_args()); } - + public function getCaller() { return $this->caller; } - public function setCaller(ServiceReferenceInterface $caller = null): void + public function setCaller(?ServiceReferenceInterface $caller = null): void { $this->caller = $caller; } - + public function getMethod(): string { return $this->method; @@ -65,17 +64,17 @@ public function setMethod($method): void { $this->method = $method; } - + public function getArguments() { return $this->arguments; } - public function setArguments(array $arguments = null): void + public function setArguments(?array $arguments = null): void { $this->arguments = $arguments; } - + public function __toString(): string { return 'mutable_method_call'; diff --git a/fixtures/Definition/Object/ImmutableByCloneObject.php b/fixtures/Definition/Object/ImmutableByCloneObject.php index 68c4869c8..8d1528457 100644 --- a/fixtures/Definition/Object/ImmutableByCloneObject.php +++ b/fixtures/Definition/Object/ImmutableByCloneObject.php @@ -26,23 +26,23 @@ class ImmutableByCloneObject implements ObjectInterface * @var object */ private $instance; - + public function __construct(string $id, object $instance) { $this->id = $id; $this->instance = $instance; } - + public function getId(): string { return $this->id; } - + public function getInstance(): object { return $this->instance; } - + public function withInstance(object $newInstance): static { return new self($this->id, $newInstance); diff --git a/fixtures/Definition/Object/ImmutableObject.php b/fixtures/Definition/Object/ImmutableObject.php index bb26a0fe9..d750fe29e 100644 --- a/fixtures/Definition/Object/ImmutableObject.php +++ b/fixtures/Definition/Object/ImmutableObject.php @@ -13,8 +13,8 @@ namespace Nelmio\Alice\Definition\Object; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\ObjectInterface; +use function Nelmio\Alice\deep_clone; class ImmutableObject implements ObjectInterface { @@ -36,17 +36,17 @@ public function __construct(string $id, $instance) $this->id = $id; $this->instance = deep_clone($instance); } - + public function getId(): string { return $this->id; } - + public function getInstance(): object { return deep_clone($this->instance); } - + public function withInstance($newInstance): static { return new self($this->id, $newInstance); diff --git a/fixtures/Definition/ServiceReference/FakeReference.php b/fixtures/Definition/ServiceReference/FakeReference.php index 7a0cc9947..ae49d292b 100644 --- a/fixtures/Definition/ServiceReference/FakeReference.php +++ b/fixtures/Definition/ServiceReference/FakeReference.php @@ -19,7 +19,7 @@ class FakeReference implements ServiceReferenceInterface { use NotCallableTrait; - + public function getId(): string { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Definition/ServiceReference/MutableReference.php b/fixtures/Definition/ServiceReference/MutableReference.php index 115c3766b..31ad59f53 100644 --- a/fixtures/Definition/ServiceReference/MutableReference.php +++ b/fixtures/Definition/ServiceReference/MutableReference.php @@ -23,7 +23,7 @@ public function setId(string $id): void { $this->id = $id; } - + public function getId(): string { return $this->id; diff --git a/fixtures/Definition/SpecificationBagFactory.php b/fixtures/Definition/SpecificationBagFactory.php index e4997d5c2..59c5cb365 100644 --- a/fixtures/Definition/SpecificationBagFactory.php +++ b/fixtures/Definition/SpecificationBagFactory.php @@ -16,14 +16,14 @@ class SpecificationBagFactory { public static function create( - MethodCallInterface $constructor = null, - PropertyBag $properties = null, - MethodCallBag $calls = null + ?MethodCallInterface $constructor = null, + ?PropertyBag $properties = null, + ?MethodCallBag $calls = null ): SpecificationBag { return new SpecificationBag( $constructor, $properties ?? new PropertyBag(), - $calls ?? new MethodCallBag() + $calls ?? new MethodCallBag(), ); } } diff --git a/fixtures/Definition/Value/DummyValue.php b/fixtures/Definition/Value/DummyValue.php index b261d948c..925543c51 100644 --- a/fixtures/Definition/Value/DummyValue.php +++ b/fixtures/Definition/Value/DummyValue.php @@ -26,12 +26,12 @@ public function __construct(string $value) { $this->value = $value; } - + public function getValue() { return $this->value; } - + public function __toString(): string { return $this->value; diff --git a/fixtures/Definition/Value/FakeObject.php b/fixtures/Definition/Value/FakeObject.php index 06db80df1..1741a7833 100644 --- a/fixtures/Definition/Value/FakeObject.php +++ b/fixtures/Definition/Value/FakeObject.php @@ -19,17 +19,17 @@ class FakeObject implements ObjectInterface { use NotCallableTrait; - + public function getId(): string { $this->__call(__METHOD__, func_get_args()); } - + public function getInstance(): object { $this->__call(__METHOD__, func_get_args()); } - + public function withInstance($newInstance): static { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Definition/Value/FakeValue.php b/fixtures/Definition/Value/FakeValue.php index a6a2e9bd8..f04384a3c 100644 --- a/fixtures/Definition/Value/FakeValue.php +++ b/fixtures/Definition/Value/FakeValue.php @@ -19,12 +19,12 @@ class FakeValue implements ValueInterface { use NotCallableTrait; - + public function getValue(): void { $this->__call(__METHOD__, func_get_args()); } - + public function __toString(): string { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Definition/Value/MutableValue.php b/fixtures/Definition/Value/MutableValue.php index 5c7ce48a4..6108066f7 100644 --- a/fixtures/Definition/Value/MutableValue.php +++ b/fixtures/Definition/Value/MutableValue.php @@ -23,7 +23,7 @@ public function __construct($value) { $this->value = $value; } - + public function getValue() { return $this->value; @@ -33,7 +33,7 @@ public function setValue($value): void { $this->value = $value; } - + public function __toString(): string { return 'mutable'; diff --git a/fixtures/Entity/Caller/Dummy.php b/fixtures/Entity/Caller/Dummy.php index 865847b6a..252a733c8 100644 --- a/fixtures/Entity/Caller/Dummy.php +++ b/fixtures/Entity/Caller/Dummy.php @@ -26,7 +26,7 @@ public function setTitle(string $title): void public function addFoo(): void { - $this->counter++; + ++$this->counter; } public function setRelatedDummy(self $related): void @@ -34,7 +34,7 @@ public function setRelatedDummy(self $related): void $this->related = $related; } - public static function create($title, $counter, self $related = null): self + public static function create($title, $counter, ?self $related = null): self { $obj = new self(); $obj->title = $title; diff --git a/fixtures/Entity/Caller/StaticService.php b/fixtures/Entity/Caller/StaticService.php index b1408dd76..aef4a72ce 100644 --- a/fixtures/Entity/Caller/StaticService.php +++ b/fixtures/Entity/Caller/StaticService.php @@ -24,7 +24,7 @@ static function (DummyWithStaticFunction $dummy) use ($title): void { $dummy->title = $title; }, null, - DummyWithStaticFunction::class + DummyWithStaticFunction::class, )($instance); } } diff --git a/fixtures/Entity/StdClassFactory.php b/fixtures/Entity/StdClassFactory.php index 7020a4ee7..4cf37b45b 100644 --- a/fixtures/Entity/StdClassFactory.php +++ b/fixtures/Entity/StdClassFactory.php @@ -32,7 +32,7 @@ public static function create(array $attributes = []): stdClass { $instance = new stdClass(); foreach ($attributes as $attribute => $value) { - $instance->$attribute = $value; + $instance->{$attribute} = $value; } return $instance; diff --git a/fixtures/FileLocator/DummyFileLocator.php b/fixtures/FileLocator/DummyFileLocator.php index b3df011aa..b53461993 100644 --- a/fixtures/FileLocator/DummyFileLocator.php +++ b/fixtures/FileLocator/DummyFileLocator.php @@ -20,7 +20,7 @@ final class DummyFileLocator implements FileLocatorInterface { use NotCallableTrait; - public function locate(string $name, string $currentPath = null): string + public function locate(string $name, ?string $currentPath = null): string { $this->__call(__METHOD__, func_get_args()); } diff --git a/fixtures/FileLocator/FakeFileLocator.php b/fixtures/FileLocator/FakeFileLocator.php index 24f55fb8c..1ff26cdf5 100644 --- a/fixtures/FileLocator/FakeFileLocator.php +++ b/fixtures/FileLocator/FakeFileLocator.php @@ -19,8 +19,8 @@ class FakeFileLocator implements FileLocatorInterface { use NotCallableTrait; - - public function locate(string $name, string $currentPath = null): string + + public function locate(string $name, ?string $currentPath = null): string { $this->__call(__FUNCTION__, func_get_args()); } diff --git a/fixtures/FixtureBuilder/Denormalizer/FakeDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/FakeDenormalizer.php index ff1ae914b..2dc328349 100644 --- a/fixtures/FixtureBuilder/Denormalizer/FakeDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/FakeDenormalizer.php @@ -20,7 +20,7 @@ class FakeDenormalizer implements DenormalizerInterface { use NotCallableTrait; - + public function denormalize(array $data): BareFixtureSet { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/DummyChainableParserAwareDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/DummyChainableParserAwareDenormalizer.php index 22889f75c..b21ab0d8f 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/DummyChainableParserAwareDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/DummyChainableParserAwareDenormalizer.php @@ -30,7 +30,7 @@ class DummyChainableParserAwareDenormalizer implements ChainableFixtureDenormali * @var FlagParserInterface|null */ public $parser; - + /** * @var FlagParserAwareInterface */ @@ -41,12 +41,12 @@ public function __construct(ChainableFixtureDenormalizerInterface $decoratedDeno $this->decoratedDenormalizer = $decoratedDenormalizer; $this->decoratedFlagAware = $decoratedFlagAware; } - + public function canDenormalize(string $reference): bool { return $this->decoratedDenormalizer->canDenormalize($reference); } - + public function denormalize( FixtureBag $builtFixtures, string $className, @@ -56,16 +56,16 @@ public function denormalize( ): FixtureBag { return $this->decoratedDenormalizer->denormalize($builtFixtures, $className, $fixtureId, $specs, $flags); } - + public function withFlagParser(FlagParserInterface $parser) { $this->decoratedFlagAware->withFlagParser($parser); $clone = clone $this; $clone->parser = $parser; - + return $clone; } - + public function __clone() { $this->decoratedDenormalizer = clone $this->decoratedDenormalizer; diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizer.php index 9a4ef1523..94a60959e 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizer.php @@ -21,12 +21,12 @@ class FakeChainableDenormalizer implements ChainableFixtureDenormalizerInterface { use NotCallableTrait; - + public function canDenormalize(string $reference): bool { $this->__call(__FUNCTION__, func_get_args()); } - + public function denormalize( FixtureBag $builtFixtures, string $className, diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizerAwareDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizerAwareDenormalizer.php index 0abe4871e..759126d5a 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizerAwareDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/Chainable/FakeChainableDenormalizerAwareDenormalizer.php @@ -38,12 +38,12 @@ public function withFixtureDenormalizer(FixtureDenormalizerInterface $denormaliz return $this; } - + public function canDenormalize(string $reference): bool { $this->__call(__FUNCTION__, func_get_args()); } - + public function denormalize( FixtureBag $builtFixtures, string $className, diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureBagDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureBagDenormalizer.php index a68f24846..ef18e0226 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureBagDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureBagDenormalizer.php @@ -20,7 +20,7 @@ class FakeFixtureBagDenormalizer implements FixtureBagDenormalizerInterface { use NotCallableTrait; - + public function denormalize(array $data): FixtureBag { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureDenormalizer.php index 5cd73bcba..a4155f4cc 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/FakeFixtureDenormalizer.php @@ -20,7 +20,7 @@ class FakeFixtureDenormalizer implements FixtureDenormalizerInterface { use NotCallableTrait; - + public function denormalize( FixtureBag $builtFixtures, string $className, diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/FakeArgumentsDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/FakeArgumentsDenormalizer.php index f013de947..f2cfb8c62 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/FakeArgumentsDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/FakeArgumentsDenormalizer.php @@ -21,7 +21,7 @@ class FakeArgumentsDenormalizer implements ArgumentsDenormalizerInterface { use NotCallableTrait; - + public function denormalize(FixtureInterface $scope, FlagParserInterface $parser, array $unparsedArguments): array { $this->__call(__FUNCTION__, func_get_args()); diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FakeCallsDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FakeCallsDenormalizer.php index dd4ceebf2..2e081e8da 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FakeCallsDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FakeCallsDenormalizer.php @@ -22,7 +22,7 @@ class FakeCallsDenormalizer implements CallsDenormalizerInterface { use NotCallableTrait; - + public function denormalize( FixtureInterface $scope, FlagParserInterface $parser, diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FakeConstructorDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FakeConstructorDenormalizer.php index 8a17cf6da..ff941d428 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FakeConstructorDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FakeConstructorDenormalizer.php @@ -22,7 +22,7 @@ class FakeConstructorDenormalizer implements ConstructorDenormalizerInterface { use NotCallableTrait; - + public function denormalize( FixtureInterface $scope, FlagParserInterface $parser, diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/DummySpecificationBagDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/DummySpecificationBagDenormalizer.php index 7c4374728..77f733f2d 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/DummySpecificationBagDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/DummySpecificationBagDenormalizer.php @@ -23,7 +23,7 @@ class DummySpecificationBagDenormalizer implements SpecificationsDenormalizerInterface { use NotCallableTrait; - + public function denormalize( FixtureInterface $fixture, FlagParserInterface $parser, diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/FakeSpecificationBagDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/FakeSpecificationBagDenormalizer.php index b14f3bf95..0562b5cfc 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/FakeSpecificationBagDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/FakeSpecificationBagDenormalizer.php @@ -22,7 +22,7 @@ class FakeSpecificationBagDenormalizer implements SpecificationsDenormalizerInterface { use NotCallableTrait; - + public function denormalize( FixtureInterface $fixture, FlagParserInterface $parser, diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/FakePropertyDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/FakePropertyDenormalizer.php index 0dbc72fcc..f0269a3fa 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/FakePropertyDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/FakePropertyDenormalizer.php @@ -22,7 +22,7 @@ class FakePropertyDenormalizer implements PropertyDenormalizerInterface { use NotCallableTrait; - + public function denormalize(FixtureInterface $scope, string $name, $value, FlagBag $flags): Property { $this->__call(__FUNCTION__, func_get_args()); diff --git a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/FakeValueDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/FakeValueDenormalizer.php index 04a6c18ac..8d0db1bd2 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/FakeValueDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/FakeValueDenormalizer.php @@ -21,8 +21,8 @@ class FakeValueDenormalizer implements ValueDenormalizerInterface { use NotCallableTrait; - - public function denormalize(FixtureInterface $scope, FlagBag $flags = null, $value): void + + public function denormalize(FixtureInterface $scope, ?FlagBag $flags = null, $value): void { $this->__call(__FUNCTION__, func_get_args()); } diff --git a/fixtures/FixtureBuilder/Denormalizer/FlagParser/Chainable/FakeChainableFlagParser.php b/fixtures/FixtureBuilder/Denormalizer/FlagParser/Chainable/FakeChainableFlagParser.php index cc8dde47f..c02980dc3 100644 --- a/fixtures/FixtureBuilder/Denormalizer/FlagParser/Chainable/FakeChainableFlagParser.php +++ b/fixtures/FixtureBuilder/Denormalizer/FlagParser/Chainable/FakeChainableFlagParser.php @@ -20,12 +20,12 @@ class FakeChainableFlagParser implements ChainableFlagParserInterface { use NotCallableTrait; - + public function canParse(string $element): bool { $this->__call(__FUNCTION__, func_get_args()); } - + public function parse(string $element): FlagBag { $this->__call(__FUNCTION__, func_get_args()); diff --git a/fixtures/FixtureBuilder/Denormalizer/FlagParser/DummyFlagParser.php b/fixtures/FixtureBuilder/Denormalizer/FlagParser/DummyFlagParser.php index 78e99b776..176056915 100644 --- a/fixtures/FixtureBuilder/Denormalizer/FlagParser/DummyFlagParser.php +++ b/fixtures/FixtureBuilder/Denormalizer/FlagParser/DummyFlagParser.php @@ -20,7 +20,7 @@ class DummyFlagParser implements FlagParserInterface { use NotCallableTrait; - + public function parse(string $element): FlagBag { return new FlagBag($element); diff --git a/fixtures/FixtureBuilder/Denormalizer/FlagParser/FakeFlagParser.php b/fixtures/FixtureBuilder/Denormalizer/FlagParser/FakeFlagParser.php index d00b451da..f4acb1b51 100644 --- a/fixtures/FixtureBuilder/Denormalizer/FlagParser/FakeFlagParser.php +++ b/fixtures/FixtureBuilder/Denormalizer/FlagParser/FakeFlagParser.php @@ -20,7 +20,7 @@ class FakeFlagParser implements FlagParserInterface { use NotCallableTrait; - + public function parse(string $element): FlagBag { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/Denormalizer/Parameter/FakeParameterBagDenormalizer.php b/fixtures/FixtureBuilder/Denormalizer/Parameter/FakeParameterBagDenormalizer.php index 974db167e..e0e46b267 100644 --- a/fixtures/FixtureBuilder/Denormalizer/Parameter/FakeParameterBagDenormalizer.php +++ b/fixtures/FixtureBuilder/Denormalizer/Parameter/FakeParameterBagDenormalizer.php @@ -20,7 +20,7 @@ class FakeParameterBagDenormalizer implements ParameterBagDenormalizerInterface { use NotCallableTrait; - + public function denormalize(array $data): ParameterBag { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/DummyLexer.php b/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/DummyLexer.php index 276a8a023..435f68d2d 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/DummyLexer.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/DummyLexer.php @@ -19,7 +19,7 @@ class DummyLexer implements LexerInterface { use NotCallableTrait; - + public function lex(string $value): array { return [$value]; diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/FakeLexer.php b/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/FakeLexer.php index cbb947aec..c81f8cf56 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/FakeLexer.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/FakeLexer.php @@ -19,7 +19,7 @@ class FakeLexer implements LexerInterface { use NotCallableTrait; - + public function lex(string $value): array { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/IsolatedSymfonyBuiltInLexer.php b/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/IsolatedSymfonyBuiltInLexer.php index 898326fc4..34ef601ac 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/IsolatedSymfonyBuiltInLexer.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Lexer/IsolatedSymfonyBuiltInLexer.php @@ -22,9 +22,7 @@ public function lex(string $value): array { return KernelIsolatedServiceCall::call( 'nelmio_alice.fixture_builder.expression_language.lexer', - static function (LexerInterface $lexer) use ($value) { - return $lexer->lex($value); - } + static fn (LexerInterface $lexer) => $lexer->lex($value), ); } } diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/FakeParser.php b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/FakeParser.php index 2c31a43c4..112ab58f6 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/FakeParser.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/FakeParser.php @@ -19,7 +19,7 @@ class FakeParser implements ParserInterface { use NotCallableTrait; - + public function parse(string $value): void { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/IsolatedSymfonyBuiltInParser.php b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/IsolatedSymfonyBuiltInParser.php index 1b5ea1af6..7306b7a42 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/IsolatedSymfonyBuiltInParser.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/IsolatedSymfonyBuiltInParser.php @@ -22,9 +22,7 @@ public function parse(string $value) { return KernelIsolatedServiceCall::call( 'nelmio_alice.fixture_builder.expression_language.parser', - static function (ParserInterface $parser) use ($value) { - return $parser->parse($value); - } + static fn (ParserInterface $parser) => $parser->parse($value), ); } } diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DummyChainableTokenParserAware.php b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DummyChainableTokenParserAware.php index 50ffb7b7b..1a961f93e 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DummyChainableTokenParserAware.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DummyChainableTokenParserAware.php @@ -24,19 +24,19 @@ class DummyChainableTokenParserAware implements ChainableTokenParserInterface, P * @var ParserInterface|null */ public $parser; - + public function canParse(Token $token): bool { return false; } - + public function withParser(ParserInterface $parser) { $this->parser = $parser; return $this; } - + public function parse(Token $token) { return ''; diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FakeChainableTokenParser.php b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FakeChainableTokenParser.php index 8bde95cd1..5c07d6f14 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FakeChainableTokenParser.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FakeChainableTokenParser.php @@ -20,12 +20,12 @@ class FakeChainableTokenParser implements ChainableTokenParserInterface { use NotCallableTrait; - + public function canParse(Token $token): bool { $this->__call(__METHOD__, func_get_args()); } - + public function parse(Token $token): void { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ImpartialChainableParserAwareParser.php b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ImpartialChainableParserAwareParser.php index c408e2e97..7f2d21cd9 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ImpartialChainableParserAwareParser.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ImpartialChainableParserAwareParser.php @@ -19,7 +19,7 @@ class ImpartialChainableParserAwareParser extends AbstractChainableParserAwareParser { use NotCallableTrait; - + public function canParse(Token $token): bool { $this->__call(__FUNCTION__, func_get_args()); diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ProphecyChainableTokenParserAware.php b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ProphecyChainableTokenParserAware.php index 303c45b17..f9c4cbd31 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ProphecyChainableTokenParserAware.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ProphecyChainableTokenParserAware.php @@ -35,17 +35,17 @@ public function __construct(ChainableTokenParserInterface $decoratedParser, Pars $this->decoratedParser = $decoratedParser; $this->decoratedAware = $decoratedAware; } - + public function canParse(Token $token): bool { return $this->decoratedParser->canParse($token); } - + public function withParser(ParserInterface $parser) { return $this->decoratedAware->withParser($parser); } - + public function parse(Token $token) { return $this->decoratedParser->parse($token); diff --git a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/FakeTokenParser.php b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/FakeTokenParser.php index 6605338d0..5762acb72 100644 --- a/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/FakeTokenParser.php +++ b/fixtures/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/FakeTokenParser.php @@ -20,7 +20,7 @@ class FakeTokenParser implements TokenParserInterface { use NotCallableTrait; - + public function parse(Token $token): void { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureBuilder/FakeFixtureBuilder.php b/fixtures/FixtureBuilder/FakeFixtureBuilder.php index 7f628b20a..f4de48024 100644 --- a/fixtures/FixtureBuilder/FakeFixtureBuilder.php +++ b/fixtures/FixtureBuilder/FakeFixtureBuilder.php @@ -20,7 +20,7 @@ class FakeFixtureBuilder implements FixtureBuilderInterface { use NotCallableTrait; - + public function build(array $data, array $parameters = [], array $objects = []): FixtureSet { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/FixtureSetFactory.php b/fixtures/FixtureSetFactory.php index 4941f3cd9..e4e902674 100644 --- a/fixtures/FixtureSetFactory.php +++ b/fixtures/FixtureSetFactory.php @@ -16,16 +16,16 @@ class FixtureSetFactory { public static function create( - ParameterBag $loadedParameters = null, - ParameterBag $injectedParameters = null, - FixtureBag $fixtures = null, - ObjectBag $objects = null + ?ParameterBag $loadedParameters = null, + ?ParameterBag $injectedParameters = null, + ?FixtureBag $fixtures = null, + ?ObjectBag $objects = null ): FixtureSet { return new FixtureSet( $loadedParameters ?? new ParameterBag(), $injectedParameters ?? new ParameterBag(), $fixtures ?? new FixtureBag(), - $objects ?? new ObjectBag() + $objects ?? new ObjectBag(), ); } } diff --git a/fixtures/Generator/Caller/FakeCallProcessor.php b/fixtures/Generator/Caller/FakeCallProcessor.php index c77d11b31..50c181f57 100644 --- a/fixtures/Generator/Caller/FakeCallProcessor.php +++ b/fixtures/Generator/Caller/FakeCallProcessor.php @@ -22,7 +22,7 @@ class FakeCallProcessor implements CallProcessorInterface { use NotCallableTrait; - + public function process( ObjectInterface $object, ResolvedFixtureSet $fixtureSet, diff --git a/fixtures/Generator/Caller/FakeCaller.php b/fixtures/Generator/Caller/FakeCaller.php index 37301fe48..ddf5a4867 100644 --- a/fixtures/Generator/Caller/FakeCaller.php +++ b/fixtures/Generator/Caller/FakeCaller.php @@ -22,7 +22,7 @@ class FakeCaller implements CallerInterface { use NotCallableTrait; - + public function doCallsOn(ObjectInterface $object, ResolvedFixtureSet $fixtureSet, GenerationContext $context): ResolvedFixtureSet { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Generator/FakeGenerator.php b/fixtures/Generator/FakeGenerator.php index 1faed227d..59ddeb01d 100644 --- a/fixtures/Generator/FakeGenerator.php +++ b/fixtures/Generator/FakeGenerator.php @@ -21,7 +21,7 @@ class FakeGenerator implements GeneratorInterface { use NotCallableTrait; - + public function generate(FixtureSet $fixtureSet): ObjectSet { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Generator/FakeObjectGenerator.php b/fixtures/Generator/FakeObjectGenerator.php index 3fb8f8c7c..87b07ee17 100644 --- a/fixtures/Generator/FakeObjectGenerator.php +++ b/fixtures/Generator/FakeObjectGenerator.php @@ -20,7 +20,7 @@ class FakeObjectGenerator implements ObjectGeneratorInterface { use NotCallableTrait; - + public function generate(FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, GenerationContext $context): ObjectBag { $this->__call(__FUNCTION__, func_get_args()); diff --git a/fixtures/Generator/Hydrator/FakeHydrator.php b/fixtures/Generator/Hydrator/FakeHydrator.php index 9cbf918f5..4c211cb67 100644 --- a/fixtures/Generator/Hydrator/FakeHydrator.php +++ b/fixtures/Generator/Hydrator/FakeHydrator.php @@ -22,7 +22,7 @@ class FakeHydrator implements HydratorInterface { use NotCallableTrait; - + public function hydrate(ObjectInterface $object, ResolvedFixtureSet $fixtureSet, GenerationContext $context): ResolvedFixtureSet { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Generator/Hydrator/FakePropertyHydrator.php b/fixtures/Generator/Hydrator/FakePropertyHydrator.php index 494ed700e..9993dd84a 100644 --- a/fixtures/Generator/Hydrator/FakePropertyHydrator.php +++ b/fixtures/Generator/Hydrator/FakePropertyHydrator.php @@ -21,7 +21,7 @@ class FakePropertyHydrator implements PropertyHydratorInterface { use NotCallableTrait; - + public function hydrate(ObjectInterface $object, Property $property, GenerationContext $context): ObjectInterface { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Generator/Instantiator/Chainable/DummyChainableInstantiator.php b/fixtures/Generator/Instantiator/Chainable/DummyChainableInstantiator.php index 76e72c8ed..b0c1a2cb5 100644 --- a/fixtures/Generator/Instantiator/Chainable/DummyChainableInstantiator.php +++ b/fixtures/Generator/Instantiator/Chainable/DummyChainableInstantiator.php @@ -22,7 +22,7 @@ protected function createInstance(FixtureInterface $fixture) { return new stdClass(); } - + public function canInstantiate(FixtureInterface $fixture): bool { return true; diff --git a/fixtures/Generator/Instantiator/Chainable/ProphecyChainableInstantiator.php b/fixtures/Generator/Instantiator/Chainable/ProphecyChainableInstantiator.php index eb97bffcf..d9c38b229 100644 --- a/fixtures/Generator/Instantiator/Chainable/ProphecyChainableInstantiator.php +++ b/fixtures/Generator/Instantiator/Chainable/ProphecyChainableInstantiator.php @@ -26,12 +26,12 @@ public function __construct(AbstractChainableInstantiator $instantiator) { $this->instantiator = $instantiator; } - + protected function createInstance(FixtureInterface $fixture) { return $this->instantiator->createInstance($fixture); } - + public function canInstantiate(FixtureInterface $fixture): bool { return $this->instantiator->canInstantiate($fixture); diff --git a/fixtures/Generator/Instantiator/FakeInstantiator.php b/fixtures/Generator/Instantiator/FakeInstantiator.php index e029307b3..afe0bb9ec 100644 --- a/fixtures/Generator/Instantiator/FakeInstantiator.php +++ b/fixtures/Generator/Instantiator/FakeInstantiator.php @@ -22,7 +22,7 @@ class FakeInstantiator implements InstantiatorInterface { use NotCallableTrait; - + public function instantiate(FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, GenerationContext $context): ResolvedFixtureSet { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Generator/ResolvedFixtureSetFactory.php b/fixtures/Generator/ResolvedFixtureSetFactory.php index 5a57b7360..4e209d80d 100644 --- a/fixtures/Generator/ResolvedFixtureSetFactory.php +++ b/fixtures/Generator/ResolvedFixtureSetFactory.php @@ -19,12 +19,12 @@ class ResolvedFixtureSetFactory { - public static function create(ParameterBag $parameters = null, FixtureBag $fixtures = null, ObjectBag $objects = null): ResolvedFixtureSet + public static function create(?ParameterBag $parameters = null, ?FixtureBag $fixtures = null, ?ObjectBag $objects = null): ResolvedFixtureSet { return new ResolvedFixtureSet( $parameters ?? new ParameterBag(), $fixtures ?? new FixtureBag(), - $objects ?? new ObjectBag() + $objects ?? new ObjectBag(), ); } } diff --git a/fixtures/Generator/Resolver/FakeFixtureBagResolver.php b/fixtures/Generator/Resolver/FakeFixtureBagResolver.php index f3d7140e1..7b8487139 100644 --- a/fixtures/Generator/Resolver/FakeFixtureBagResolver.php +++ b/fixtures/Generator/Resolver/FakeFixtureBagResolver.php @@ -19,7 +19,7 @@ class FakeFixtureBagResolver implements FixtureBagResolverInterface { use NotCallableTrait; - + public function resolve(FixtureBag $unresolvedFixtures): FixtureBag { $this->__call(__FUNCTION__, func_get_args()); diff --git a/fixtures/Generator/Resolver/FakeParameterBagResolver.php b/fixtures/Generator/Resolver/FakeParameterBagResolver.php index 5f4296c64..3dbf864e2 100644 --- a/fixtures/Generator/Resolver/FakeParameterBagResolver.php +++ b/fixtures/Generator/Resolver/FakeParameterBagResolver.php @@ -19,8 +19,8 @@ class FakeParameterBagResolver implements ParameterBagResolverInterface { use NotCallableTrait; - - public function resolve(ParameterBag $unresolvedParameters, ParameterBag $injectedParameters = null): ParameterBag + + public function resolve(ParameterBag $unresolvedParameters, ?ParameterBag $injectedParameters = null): ParameterBag { $this->__call(__FUNCTION__, func_get_args()); } diff --git a/fixtures/Generator/Resolver/FakeParameterResolver.php b/fixtures/Generator/Resolver/FakeParameterResolver.php index b4254f81e..8f6f7bbd5 100644 --- a/fixtures/Generator/Resolver/FakeParameterResolver.php +++ b/fixtures/Generator/Resolver/FakeParameterResolver.php @@ -20,7 +20,7 @@ class FakeParameterResolver implements ParameterResolverInterface { use NotCallableTrait; - + public function resolve( Parameter $parameter, ParameterBag $unresolvedParameters, diff --git a/fixtures/Generator/Resolver/Parameter/Chainable/DummyChainableParameterResolverAwareResolver.php b/fixtures/Generator/Resolver/Parameter/Chainable/DummyChainableParameterResolverAwareResolver.php index eda6ff450..921196faf 100644 --- a/fixtures/Generator/Resolver/Parameter/Chainable/DummyChainableParameterResolverAwareResolver.php +++ b/fixtures/Generator/Resolver/Parameter/Chainable/DummyChainableParameterResolverAwareResolver.php @@ -26,21 +26,21 @@ class DummyChainableParameterResolverAwareResolver implements ChainableParameter public $resolver; - public function __construct(ParameterResolverInterface $resolver = null) + public function __construct(?ParameterResolverInterface $resolver = null) { $this->resolver = $resolver; } - + public function withResolver(ParameterResolverInterface $resolver) { return new self($resolver); } - + public function canResolve(Parameter $parameter): bool { $this->__call(__FUNCTION__, func_get_args()); } - + public function resolve( Parameter $parameter, ParameterBag $unresolvedParameters, diff --git a/fixtures/Generator/Resolver/Parameter/Chainable/FakeChainableParameterResolver.php b/fixtures/Generator/Resolver/Parameter/Chainable/FakeChainableParameterResolver.php index 26183162d..ab6ec83c8 100644 --- a/fixtures/Generator/Resolver/Parameter/Chainable/FakeChainableParameterResolver.php +++ b/fixtures/Generator/Resolver/Parameter/Chainable/FakeChainableParameterResolver.php @@ -21,12 +21,12 @@ class FakeChainableParameterResolver implements ChainableParameterResolverInterface { use NotCallableTrait; - + public function canResolve(Parameter $parameter): bool { $this->__call(__FUNCTION__, func_get_args()); } - + public function resolve( Parameter $parameter, ParameterBag $unresolvedParameters, diff --git a/fixtures/Generator/Resolver/Parameter/IsolatedSymfonyParameterBagResolver.php b/fixtures/Generator/Resolver/Parameter/IsolatedSymfonyParameterBagResolver.php index 6ece8bb02..e28a1e1ac 100644 --- a/fixtures/Generator/Resolver/Parameter/IsolatedSymfonyParameterBagResolver.php +++ b/fixtures/Generator/Resolver/Parameter/IsolatedSymfonyParameterBagResolver.php @@ -19,13 +19,11 @@ class IsolatedSymfonyParameterBagResolver implements ParameterBagResolverInterface { - public function resolve(ParameterBag $unresolvedParameters, ParameterBag $injectedParameters = null): ParameterBag + public function resolve(ParameterBag $unresolvedParameters, ?ParameterBag $injectedParameters = null): ParameterBag { return KernelIsolatedServiceCall::call( 'nelmio_alice.generator.resolver.parameter_bag', - static function (ParameterBagResolverInterface $resolver) use ($unresolvedParameters, $injectedParameters) { - return $resolver->resolve($unresolvedParameters, $injectedParameters); - } + static fn (ParameterBagResolverInterface $resolver) => $resolver->resolve($unresolvedParameters, $injectedParameters), ); } } diff --git a/fixtures/Generator/Resolver/Value/FakeChainableValueResolver.php b/fixtures/Generator/Resolver/Value/FakeChainableValueResolver.php index 78c441b76..44fb15aea 100644 --- a/fixtures/Generator/Resolver/Value/FakeChainableValueResolver.php +++ b/fixtures/Generator/Resolver/Value/FakeChainableValueResolver.php @@ -23,12 +23,12 @@ class FakeChainableValueResolver implements ChainableValueResolverInterface { use NotCallableTrait; - + public function canResolve(ValueInterface $value): bool { $this->__call(__METHOD__, func_get_args()); } - + public function resolve( ValueInterface $value, FixtureInterface $fixture, diff --git a/fixtures/Loader/FakeDataLoader.php b/fixtures/Loader/FakeDataLoader.php index d35e2bea1..6d37802e2 100644 --- a/fixtures/Loader/FakeDataLoader.php +++ b/fixtures/Loader/FakeDataLoader.php @@ -20,7 +20,7 @@ class FakeDataLoader implements DataLoaderInterface { use NotCallableTrait; - + public function loadData(array $data, array $parameters = [], array $objects = []): ObjectSet { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Loader/IsolatedLoader.php b/fixtures/Loader/IsolatedLoader.php index 6e2ba11a2..2aeb835f0 100644 --- a/fixtures/Loader/IsolatedLoader.php +++ b/fixtures/Loader/IsolatedLoader.php @@ -28,12 +28,12 @@ public function loadData(array $data, array $parameters = [], array $objects = [ { return (new NativeLoader())->loadData($data, $parameters, $objects); } - + public function loadFiles(array $files, array $parameters = [], array $objects = []): ObjectSet { return (new NativeLoader())->loadFiles($files, $parameters, $objects); } - + public function loadFile(string $file, array $parameters = [], array $objects = []): ObjectSet { return (new NativeLoader())->loadFile($file, $parameters, $objects); diff --git a/fixtures/Loader/IsolatedSymfonyLoader.php b/fixtures/Loader/IsolatedSymfonyLoader.php index 4f8e42b2e..a14c471c7 100644 --- a/fixtures/Loader/IsolatedSymfonyLoader.php +++ b/fixtures/Loader/IsolatedSymfonyLoader.php @@ -28,19 +28,15 @@ public function loadData(array $data, array $parameters = [], array $objects = [ { return KernelIsolatedServiceCall::call( 'nelmio_alice.data_loader', - static function (DataLoaderInterface $loader) use ($data, $parameters, $objects) { - return $loader->loadData($data, $parameters, $objects); - } + static fn (DataLoaderInterface $loader) => $loader->loadData($data, $parameters, $objects), ); } - + public function loadFile(string $file, array $parameters = [], array $objects = []): ObjectSet { return KernelIsolatedServiceCall::call( 'nelmio_alice.file_loader', - static function (FileLoaderInterface $loader) use ($file, $parameters, $objects) { - return $loader->loadFile($file, $parameters, $objects); - } + static fn (FileLoaderInterface $loader) => $loader->loadFile($file, $parameters, $objects), ); } } diff --git a/fixtures/Loader/NonIsolatedSymfonyLoader.php b/fixtures/Loader/NonIsolatedSymfonyLoader.php index 5376564a5..5f24c8fb6 100644 --- a/fixtures/Loader/NonIsolatedSymfonyLoader.php +++ b/fixtures/Loader/NonIsolatedSymfonyLoader.php @@ -30,17 +30,17 @@ public function __construct(ContainerInterface $container) { $this->container = $container; } - + public function loadData(array $data, array $parameters = [], array $objects = []): ObjectSet { return $this->container->get('nelmio_alice.data_loader')->loadData($data, $parameters, $objects); } - + public function loadFiles(array $files, array $parameters = [], array $objects = []): ObjectSet { return $this->container->get('nelmio_alice.files_loader')->loadFiles($files, $parameters, $objects); } - + public function loadFile(string $file, array $parameters = [], array $objects = []): ObjectSet { return $this->container->get('nelmio_alice.file_loader')->loadFile($file, $parameters, $objects); diff --git a/fixtures/NotCallableTrait.php b/fixtures/NotCallableTrait.php index 6fa50f34e..59d44f781 100644 --- a/fixtures/NotCallableTrait.php +++ b/fixtures/NotCallableTrait.php @@ -22,8 +22,8 @@ public function __call($method, $arguments): void throw new DomainException( sprintf( 'Did not expect "%s" to be called.', - $method - ) + $method, + ), ); } } diff --git a/fixtures/ObjectSetFactory.php b/fixtures/ObjectSetFactory.php index d35203332..85ddceaa2 100644 --- a/fixtures/ObjectSetFactory.php +++ b/fixtures/ObjectSetFactory.php @@ -15,11 +15,11 @@ class ObjectSetFactory { - public static function create(ParameterBag $parameters = null, ObjectBag $objects = null): ObjectSet + public static function create(?ParameterBag $parameters = null, ?ObjectBag $objects = null): ObjectSet { return new ObjectSet( $parameters ?? new ParameterBag(), - $objects ?? new ObjectBag() + $objects ?? new ObjectBag(), ); } } diff --git a/fixtures/Parser/FakeParser.php b/fixtures/Parser/FakeParser.php index 95d2ed175..8bac9f494 100644 --- a/fixtures/Parser/FakeParser.php +++ b/fixtures/Parser/FakeParser.php @@ -19,7 +19,7 @@ class FakeParser implements ParserInterface { use NotCallableTrait; - + public function parse(string $file): array { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/Parser/files/php/named_parameters.php b/fixtures/Parser/files/php/named_parameters.php index aa4cbe403..0a475bb0d 100644 --- a/fixtures/Parser/files/php/named_parameters.php +++ b/fixtures/Parser/files/php/named_parameters.php @@ -12,20 +12,20 @@ declare(strict_types=1); return [ - 'Nelmio\Alice\DummyWithMethods' =>[ - 'dummy_with_methods' =>[ - '__construct' =>[ - '$foo1' =>'foo1', - '$foo2' =>'foo2' + 'Nelmio\Alice\DummyWithMethods' => [ + 'dummy_with_methods' => [ + '__construct' => [ + '$foo1' => 'foo1', + '$foo2' => 'foo2', ], - '__calls' =>[ + '__calls' => [ [ - 'bar' =>[ - '$bar1' =>'bar1', - '$bar2' =>'bar2' - ] - ] - ] - ] - ] + 'bar' => [ + '$bar1' => 'bar1', + '$bar2' => 'bar2', + ], + ], + ], + ], + ], ]; diff --git a/fixtures/Symfony/KernelFactory.php b/fixtures/Symfony/KernelFactory.php index 5b05c416c..8c4b0b5a7 100644 --- a/fixtures/Symfony/KernelFactory.php +++ b/fixtures/Symfony/KernelFactory.php @@ -13,17 +13,17 @@ namespace Nelmio\Alice\Symfony; -use function bin2hex; use Nelmio\Alice\Bridge\Symfony\Application\AppKernel; -use function random_bytes; use Symfony\Component\HttpKernel\KernelInterface; +use function bin2hex; +use function random_bytes; class KernelFactory { public static $environments = []; public static function createKernel( - string $config = null, + ?string $config = null, string $kernelClass = AppKernel::class, string $environment = 'test', $debug = true diff --git a/fixtures/Symfony/PropertyAccess/FakePropertyAccessor.php b/fixtures/Symfony/PropertyAccess/FakePropertyAccessor.php index 419716fe5..ab0923dac 100644 --- a/fixtures/Symfony/PropertyAccess/FakePropertyAccessor.php +++ b/fixtures/Symfony/PropertyAccess/FakePropertyAccessor.php @@ -19,22 +19,22 @@ class FakePropertyAccessor implements PropertyAccessorInterface { use NotCallableTrait; - + public function setValue(&$objectOrArray, $propertyPath, $value): void { $this->__call(__METHOD__, func_get_args()); } - + public function getValue($objectOrArray, $propertyPath): mixed { $this->__call(__METHOD__, func_get_args()); } - + public function isWritable($objectOrArray, $propertyPath): bool { $this->__call(__METHOD__, func_get_args()); } - + public function isReadable($objectOrArray, $propertyPath): bool { $this->__call(__METHOD__, func_get_args()); diff --git a/fixtures/User.php b/fixtures/User.php index daacf5e67..597265710 100644 --- a/fixtures/User.php +++ b/fixtures/User.php @@ -24,7 +24,7 @@ public function getId(): string return $this->id; } - public function setId(string $id): User + public function setId(string $id): self { $this->id = $id; @@ -36,7 +36,7 @@ public function getName(): ?string return $this->name; } - public function setName(?string $name): User + public function setName(?string $name): self { $this->name = $name; diff --git a/fixtures/UserDetail.php b/fixtures/UserDetail.php index b30f06b2e..9a94b54a1 100644 --- a/fixtures/UserDetail.php +++ b/fixtures/UserDetail.php @@ -30,7 +30,7 @@ public function getEmail(): ?string return $this->email; } - public function setEmail(?string $email): UserDetail + public function setEmail(?string $email): self { $this->email = $email; @@ -42,7 +42,7 @@ public function getUser(): User return $this->user; } - public function setUser(User $user): UserDetail + public function setUser(User $user): self { $this->user = $user; diff --git a/profiling/scenario0/blackfire.php b/profiling/scenario0/blackfire.php index 921ccfa9f..185fdce10 100644 --- a/profiling/scenario0/blackfire.php +++ b/profiling/scenario0/blackfire.php @@ -44,11 +44,11 @@ sprintf( 'Start profiling of %s with %d samples.', $config->getTitle(), - $config->getSamples() - ) + $config->getSamples(), + ), ); -for ($i = 1; $i <= $config->getSamples(); $i++) { +for ($i = 1; $i <= $config->getSamples(); ++$i) { $probe->enable(); script($faker); @@ -65,17 +65,17 @@ function script(Generator $faker) { $objects = []; - for ($i = 0; $i <= 1000; $i++) { + for ($i = 0; $i <= 1000; ++$i) { $objects['immutable_user_'.$i] = new ImmutableUser( $faker->userName, $faker->name, $faker->dateTime, $faker->email, - $faker->randomNumber + $faker->randomNumber, ); } - for ($i = 0; $i <= 1000; $i++) { + for ($i = 0; $i <= 1000; ++$i) { $user = new MutableUser(); $user->setUsername($faker->userName); $user->setFullname($faker->name); @@ -86,7 +86,7 @@ function script(Generator $faker) $objects['mutable_user_'.$i] = $user; } - for ($i = 0; $i <= 1000; $i++) { + for ($i = 0; $i <= 1000; ++$i) { $user = new PublicUser(); $user->username = $faker->userName; $user->fullname = $faker->name; @@ -97,7 +97,7 @@ function script(Generator $faker) $objects['public_user_'.$i] = $user; } - for ($i = 0; $i <= 1000; $i++) { + for ($i = 0; $i <= 1000; ++$i) { $user = new stdClass(); $user->username = $faker->userName; $user->fullname = $faker->name; diff --git a/profiling/scenario1/blackfire_immutable.php b/profiling/scenario1/blackfire_immutable.php index 82979ca74..33267c6a1 100644 --- a/profiling/scenario1/blackfire_immutable.php +++ b/profiling/scenario1/blackfire_immutable.php @@ -37,12 +37,12 @@ sprintf( 'Start profiling of %s with %d samples.', $config->getTitle(), - $config->getSamples() - ) + $config->getSamples(), + ), ); $loader = new NativeLoader(); -for ($i = 1; $i <= $config->getSamples(); $i++) { +for ($i = 1; $i <= $config->getSamples(); ++$i) { $probe->enable(); $loader->loadFile(__DIR__.'/immutable_user.yml'); diff --git a/profiling/scenario1/blackfire_mutable.php b/profiling/scenario1/blackfire_mutable.php index 1d9e93b52..1763a23f0 100644 --- a/profiling/scenario1/blackfire_mutable.php +++ b/profiling/scenario1/blackfire_mutable.php @@ -37,12 +37,12 @@ sprintf( 'Start profiling of %s with %d samples.', $config->getTitle(), - $config->getSamples() - ) + $config->getSamples(), + ), ); $loader = new NativeLoader(); -for ($i = 1; $i <= $config->getSamples(); $i++) { +for ($i = 1; $i <= $config->getSamples(); ++$i) { $probe->enable(); $loader->loadFile(__DIR__.'/mutable_user.yml'); diff --git a/profiling/scenario1/blackfire_public.php b/profiling/scenario1/blackfire_public.php index 379177bd1..481f00830 100644 --- a/profiling/scenario1/blackfire_public.php +++ b/profiling/scenario1/blackfire_public.php @@ -37,12 +37,12 @@ sprintf( 'Start profiling of %s with %d samples.', $config->getTitle(), - $config->getSamples() - ) + $config->getSamples(), + ), ); $loader = new NativeLoader(); -for ($i = 1; $i <= $config->getSamples(); $i++) { +for ($i = 1; $i <= $config->getSamples(); ++$i) { $probe->enable(); $loader->loadFile(__DIR__.'/public_user.yml'); diff --git a/profiling/scenario1/blackfire_stdClass.php b/profiling/scenario1/blackfire_stdClass.php index 0d8003593..5707fbf5c 100644 --- a/profiling/scenario1/blackfire_stdClass.php +++ b/profiling/scenario1/blackfire_stdClass.php @@ -37,12 +37,12 @@ sprintf( 'Start profiling of %s with %d samples.', $config->getTitle(), - $config->getSamples() - ) + $config->getSamples(), + ), ); $loader = new NativeLoader(); -for ($i = 1; $i <= $config->getSamples(); $i++) { +for ($i = 1; $i <= $config->getSamples(); ++$i) { $probe->enable(); $loader->loadFile(__DIR__.'/stdClass.yml'); diff --git a/profiling/scenario2/blackfire.php b/profiling/scenario2/blackfire.php index 21dbb58ed..144e6b567 100644 --- a/profiling/scenario2/blackfire.php +++ b/profiling/scenario2/blackfire.php @@ -37,12 +37,12 @@ sprintf( 'Start profiling of %s with %d samples.', $config->getTitle(), - $config->getSamples() - ) + $config->getSamples(), + ), ); $loader = new NativeLoader(); -for ($i = 1; $i <= $config->getSamples(); $i++) { +for ($i = 1; $i <= $config->getSamples(); ++$i) { $probe->enable(); $loader->loadFile(__DIR__.'/fixtures.yml'); diff --git a/profiling/scenario3/blackfire.php b/profiling/scenario3/blackfire.php index 3c7300983..e789d86bb 100644 --- a/profiling/scenario3/blackfire.php +++ b/profiling/scenario3/blackfire.php @@ -37,12 +37,12 @@ sprintf( 'Start profiling of %s with %d samples.', $config->getTitle(), - $config->getSamples() - ) + $config->getSamples(), + ), ); $loader = new NativeLoader(); -for ($i = 1; $i <= $config->getSamples(); $i++) { +for ($i = 1; $i <= $config->getSamples(); ++$i) { $probe->enable(); $loader->loadFile(__DIR__.'/fixtures.yml'); diff --git a/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterFakerProvidersPass.php b/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterFakerProvidersPass.php index 5b54a8c5c..45149eda9 100644 --- a/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterFakerProvidersPass.php +++ b/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterFakerProvidersPass.php @@ -30,7 +30,7 @@ public function __construct() { $this->taggedDefinitionsLocator = new TaggedDefinitionsLocator(); } - + public function process(ContainerBuilder $container): void { $fakerGenerator = $container->findDefinition('nelmio_alice.faker.generator'); diff --git a/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterTagServicesPass.php b/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterTagServicesPass.php index 89e643ba0..5a995e842 100644 --- a/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterTagServicesPass.php +++ b/src/Bridge/Symfony/DependencyInjection/Compiler/RegisterTagServicesPass.php @@ -42,7 +42,7 @@ public function __construct(string $registry, string $tagName) $this->tagName = $tagName; $this->taggedDefinitionsLocator = new TaggedDefinitionsLocator(); } - + public function process(ContainerBuilder $container): void { $registry = $container->findDefinition($this->registry); diff --git a/src/Bridge/Symfony/DependencyInjection/Configuration.php b/src/Bridge/Symfony/DependencyInjection/Configuration.php index 6beacb98a..7b9be9bbc 100644 --- a/src/Bridge/Symfony/DependencyInjection/Configuration.php +++ b/src/Bridge/Symfony/DependencyInjection/Configuration.php @@ -30,69 +30,68 @@ public function getConfigTreeBuilder(): TreeBuilder $treeBuilder ->getRootNode() ->children() - ->scalarNode('locale') - ->defaultValue('en_US') - ->info('Default locale for the Faker Generator') - ->validate() - ->always($this->createStringValidatorClosure()) - ->end() - ->end() - ->scalarNode('seed') - ->defaultValue(1) - ->info('Value used make sure Faker generates data consistently across runs, set to null to disable.') - ->validate() - ->always( - static function ($seed) { - if (null === $seed || (is_int($seed) && $seed > 0)) { - return $seed; - } + ->scalarNode('locale') + ->defaultValue('en_US') + ->info('Default locale for the Faker Generator') + ->validate() + ->always($this->createStringValidatorClosure()) + ->end() + ->end() + ->scalarNode('seed') + ->defaultValue(1) + ->info('Value used make sure Faker generates data consistently across runs, set to null to disable.') + ->validate() + ->always( + static function ($seed) { + if (null === $seed || (is_int($seed) && $seed > 0)) { + return $seed; + } - throw InvalidArgumentExceptionFactory::createForInvalidSeedConfigurationValue($seed); - } - ) - ->end() - ->end() - ->arrayNode('functions_blacklist') - ->scalarPrototype()->end() - ->defaultValue(['current']) - ->info( - 'Some PHP native functions may conflict with Faker formatters. By default, PHP native ' - .'functions are used over Faker formatters. If you want to change that, simply blacklist the ' - .'PHP function.' - ) - ->validate() - ->always( - static function (array $value) { - foreach ($value as $item) { - if (false === is_string($item)) { - throw InvalidArgumentExceptionFactory::createForExpectedConfigurationArrayOfStringValue($item); - } - } + throw InvalidArgumentExceptionFactory::createForInvalidSeedConfigurationValue($seed); + }, + ) + ->end() + ->end() + ->arrayNode('functions_blacklist') + ->scalarPrototype()->end() + ->defaultValue(['current']) + ->info( + 'Some PHP native functions may conflict with Faker formatters. By default, PHP native ' + .'functions are used over Faker formatters. If you want to change that, simply blacklist the ' + .'PHP function.', + ) + ->validate() + ->always( + static function (array $value) { + foreach ($value as $item) { + if (false === is_string($item)) { + throw InvalidArgumentExceptionFactory::createForExpectedConfigurationArrayOfStringValue($item); + } + } - return $value; - } - ) - ->end() - ->end() - ->integerNode('loading_limit') - ->defaultValue(5) - ->info( - 'Alice may do some recursion to resolve certain values. This parameter defines a limit which ' - .'will stop the resolution once reached.' - ) - ->validate() - ->always($this->createPositiveIntegerValidatorClosure()) - ->end() - ->end() - ->integerNode('max_unique_values_retry') - ->defaultValue(150) - ->info('Maximum number of time Alice can try to generate a unique value before stopping and failing.') - ->validate() - ->always($this->createPositiveIntegerValidatorClosure()) - ->end() - ->end() + return $value; + }, + ) + ->end() + ->end() + ->integerNode('loading_limit') + ->defaultValue(5) + ->info( + 'Alice may do some recursion to resolve certain values. This parameter defines a limit which ' + .'will stop the resolution once reached.', + ) + ->validate() + ->always($this->createPositiveIntegerValidatorClosure()) + ->end() + ->end() + ->integerNode('max_unique_values_retry') + ->defaultValue(150) + ->info('Maximum number of time Alice can try to generate a unique value before stopping and failing.') + ->validate() + ->always($this->createPositiveIntegerValidatorClosure()) + ->end() ->end() - ; + ->end(); return $treeBuilder; } diff --git a/src/Bridge/Symfony/DependencyInjection/NelmioAliceExtension.php b/src/Bridge/Symfony/DependencyInjection/NelmioAliceExtension.php index a18479a33..a74a9ec2e 100644 --- a/src/Bridge/Symfony/DependencyInjection/NelmioAliceExtension.php +++ b/src/Bridge/Symfony/DependencyInjection/NelmioAliceExtension.php @@ -26,8 +26,8 @@ */ final class NelmioAliceExtension extends Extension { - const SERVICES_DIR = __DIR__.'/../Resources/config'; - + public const SERVICES_DIR = __DIR__.'/../Resources/config'; + public function load(array $configs, ContainerBuilder $container): void { $this->loadConfig($configs, $container); @@ -47,7 +47,7 @@ private function loadConfig(array $configs, ContainerBuilder $container): void foreach ($processedConfiguration as $key => $value) { $container->setParameter( $this->getAlias().'.'.$key, - $value + $value, ); } } @@ -64,7 +64,7 @@ private function loadServices(ContainerBuilder $container): void foreach ($finder as $file) { $loader->load( - $file->getRelativePathname() + $file->getRelativePathname(), ); } diff --git a/src/Bridge/Symfony/NelmioAliceBundle.php b/src/Bridge/Symfony/NelmioAliceBundle.php index 2d7bc8640..c8e3117e1 100644 --- a/src/Bridge/Symfony/NelmioAliceBundle.php +++ b/src/Bridge/Symfony/NelmioAliceBundle.php @@ -30,56 +30,56 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.file_parser.registry', - 'nelmio_alice.file_parser' - ) + 'nelmio_alice.file_parser', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.fixture_builder.denormalizer.flag_parser.registry', - 'nelmio_alice.fixture_builder.denormalizer.chainable_flag_parser' - ) + 'nelmio_alice.fixture_builder.denormalizer.chainable_flag_parser', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.fixture_builder.denormalizer.fixture.registry_denormalizer', - 'nelmio_alice.fixture_builder.denormalizer.chainable_fixture_denormalizer' - ) + 'nelmio_alice.fixture_builder.denormalizer.chainable_fixture_denormalizer', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.fixture_builder.denormalizer.fixture.specs.calls.simple_denormalizer', - 'nelmio_alice.fixture_builder.denormalizer.chainable_method_flag_handler' - ) + 'nelmio_alice.fixture_builder.denormalizer.chainable_method_flag_handler', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.fixture_builder.expression_language.parser.token_parser.registry', - 'nelmio_alice.fixture_builder.expression_language.chainable_token_parser' - ) + 'nelmio_alice.fixture_builder.expression_language.chainable_token_parser', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.generator.instantiator.registry', - 'nelmio_alice.generator.instantiator.chainable_instantiator' - ) + 'nelmio_alice.generator.instantiator.chainable_instantiator', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.generator.caller.registry', - 'nelmio_alice.generator.caller.chainable_call_processor' - ) + 'nelmio_alice.generator.caller.chainable_call_processor', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.generator.resolver.parameter.registry', - 'nelmio_alice.generator.resolver.parameter.chainable_resolver' - ) + 'nelmio_alice.generator.resolver.parameter.chainable_resolver', + ), ); $container->addCompilerPass( new RegisterTagServicesPass( 'nelmio_alice.generator.resolver.value.registry', - 'nelmio_alice.generator.resolver.value.chainable_resolver' - ) + 'nelmio_alice.generator.resolver.value.chainable_resolver', + ), ); } } diff --git a/src/DataLoaderInterface.php b/src/DataLoaderInterface.php index d43b06e33..187e8dcd2 100644 --- a/src/DataLoaderInterface.php +++ b/src/DataLoaderInterface.php @@ -23,9 +23,9 @@ interface DataLoaderInterface /** * Loads a data set. * - * @param array $data Data to load - * @param array $parameters Additional parameters to inject - * @param array $objects Additional objects to inject + * @param array $data Data to load + * @param array $parameters Additional parameters to inject + * @param array $objects Additional objects to inject * * @throws LoadingThrowable * diff --git a/src/Definition/Fixture/FixtureId.php b/src/Definition/Fixture/FixtureId.php index cbfa888fe..067d331ab 100644 --- a/src/Definition/Fixture/FixtureId.php +++ b/src/Definition/Fixture/FixtureId.php @@ -26,7 +26,7 @@ public function __construct(string $id) { $this->id = $id; } - + public function getId(): string { return $this->id; diff --git a/src/Definition/Fixture/SimpleFixture.php b/src/Definition/Fixture/SimpleFixture.php index 0e6290ea0..ff4ef478d 100644 --- a/src/Definition/Fixture/SimpleFixture.php +++ b/src/Definition/Fixture/SimpleFixture.php @@ -52,22 +52,22 @@ public function __construct(string $id, string $className, SpecificationBag $spe $this->specs = $specs; $this->valueForCurrent = $valueForCurrent; } - + public function getId(): string { return $this->id; } - + public function getClassName(): string { return $this->className; } - + public function getSpecs(): SpecificationBag { return $this->specs; } - + public function getValueForCurrent() { if (null === $this->valueForCurrent) { @@ -76,7 +76,7 @@ public function getValueForCurrent() return $this->valueForCurrent; } - + public function withSpecs(SpecificationBag $specs): self { $clone = clone $this; diff --git a/src/Definition/Fixture/SimpleFixtureWithFlags.php b/src/Definition/Fixture/SimpleFixtureWithFlags.php index 94e12f998..7edd49792 100644 --- a/src/Definition/Fixture/SimpleFixtureWithFlags.php +++ b/src/Definition/Fixture/SimpleFixtureWithFlags.php @@ -43,35 +43,35 @@ public function __construct(FixtureInterface $fixture, FlagBag $flags) $this->fixture = clone $fixture; $this->flags = $flags; } - + public function getId(): string { return $this->fixture->getId(); } - + public function getClassName(): string { return $this->fixture->getClassName(); } - + public function getSpecs(): SpecificationBag { return $this->fixture->getSpecs(); } - + public function getValueForCurrent() { return $this->fixture->getValueForCurrent(); } - + public function withSpecs(SpecificationBag $specs): self { $clone = clone $this; $clone->fixture = $this->fixture->withSpecs($specs); - + return $clone; } - + public function getFlags(): FlagBag { return $this->flags; diff --git a/src/Definition/Fixture/TemplatingFixture.php b/src/Definition/Fixture/TemplatingFixture.php index 2b20762c0..6994cc9ab 100644 --- a/src/Definition/Fixture/TemplatingFixture.php +++ b/src/Definition/Fixture/TemplatingFixture.php @@ -38,32 +38,32 @@ public function __construct(FixtureWithFlagsInterface $fixture) $this->fixture = clone $fixture; $this->templating = new Templating($fixture); } - + public function getId(): string { return $this->fixture->getId(); } - + public function getClassName(): string { return $this->fixture->getClassName(); } - + public function getSpecs(): SpecificationBag { return $this->fixture->getSpecs(); } - + public function getValueForCurrent() { return $this->fixture->getValueForCurrent(); } - + public function withSpecs(SpecificationBag $specs): self { $clone = clone $this; $clone->fixture = $this->fixture->withSpecs($specs); - + return $clone; } @@ -84,7 +84,7 @@ public function getExtendedFixturesReferences(): array { return $this->templating->getExtendedFixtures(); } - + public function getFlags(): FlagBag { return $this->fixture->getFlags(); diff --git a/src/Definition/Flag/OptionalFlag.php b/src/Definition/Flag/OptionalFlag.php index 1bcb0b7c8..a090dcd14 100644 --- a/src/Definition/Flag/OptionalFlag.php +++ b/src/Definition/Flag/OptionalFlag.php @@ -41,7 +41,7 @@ public function getPercentage(): int { return $this->percentage; } - + public function __toString(): string { return '%?'; diff --git a/src/Definition/FlagBag.php b/src/Definition/FlagBag.php index 8c0e5c1d1..8f15ee88b 100644 --- a/src/Definition/FlagBag.php +++ b/src/Definition/FlagBag.php @@ -16,8 +16,8 @@ use ArrayIterator; use Countable; use IteratorAggregate; -use function Nelmio\Alice\deep_clone; use Traversable; +use function Nelmio\Alice\deep_clone; /** * Collection of flags. @@ -44,7 +44,7 @@ public function __construct(string $key) public function withKey(string $key): self { - $clone = clone ($this); + $clone = clone $this; $clone->key = $key; return $clone; @@ -56,7 +56,7 @@ public function withKey(string $key): self */ public function withFlag(FlagInterface $flag): self { - $clone = clone ($this); + $clone = clone $this; $clone->flags[$flag->__toString()] = deep_clone($flag); return $clone; @@ -73,17 +73,17 @@ public function withFlag(FlagInterface $flag): self public function mergeWith(self $flags, bool $override = true): self { if ($override) { - $clone = clone ($this); + $clone = clone $this; foreach ($flags as $flag) { /** @var FlagInterface $flag */ - $clone->flags[$flag->__toString()] = clone ($flag); + $clone->flags[$flag->__toString()] = clone $flag; } } else { - $clone = clone ($flags); + $clone = clone $flags; $clone->key = $this->key; foreach ($this as $flag) { /** @var FlagInterface $flag */ - $clone->flags[$flag->__toString()] = clone ($flag); + $clone->flags[$flag->__toString()] = clone $flag; } } @@ -94,12 +94,12 @@ public function getKey(): string { return $this->key; } - + public function getIterator(): Traversable { return new ArrayIterator(array_values($this->flags)); } - + public function count(): int { return count($this->flags); diff --git a/src/Definition/MethodCall/ConfiguratorMethodCall.php b/src/Definition/MethodCall/ConfiguratorMethodCall.php index 775882002..e32c5425d 100644 --- a/src/Definition/MethodCall/ConfiguratorMethodCall.php +++ b/src/Definition/MethodCall/ConfiguratorMethodCall.php @@ -29,22 +29,22 @@ public function __construct(MethodCallInterface $methodCall) { $this->methodCall = $methodCall; } - - public function withArguments(array $arguments = null): self + + public function withArguments(?array $arguments = null): self { return new self($this->methodCall->withArguments($arguments)); } - + public function getCaller() { return $this->methodCall->getCaller(); } - + public function getMethod(): string { return $this->methodCall->getMethod(); } - + public function getArguments() { return $this->methodCall->getArguments(); @@ -54,7 +54,7 @@ public function getOriginalMethodCall(): MethodCallInterface { return $this->methodCall; } - + public function __toString(): string { return $this->methodCall->__toString(); diff --git a/src/Definition/MethodCall/MethodCallWithReference.php b/src/Definition/MethodCall/MethodCallWithReference.php index 73f4dd2ce..770cc15d5 100644 --- a/src/Definition/MethodCall/MethodCallWithReference.php +++ b/src/Definition/MethodCall/MethodCallWithReference.php @@ -46,7 +46,7 @@ final class MethodCallWithReference implements MethodCallInterface /** * @param ValueInterface[]|array|null $arguments */ - public function __construct(ServiceReferenceInterface $caller, string $method, array $arguments = null) + public function __construct(ServiceReferenceInterface $caller, string $method, ?array $arguments = null) { $this->caller = clone $caller; $this->method = $method; @@ -58,30 +58,30 @@ public function __construct(ServiceReferenceInterface $caller, string $method, a $this->stringValue = $caller->getId().'->'.$method; } } - - public function withArguments(array $arguments = null): self + + public function withArguments(?array $arguments = null): self { $clone = clone $this; $clone->arguments = $arguments; return $clone; } - + public function getCaller() { return clone $this->caller; } - + public function getMethod(): string { return $this->method; } - + public function getArguments() { return $this->arguments; } - + public function __toString(): string { return $this->stringValue; diff --git a/src/Definition/MethodCall/NoMethodCall.php b/src/Definition/MethodCall/NoMethodCall.php index 855e3d171..ad21eb058 100644 --- a/src/Definition/MethodCall/NoMethodCall.php +++ b/src/Definition/MethodCall/NoMethodCall.php @@ -23,26 +23,26 @@ */ final class NoMethodCall implements MethodCallInterface { - public function withArguments(array $arguments = null): never + public function withArguments(?array $arguments = null): never { $this->throwException(__METHOD__); } - + public function getCaller(): never { $this->throwException(__METHOD__); } - + public function getMethod(): never { $this->throwException(__METHOD__); } - + public function getArguments(): never { $this->throwException(__METHOD__); } - + public function __toString(): string { return 'none'; diff --git a/src/Definition/MethodCall/OptionalMethodCall.php b/src/Definition/MethodCall/OptionalMethodCall.php index 7a40aabc7..5e273e49e 100644 --- a/src/Definition/MethodCall/OptionalMethodCall.php +++ b/src/Definition/MethodCall/OptionalMethodCall.php @@ -36,25 +36,25 @@ public function __construct(MethodCallInterface $methodCall, OptionalFlag $flag) $this->methodCall = $methodCall; $this->flag = $flag; } - - public function withArguments(array $arguments = null): self + + public function withArguments(?array $arguments = null): self { $clone = clone $this; $clone->methodCall = $clone->methodCall->withArguments($arguments); return $clone; } - + public function getCaller() { return $this->methodCall->getCaller(); } - + public function getMethod(): string { return $this->methodCall->getMethod(); } - + public function getArguments() { return $this->methodCall->getArguments(); @@ -72,7 +72,7 @@ public function getOriginalMethodCall(): MethodCallInterface { return $this->methodCall; } - + public function __toString(): string { return $this->methodCall->__toString(); diff --git a/src/Definition/MethodCall/SimpleMethodCall.php b/src/Definition/MethodCall/SimpleMethodCall.php index d8a164e83..3776c2752 100644 --- a/src/Definition/MethodCall/SimpleMethodCall.php +++ b/src/Definition/MethodCall/SimpleMethodCall.php @@ -34,35 +34,35 @@ final class SimpleMethodCall implements MethodCallInterface /** * @param ValueInterface[]|array|null $arguments */ - public function __construct(string $method, array $arguments = null) + public function __construct(string $method, ?array $arguments = null) { $this->method = $method; $this->arguments = $arguments; } - - public function withArguments(array $arguments = null): self + + public function withArguments(?array $arguments = null): self { $clone = clone $this; $clone->arguments = $arguments; return $clone; } - + public function getCaller() { return null; } - + public function getMethod(): string { return $this->method; } - + public function getArguments() { return $this->arguments; } - + public function __toString(): string { return $this->method; diff --git a/src/Definition/MethodCallBag.php b/src/Definition/MethodCallBag.php index b893da6ac..e3ec3eade 100644 --- a/src/Definition/MethodCallBag.php +++ b/src/Definition/MethodCallBag.php @@ -51,12 +51,12 @@ public function isEmpty(): bool { return [] === $this->methodCalls; } - + public function getIterator(): Traversable { return new ArrayIterator(array_values($this->methodCalls)); } - + public function count(): int { return count($this->methodCalls); diff --git a/src/Definition/MethodCallInterface.php b/src/Definition/MethodCallInterface.php index fe5580ba8..4d1397037 100644 --- a/src/Definition/MethodCallInterface.php +++ b/src/Definition/MethodCallInterface.php @@ -24,13 +24,13 @@ interface MethodCallInterface * * @return static */ - public function withArguments(array $arguments = null); + public function withArguments(?array $arguments = null); /** * @return ServiceReferenceInterface|null No caller means that the caller is the instance of the object itself. */ public function getCaller(); - + /** * @return string Method name */ @@ -40,6 +40,6 @@ public function getMethod(): string; * @return ValueInterface[]|array|null */ public function getArguments(); - + public function __toString(): string; } diff --git a/src/Definition/Object/CompleteObject.php b/src/Definition/Object/CompleteObject.php index 3cb91e0c8..e4a08b4c9 100644 --- a/src/Definition/Object/CompleteObject.php +++ b/src/Definition/Object/CompleteObject.php @@ -30,17 +30,17 @@ public function __construct(ObjectInterface $object) { $this->object = $object; } - + public function getId(): string { return $this->object->getId(); } - + public function getInstance(): object { return $this->object->getInstance(); } - + public function withInstance(object $newInstance): static { throw new LogicException('Cannot create a new object from a complete object.'); diff --git a/src/Definition/Object/SimpleObject.php b/src/Definition/Object/SimpleObject.php index 1f93ce4e6..452765690 100644 --- a/src/Definition/Object/SimpleObject.php +++ b/src/Definition/Object/SimpleObject.php @@ -35,7 +35,7 @@ public function __construct(string $id, object $instance) $this->reference = $id; $this->instance = $instance; } - + public function withInstance($newInstance): static { $clone = clone $this; @@ -43,12 +43,12 @@ public function withInstance($newInstance): static return $clone; } - + public function getId(): string { return $this->reference; } - + public function getInstance(): object { return $this->instance; diff --git a/src/Definition/Property.php b/src/Definition/Property.php index 23a9513d2..64c08dbce 100644 --- a/src/Definition/Property.php +++ b/src/Definition/Property.php @@ -39,7 +39,8 @@ public function __construct(string $name, $value) } /** - * param ValueInterface|mixed $value + * param ValueInterface|mixed $value. + * @param mixed $value */ public function withValue($value): self { diff --git a/src/Definition/PropertyBag.php b/src/Definition/PropertyBag.php index ccf89db1e..b06ec5678 100644 --- a/src/Definition/PropertyBag.php +++ b/src/Definition/PropertyBag.php @@ -29,7 +29,7 @@ public function with(Property $property): self { $clone = clone $this; $clone->properties[$property->getName()] = $property; - + return $clone; } @@ -43,7 +43,7 @@ public function mergeWith(self $propertyBag): self foreach ($this->properties as $name => $property) { $clone->properties[$name] = $property; } - + return $clone; } @@ -51,12 +51,12 @@ public function isEmpty(): bool { return [] === $this->properties; } - + public function getIterator(): Traversable { return new ArrayIterator(array_values($this->properties)); } - + public function count(): int { return count($this->properties); diff --git a/src/Definition/RangeName.php b/src/Definition/RangeName.php index 2dc37b8cb..abcb402d8 100644 --- a/src/Definition/RangeName.php +++ b/src/Definition/RangeName.php @@ -19,12 +19,12 @@ final class RangeName * @var string */ private $name; - + /** * @var int */ private $from; - + /** * @var int */ diff --git a/src/Definition/ServiceReference/StaticReference.php b/src/Definition/ServiceReference/StaticReference.php index adc300cca..518e00daa 100644 --- a/src/Definition/ServiceReference/StaticReference.php +++ b/src/Definition/ServiceReference/StaticReference.php @@ -16,7 +16,7 @@ use Nelmio\Alice\Definition\ServiceReferenceInterface; /** - * Value object to point to refer to a static service, e.g. 'Nelmio\User\UserFactory' + * Value object to point to refer to a static service, e.g. 'Nelmio\User\UserFactory'. */ final class StaticReference implements ServiceReferenceInterface { diff --git a/src/Definition/SpecificationBag.php b/src/Definition/SpecificationBag.php index f7b939f72..957be18df 100644 --- a/src/Definition/SpecificationBag.php +++ b/src/Definition/SpecificationBag.php @@ -23,25 +23,25 @@ final class SpecificationBag * @var MethodCallInterface|null */ private $constructor; - + /** * @var PropertyBag */ private $properties; - + /** * @var MethodCallBag */ private $calls; - - public function __construct(MethodCallInterface $constructor = null, PropertyBag $properties, MethodCallBag $calls) + + public function __construct(?MethodCallInterface $constructor = null, PropertyBag $properties, MethodCallBag $calls) { $this->constructor = $constructor; $this->properties = $properties; $this->calls = $calls; } - public function withConstructor(MethodCallInterface $constructor = null): self + public function withConstructor(?MethodCallInterface $constructor = null): self { $clone = clone $this; $clone->constructor = $constructor; @@ -56,12 +56,12 @@ public function getConstructor() { return $this->constructor; } - + public function getProperties(): PropertyBag { return $this->properties; } - + public function getMethodCalls(): MethodCallBag { return $this->calls; @@ -77,7 +77,7 @@ public function mergeWith(self $specs): self if (null === $clone->constructor) { $clone->constructor = $specs->constructor; } - + $clone->properties = $this->properties->mergeWith($specs->properties); $clone->calls = $this->calls->mergeWith($specs->calls); diff --git a/src/Definition/Value/ArrayValue.php b/src/Definition/Value/ArrayValue.php index 901809fbd..083adde7e 100644 --- a/src/Definition/Value/ArrayValue.php +++ b/src/Definition/Value/ArrayValue.php @@ -13,8 +13,8 @@ namespace Nelmio\Alice\Definition\Value; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\Definition\ValueInterface; +use function Nelmio\Alice\deep_clone; final class ArrayValue implements ValueInterface { @@ -38,7 +38,7 @@ public function getValue(): array { return deep_clone($this->values); } - + public function __toString(): string { return var_export($this->values, true); diff --git a/src/Definition/Value/DynamicArrayValue.php b/src/Definition/Value/DynamicArrayValue.php index f95c67755..8d282f5ee 100644 --- a/src/Definition/Value/DynamicArrayValue.php +++ b/src/Definition/Value/DynamicArrayValue.php @@ -13,9 +13,9 @@ namespace Nelmio\Alice\Definition\Value; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\Definition\ValueInterface; use Nelmio\Alice\Throwable\Error\TypeErrorFactory; +use function Nelmio\Alice\deep_clone; /** * Value object representing an array like "10x @user0". '10' is called "quantifier" and "@user0" is called "element". @@ -78,7 +78,7 @@ public function getValue(): array $this->getElement(), ]; } - + public function __toString(): string { return sprintf('%sx %s', $this->quantifier, $this->element); diff --git a/src/Definition/Value/EvaluatedValue.php b/src/Definition/Value/EvaluatedValue.php index f762a62e4..b1e388344 100644 --- a/src/Definition/Value/EvaluatedValue.php +++ b/src/Definition/Value/EvaluatedValue.php @@ -31,7 +31,7 @@ public function getValue(): string { return $this->expression; } - + public function __toString(): string { return $this->expression; diff --git a/src/Definition/Value/FixtureMethodCallValue.php b/src/Definition/Value/FixtureMethodCallValue.php index 764e46371..6e988d7bc 100644 --- a/src/Definition/Value/FixtureMethodCallValue.php +++ b/src/Definition/Value/FixtureMethodCallValue.php @@ -16,7 +16,7 @@ use Nelmio\Alice\Definition\ValueInterface; /** - * Value object representing "@user0->getUserName()" + * Value object representing "@user0->getUserName()". */ final class FixtureMethodCallValue implements ValueInterface { @@ -45,7 +45,7 @@ public function getFunctionCall(): FunctionCallValue { return $this->function; } - + public function getValue(): array { return [ @@ -53,14 +53,14 @@ public function getValue(): array $this->function, ]; } - + public function __toString(): string { return sprintf( '%s->%s(%s)', $this->reference, $this->function->getName(), - [] === $this->function->getArguments() ? '' : var_export($this->function->getArguments(), true) + [] === $this->function->getArguments() ? '' : var_export($this->function->getArguments(), true), ); } } diff --git a/src/Definition/Value/FixturePropertyValue.php b/src/Definition/Value/FixturePropertyValue.php index 9cfaa19ed..604ded8f3 100644 --- a/src/Definition/Value/FixturePropertyValue.php +++ b/src/Definition/Value/FixturePropertyValue.php @@ -45,7 +45,7 @@ public function getProperty(): string { return $this->property; } - + public function getValue(): array { return [ @@ -53,7 +53,7 @@ public function getValue(): array $this->property, ]; } - + public function __toString(): string { return sprintf('%s->%s', $this->reference, $this->property); diff --git a/src/Definition/Value/FixtureReferenceValue.php b/src/Definition/Value/FixtureReferenceValue.php index 9c87bbf17..d6905b649 100644 --- a/src/Definition/Value/FixtureReferenceValue.php +++ b/src/Definition/Value/FixtureReferenceValue.php @@ -37,7 +37,7 @@ public function __construct($reference) } elseif (is_array($reference)) { $referenceString = 'array'; } else { - $referenceString = is_scalar($reference) ? gettype($reference) : get_class($reference); + $referenceString = is_scalar($reference) ? gettype($reference) : $reference::class; } throw InvalidArgumentExceptionFactory::createForInvalidReferenceType($referenceString); diff --git a/src/Definition/Value/FunctionCallValue.php b/src/Definition/Value/FunctionCallValue.php index 0a6f4b6c6..d964687dd 100644 --- a/src/Definition/Value/FunctionCallValue.php +++ b/src/Definition/Value/FunctionCallValue.php @@ -13,8 +13,8 @@ namespace Nelmio\Alice\Definition\Value; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\Definition\ValueInterface; +use function Nelmio\Alice\deep_clone; /** * Value object representing ''. @@ -49,7 +49,7 @@ public function getArguments(): array { return deep_clone($this->arguments); } - + public function getValue() { return [ @@ -57,7 +57,7 @@ public function getValue() $this->getArguments(), ]; } - + public function __toString(): string { return sprintf('<%s(%s)>', $this->name, [] === $this->arguments ? '' : var_export($this->arguments, true)); diff --git a/src/Definition/Value/ListValue.php b/src/Definition/Value/ListValue.php index f1f19b8e8..9a2baff31 100644 --- a/src/Definition/Value/ListValue.php +++ b/src/Definition/Value/ListValue.php @@ -13,8 +13,8 @@ namespace Nelmio\Alice\Definition\Value; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\Definition\ValueInterface; +use function Nelmio\Alice\deep_clone; /** * Value representing a list of values which will be chained. For example ' <{bar}>' will be composed of a @@ -42,7 +42,7 @@ public function getValue(): array { return deep_clone($this->values); } - + public function __toString(): string { return implode('', $this->values); diff --git a/src/Definition/Value/NestedValue.php b/src/Definition/Value/NestedValue.php index 4a0443991..148d5c736 100644 --- a/src/Definition/Value/NestedValue.php +++ b/src/Definition/Value/NestedValue.php @@ -37,7 +37,7 @@ public function getValue(): array { return $this->values; } - + public function __toString(): string { return sprintf('(nested) %s', var_export($this->values, true)); diff --git a/src/Definition/Value/OptionalValue.php b/src/Definition/Value/OptionalValue.php index dddeabf01..57429a969 100644 --- a/src/Definition/Value/OptionalValue.php +++ b/src/Definition/Value/OptionalValue.php @@ -17,7 +17,7 @@ use Nelmio\Alice\Throwable\Error\TypeErrorFactory; /** - * Value object representing "80%? 'value': 'empty'" + * Value object representing "80%? 'value': 'empty'". */ final class OptionalValue implements ValueInterface { @@ -37,7 +37,7 @@ final class OptionalValue implements ValueInterface private $secondMember; /** - * @param int|string|ValueInterface $quantifier + * @param int|string|ValueInterface $quantifier * @param string|ValueInterface $firstMember * @param string|ValueInterface|null $secondMember */ @@ -99,14 +99,14 @@ public function getValue(): array $this->getSecondMember(), ]; } - + public function __toString(): string { return sprintf( '%s%%? %s : %s', $this->quantifier, $this->firstMember, - $this->secondMember ?? 'null' + $this->secondMember ?? 'null', ); } } diff --git a/src/Definition/Value/ParameterValue.php b/src/Definition/Value/ParameterValue.php index 76287cb89..9e2554dd8 100644 --- a/src/Definition/Value/ParameterValue.php +++ b/src/Definition/Value/ParameterValue.php @@ -13,9 +13,9 @@ namespace Nelmio\Alice\Definition\Value; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\Definition\ValueInterface; use Nelmio\Alice\Throwable\Error\TypeErrorFactory; +use function Nelmio\Alice\deep_clone; /** * Value object representing '<{param}>'. @@ -38,12 +38,12 @@ public function __construct($parameterKey) $this->parameterKey = $parameterKey; } - + public function getValue() { return deep_clone($this->parameterKey); } - + public function __toString(): string { return sprintf('<{%s}>', $this->parameterKey); diff --git a/src/Definition/Value/ResolvedFunctionCallValue.php b/src/Definition/Value/ResolvedFunctionCallValue.php index 2b7cb1cd1..1bbf8c8cf 100644 --- a/src/Definition/Value/ResolvedFunctionCallValue.php +++ b/src/Definition/Value/ResolvedFunctionCallValue.php @@ -48,7 +48,7 @@ public function getArguments(): array { return $this->arguments; } - + public function getValue() { return [ @@ -56,7 +56,7 @@ public function getValue() $this->getArguments(), ]; } - + public function __toString(): string { return sprintf('<%s(%s)>', $this->name, [] === $this->arguments ? '' : var_export($this->arguments, true)); diff --git a/src/Definition/Value/UniqueValue.php b/src/Definition/Value/UniqueValue.php index 5ac75ece0..5620d71c2 100644 --- a/src/Definition/Value/UniqueValue.php +++ b/src/Definition/Value/UniqueValue.php @@ -13,9 +13,9 @@ namespace Nelmio\Alice\Definition\Value; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\Definition\ValueInterface; use Nelmio\Alice\Throwable\Exception\InvalidArgumentExceptionFactory; +use function Nelmio\Alice\deep_clone; final class UniqueValue implements ValueInterface { @@ -24,11 +24,11 @@ final class UniqueValue implements ValueInterface */ private $id; - private $value; /** - * @param string $id Unique across a fixture set, is used to generate unique values. + * @param string $id Unique across a fixture set, is used to generate unique values. + * @param mixed $value */ public function __construct(string $id, $value) { @@ -50,19 +50,19 @@ public function getId(): string { return $this->id; } - + public function getValue() { return deep_clone($this->value); } - + public function __toString(): string { return sprintf( '(unique) %s', $this->value instanceof ValueInterface ? $this->value - : var_export($this->value, true) + : var_export($this->value, true), ); } } diff --git a/src/Definition/Value/ValueForCurrentValue.php b/src/Definition/Value/ValueForCurrentValue.php index 3b2a82d1e..b70734ada 100644 --- a/src/Definition/Value/ValueForCurrentValue.php +++ b/src/Definition/Value/ValueForCurrentValue.php @@ -24,7 +24,7 @@ public function getValue(): string { return 'current'; } - + public function __toString(): string { return 'current'; diff --git a/src/Definition/Value/VariableValue.php b/src/Definition/Value/VariableValue.php index 7bc3b8fc8..fd7f8561d 100644 --- a/src/Definition/Value/VariableValue.php +++ b/src/Definition/Value/VariableValue.php @@ -32,12 +32,12 @@ public function __construct(string $variable) { $this->variable = $variable; } - + public function getValue(): string { return $this->variable; } - + public function __toString(): string { return sprintf('$%s', $this->variable); diff --git a/src/Faker/GeneratorFactory.php b/src/Faker/GeneratorFactory.php index bc0b8382e..2adf436f0 100644 --- a/src/Faker/GeneratorFactory.php +++ b/src/Faker/GeneratorFactory.php @@ -50,7 +50,7 @@ public function createOrReturnExistingInstance(string $locale): FakerGenerator $instance = FakerFactory::create($locale); $generatorProviders = $this->generator->getProviders(); foreach ($generatorProviders as $provider) { - if (1 !== preg_match('/^Faker\\\Provider/u', get_class($provider))) { + if (1 !== preg_match('/^Faker\\\Provider/u', $provider::class)) { $instance->addProvider($provider); } } diff --git a/src/Faker/Provider/AliceProvider.php b/src/Faker/Provider/AliceProvider.php index 4f5e15029..8333f1cc1 100644 --- a/src/Faker/Provider/AliceProvider.php +++ b/src/Faker/Provider/AliceProvider.php @@ -20,6 +20,7 @@ final class AliceProvider /** * Returns whatever is passed to it. This allows you among other things to use a PHP expression while still * benefiting from variable replacement. + * @param mixed $expression */ public static function identity($expression) { diff --git a/src/FileLocator/DefaultFileLocator.php b/src/FileLocator/DefaultFileLocator.php index d5dca35bb..51b8504cc 100644 --- a/src/FileLocator/DefaultFileLocator.php +++ b/src/FileLocator/DefaultFileLocator.php @@ -25,7 +25,7 @@ */ final class DefaultFileLocator implements FileLocatorInterface { - public function locate(string $name, string $currentPath = null): string + public function locate(string $name, ?string $currentPath = null): string { if ('' === $name) { throw FileNotFoundException::createForEmptyFile(); @@ -45,15 +45,14 @@ public function locate(string $name, string $currentPath = null): string private function isAbsolutePath(string $file): bool { - return ($file[0] === '/' - || $file[0] === '\\' + return '/' === $file[0] + || '\\' === $file[0] || ( - strlen($file) > 3 + mb_strlen($file) > 3 && ctype_alpha($file[0]) - && $file[1] === ':' - && ($file[2] === '\\' || $file[2] === '/') + && ':' === $file[1] + && ('\\' === $file[2] || '/' === $file[2]) ) - || null !== parse_url($file, PHP_URL_SCHEME) - ); + || null !== parse_url($file, PHP_URL_SCHEME); } } diff --git a/src/FileLocatorInterface.php b/src/FileLocatorInterface.php index 03384951e..345e79277 100644 --- a/src/FileLocatorInterface.php +++ b/src/FileLocatorInterface.php @@ -25,5 +25,5 @@ interface FileLocatorInterface * * @return string The full path to the file */ - public function locate(string $name, string $currentPath = null): string; + public function locate(string $name, ?string $currentPath = null): string; } diff --git a/src/FilesLoaderInterface.php b/src/FilesLoaderInterface.php index 3a9a87791..ec26fbad2 100644 --- a/src/FilesLoaderInterface.php +++ b/src/FilesLoaderInterface.php @@ -23,7 +23,7 @@ interface FilesLoaderInterface /** * Loads a collection of fixture files. * - * @param string[] $files Files to load. + * @param string[] $files Files to load. * @param array $parameters Additional parameters to inject. * @param array $objects Additional objects to inject. * diff --git a/src/FixtureBag.php b/src/FixtureBag.php index 2f877ce23..4dce476c9 100644 --- a/src/FixtureBag.php +++ b/src/FixtureBag.php @@ -37,7 +37,7 @@ public function with(FixtureInterface $fixture): self { $clone = clone $this; $clone->fixtures[$fixture->getId()] = clone $fixture; - + return $clone; } @@ -85,7 +85,7 @@ public function get(string $id): FixtureInterface throw FixtureNotFoundExceptionFactory::create($id); } - + public function getIterator(): Traversable { return new ArrayIterator($this->fixtures); diff --git a/src/FixtureBuilder/BareFixtureSet.php b/src/FixtureBuilder/BareFixtureSet.php index 4d749bd09..56f9e6334 100644 --- a/src/FixtureBuilder/BareFixtureSet.php +++ b/src/FixtureBuilder/BareFixtureSet.php @@ -26,7 +26,7 @@ final class BareFixtureSet * @var ParameterBag */ private $parameters; - + /** * @var FixtureBag */ @@ -37,12 +37,12 @@ public function __construct(ParameterBag $parameters, FixtureBag $fixtures) $this->parameters = $parameters; $this->fixtures = $fixtures; } - + public function getParameters(): ParameterBag { return $this->parameters; } - + public function getFixtures(): FixtureBag { return $this->fixtures; diff --git a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/CollectionDenormalizerWithTemporaryFixture.php b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/CollectionDenormalizerWithTemporaryFixture.php index a7f8a9419..b48305bb3 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/CollectionDenormalizerWithTemporaryFixture.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/CollectionDenormalizerWithTemporaryFixture.php @@ -55,34 +55,34 @@ final class CollectionDenormalizerWithTemporaryFixture implements CollectionDeno public function __construct( CollectionDenormalizer $decoratedCollectionDenormalizer, - FixtureDenormalizerInterface $decoratedDenormalizer = null, - FlagParserInterface $parser = null + ?FixtureDenormalizerInterface $decoratedDenormalizer = null, + ?FlagParserInterface $parser = null ) { $this->collectionDenormalizer = $decoratedCollectionDenormalizer; $this->denormalizer = $decoratedDenormalizer; $this->parser = $parser; } - + public function withFlagParser(FlagParserInterface $parser): self { - return new static($this->collectionDenormalizer, $this->denormalizer, $parser); + return new self($this->collectionDenormalizer, $this->denormalizer, $parser); } - + public function withFixtureDenormalizer(FixtureDenormalizerInterface $denormalizer) { - return new static($this->collectionDenormalizer, $denormalizer, $this->parser); + return new self($this->collectionDenormalizer, $denormalizer, $this->parser); } - + public function canDenormalize(string $reference): bool { return $this->collectionDenormalizer->canDenormalize($reference); } - + public function buildIds(string $id): array { return $this->collectionDenormalizer->buildIds($id); } - + public function denormalize( FixtureBag $builtFixtures, string $className, @@ -109,7 +109,7 @@ public function denormalize( $builtFixtures, $className, $specs, - $flags + $flags, ); $fixtureIds = $this->buildIds($fixtureId); @@ -121,11 +121,11 @@ public function denormalize( $fixtureId, $tempFixture->getClassName(), $tempFixture->getSpecs(), - (string) $valueForCurrent + (string) $valueForCurrent, ), - $flags->withKey($fixtureId) - ) - ) + $flags->withKey($fixtureId), + ), + ), ); } @@ -152,7 +152,7 @@ private function denormalizeTemporaryFixture( $className, $tempFixtureId, $specs, - $flags + $flags, ); $tempFixture = $builtFixtures->get($tempFixtureId); diff --git a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizer.php index e0ec4ffa9..95a7e66d3 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizer.php @@ -23,17 +23,17 @@ final class NullListNameDenormalizer implements CollectionDenormalizer use IsAServiceTrait; /** @private */ - const REGEX = '/\{(?[\p{L}\d\._\/]+(?:,\s[^,\s]+)*)\}/u'; - + public const REGEX = '/\{(?[\p{L}\d\._\/]+(?:,\s[^,\s]+)*)\}/u'; + public function canDenormalize(string $reference, array &$matches = []): bool { if (1 === preg_match(self::REGEX, $reference, $matches)) { - return false === strpos($matches['list'], '..'); + return false === mb_strpos($matches['list'], '..'); } return false; } - + public function denormalize( FixtureBag $builtFixtures, string $className, @@ -68,7 +68,7 @@ public function buildIds(string $id): array str_replace( sprintf('{%s}', $matches['list']), $element, - $id + $id, ) ] = $element; } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizer.php index f32538eb6..088f77245 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizer.php @@ -78,7 +78,7 @@ public function buildIds(string $id): array str_replace( $this->token, (string) $currentIndex, - $range->getName() + $range->getName(), ) ] = $currentIndex; } @@ -101,7 +101,7 @@ private function buildRange(string $name): RangeName $reference = str_replace( sprintf('{%s}', $matches['range']), $this->token, - $name + $name, ); $step = 1; diff --git a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizer.php index d7f30261f..b7c087ff2 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizer.php @@ -47,7 +47,7 @@ final class ReferenceRangeNameDenormalizer implements ChainableFixtureDenormaliz */ private $specsDenormalizer; - public function __construct(SpecificationsDenormalizerInterface $specsDenormalizer, FlagParserInterface $parser = null) + public function __construct(SpecificationsDenormalizerInterface $specsDenormalizer, ?FlagParserInterface $parser = null) { $this->specsDenormalizer = $specsDenormalizer; $this->flagParser = $parser; @@ -94,12 +94,12 @@ public function denormalize( $builtFixtures = $builtFixtures->with( $this->buildFixture( - $fixtureIdPrefix . $referencedFixtureId, + $fixtureIdPrefix.$referencedFixtureId, $className, $specs, $idFlags->mergeWith($flags), - $valueForCurrent - ) + $valueForCurrent, + ), ); } @@ -124,13 +124,11 @@ private function buildReferencedValues( /** @var array $matchedFixtures */ $matchedFixtures = array_filter( $builtFixtures->toArray(), - static function (string $referenceName) use ($referencedName) { - return str_starts_with($referenceName, $referencedName); - }, - ARRAY_FILTER_USE_KEY + static fn (string $referenceName) => str_starts_with($referenceName, $referencedName), + ARRAY_FILTER_USE_KEY, ); - if (count($matchedFixtures) === 0) { + if (0 === count($matchedFixtures)) { throw FixtureNotFoundExceptionFactory::createWildcard($referencedName); } @@ -147,7 +145,7 @@ private function determineFixtureIdPrefix(string $fixtureId): string return str_replace( sprintf('{%s}', $matches['expression']), '', - $matches[0] + $matches[0], ); } @@ -162,17 +160,17 @@ private function buildFixture( $fixtureId, $className, new SpecificationBag(null, new PropertyBag(), new MethodCallBag()), - $valueForCurrent + $valueForCurrent, ); $fixture = $fixture->withSpecs( - $this->specsDenormalizer->denormalize($fixture, $this->flagParser, $specs) + $this->specsDenormalizer->denormalize($fixture, $this->flagParser, $specs), ); return new TemplatingFixture( new SimpleFixtureWithFlags( $fixture, - $flags->withKey($fixtureId) - ) + $flags->withKey($fixtureId), + ), ); } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleCollectionDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleCollectionDenormalizer.php index 802911487..8bac88442 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleCollectionDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleCollectionDenormalizer.php @@ -53,8 +53,8 @@ final class SimpleCollectionDenormalizer implements CollectionDenormalizer, Fixt public function __construct( CollectionDenormalizer $decoratedCollectionDenormalizer, - FixtureDenormalizerInterface $decoratedDenormalizer = null, - FlagParserInterface $parser = null + ?FixtureDenormalizerInterface $decoratedDenormalizer = null, + ?FlagParserInterface $parser = null ) { if ($decoratedCollectionDenormalizer instanceof FixtureDenormalizerAwareInterface && null !== $decoratedDenormalizer @@ -72,22 +72,22 @@ public function __construct( $this->denormalizer = $decoratedDenormalizer; $this->parser = $parser; } - + public function withFlagParser(FlagParserInterface $parser): self { - return new static($this->collectionDenormalizer, $this->denormalizer, $parser); + return new self($this->collectionDenormalizer, $this->denormalizer, $parser); } - + public function withFixtureDenormalizer(FixtureDenormalizerInterface $denormalizer) { - return new static($this->collectionDenormalizer, $denormalizer, $this->parser); + return new self($this->collectionDenormalizer, $denormalizer, $this->parser); } - + public function canDenormalize(string $reference): bool { return $this->collectionDenormalizer->canDenormalize($reference); } - + public function buildIds(string $id): array { return $this->collectionDenormalizer->buildIds($id); @@ -125,7 +125,7 @@ public function denormalize( $fixtureId, $specs, $flags, - (string) $valueForCurrent + (string) $valueForCurrent, ); } @@ -145,7 +145,7 @@ private function denormalizeFixture( $className, $fixtureId, $specs, - $flags + $flags, ); // At this point we remove the denormalized fixture to re-create a new one with this time its value for current @@ -162,11 +162,11 @@ private function denormalizeFixture( $fixtureId, $builtFixture->getClassName(), $builtFixture->getSpecs(), - $valueForCurrent + $valueForCurrent, ), - $flags->withKey($fixtureId) - ) - ) + $flags->withKey($fixtureId), + ), + ), ); } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizer.php index 056c95286..9e07a52b4 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizer.php @@ -36,51 +36,51 @@ final class SimpleDenormalizer implements ChainableFixtureDenormalizerInterface, * @var FlagParserInterface|null */ private $flagParser; - + /** * @var SpecificationsDenormalizerInterface */ private $specsDenormalizer; - public function __construct(SpecificationsDenormalizerInterface $specsDenormalizer, FlagParserInterface $parser = null) + public function __construct(SpecificationsDenormalizerInterface $specsDenormalizer, ?FlagParserInterface $parser = null) { $this->specsDenormalizer = $specsDenormalizer; $this->flagParser = $parser; } - + public function withFlagParser(FlagParserInterface $parser): self { return new self($this->specsDenormalizer, $parser); } - + public function canDenormalize(string $reference): bool { - return false === strpos($reference, '{'); + return false === mb_strpos($reference, '{'); } - + public function denormalize(FixtureBag $builtFixtures, string $className, string $unparsedFixtureId, array $specs, FlagBag $flags): FixtureBag { if (null === $this->flagParser) { throw FlagParserExceptionFactory::createForExpectedMethodToBeCalledIfHasAParser(__METHOD__); } - + $idFlags = $this->flagParser->parse($unparsedFixtureId); $fixture = new SimpleFixture( $idFlags->getKey(), $className, - new SpecificationBag(null, new PropertyBag(), new MethodCallBag()) + new SpecificationBag(null, new PropertyBag(), new MethodCallBag()), ); $fixture = $fixture->withSpecs( - $this->specsDenormalizer->denormalize($fixture, $this->flagParser, $specs) + $this->specsDenormalizer->denormalize($fixture, $this->flagParser, $specs), ); return $builtFixtures->with( new TemplatingFixture( new SimpleFixtureWithFlags( $fixture, - $idFlags->mergeWith($flags) - ) - ) + $idFlags->mergeWith($flags), + ), + ), ); } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerInterface.php b/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerInterface.php index 8d97cb548..a7939eb64 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerInterface.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerInterface.php @@ -22,9 +22,9 @@ interface FixtureDenormalizerInterface /** * A more specific version of {@see \Nelmio\Alice\BuilderInterface} dedicated to fixtures. * - * @param string $className FQCN (no flags) - * @param array $specs Contains the list of property calls, constructor specification and method calls - * @param FlagBag $flags Flags inherited from the namespace. + * @param string $className FQCN (no flags) + * @param array $specs Contains the list of property calls, constructor specification and method calls + * @param FlagBag $flags Flags inherited from the namespace. * * @throws DenormalizationThrowable * diff --git a/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistry.php b/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistry.php index 03afbe043..e787e909b 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistry.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistry.php @@ -24,7 +24,7 @@ final class FixtureDenormalizerRegistry implements FixtureDenormalizerInterface { use IsAServiceTrait; - + /** * @var ChainableFixtureDenormalizerInterface[] */ @@ -43,15 +43,15 @@ public function __construct(FlagParserInterface $flagParser, array $denormalizer if ($denormalizer instanceof FixtureDenormalizerAwareInterface) { $denormalizer = $denormalizer->withFixtureDenormalizer($this); } - + if ($denormalizer instanceof FlagParserAwareInterface) { $denormalizer = $denormalizer->withFlagParser($flagParser); } - + $this->denormalizers[] = $denormalizer; } } - + public function denormalize(FixtureBag $builtFixtures, string $className, string $fixtureId, array $specs, FlagBag $flags): FixtureBag { foreach ($this->denormalizers as $denormalizer) { diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizer.php index a36bd808b..cbcf4cb10 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizer.php @@ -69,8 +69,8 @@ public function denormalize(array $data): FixtureBag sprintf( 'Expected an array for the class "%s", found "%s" instead.', $fqcnWithFlags, - gettype($rawFixtureSet) - ) + gettype($rawFixtureSet), + ), ); } @@ -81,7 +81,7 @@ public function denormalize(array $data): FixtureBag $fqcn, $reference, $specs ?? [], - $flags + $flags, ); } } catch (UnexpectedValueException $exception) { diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizer.php index cce447d3e..e0c76f38f 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizer.php @@ -32,7 +32,7 @@ public function __construct(ValueDenormalizerInterface $valueDenormalizer) { $this->valueDenormalizer = $valueDenormalizer; } - + public function denormalize( FixtureInterface $scope, FlagParserInterface $parser, diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ArgumentsDenormalizerInterface.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ArgumentsDenormalizerInterface.php index 1a8ea55f3..86702a6da 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ArgumentsDenormalizerInterface.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ArgumentsDenormalizerInterface.php @@ -26,7 +26,6 @@ interface ArgumentsDenormalizerInterface /** * Denormalizes an array of arguments. * - * * @throws DenormalizationThrowable * * @return array|ValueInterface[] diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizer.php index 5f9a46a31..9c1ec41e1 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizer.php @@ -35,16 +35,14 @@ final class CallsWithFlagsDenormalizer implements CallsDenormalizerInterface private $methodFlagHandlers; /** - * @param MethodFlagHandler[] $methodFlagHandlers + * @param MethodFlagHandler[] $methodFlagHandlers */ public function __construct(CallsDenormalizerInterface $callsDenormalizer, array $methodFlagHandlers) { $this->callsDenormalizer = $callsDenormalizer; - $this->methodFlagHandlers = (static function (MethodFlagHandler ...$handlers) { - return $handlers; - })(...$methodFlagHandlers); + $this->methodFlagHandlers = (static fn (MethodFlagHandler ...$handlers) => $handlers)(...$methodFlagHandlers); } - + public function denormalize( FixtureInterface $scope, FlagParserInterface $parser, diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizer.php index 43e33bf0a..083b128e7 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizer.php @@ -38,7 +38,7 @@ public function __construct(ArgumentsDenormalizerInterface $argumentsDenormalize { $this->argumentsDenormalizer = $argumentsDenormalizer; } - + public function denormalize( FixtureInterface $scope, FlagParserInterface $parser, @@ -60,7 +60,7 @@ public function denormalize( */ private function getCallerReference(FixtureInterface $scope, string $method): array { - if (false === strpos($method, '::')) { + if (false === mb_strpos($method, '::')) { return [null, $method]; } @@ -71,8 +71,8 @@ private function getCallerReference(FixtureInterface $scope, string $method): ar [$caller, $method] = $explodedMethod; - if (0 === strpos($caller, '@')) { - return [new InstantiatedReference(substr($caller, 1)), $method]; + if (0 === mb_strpos($caller, '@')) { + return [new InstantiatedReference(mb_substr($caller, 1)), $method]; } return [new StaticReference($caller), $method]; diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandler.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandler.php index bf16d71bc..f6e98980a 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandler.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandler.php @@ -23,12 +23,11 @@ final class ConfiguratorFlagHandler implements MethodFlagHandler { use IsAServiceTrait; - + public function handleMethodFlags(MethodCallInterface $methodCall, FlagInterface $flag): MethodCallInterface { return $flag instanceof ConfiguratorFlag ? new ConfiguratorMethodCall($methodCall) - : $methodCall - ; + : $methodCall; } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandler.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandler.php index fb714964a..235a3b63b 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandler.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandler.php @@ -23,12 +23,11 @@ final class OptionalFlagHandler implements MethodFlagHandler { use IsAServiceTrait; - + public function handleMethodFlags(MethodCallInterface $methodCall, FlagInterface $flag): MethodCallInterface { return $flag instanceof OptionalFlag ? new OptionalMethodCall($methodCall, $flag) - : $methodCall - ; + : $methodCall; } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/CallsDenormalizerInterface.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/CallsDenormalizerInterface.php index de7254fc3..ba98de7a6 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/CallsDenormalizerInterface.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/CallsDenormalizerInterface.php @@ -23,7 +23,7 @@ interface CallsDenormalizerInterface /** * Denormalizes a method call. * - * @param FixtureInterface $scope See SpecificationsDenormalizerInterface + * @param FixtureInterface $scope See SpecificationsDenormalizerInterface * * @throws DenormalizationThrowable * diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizer.php index 526461366..17d9f5c3e 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizer.php @@ -46,7 +46,7 @@ public function denormalize( ): MethodCallInterface { return new SimpleMethodCall( '__construct', - $this->argumentDenormalizer->denormalize($scope, $parser, $unparsedConstructor) + $this->argumentDenormalizer->denormalize($scope, $parser, $unparsedConstructor), ); } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizer.php index 9b03dd780..1e8ca0396 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizer.php @@ -34,7 +34,7 @@ public function __construct(CallsDenormalizerInterface $callsDenormalizer) { $this->callsDenormalizer = $callsDenormalizer; } - + public function denormalize( FixtureInterface $scope, FlagParserInterface $parser, @@ -56,11 +56,11 @@ public function denormalize( throw DenormalizerExceptionFactory::createForUndenormalizableFactory(); } - if (false === strpos($method, '::')) { + if (false === mb_strpos($method, '::')) { $method = sprintf( '%s::%s', $scope->getClassName(), - $method + $method, ); } @@ -68,7 +68,7 @@ public function denormalize( $scope, $parser, $method, - $arguments + $arguments, ); } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LegacyConstructorDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LegacyConstructorDenormalizer.php index 9062d8d29..3ce212427 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LegacyConstructorDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LegacyConstructorDenormalizer.php @@ -41,7 +41,7 @@ public function __construct( $this->constructorDenormalizer = $constructorDenormalizer; $this->factoryDenormalizer = $factoryDenormalizer; } - + public function denormalize( FixtureInterface $scope, FlagParserInterface $parser, diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ConstructorDenormalizerInterface.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ConstructorDenormalizerInterface.php index 0b773e593..bad1214ce 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ConstructorDenormalizerInterface.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ConstructorDenormalizerInterface.php @@ -23,7 +23,6 @@ interface ConstructorDenormalizerInterface /** * Denormalizes a constructor. * - * * @throws DenormalizationThrowable * * @example diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizer.php index eb043d0f8..454105860 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizer.php @@ -33,7 +33,7 @@ public function __construct(ValueDenormalizerInterface $valueDenormalizer) { $this->valueDenormalizer = $valueDenormalizer; } - + public function denormalize(FixtureInterface $scope, string $name, $value, FlagBag $flags): Property { $value = $this->valueDenormalizer->denormalize($scope, $flags, $value); diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/PropertyDenormalizerInterface.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/PropertyDenormalizerInterface.php index 89b1c50fc..ea6029c59 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/PropertyDenormalizerInterface.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/PropertyDenormalizerInterface.php @@ -24,6 +24,7 @@ interface PropertyDenormalizerInterface * Denormalizes a property. * * @param FixtureInterface $scope See SpecificationsDenormalizerInterface::denormalize() + * @param mixed $value * * @throws DenormalizationThrowable */ diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php index c009e8867..114390aa2 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php @@ -52,7 +52,7 @@ public function __construct( $this->propertyDenormalizer = $propertyDenormalizer; $this->callsDenormalizer = $callsDenormalizer; } - + public function denormalize(FixtureInterface $scope, FlagParserInterface $parser, array $unparsedSpecs): SpecificationBag { $constructor = null; @@ -64,8 +64,8 @@ public function denormalize(FixtureInterface $scope, FlagParserInterface $parser throw new InvalidArgumentException( sprintf( 'Invalid property name: %s.', - $unparsedPropertyName - ) + $unparsedPropertyName, + ), ); } @@ -76,7 +76,7 @@ public function denormalize(FixtureInterface $scope, FlagParserInterface $parser @trigger_error( 'Using factories with the fixture keyword "__construct" has been deprecated since ' .'3.0.0 and will no longer be supported in Alice 4.0.0. Use "__factory" instead.', - E_USER_DEPRECATED + E_USER_DEPRECATED, ); } @@ -112,8 +112,7 @@ private function denormalizeConstructor( ): MethodCallInterface { return (false === $value) ? new NoMethodCall() - : $this->constructorDenormalizer->denormalize($scope, $parser, $value) - ; + : $this->constructorDenormalizer->denormalize($scope, $parser, $value); } private function denormalizeFactory( @@ -180,7 +179,7 @@ private function denormalizeCallMethod( $scope, $parser, $unparsedMethod, - $methodCall[$unparsedMethod] + $methodCall[$unparsedMethod], ); } } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php index 65758c268..dace6cfb4 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php @@ -36,8 +36,8 @@ public function __construct(ParserInterface $parser) { $this->parser = $parser; } - - public function denormalize(FixtureInterface $scope, FlagBag $flags = null, $value) + + public function denormalize(FixtureInterface $scope, ?FlagBag $flags = null, $value) { if (is_string($value)) { return $this->parseValue($this->parser, $value); diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizer.php index c5c06a6ee..b172b88a2 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizer.php @@ -41,9 +41,10 @@ public function __construct(ValueDenormalizerInterface $decoratedDenormalizer) } /** + * @param mixed $value * @throws InvalidScopeException */ - public function denormalize(FixtureInterface $scope, FlagBag $flags = null, $value) + public function denormalize(FixtureInterface $scope, ?FlagBag $flags = null, $value) { $value = $this->denormalizer->denormalize($scope, $flags, $value); @@ -54,7 +55,7 @@ public function denormalize(FixtureInterface $scope, FlagBag $flags = null, $val return $this->generateValue($scope, $flags, $value); } - private function requiresUnique(FlagBag $flags = null): bool + private function requiresUnique(?FlagBag $flags = null): bool { if (null === $flags) { return false; @@ -77,7 +78,7 @@ private function requiresUnique(FlagBag $flags = null): bool private function generateValue(FixtureInterface $scope, FlagBag $flags, $value): ValueInterface { $uniqueId = sprintf('%s#%s', $scope->getClassName(), $flags->getKey()); - if ('temporary_id' === substr($scope->getId(), 0, 12)) { + if ('temporary_id' === mb_substr($scope->getId(), 0, 12)) { throw DenormalizerExceptionFactory::createForInvalidScopeForUniqueValue(); } @@ -86,7 +87,7 @@ private function generateValue(FixtureInterface $scope, FlagBag $flags, $value): return new DynamicArrayValue( $value->getQuantifier(), - new UniqueValue($uniqueId, $value->getElement()) + new UniqueValue($uniqueId, $value->getElement()), ); } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ValueDenormalizerInterface.php b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ValueDenormalizerInterface.php index 41303db0c..7d905adca 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ValueDenormalizerInterface.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/ValueDenormalizerInterface.php @@ -24,10 +24,11 @@ interface ValueDenormalizerInterface * Denormalizes a given value. For example, will denormalize '$username' into a VariableValue. * * @param FixtureInterface $scope Used for unique values for example. + * @param mixed $value * * @throws DenormalizationThrowable * * @return ValueInterface|mixed */ - public function denormalize(FixtureInterface $scope, FlagBag $flags = null, $value); + public function denormalize(FixtureInterface $scope, ?FlagBag $flags = null, $value); } diff --git a/src/FixtureBuilder/Denormalizer/Fixture/TolerantFixtureDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/TolerantFixtureDenormalizer.php index a5a757047..732a404d0 100644 --- a/src/FixtureBuilder/Denormalizer/Fixture/TolerantFixtureDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/Fixture/TolerantFixtureDenormalizer.php @@ -25,17 +25,17 @@ final class TolerantFixtureDenormalizer implements FixtureDenormalizerInterface { use IsAServiceTrait; - + /** * @var FixtureDenormalizerInterface */ private $denormalizer; - + public function __construct(FixtureDenormalizerInterface $denormalizer) { $this->denormalizer = $denormalizer; } - + public function denormalize(FixtureBag $builtFixtures, string $className, string $fixtureId, array $specs, FlagBag $flags): FixtureBag { try { @@ -53,10 +53,10 @@ public function denormalize(FixtureBag $builtFixtures, string $className, string 'An error occurred while denormalizing the fixture "%s" (%s): %s', $fixtureId, $className, - $throwable->getMessage() + $throwable->getMessage(), ), $throwable->getCode(), - $throwable + $throwable, ]; throw new $throwableClass(...$arguments); diff --git a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParser.php b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParser.php index 5fa3a73ad..440e71413 100644 --- a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParser.php +++ b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParser.php @@ -21,12 +21,12 @@ final class ConfiguratorFlagParser implements ChainableFlagParserInterface { use IsAServiceTrait; - + public function canParse(string $element): bool { return 'configurator' === $element; } - + public function parse(string $element): FlagBag { return (new FlagBag(''))->withFlag(new ConfiguratorFlag()); diff --git a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParser.php b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParser.php index 5680699fc..7407214cb 100644 --- a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParser.php +++ b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParser.php @@ -24,19 +24,19 @@ final class ExtendFlagParser implements ChainableFlagParserInterface use IsAServiceTrait; /** @interval */ - const REGEX = '/^extends (?.+)$/'; - + public const REGEX = '/^extends (?.+)$/'; + public function canParse(string $element, array &$matches = []): bool { return 1 === preg_match(self::REGEX, $element, $matches); } - + public function parse(string $element): FlagBag { $matches = []; $this->canParse($element, $matches); $extended = new FixtureReference($matches['reference']); - + return (new FlagBag(''))->withFlag(new ExtendFlag($extended)); } } diff --git a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParser.php b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParser.php index c0ce7081a..08091414b 100644 --- a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParser.php +++ b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParser.php @@ -23,19 +23,19 @@ final class OptionalFlagParser implements ChainableFlagParserInterface use IsAServiceTrait; /** @interval */ - const REGEX = '/^(?\d+)\%\?$/'; - + public const REGEX = '/^(?\d+)\%\?$/'; + public function canParse(string $element, array &$matches = []): bool { return 1 === preg_match(self::REGEX, $element, $matches); } - + public function parse(string $element): FlagBag { $matches = []; $this->canParse($element, $matches); $percentage = (int) $matches['percentage']; - + return (new FlagBag(''))->withFlag(new OptionalFlag($percentage)); } } diff --git a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParser.php b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParser.php index 2e80be8f2..0d2bb3b46 100644 --- a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParser.php +++ b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParser.php @@ -21,12 +21,12 @@ final class TemplateFlagParser implements ChainableFlagParserInterface { use IsAServiceTrait; - + public function canParse(string $element): bool { return 'template' === $element; } - + public function parse(string $element): FlagBag { return (new FlagBag(''))->withFlag(new TemplateFlag()); diff --git a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParser.php b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParser.php index f858d862d..dfe71a2cc 100644 --- a/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParser.php +++ b/src/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParser.php @@ -21,12 +21,12 @@ final class UniqueFlagParser implements ChainableFlagParserInterface { use IsAServiceTrait; - + public function canParse(string $element): bool { return 'unique' === $element; } - + public function parse(string $element): FlagBag { return (new FlagBag(''))->withFlag(new UniqueFlag()); diff --git a/src/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParser.php b/src/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParser.php index 4516e1bf4..d916bd469 100644 --- a/src/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParser.php +++ b/src/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParser.php @@ -25,7 +25,7 @@ final class ElementFlagParser implements FlagParserInterface use IsAServiceTrait; /** @private */ - const REGEX = '/\s*(?.+?)\s\((?.+).*\)$/'; + public const REGEX = '/\s*(?.+?)\s\((?.+).*\)$/'; /** * @var FlagParserInterface @@ -36,7 +36,7 @@ public function __construct(FlagParserInterface $parser) { $this->parser = $parser; } - + public function parse(string $element): FlagBag { if (1 !== preg_match(self::REGEX, $element, $matches)) { @@ -47,7 +47,7 @@ public function parse(string $element): FlagBag $stringFlags = preg_split('/\s*,\s*/', $matches['stringFlags']); foreach ($stringFlags as $stringFlag) { $flags = $flags->mergeWith( - $this->parser->parse(trim($stringFlag)) + $this->parser->parse(trim($stringFlag)), ); } diff --git a/src/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistry.php b/src/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistry.php index dbc6b852e..262389ca9 100644 --- a/src/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistry.php +++ b/src/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistry.php @@ -36,12 +36,10 @@ final class FlagParserRegistry implements FlagParserInterface public function __construct(array $parsers) { $this->parsers = ( - static function (ChainableFlagParserInterface ...$parsers) { - return $parsers; - } + static fn (ChainableFlagParserInterface ...$parsers) => $parsers )(...$parsers); } - + public function parse(string $element): FlagBag { foreach ($this->parsers as $parser) { diff --git a/src/FixtureBuilder/Denormalizer/SimpleDenormalizer.php b/src/FixtureBuilder/Denormalizer/SimpleDenormalizer.php index 872019970..38fed3d50 100644 --- a/src/FixtureBuilder/Denormalizer/SimpleDenormalizer.php +++ b/src/FixtureBuilder/Denormalizer/SimpleDenormalizer.php @@ -36,7 +36,7 @@ public function __construct(ParameterBagDenormalizerInterface $parametersDenorma $this->parametersDenormalizer = $parametersDenormalizer; $this->fixturesDenormalizer = $fixturesDenormalizer; } - + public function denormalize(array $data): BareFixtureSet { $parameters = $this->parametersDenormalizer->denormalize($data); diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexer.php index 1b80c82b6..40c378838 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexer.php @@ -31,7 +31,7 @@ public function __construct(LexerInterface $decoratedLexer) { $this->lexer = $decoratedLexer; } - + public function lex(string $value): array { if ('' === $value) { diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexer.php index 88e40bf4f..bd11c2c2c 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexer.php @@ -25,7 +25,7 @@ final class FunctionLexer implements LexerInterface use IsAServiceTrait; /** @private */ - const DELIMITER= '___##'; + public const DELIMITER = '___##'; /** * @var LexerInterface diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizer.php index 6d4337115..cd0c7aff7 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizer.php @@ -25,7 +25,7 @@ final class FunctionTokenizer use IsAServiceTrait; /** @internal */ - const DELIMITER= '___##'; + public const DELIMITER = '___##'; private $tokenizer; @@ -46,8 +46,7 @@ public function tokenize(string $value): string foreach ($tree as $node) { $tokenizedValue .= ($this->tokenizer->isOpeningToken($node)) ? sprintf('', $node) - : $node - ; + : $node; } return $tokenizedValue; @@ -55,7 +54,7 @@ public function tokenize(string $value): string public function isTokenized(string $value): bool { - return strpos($value, 'tokenizer->detokenize($value); } @@ -122,7 +121,7 @@ private function buildTree(string $originalValue, array $tokens): array private function append(array &$tree, array $values, int $startKey, int $endKey): void { $value = ''; - for ($i = $startKey; $i < $endKey; $i++) { + for ($i = $startKey; $i < $endKey; ++$i) { $value .= $values[$i]; } diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTreeTokenizer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTreeTokenizer.php index a406f9694..a8a20ce01 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTreeTokenizer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTreeTokenizer.php @@ -23,7 +23,7 @@ final class FunctionTreeTokenizer use IsAServiceTrait; /** @private */ - const DELIMITER= '___##'; + public const DELIMITER = '___##'; /** * Replaces the function delimiters by tokens to easily identify them in the future and return the value splat into @@ -46,17 +46,17 @@ public function tokenize(string $value): array $value = preg_replace( '/(.*?)<((?:.*?:)?(?:\p{L}|_|[0-9])+?)\((.*?)/', sprintf('$1%1$sFUNCTION_START__$2__%1$s$3', self::DELIMITER), - $value + $value, ); $value = preg_replace( '/<\(/', sprintf('%1$sIDENTITY_START%1$s', self::DELIMITER), - $value + $value, ); $value = preg_replace( '/\)>/', sprintf('%1$sIDENTITY_OR_FUNCTION_END%1$s', self::DELIMITER), - $value + $value, ); return preg_split(sprintf('/%s/', self::DELIMITER), $value, -1, PREG_SPLIT_NO_EMPTY); @@ -68,33 +68,32 @@ public function tokenize(string $value): array public function detokenize(string $value): string { $count = 1; - while ($count !== 0) { + while (0 !== $count) { $value = preg_replace( '/FUNCTION_START__(.*?)__/', '<$1(', $value, 1, - $count + $count, ); } $value = preg_replace( '/IDENTITY_START/', '<(', - $value + $value, ); - $value = preg_replace( + + return preg_replace( '/IDENTITY_OR_FUNCTION_END/', ')>', - $value + $value, ); - - return $value; } public function isOpeningToken(string $value): bool { - return 'FUNCTION_START__' === substr($value, 0, 16) || 'IDENTITY_START' === substr($value, 0, 14); + return 'FUNCTION_START__' === mb_substr($value, 0, 16) || 'IDENTITY_START' === mb_substr($value, 0, 14); } public function isClosingToken(string $value): bool diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexer.php index c6e708323..f33700e6d 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexer.php @@ -27,7 +27,7 @@ final class GlobalPatternsLexer implements LexerInterface { use IsAServiceTrait; - const PATTERNS = [ + public const PATTERNS = [ '/^(?:\d+|<.*>)x .*/' => TokenType::DYNAMIC_ARRAY_TYPE, '/^.*(?:\d+|<.*>)x .*/' => null, '/^[^<>\[\%\$@\\\]+$/' => TokenType::STRING_TYPE, diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexer.php index 53d731965..045a49bc9 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexer.php @@ -28,7 +28,7 @@ final class ReferenceLexer implements LexerInterface { use IsAServiceTrait; - const PATTERNS = [ + public const PATTERNS = [ '/^@.*->\S+\(.*\)/' => TokenType::METHOD_REFERENCE_TYPE, '/^@.*->[^\(\)\ \{]+/' => TokenType::PROPERTY_REFERENCE_TYPE, '/^@[^\ @\-]+\{\d+\.\.\d+\}/' => TokenType::RANGE_REFERENCE_TYPE, @@ -41,9 +41,7 @@ final class ReferenceLexer implements LexerInterface ]; /** - * Lex a value with the mask "@X" where X is a valid possible reference - * - * + * Lex a value with the mask "@X" where X is a valid possible reference. * * @throws LexException */ diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexer.php index e17be9e10..2034322d9 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexer.php @@ -34,7 +34,7 @@ public function __construct(LexerInterface $decoratedLexer) { $this->decoratedLexer = $decoratedLexer; } - + public function lex(string $value): array { $tokens = $this->decoratedLexer->lex($value); @@ -48,21 +48,21 @@ public function lex(string $value): array continue; } - if ($token->getType() === TokenType::STRING_TYPE && - $nextToken->getType() === TokenType::SIMPLE_REFERENCE_TYPE && - trim($token->getValue()) !== '' && - !in_array(substr($token->getValue(), -1), [' ', '\''], true) + if (TokenType::STRING_TYPE === $token->getType() + && TokenType::SIMPLE_REFERENCE_TYPE === $nextToken->getType() + && '' !== trim($token->getValue()) + && !in_array(mb_substr($token->getValue(), -1), [' ', '\''], true) ) { array_splice($tokens, $idx, 2, [ new Token( $token->getValue().$nextToken->getValue(), - new TokenType(TokenType::STRING_TYPE) - ) + new TokenType(TokenType::STRING_TYPE), + ), ]); } ++$idx; - } while ($token !== false && $nextToken !== false); + } while (false !== $token && false !== $nextToken); return $tokens; } diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php index 4c2d13860..53fde47de 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php @@ -27,9 +27,9 @@ final class SubPatternsLexer implements LexerInterface { use IsAServiceTrait; - const REFERENCE_LEXER = 'reference'; + public const REFERENCE_LEXER = 'reference'; - const PATTERNS = [ + public const PATTERNS = [ '/^((?:\d+|<.+>)%\? [^:]+:[^\ ]+)/' => null, '/^((?:\d+|\d*\.\d+|<.+>)%\? [^:]+(?:\: +\S+)?)/' => TokenType::OPTIONAL_TYPE, '/^((?:\d+|\d*\.\d+|<.+>)%\? : ?[^\ ]+?)/' => null, @@ -75,16 +75,16 @@ public function __construct(LexerInterface $referenceLexer) public function lex(string $value): array { $offset = 0; - $valueLength = strlen($value); + $valueLength = mb_strlen($value); $tokens = []; while ($offset < $valueLength) { - $valueFragment = substr($value, $offset); + $valueFragment = mb_substr($value, $offset); $fragmentTokens = $this->lexFragment($this->referenceLexer, $valueFragment); foreach ($fragmentTokens as $fragmentToken) { $tokens[] = $fragmentToken; - $offset += strlen($fragmentToken->getValue()); + $offset += mb_strlen($fragmentToken->getValue()); } } diff --git a/src/FixtureBuilder/ExpressionLanguage/LexerInterface.php b/src/FixtureBuilder/ExpressionLanguage/LexerInterface.php index 34e118617..73c6467a7 100644 --- a/src/FixtureBuilder/ExpressionLanguage/LexerInterface.php +++ b/src/FixtureBuilder/ExpressionLanguage/LexerInterface.php @@ -23,7 +23,6 @@ interface LexerInterface /** * Converts a string into a sequence of tokens. * - * * @throws ExpressionLanguageParseThrowable * * @return Token[] diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParser.php index 7902ee6cf..e6b306938 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParser.php @@ -53,15 +53,14 @@ public function parse(string $value) $mergedValues = array_reduce( $parsedValue->getValue(), [$this, 'mergeFunctionFixtureReferences'], - [] + [], ); return (1 === count($mergedValues)) ? $mergedValues[0] - : new ListValue($mergedValues) - ; + : new ListValue($mergedValues); } - + private function mergeFunctionFixtureReferences(array $values, $value): array { $lastElement = end($values); @@ -75,7 +74,7 @@ private function mergeFunctionFixtureReferences(array $values, $value): array new ListValue([ $lastElement->getValue(), $value, - ]) + ]), ); return $values; diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php index e755331de..d8396681a 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php @@ -46,10 +46,9 @@ public function __construct(LexerInterface $lexer, TokenParserInterface $tokenPa $this->lexer = $lexer; $this->tokenParser = ($tokenParser instanceof ParserAwareInterface) ? $tokenParser->withParser($this) - : $tokenParser - ; + : $tokenParser; } - + public function parse(string $value) { $tokens = $this->lexer->lex($value); @@ -60,20 +59,19 @@ public function parse(string $value) if (count($parsedTokens) > 1) { $first = reset($parsedTokens); - if (is_string($first) && trim($first) === '') { + if (is_string($first) && '' === trim($first)) { array_shift($parsedTokens); } $last = end($parsedTokens); - if (is_string($last) && trim($last) === '') { + if (is_string($last) && '' === trim($last)) { array_pop($parsedTokens); } } return (1 === count($parsedTokens)) ? $parsedTokens[0] - : new ListValue($parsedTokens) - ; + : new ListValue($parsedTokens); } /** @@ -97,7 +95,7 @@ private function parseToken(array $parsedTokens, TokenParserInterface $parser, T new ListValue([ $lastParsedToken->getValue(), $parsedToken, - ]) + ]), ); return $parsedTokens; @@ -106,8 +104,7 @@ private function parseToken(array $parsedTokens, TokenParserInterface $parser, T $parsedToken = ($parsedToken instanceof NestedValue) ? $parsedToken->getValue() - : [$parsedToken] - ; + : [$parsedToken]; foreach ($parsedToken as $value) { $parsedTokens[] = $value; diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParser.php index 775353510..78553c1cb 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParser.php @@ -50,15 +50,14 @@ public function parse(string $value) $mergedValues = array_reduce( $parsedValue->getValue(), [$this, 'mergeStrings'], - $initial = [] + $initial = [], ); return (1 === count($mergedValues)) ? $mergedValues[0] - : new ListValue($mergedValues) - ; + : new ListValue($mergedValues); } - + private function mergeStrings(array $values, $value): array { if (false === is_string($value)) { diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParser.php index 2a4b6e9bb..69576aadf 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParser.php @@ -34,11 +34,11 @@ abstract class AbstractChainableParserAwareParser implements ChainableTokenParse */ protected $parser; - public function __construct(ParserInterface $parser = null) + public function __construct(?ParserInterface $parser = null) { $this->parser = $parser; } - + public function withParser(ParserInterface $parser) { return new static($parser); diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParser.php index d9712323a..e5a19bf1e 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParser.php @@ -25,18 +25,16 @@ final class DynamicArrayTokenParser extends AbstractChainableParserAwareParser { /** @private */ - const REGEX = '/^(?\d+|<.*>)x (?.*)/'; - + public const REGEX = '/^(?\d+|<.*>)x (?.*)/'; + public function canParse(Token $token): bool { - return $token->getType() === TokenType::DYNAMIC_ARRAY_TYPE; + return TokenType::DYNAMIC_ARRAY_TYPE === $token->getType(); } /** * Parses "10x @user*", "*", etc. * - * - * * @throws ParseException */ public function parse(Token $token): DynamicArrayValue @@ -54,7 +52,7 @@ public function parse(Token $token): DynamicArrayValue return new DynamicArrayValue( $quantifier, - $this->parser->parse($matches['elements']) + $this->parser->parse($matches['elements']), ); } } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParser.php index ad50559e6..9f5d8dd01 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParser.php @@ -36,7 +36,7 @@ public function __construct() { $this->tokenizer = new FunctionTokenizer(); } - + public function canParse(Token $token): bool { return TokenType::ESCAPED_VALUE_TYPE === $token->getType(); @@ -52,6 +52,6 @@ public function parse(Token $token): string throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); } - return $this->tokenizer->detokenize(substr($value, 1)); + return $this->tokenizer->detokenize(mb_substr($value, 1)); } } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParser.php index 996c3d32d..e1fbb6ee7 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParser.php @@ -31,7 +31,7 @@ final class FixtureListReferenceTokenParser implements ChainableTokenParserInter use IsAServiceTrait; /** @private */ - const REGEX = NullListNameDenormalizer::REGEX; + public const REGEX = NullListNameDenormalizer::REGEX; /** * @var string Unique token @@ -42,10 +42,10 @@ public function __construct() { $this->token = uniqid(__CLASS__, true); } - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::LIST_REFERENCE_TYPE; + return TokenType::LIST_REFERENCE_TYPE === $token->getType(); } /** @@ -73,7 +73,7 @@ public function parse(Token $token) private function buildReferences(Token $token): array { $matches = []; - $name = (string) substr($token->getValue(), 1); + $name = (string) mb_substr($token->getValue(), 1); if (1 !== preg_match(self::REGEX, $name, $matches)) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); @@ -86,7 +86,7 @@ private function buildReferences(Token $token): array $fixtureId = str_replace( sprintf('{%s}', $matches['list']), $element, - $name + $name, ); $references[] = new FixtureReferenceValue($fixtureId); } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParser.php index 5e7c318fb..8f1e35deb 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParser.php @@ -27,17 +27,15 @@ final class FixtureMethodReferenceTokenParser extends AbstractChainableParserAwareParser { use IsAServiceTrait; - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::METHOD_REFERENCE_TYPE; + return TokenType::METHOD_REFERENCE_TYPE === $token->getType(); } /** * Parses expressions such as "@username->getName()". * - * - * * @throws ParseException */ public function parse(Token $token) diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php index 4a6e1ee84..e416fed76 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php @@ -32,7 +32,7 @@ final class FixtureRangeReferenceTokenParser implements ChainableTokenParserInte use IsAServiceTrait; /** @private */ - const REGEX = NullRangeNameDenormalizer::REGEX; + public const REGEX = NullRangeNameDenormalizer::REGEX; /** * @var string Unique token @@ -46,7 +46,7 @@ public function __construct() public function canParse(Token $token): bool { - return $token->getType() === TokenType::RANGE_REFERENCE_TYPE; + return TokenType::RANGE_REFERENCE_TYPE === $token->getType(); } /** @@ -80,7 +80,7 @@ public function parse(Token $token) private function buildRange(Token $token): RangeName { $matches = []; - $name = substr($token->getValue(), 1); + $name = mb_substr($token->getValue(), 1); if (1 !== preg_match(self::REGEX, (string) $name, $matches)) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FunctionTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FunctionTokenParser.php index f4de3b62d..d3152f990 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FunctionTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FunctionTokenParser.php @@ -13,7 +13,6 @@ namespace Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable; -use const DIRECTORY_SEPARATOR; use Nelmio\Alice\Definition\Value\EvaluatedValue; use Nelmio\Alice\Definition\Value\FunctionCallValue; use Nelmio\Alice\Definition\Value\ValueForCurrentValue; @@ -25,6 +24,7 @@ use Nelmio\Alice\IsAServiceTrait; use Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\ExpressionLanguageExceptionFactory; use Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\ParseException; +use const DIRECTORY_SEPARATOR; /** * @internal @@ -34,7 +34,7 @@ final class FunctionTokenParser implements ChainableTokenParserInterface, Parser use IsAServiceTrait; /** @private */ - const REGEX = '/^\s*<(?(.|\r?\n)+?)\((?.*)\)>\s*$/s'; + public const REGEX = '/^\s*<(?(.|\r?\n)+?)\((?.*)\)>\s*$/s'; /** * @var ArgumentEscaper @@ -46,20 +46,20 @@ final class FunctionTokenParser implements ChainableTokenParserInterface, Parser */ protected $parser; - public function __construct(ArgumentEscaper $argumentEscaper, ParserInterface $parser = null) + public function __construct(ArgumentEscaper $argumentEscaper, ?ParserInterface $parser = null) { $this->argumentEscaper = $argumentEscaper; $this->parser = $parser; } - + public function withParser(ParserInterface $parser) { - return new static($this->argumentEscaper, $parser); + return new self($this->argumentEscaper, $parser); } - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::FUNCTION_TYPE; + return TokenType::FUNCTION_TYPE === $token->getType(); } /** @@ -85,10 +85,8 @@ public function parse(Token $token): FunctionCallValue if ('identity' === $function) { $value = preg_replace_callback( '/__ARG_TOKEN__[\da-z]{32}/', - static function (array $matches) use ($argumentEscaper): string { - return '\''.$argumentEscaper->unescape($matches[0]).'\''; - }, - $matches['arguments'] + static fn (array $matches): string => '\''.$argumentEscaper->unescape($matches[0]).'\'', + $matches['arguments'], ); $arguments = [new EvaluatedValue($value)]; @@ -119,7 +117,7 @@ static function (array $matches) use ($argumentEscaper): string { return $argumentEscaper->escape($string); }, - $argumentsString + $argumentsString, ); $arguments = []; @@ -136,13 +134,13 @@ static function (array $matches) use ($argumentEscaper): string { private function parseArgument(ParserInterface $parser, string $value) { switch (true) { - case $value === 'true': + case 'true' === $value: return true; - case $value === 'false': + case 'false' === $value: return false; - case $value === 'null': + case 'null' === $value: return null; case preg_match('/^([-+])?([0-9]+)$/', $value, $matches): diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php index 7cc29ffa7..399ba6329 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php @@ -39,7 +39,7 @@ final class IdentityTokenParser implements ChainableTokenParserInterface, Parser */ private $tokenizer; - public function __construct(ChainableTokenParserInterface $decoratedTokenParser, ParserInterface $parser = null) + public function __construct(ChainableTokenParserInterface $decoratedTokenParser, ?ParserInterface $parser = null) { if (null !== $parser && $decoratedTokenParser instanceof ParserAwareInterface) { $decoratedTokenParser = $decoratedTokenParser->withParser($parser); @@ -48,15 +48,15 @@ public function __construct(ChainableTokenParserInterface $decoratedTokenParser, $this->decoratedTokenParser = $decoratedTokenParser; $this->tokenizer = new FunctionTokenizer(); } - + public function withParser(ParserInterface $parser): self { - return new static($this->decoratedTokenParser, $parser); + return new self($this->decoratedTokenParser, $parser); } - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::IDENTITY_TYPE; + return TokenType::IDENTITY_TYPE === $token->getType(); } /** @@ -72,7 +72,7 @@ public function parse(Token $token) $realValue = preg_replace('/^<\((.*)\)>$/s', '', $value); return $this->decoratedTokenParser->parse( - new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE)) + new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE)), ); } } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParser.php index 511121b78..f1c01c775 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParser.php @@ -28,14 +28,12 @@ final class MethodReferenceTokenParser extends AbstractChainableParserAwareParse { public function canParse(Token $token): bool { - return $token->getType() === TokenType::METHOD_REFERENCE_TYPE; + return TokenType::METHOD_REFERENCE_TYPE === $token->getType(); } /** * Parses tokens values like "@user->getUserName()". * - * - * * @throws ParseException */ public function parse(Token $token): FixtureMethodCallValue @@ -43,7 +41,7 @@ public function parse(Token $token): FixtureMethodCallValue parent::parse($token); $explodedValue = explode('->', $token->getValue()); - if (count($explodedValue) !== 2) { + if (2 !== count($explodedValue)) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); } @@ -51,8 +49,8 @@ public function parse(Token $token): FixtureMethodCallValue $method = $this->parser->parse( sprintf( '<%s>', - $explodedValue[1] - ) + $explodedValue[1], + ), ); if ($reference instanceof FixtureReferenceValue && $method instanceof FunctionCallValue) { diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParser.php index 9eb20bf49..e0b63a9d6 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParser.php @@ -25,11 +25,11 @@ final class OptionalTokenParser extends AbstractChainableParserAwareParser { /** @private */ - const REGEX = '/^(?\d+|\d*\.\d+|<.+>)%\? \ *?(?[^:]+)(?:\: +(?[^\ ]+))?/'; - + public const REGEX = '/^(?\d+|\d*\.\d+|<.+>)%\? \ *?(?[^:]+)(?:\: +(?[^\ ]+))?/'; + public function canParse(Token $token): bool { - return $token->getType() === TokenType::OPTIONAL_TYPE; + return TokenType::OPTIONAL_TYPE === $token->getType(); } /** @@ -52,7 +52,7 @@ public function parse(Token $token): OptionalValue $this->parser->parse(trim($matches['first_member'])), array_key_exists('second_member', $matches) ? $this->parser->parse($matches['second_member']) - : null + : null, ); } } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParser.php index 6fba42667..443bcddf2 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParser.php @@ -31,7 +31,7 @@ final class ParameterTokenParser implements ChainableTokenParserInterface public function canParse(Token $token): bool { - return $token->getType() === TokenType::PARAMETER_TYPE; + return TokenType::PARAMETER_TYPE === $token->getType(); } /** @@ -46,7 +46,7 @@ public function parse(Token $token): ParameterValue $value = $token->getValue(); try { - $paramKey = strlen($value) > 3 ? substr($value, 2, -2) : false; + $paramKey = mb_strlen($value) > 3 ? mb_substr($value, 2, -2) : false; return new ParameterValue($paramKey); } catch (TypeError $error) { diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParser.php index 816237bcb..0936f541e 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParser.php @@ -27,14 +27,12 @@ final class PropertyReferenceTokenParser extends AbstractChainableParserAwarePar { public function canParse(Token $token): bool { - return $token->getType() === TokenType::PROPERTY_REFERENCE_TYPE; + return TokenType::PROPERTY_REFERENCE_TYPE === $token->getType(); } /** * Parses tokens values like "@user->username". * - * - * * @throws ParseException */ public function parse(Token $token): FixturePropertyValue @@ -42,7 +40,7 @@ public function parse(Token $token): FixturePropertyValue parent::parse($token); $explodedValue = explode('->', $token->getValue()); - if (count($explodedValue) !== 2) { + if (2 !== count($explodedValue)) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); } @@ -53,7 +51,7 @@ public function parse(Token $token): FixturePropertyValue return new FixturePropertyValue( $reference, - $explodedValue[1] + $explodedValue[1], ); } } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParser.php index 1219ae981..fbeb62982 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParser.php @@ -30,7 +30,7 @@ final class SimpleReferenceTokenParser implements ChainableTokenParserInterface public function canParse(Token $token): bool { - return $token->getType() === TokenType::SIMPLE_REFERENCE_TYPE; + return TokenType::SIMPLE_REFERENCE_TYPE === $token->getType(); } /** @@ -45,7 +45,7 @@ public function parse(Token $token): FixtureReferenceValue throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); } - return new FixtureReferenceValue(substr($value, 1)); + return new FixtureReferenceValue(mb_substr($value, 1)); } catch (InvalidArgumentException $exception) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token, 0, $exception); } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParser.php index 988a4e283..30054b65c 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParser.php @@ -28,7 +28,7 @@ final class StringArrayTokenParser extends AbstractChainableParserAwareParser { public function canParse(Token $token): bool { - return $token->getType() === TokenType::STRING_ARRAY_TYPE; + return TokenType::STRING_ARRAY_TYPE === $token->getType(); } /** @@ -43,7 +43,7 @@ public function parse(Token $token): ValueInterface $value = $token->getValue(); try { - $elements = substr($value, 1, -1); + $elements = mb_substr($value, 1, -1); return new ArrayValue($this->parseElements($this->parser, $elements)); } catch (TypeError $error) { diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParser.php index 0e0e54f84..801b3e119 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParser.php @@ -34,12 +34,12 @@ public function __construct(ArgumentEscaper $argumentEscaper) { $this->argumentEscaper = $argumentEscaper; } - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::STRING_TYPE; + return TokenType::STRING_TYPE === $token->getType(); } - + public function parse(Token $token) { return $this->argumentEscaper->unescape($token->getValue()); diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/TolerantFunctionTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/TolerantFunctionTokenParser.php index 3a6fa0d5b..393e5b7f7 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/TolerantFunctionTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/TolerantFunctionTokenParser.php @@ -34,14 +34,14 @@ final class TolerantFunctionTokenParser extends AbstractChainableParserAwarePars use IsAServiceTrait; /** @private */ - const REGEX = '/(\)>)(.*?))(.*?)functionTokenParser = $functionTokenParser; } - + public function withParser(ParserInterface $parser): self { return new self($this->functionTokenParser, $parser); } - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::FUNCTION_TYPE; + return TokenType::FUNCTION_TYPE === $token->getType(); } /** @@ -71,7 +71,7 @@ public function canParse(Token $token): bool * * @TODO: handle redundant ListValue tokens */ - public function parse(Token $token): FunctionCallValue|ListValue|ValueInterface|string + public function parse(Token $token): FunctionCallValue|ListValue|string|ValueInterface { parent::parse($token); diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableReferenceTokenParser.php index 913a22ad8..53c204802 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableReferenceTokenParser.php @@ -31,10 +31,10 @@ final class VariableReferenceTokenParser implements ChainableTokenParserInterface { use IsAServiceTrait; - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::VARIABLE_REFERENCE_TYPE; + return TokenType::VARIABLE_REFERENCE_TYPE === $token->getType(); } /** @@ -49,14 +49,14 @@ public function parse(Token $token): FixtureReferenceValue try { return new FixtureReferenceValue( new ListValue([ - substr($parts[0], 1), + mb_substr($parts[0], 1), 'current' === $variable ? new FunctionCallValue( 'current', - [new ValueForCurrentValue()] + [new ValueForCurrentValue()], ) - : new VariableValue($variable) - ]) + : new VariableValue($variable), + ]), ); } catch (InvalidArgumentException $exception) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token, 0, $exception); diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParser.php index a31428cf9..a7a663da7 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParser.php @@ -33,7 +33,7 @@ final class VariableTokenParser implements ChainableTokenParserInterface public function canParse(Token $token): bool { - return $token->getType() === TokenType::VARIABLE_TYPE; + return TokenType::VARIABLE_TYPE === $token->getType(); } /** @@ -45,14 +45,14 @@ public function canParse(Token $token): bool */ public function parse(Token $token) { - $variable = !is_string($token->getValue()) || $token->getValue() === '' + $variable = !is_string($token->getValue()) || '' === $token->getValue() ? false - : substr($token->getValue(), 1); + : mb_substr($token->getValue(), 1); if ('current' === $variable) { return new FunctionCallValue( 'current', - [new ValueForCurrentValue()] + [new ValueForCurrentValue()], ); } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/WildcardReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/WildcardReferenceTokenParser.php index bccef55c6..796419a5c 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/WildcardReferenceTokenParser.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/WildcardReferenceTokenParser.php @@ -27,10 +27,10 @@ final class WildcardReferenceTokenParser implements ChainableTokenParserInterface { use IsAServiceTrait; - + public function canParse(Token $token): bool { - return $token->getType() === TokenType::WILDCARD_REFERENCE_TYPE; + return TokenType::WILDCARD_REFERENCE_TYPE === $token->getType(); } /** @@ -43,7 +43,7 @@ public function canParse(Token $token): bool public function parse(Token $token) { $value = $token->getValue(); - $fixtureId = substr($value, 1, -1); + $fixtureId = mb_substr($value, 1, -1); if (false === $fixtureId) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); } diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistry.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistry.php index 7e3aa17e4..2a205c83b 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistry.php +++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistry.php @@ -39,25 +39,22 @@ final class TokenParserRegistry implements TokenParserInterface, ParserAwareInte public function __construct(array $parsers) { $this->parsers = ( - static function (ChainableTokenParserInterface ...$parsers) { - return $parsers; - } + static fn (ChainableTokenParserInterface ...$parsers) => $parsers )(...$parsers); } - + public function withParser(ParserInterface $parser): self { $parsers = []; foreach ($this->parsers as $tokenParser) { $parsers[] = ($tokenParser instanceof ParserAwareInterface) ? $tokenParser->withParser($parser) - : $tokenParser - ; + : $tokenParser; } return new self($parsers); } - + public function parse(Token $token) { foreach ($this->parsers as $parser) { diff --git a/src/FixtureBuilder/ExpressionLanguage/ParserInterface.php b/src/FixtureBuilder/ExpressionLanguage/ParserInterface.php index 870867b7b..d672433fa 100644 --- a/src/FixtureBuilder/ExpressionLanguage/ParserInterface.php +++ b/src/FixtureBuilder/ExpressionLanguage/ParserInterface.php @@ -26,7 +26,6 @@ interface ParserInterface * must be processed (like '$username'). If the value must be processed, it will be parsed to generate a value (a * ValueInterface instance) ready for processing. * - * * @throws ExpressionLanguageParseThrowable * * @return ValueInterface|string|array diff --git a/src/FixtureBuilder/ExpressionLanguage/Token.php b/src/FixtureBuilder/ExpressionLanguage/Token.php index 2ee59e1e0..0d5f45071 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Token.php +++ b/src/FixtureBuilder/ExpressionLanguage/Token.php @@ -22,7 +22,7 @@ final class Token * @var string */ private $value; - + /** * @var TokenType */ @@ -33,15 +33,15 @@ public function __construct(string $value, TokenType $type) $this->value = $value; $this->type = $type; } - + public function withValue(string $value): self { $clone = clone $this; $clone->value = $value; - + return $clone; } - + public function getValue(): string { return $this->value; diff --git a/src/FixtureBuilder/ExpressionLanguage/TokenType.php b/src/FixtureBuilder/ExpressionLanguage/TokenType.php index c75a1d972..468c5b310 100644 --- a/src/FixtureBuilder/ExpressionLanguage/TokenType.php +++ b/src/FixtureBuilder/ExpressionLanguage/TokenType.php @@ -20,25 +20,25 @@ */ final class TokenType { - const STRING_TYPE = 'STRING_TYPE'; - const PARAMETER_TYPE = 'PARAMETER_TYPE'; - const ESCAPED_VALUE_TYPE = 'ESCAPED_VALUE_TYPE'; - const FUNCTION_TYPE = 'FUNCTION_TYPE'; - const IDENTITY_TYPE = 'IDENTITY_TYPE'; - const OPTIONAL_TYPE = 'OPTIONAL_TYPE'; + public const STRING_TYPE = 'STRING_TYPE'; + public const PARAMETER_TYPE = 'PARAMETER_TYPE'; + public const ESCAPED_VALUE_TYPE = 'ESCAPED_VALUE_TYPE'; + public const FUNCTION_TYPE = 'FUNCTION_TYPE'; + public const IDENTITY_TYPE = 'IDENTITY_TYPE'; + public const OPTIONAL_TYPE = 'OPTIONAL_TYPE'; - const DYNAMIC_ARRAY_TYPE = 'DYNAMIC_ARRAY_TYPE'; - const STRING_ARRAY_TYPE = 'STRING_ARRAY_TYPE'; + public const DYNAMIC_ARRAY_TYPE = 'DYNAMIC_ARRAY_TYPE'; + public const STRING_ARRAY_TYPE = 'STRING_ARRAY_TYPE'; - const SIMPLE_REFERENCE_TYPE = 'SIMPLE_REFERENCE_TYPE'; - const LIST_REFERENCE_TYPE = 'LIST_REFERENCE_TYPE'; - const WILDCARD_REFERENCE_TYPE = 'WILDCARD_REFERENCE_TYPE'; - const RANGE_REFERENCE_TYPE = 'RANGE_REFERENCE_TYPE'; - const PROPERTY_REFERENCE_TYPE = 'PROPERTY_REFERENCE_TYPE'; - const METHOD_REFERENCE_TYPE = 'METHOD_REFERENCE_TYPE'; - const VARIABLE_REFERENCE_TYPE = 'VARIABLE_REFERENCE_TYPE'; + public const SIMPLE_REFERENCE_TYPE = 'SIMPLE_REFERENCE_TYPE'; + public const LIST_REFERENCE_TYPE = 'LIST_REFERENCE_TYPE'; + public const WILDCARD_REFERENCE_TYPE = 'WILDCARD_REFERENCE_TYPE'; + public const RANGE_REFERENCE_TYPE = 'RANGE_REFERENCE_TYPE'; + public const PROPERTY_REFERENCE_TYPE = 'PROPERTY_REFERENCE_TYPE'; + public const METHOD_REFERENCE_TYPE = 'METHOD_REFERENCE_TYPE'; + public const VARIABLE_REFERENCE_TYPE = 'VARIABLE_REFERENCE_TYPE'; - const VARIABLE_TYPE = 'VARIABLE_TYPE'; + public const VARIABLE_TYPE = 'VARIABLE_TYPE'; private static $values = [ self::STRING_TYPE => true, @@ -69,10 +69,10 @@ public function __construct(string $type) if (false === array_key_exists($type, self::$values)) { throw InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageTokenType($type); } - + $this->value = $type; } - + public function getValue(): string { return $this->value; diff --git a/src/FixtureBuilder/SimpleBuilder.php b/src/FixtureBuilder/SimpleBuilder.php index 3838e30e1..7279defdd 100644 --- a/src/FixtureBuilder/SimpleBuilder.php +++ b/src/FixtureBuilder/SimpleBuilder.php @@ -32,16 +32,16 @@ public function __construct(DenormalizerInterface $denormalizer) { $this->denormalizer = $denormalizer; } - + public function build(array $data, array $parameters = [], array $objects = []): FixtureSet { $bareFixtureSet = $this->denormalizer->denormalize($data); - + return new FixtureSet( $bareFixtureSet->getParameters(), new ParameterBag($parameters), $bareFixtureSet->getFixtures(), - new ObjectBag($objects) + new ObjectBag($objects), ); } } diff --git a/src/FixtureInterface.php b/src/FixtureInterface.php index d93846626..53bee7908 100644 --- a/src/FixtureInterface.php +++ b/src/FixtureInterface.php @@ -38,7 +38,6 @@ public function getValueForCurrent(); /** * Creates a new instance with the given specs. * - * * @return static */ public function withSpecs(SpecificationBag $specs); diff --git a/src/FixtureSet.php b/src/FixtureSet.php index e1b36716a..3955afce4 100644 --- a/src/FixtureSet.php +++ b/src/FixtureSet.php @@ -22,17 +22,17 @@ final class FixtureSet * @var ParameterBag */ private $loadedParameters; - + /** * @var ParameterBag */ private $injectedParameters; - + /** * @var FixtureBag */ private $fixtures; - + /** * @var ObjectBag */ diff --git a/src/Generator/Caller/CallProcessorRegistry.php b/src/Generator/Caller/CallProcessorRegistry.php index 8791827a0..bb2b0aa3d 100644 --- a/src/Generator/Caller/CallProcessorRegistry.php +++ b/src/Generator/Caller/CallProcessorRegistry.php @@ -14,7 +14,6 @@ namespace Nelmio\Alice\Generator\Caller; use Nelmio\Alice\Definition\MethodCallInterface; - use Nelmio\Alice\Generator\GenerationContext; use Nelmio\Alice\Generator\ResolvedFixtureSet; use Nelmio\Alice\IsAServiceTrait; @@ -32,15 +31,12 @@ final class CallProcessorRegistry implements CallProcessorInterface public function __construct(array $processors) { - $processors = (static function (ChainableCallProcessorInterface ...$processors) { - return $processors; - })(...$processors); + $processors = (static fn (ChainableCallProcessorInterface ...$processors) => $processors)(...$processors); foreach ($processors as $processor) { $this->processors[] = $processor instanceof CallProcessorAwareInterface ? $processor->withProcessor($this) - : $processor - ; + : $processor; } } diff --git a/src/Generator/Caller/Chainable/ConfiguratorMethodCallProcessor.php b/src/Generator/Caller/Chainable/ConfiguratorMethodCallProcessor.php index 884900be7..0ffcaf87d 100644 --- a/src/Generator/Caller/Chainable/ConfiguratorMethodCallProcessor.php +++ b/src/Generator/Caller/Chainable/ConfiguratorMethodCallProcessor.php @@ -14,7 +14,6 @@ namespace Nelmio\Alice\Generator\Caller\Chainable; use LogicException; -use function method_exists; use Nelmio\Alice\Definition\MethodCall\ConfiguratorMethodCall; use Nelmio\Alice\Definition\MethodCallInterface; use Nelmio\Alice\Generator\Caller\CallProcessorAwareInterface; @@ -24,6 +23,7 @@ use Nelmio\Alice\Generator\ResolvedFixtureSet; use Nelmio\Alice\IsAServiceTrait; use Nelmio\Alice\ObjectInterface; +use function method_exists; final class ConfiguratorMethodCallProcessor implements ChainableCallProcessorInterface, CallProcessorAwareInterface { @@ -34,21 +34,21 @@ final class ConfiguratorMethodCallProcessor implements ChainableCallProcessorInt */ private $processor; - public function __construct(CallProcessorInterface $processor = null) + public function __construct(?CallProcessorInterface $processor = null) { $this->processor = $processor; } - + public function withProcessor(CallProcessorInterface $processor): self { return new self($processor); } - + public function canProcess(MethodCallInterface $methodCall): bool { return $methodCall instanceof ConfiguratorMethodCall; } - + public function process( ObjectInterface $object, ResolvedFixtureSet $fixtureSet, @@ -67,7 +67,7 @@ public function process( $object, $fixtureSet, $context, - $methodCall->getOriginalMethodCall() + $methodCall->getOriginalMethodCall(), ); $context->unmarkRetrieveCallResult(); diff --git a/src/Generator/Caller/Chainable/MethodCallWithReferenceProcessor.php b/src/Generator/Caller/Chainable/MethodCallWithReferenceProcessor.php index 8ebe5d594..f479034b0 100644 --- a/src/Generator/Caller/Chainable/MethodCallWithReferenceProcessor.php +++ b/src/Generator/Caller/Chainable/MethodCallWithReferenceProcessor.php @@ -26,14 +26,13 @@ final class MethodCallWithReferenceProcessor implements ChainableCallProcessorInterface { use IsAServiceTrait; - + public function canProcess(MethodCallInterface $methodCall): bool { - return ( + return $methodCall instanceof MethodCallWithReference && null !== $methodCall->getCaller() - && $methodCall->getCaller() instanceof StaticReference - ); + && $methodCall->getCaller() instanceof StaticReference; } /** @@ -59,7 +58,7 @@ public function process( } return $fixtureSet->withObjects( - $fixtureSet->getObjects()->with($object) + $fixtureSet->getObjects()->with($object), ); } } diff --git a/src/Generator/Caller/Chainable/OptionalMethodCallProcessor.php b/src/Generator/Caller/Chainable/OptionalMethodCallProcessor.php index a9104bd90..16eb9c7ce 100644 --- a/src/Generator/Caller/Chainable/OptionalMethodCallProcessor.php +++ b/src/Generator/Caller/Chainable/OptionalMethodCallProcessor.php @@ -33,16 +33,16 @@ final class OptionalMethodCallProcessor implements ChainableCallProcessorInterfa */ private $processor; - public function __construct(CallProcessorInterface $processor = null) + public function __construct(?CallProcessorInterface $processor = null) { $this->processor = $processor; } - + public function withProcessor(CallProcessorInterface $processor): self { return new self($processor); } - + public function canProcess(MethodCallInterface $methodCall): bool { return $methodCall instanceof OptionalMethodCall; @@ -65,7 +65,7 @@ public function process( throw new LogicException('TODO'); } - if (mt_rand(0, 99) >= $methodCall->getPercentage()) { + if (random_int(0, 99) >= $methodCall->getPercentage()) { return $fixtureSet; } @@ -73,7 +73,7 @@ public function process( $object, $fixtureSet, $context, - $methodCall->getOriginalMethodCall() + $methodCall->getOriginalMethodCall(), ); } } diff --git a/src/Generator/Caller/Chainable/SimpleMethodCallProcessor.php b/src/Generator/Caller/Chainable/SimpleMethodCallProcessor.php index 0ad7447f9..4e94ea525 100644 --- a/src/Generator/Caller/Chainable/SimpleMethodCallProcessor.php +++ b/src/Generator/Caller/Chainable/SimpleMethodCallProcessor.php @@ -24,12 +24,12 @@ final class SimpleMethodCallProcessor implements ChainableCallProcessorInterface { use IsAServiceTrait; - + public function canProcess(MethodCallInterface $methodCall): bool { return $methodCall instanceof SimpleMethodCall; } - + public function process( ObjectInterface $object, ResolvedFixtureSet $fixtureSet, @@ -43,7 +43,7 @@ public function process( } return $fixtureSet->withObjects( - $fixtureSet->getObjects()->with($object) + $fixtureSet->getObjects()->with($object), ); } } diff --git a/src/Generator/Caller/SimpleCaller.php b/src/Generator/Caller/SimpleCaller.php index b2ca76814..bd045c43c 100644 --- a/src/Generator/Caller/SimpleCaller.php +++ b/src/Generator/Caller/SimpleCaller.php @@ -50,19 +50,19 @@ final class SimpleCaller implements CallerInterface, ValueResolverAwareInterface // TODO: make $namedArgumentsResolver non-nullable in 4.0. It is currently nullable only for BC purposes public function __construct( CallProcessorInterface $callProcessor, - ValueResolverInterface $resolver = null, - NamedArgumentsResolver $namedArgumentsResolver = null + ?ValueResolverInterface $resolver = null, + ?NamedArgumentsResolver $namedArgumentsResolver = null ) { $this->callProcessor = $callProcessor; $this->resolver = $resolver; $this->namedArgumentsResolver = $namedArgumentsResolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($this->callProcessor, $resolver, $this->namedArgumentsResolver); } - + public function doCallsOn( ObjectInterface $object, ResolvedFixtureSet $fixtureSet, @@ -85,7 +85,7 @@ public function doCallsOn( $fixture, $fixtureSet, $scope, - $context + $context, ); $fixtureSet = $this->callProcessor->process($object, $fixtureSet, $context, $methodCall); diff --git a/src/Generator/CallerInterface.php b/src/Generator/CallerInterface.php index 4a1f97e60..2780979e0 100644 --- a/src/Generator/CallerInterface.php +++ b/src/Generator/CallerInterface.php @@ -20,7 +20,7 @@ interface CallerInterface /** * Do calls on the already hydrated object. * - * @param ObjectInterface $object Hydrated object + * @param ObjectInterface $object Hydrated object * * @return ResolvedFixtureSet Set containing the object on which the calls have been made. */ diff --git a/src/Generator/ConfiguratorInterface.php b/src/Generator/ConfiguratorInterface.php index 2d172a98e..604a6cbe2 100644 --- a/src/Generator/ConfiguratorInterface.php +++ b/src/Generator/ConfiguratorInterface.php @@ -22,7 +22,7 @@ interface ConfiguratorInterface * Configures a given object. Has access to the current fixture set and returns the new fixture set containing the * configured object. * - * @param ObjectInterface $object Object to configure + * @param ObjectInterface $object Object to configure * * @throws ConfigurationThrowable */ diff --git a/src/Generator/DoublePassGenerator.php b/src/Generator/DoublePassGenerator.php index 6a1cd0d75..89d7e694f 100644 --- a/src/Generator/DoublePassGenerator.php +++ b/src/Generator/DoublePassGenerator.php @@ -37,7 +37,7 @@ public function __construct(FixtureSetResolverInterface $resolver, ObjectGenerat $this->resolver = $resolver; $this->generator = $generator; } - + public function generate(FixtureSet $fixtureSet): ObjectSet { $resolvedFixtureSet = $this->resolver->resolve($fixtureSet); diff --git a/src/Generator/FixtureSetResolverInterface.php b/src/Generator/FixtureSetResolverInterface.php index cfc14793b..e9dbe262a 100644 --- a/src/Generator/FixtureSetResolverInterface.php +++ b/src/Generator/FixtureSetResolverInterface.php @@ -21,7 +21,6 @@ interface FixtureSetResolverInterface /** * Resolves the loaded parameters and merge the injected ones with them and also resolves the fixture flags. * - * * @throws ResolutionThrowable */ public function resolve(FixtureSet $fixtureSet): ResolvedFixtureSet; diff --git a/src/Generator/Hydrator/Property/SymfonyPropertyAccessorHydrator.php b/src/Generator/Hydrator/Property/SymfonyPropertyAccessorHydrator.php index 6747df3db..4269c2e3e 100644 --- a/src/Generator/Hydrator/Property/SymfonyPropertyAccessorHydrator.php +++ b/src/Generator/Hydrator/Property/SymfonyPropertyAccessorHydrator.php @@ -13,7 +13,6 @@ namespace Nelmio\Alice\Generator\Hydrator\Property; -use function enum_exists; use Nelmio\Alice\Definition\Object\SimpleObject; use Nelmio\Alice\Definition\Property; use Nelmio\Alice\Generator\GenerationContext; @@ -36,6 +35,7 @@ use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException as SymfonyNoSuchPropertyException; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use TypeError; +use function enum_exists; final class SymfonyPropertyAccessorHydrator implements PropertyHydratorInterface { @@ -54,7 +54,7 @@ public function __construct(PropertyAccessorInterface $propertyAccessor) /** * @throws NoSuchPropertyException * @throws InaccessiblePropertyException - * @throws InvalidArgumentException When the typehint does not match for example + * @throws InvalidArgumentException When the typehint does not match for example * @throws HydrationException */ public function hydrate(ObjectInterface $object, Property $property, GenerationContext $context): ObjectInterface @@ -121,7 +121,7 @@ private static function castValueToEnum(ReflectionType $enumType, Property $prop foreach ($reflectionEnumBackedCases as $reflectionCase) { $caseValue = $reflectionCase->getValue()->value ?? $reflectionCase->getValue()->name; - if ($property->getValue() === ($caseValue)) { + if ($property->getValue() === $caseValue) { return $property->withValue($reflectionCase->getValue()); } } diff --git a/src/Generator/Hydrator/SimpleHydrator.php b/src/Generator/Hydrator/SimpleHydrator.php index d95711548..c94f58f24 100644 --- a/src/Generator/Hydrator/SimpleHydrator.php +++ b/src/Generator/Hydrator/SimpleHydrator.php @@ -40,17 +40,17 @@ final class SimpleHydrator implements HydratorInterface, ValueResolverAwareInter */ private $resolver; - public function __construct(PropertyHydratorInterface $hydrator, ValueResolverInterface $resolver = null) + public function __construct(PropertyHydratorInterface $hydrator, ?ValueResolverInterface $resolver = null) { $this->hydrator = $hydrator; $this->resolver = $resolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($this->hydrator, $resolver); } - + public function hydrate( ObjectInterface $object, ResolvedFixtureSet $fixtureSet, @@ -86,7 +86,7 @@ public function hydrate( } return $fixtureSet->withObjects( - $fixtureSet->getObjects()->with($object) + $fixtureSet->getObjects()->with($object), ); } } diff --git a/src/Generator/HydratorInterface.php b/src/Generator/HydratorInterface.php index f1e003d13..2837b1431 100644 --- a/src/Generator/HydratorInterface.php +++ b/src/Generator/HydratorInterface.php @@ -22,7 +22,7 @@ interface HydratorInterface * Hydrates the given object. Has access to the current fixture set and returns the new fixture set containing the * hydrated object. * - * @param ObjectInterface $object Object to hydrate + * @param ObjectInterface $object Object to hydrate * * @throws HydrationThrowable */ diff --git a/src/Generator/Instantiator/Chainable/AbstractChainableInstantiator.php b/src/Generator/Instantiator/Chainable/AbstractChainableInstantiator.php index 1b5ea1876..495e2e787 100644 --- a/src/Generator/Instantiator/Chainable/AbstractChainableInstantiator.php +++ b/src/Generator/Instantiator/Chainable/AbstractChainableInstantiator.php @@ -50,8 +50,8 @@ public function instantiate( $objects = $fixtureSet->getObjects()->with( new SimpleObject( $fixture->getId(), - $instance - ) + $instance, + ), ); return $fixtureSet->withObjects($objects); diff --git a/src/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiator.php b/src/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiator.php index 7307722b4..37e349c99 100644 --- a/src/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiator.php +++ b/src/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiator.php @@ -25,23 +25,23 @@ final class NoCallerMethodCallInstantiator extends AbstractChainableInstantiator private $namedArgumentsResolver; // TODO: make $namedArgumentsResolver non-nullable in 4.0. It is currently nullable only for BC purposes - public function __construct(NamedArgumentsResolver $namedArgumentsResolver = null) + public function __construct(?NamedArgumentsResolver $namedArgumentsResolver = null) { $this->namedArgumentsResolver = $namedArgumentsResolver; } - + public function canInstantiate(FixtureInterface $fixture): bool { $constructor = $fixture->getSpecs()->getConstructor(); return null !== $constructor && false === $constructor instanceof NoMethodCall && null === $constructor->getCaller(); } - + protected function createInstance(FixtureInterface $fixture) { [$class, $arguments] = [ $fixture->getClassName(), - $fixture->getSpecs()->getConstructor()->getArguments() + $fixture->getSpecs()->getConstructor()->getArguments(), ]; if (null !== $this->namedArgumentsResolver) { diff --git a/src/Generator/Instantiator/Chainable/NoMethodCallInstantiator.php b/src/Generator/Instantiator/Chainable/NoMethodCallInstantiator.php index 7f74bffab..51a35fa8b 100644 --- a/src/Generator/Instantiator/Chainable/NoMethodCallInstantiator.php +++ b/src/Generator/Instantiator/Chainable/NoMethodCallInstantiator.php @@ -25,7 +25,7 @@ public function canInstantiate(FixtureInterface $fixture): bool { return $fixture->getSpecs()->getConstructor() instanceof NoMethodCall; } - + protected function createInstance(FixtureInterface $fixture) { try { diff --git a/src/Generator/Instantiator/Chainable/NullConstructorInstantiator.php b/src/Generator/Instantiator/Chainable/NullConstructorInstantiator.php index 35e601bb1..e6790f2f4 100644 --- a/src/Generator/Instantiator/Chainable/NullConstructorInstantiator.php +++ b/src/Generator/Instantiator/Chainable/NullConstructorInstantiator.php @@ -24,7 +24,7 @@ public function canInstantiate(FixtureInterface $fixture): bool { return null === $fixture->getSpecs()->getConstructor(); } - + protected function createInstance(FixtureInterface $fixture) { $class = $fixture->getClassName(); diff --git a/src/Generator/Instantiator/Chainable/StaticFactoryInstantiator.php b/src/Generator/Instantiator/Chainable/StaticFactoryInstantiator.php index 074b764ce..71a913f8e 100644 --- a/src/Generator/Instantiator/Chainable/StaticFactoryInstantiator.php +++ b/src/Generator/Instantiator/Chainable/StaticFactoryInstantiator.php @@ -27,18 +27,18 @@ final class StaticFactoryInstantiator extends AbstractChainableInstantiator private $namedArgumentsResolver; // TODO: make $namedArgumentsResolver non-nullable in 4.0. It is currently nullable only for BC purposes - public function __construct(NamedArgumentsResolver $namedArgumentsResolver = null) + public function __construct(?NamedArgumentsResolver $namedArgumentsResolver = null) { $this->namedArgumentsResolver = $namedArgumentsResolver; } - + public function canInstantiate(FixtureInterface $fixture): bool { $constructor = $fixture->getSpecs()->getConstructor(); return null !== $constructor && false === $constructor instanceof NoMethodCall && $constructor->getCaller() instanceof StaticReference; } - + protected function createInstance(FixtureInterface $fixture) { $constructor = $fixture->getSpecs()->getConstructor(); @@ -46,7 +46,7 @@ protected function createInstance(FixtureInterface $fixture) $fixture->getClassName(), $constructor->getCaller()->getId(), $constructor->getMethod(), - $constructor->getArguments() + $constructor->getArguments(), ]; if (null === $arguments) { diff --git a/src/Generator/Instantiator/ExistingInstanceInstantiator.php b/src/Generator/Instantiator/ExistingInstanceInstantiator.php index 4d6e6b31c..fb7eed94b 100644 --- a/src/Generator/Instantiator/ExistingInstanceInstantiator.php +++ b/src/Generator/Instantiator/ExistingInstanceInstantiator.php @@ -34,20 +34,20 @@ final class ExistingInstanceInstantiator implements InstantiatorInterface, Value */ private $instantiator; - public function __construct(InstantiatorInterface $decoratedInstantiator, ValueResolverInterface $resolver = null) + public function __construct(InstantiatorInterface $decoratedInstantiator, ?ValueResolverInterface $resolver = null) { - if ($resolver !== null && $decoratedInstantiator instanceof ValueResolverAwareInterface) { + if (null !== $resolver && $decoratedInstantiator instanceof ValueResolverAwareInterface) { $decoratedInstantiator = $decoratedInstantiator->withValueResolver($resolver); } $this->instantiator = $decoratedInstantiator; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($this->instantiator, $resolver); } - + public function instantiate( FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, diff --git a/src/Generator/Instantiator/InstantiatorRegistry.php b/src/Generator/Instantiator/InstantiatorRegistry.php index ac26286b7..5a3a48790 100644 --- a/src/Generator/Instantiator/InstantiatorRegistry.php +++ b/src/Generator/Instantiator/InstantiatorRegistry.php @@ -37,25 +37,22 @@ final class InstantiatorRegistry implements InstantiatorInterface, ValueResolver public function __construct(array $instantiators) { $this->instantiators = ( - static function (ChainableInstantiatorInterface ...$instantiators) { - return $instantiators; - } + static fn (ChainableInstantiatorInterface ...$instantiators) => $instantiators )(...$instantiators); } - + public function withValueResolver(ValueResolverInterface $resolver): self { $instantiators = []; foreach ($this->instantiators as $instantiator) { $instantiators[] = ($instantiator instanceof ValueResolverAwareInterface) ? $instantiator->withValueResolver($resolver) - : $instantiator - ; + : $instantiator; } return new self($instantiators); } - + public function instantiate( FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, diff --git a/src/Generator/Instantiator/InstantiatorResolver.php b/src/Generator/Instantiator/InstantiatorResolver.php index 70252b302..2517d552d 100644 --- a/src/Generator/Instantiator/InstantiatorResolver.php +++ b/src/Generator/Instantiator/InstantiatorResolver.php @@ -45,7 +45,7 @@ final class InstantiatorResolver implements InstantiatorInterface, ValueResolver */ private $valueResolver; - public function __construct(InstantiatorInterface $instantiator, ValueResolverInterface $valueResolver = null) + public function __construct(InstantiatorInterface $instantiator, ?ValueResolverInterface $valueResolver = null) { if (null !== $valueResolver && $instantiator instanceof ValueResolverAwareInterface) { $instantiator = $instantiator->withValueResolver($valueResolver); @@ -54,7 +54,7 @@ public function __construct(InstantiatorInterface $instantiator, ValueResolverIn $this->instantiator = $instantiator; $this->valueResolver = $valueResolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($this->instantiator, $resolver); @@ -101,14 +101,14 @@ private function resolveFixtureConstructor( $this->valueResolver, $fixture, $set, - $context + $context, ); return [ $fixture->withSpecs( $specs->withConstructor( - $constructor->withArguments($resolvedArguments) - ) + $constructor->withArguments($resolvedArguments), + ), ), $set, ]; @@ -148,7 +148,7 @@ private function resolveArguments( $scope[$index] = $value; } - $argumentPosition++; + ++$argumentPosition; } } diff --git a/src/Generator/InstantiatorInterface.php b/src/Generator/InstantiatorInterface.php index ae64cb536..e61897370 100644 --- a/src/Generator/InstantiatorInterface.php +++ b/src/Generator/InstantiatorInterface.php @@ -22,7 +22,6 @@ interface InstantiatorInterface * Instantiates the object described by the given fixture. Has access to the current fixture set and returns the new * fixture set containing the instantiated the object. * - * * @throws InstantiationThrowable */ public function instantiate( diff --git a/src/Generator/NamedArgumentsResolver.php b/src/Generator/NamedArgumentsResolver.php index 21d1a416a..3a0d27179 100644 --- a/src/Generator/NamedArgumentsResolver.php +++ b/src/Generator/NamedArgumentsResolver.php @@ -72,23 +72,21 @@ public function resolveArguments(array $arguments, string $className, string $me 'Argument $%s of %s::%s() is not passed a value and does not define a default one.', $name, $className, - $methodName + $methodName, )); } $buffer[] = $parameter->getDefaultValue(); } - $unknownNamedParameters = array_filter(array_keys($arguments), static function ($key) { - return is_string($key); - }); + $unknownNamedParameters = array_filter(array_keys($arguments), static fn ($key) => is_string($key)); if ([] !== $unknownNamedParameters) { throw new RuntimeException(sprintf( 'Unknown arguments for %s::%s(): $%s.', $className, $methodName, - implode(', $', $unknownNamedParameters) + implode(', $', $unknownNamedParameters), )); } diff --git a/src/Generator/ObjectGenerator/CompleteObjectGenerator.php b/src/Generator/ObjectGenerator/CompleteObjectGenerator.php index da6c084a5..6cb5b8cd1 100644 --- a/src/Generator/ObjectGenerator/CompleteObjectGenerator.php +++ b/src/Generator/ObjectGenerator/CompleteObjectGenerator.php @@ -25,7 +25,7 @@ final class CompleteObjectGenerator implements ObjectGeneratorInterface { use IsAServiceTrait; - + /** * @var ObjectGeneratorInterface */ @@ -35,7 +35,7 @@ public function __construct(ObjectGeneratorInterface $objectGenerator) { $this->objectGenerator = $objectGenerator; } - + public function generate( FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, @@ -62,7 +62,7 @@ public function generate( private function isObjectComplete(FixtureInterface $fixture, ObjectInterface $object, GenerationContext $context): bool { - return ( + return $object instanceof CompleteObject || $context->needsCompleteGeneration() || false === $context->isFirstPass() @@ -70,7 +70,6 @@ private function isObjectComplete(FixtureInterface $fixture, ObjectInterface $ob false === $context->needsCompleteGeneration() && $fixture->getSpecs()->getProperties()->isEmpty() && $fixture->getSpecs()->getMethodCalls()->isEmpty() - ) - ); + ); } } diff --git a/src/Generator/ObjectGenerator/SimpleObjectGenerator.php b/src/Generator/ObjectGenerator/SimpleObjectGenerator.php index 7b361e1c4..932fcf6e2 100644 --- a/src/Generator/ObjectGenerator/SimpleObjectGenerator.php +++ b/src/Generator/ObjectGenerator/SimpleObjectGenerator.php @@ -35,12 +35,12 @@ final class SimpleObjectGenerator implements ObjectGeneratorInterface { use IsAServiceTrait; - + /** * @var InstantiatorInterface */ private $instantiator; - + /** * @var HydratorInterface */ @@ -77,7 +77,7 @@ public function __construct( $this->hydrator = $hydrator; $this->caller = $caller; } - + public function generate( FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, @@ -102,10 +102,10 @@ public function generate( 'An error occurred while generating the fixture "%s" (%s): %s', $fixture->getId(), $fixture->getClassName(), - $throwable->getMessage() + $throwable->getMessage(), ), $throwable->getCode(), - $throwable + $throwable, ]; throw new $throwableClass(...$arguments); @@ -161,8 +161,8 @@ private function tryToMarkObjectAsComplete(FixtureInterface $fixture, ResolvedFi return $set->withObjects( $set->getObjects()->with( - new CompleteObject($object) - ) + new CompleteObject($object), + ), ); } @@ -170,7 +170,7 @@ private function isObjectComplete(FixtureInterface $fixture, ResolvedFixtureSet { $object = $set->getObjects()->get($fixture); - return ( + return $object instanceof CompleteObject || $context->needsCompleteGeneration() || false === $context->isFirstPass() @@ -178,7 +178,6 @@ private function isObjectComplete(FixtureInterface $fixture, ResolvedFixtureSet false === $context->needsCompleteGeneration() && $fixture->getSpecs()->getProperties()->isEmpty() && $fixture->getSpecs()->getMethodCalls()->isEmpty() - ) - ); + ); } } diff --git a/src/Generator/ResolvedValueWithFixtureSet.php b/src/Generator/ResolvedValueWithFixtureSet.php index 334b87042..245a2fa18 100644 --- a/src/Generator/ResolvedValueWithFixtureSet.php +++ b/src/Generator/ResolvedValueWithFixtureSet.php @@ -19,18 +19,18 @@ final class ResolvedValueWithFixtureSet { private $value; - + /** * @var ResolvedFixtureSet */ private $set; - + public function __construct($resolvedValue, ResolvedFixtureSet $set) { $this->value = $resolvedValue; $this->set = $set; } - + public function getValue() { return $this->value; diff --git a/src/Generator/Resolver/Fixture/TemplateFixtureBagResolver.php b/src/Generator/Resolver/Fixture/TemplateFixtureBagResolver.php index 46f6affa4..a3bbf4676 100644 --- a/src/Generator/Resolver/Fixture/TemplateFixtureBagResolver.php +++ b/src/Generator/Resolver/Fixture/TemplateFixtureBagResolver.php @@ -36,7 +36,7 @@ public function __construct() { $this->resolver = new TemplateFixtureResolver(); } - + public function resolve(FixtureBag $unresolvedFixtures): FixtureBag { $resolvedFixtures = new TemplatingFixtureBag(); @@ -45,7 +45,7 @@ public function resolve(FixtureBag $unresolvedFixtures): FixtureBag $this->resolver, $fixture, $unresolvedFixtures, - $resolvedFixtures + $resolvedFixtures, ); } @@ -75,7 +75,7 @@ public function resolveFixture( $fixture, $unresolvedFixtures, $resolvedFixtures, - $context + $context, ); } } diff --git a/src/Generator/Resolver/Fixture/TemplateFixtureResolver.php b/src/Generator/Resolver/Fixture/TemplateFixtureResolver.php index a1c90f700..7b9ba13b0 100644 --- a/src/Generator/Resolver/Fixture/TemplateFixtureResolver.php +++ b/src/Generator/Resolver/Fixture/TemplateFixtureResolver.php @@ -33,7 +33,7 @@ final class TemplateFixtureResolver * @throws FixtureNotFoundException */ public function resolve( - TemplatingFixture|FixtureInterface $fixture, + FixtureInterface|TemplatingFixture $fixture, FixtureBag $unresolvedFixtures, TemplatingFixtureBag $resolvedFixtures, ResolvingContext $context @@ -57,7 +57,7 @@ public function resolve( : [], $unresolvedFixtures, $resolvedFixtures, - $context + $context, ); $fixture = $this->getExtendedFixture($fixture, $extendedFixtures); @@ -65,7 +65,7 @@ public function resolve( } /** - * @param FixtureReference[] $extendedFixtureReferences + * @param FixtureReference[] $extendedFixtureReferences * * @throws FixtureNotFoundException * @@ -94,7 +94,7 @@ private function resolveExtendedFixtures( } $fixtures = $fixtures->with( - $resolvedFixtures->getTemplate($fixtureId) + $resolvedFixtures->getTemplate($fixtureId), ); continue; @@ -109,11 +109,11 @@ private function resolveExtendedFixtures( $unresolvedFixtures->get($fixtureId), $unresolvedFixtures, $resolvedFixtures, - $context + $context, ); $fixtures = $fixtures->with( - $resolvedFixtures->get($fixtureId) + $resolvedFixtures->get($fixtureId), ); } diff --git a/src/Generator/Resolver/FixtureBagResolverInterface.php b/src/Generator/Resolver/FixtureBagResolverInterface.php index 9a5ee4e39..84a7e24ad 100644 --- a/src/Generator/Resolver/FixtureBagResolverInterface.php +++ b/src/Generator/Resolver/FixtureBagResolverInterface.php @@ -21,7 +21,6 @@ interface FixtureBagResolverInterface /** * Resolves a collection of fixtures. * - * * @throws ResolutionThrowable * * @return FixtureBag Resolved fixtures. diff --git a/src/Generator/Resolver/FixtureSet/FakeFixtureSetResolver.php b/src/Generator/Resolver/FixtureSet/FakeFixtureSetResolver.php index 53756ff01..1f1389492 100644 --- a/src/Generator/Resolver/FixtureSet/FakeFixtureSetResolver.php +++ b/src/Generator/Resolver/FixtureSet/FakeFixtureSetResolver.php @@ -21,7 +21,7 @@ class FakeFixtureSetResolver implements FixtureSetResolverInterface { use NotCallableTrait; - + public function resolve(FixtureSet $fixtureSet): ResolvedFixtureSet { $this->__call(__FUNCTION__, func_get_args()); diff --git a/src/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolver.php b/src/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolver.php index ef5eb6907..029e0764d 100644 --- a/src/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolver.php +++ b/src/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolver.php @@ -36,7 +36,7 @@ public function __construct(FixtureSetResolverInterface $decoratedResolver) { $this->resolver = $decoratedResolver; } - + public function resolve(FixtureSet $unresolvedFixtureSet): ResolvedFixtureSet { $resolvedFixtureSet = $this->resolver->resolve($unresolvedFixtureSet); diff --git a/src/Generator/Resolver/FixtureSet/SimpleFixtureSetResolver.php b/src/Generator/Resolver/FixtureSet/SimpleFixtureSetResolver.php index fdb1dc9e9..8da142d6c 100644 --- a/src/Generator/Resolver/FixtureSet/SimpleFixtureSetResolver.php +++ b/src/Generator/Resolver/FixtureSet/SimpleFixtureSetResolver.php @@ -39,12 +39,12 @@ public function __construct(ParameterBagResolverInterface $parameterResolver, Fi $this->parameterResolver = $parameterResolver; $this->fixtureResolver = $fixtureResolver; } - + public function resolve(FixtureSet $fixtureSet): ResolvedFixtureSet { $parameters = $this->parameterResolver->resolve( $fixtureSet->getLoadedParameters(), - $fixtureSet->getInjectedParameters() + $fixtureSet->getInjectedParameters(), ); $fixtures = $this->fixtureResolver->resolve($fixtureSet->getFixtures()); diff --git a/src/Generator/Resolver/Parameter/Chainable/ArrayParameterResolver.php b/src/Generator/Resolver/Parameter/Chainable/ArrayParameterResolver.php index 3028957b8..10c1dcad6 100644 --- a/src/Generator/Resolver/Parameter/Chainable/ArrayParameterResolver.php +++ b/src/Generator/Resolver/Parameter/Chainable/ArrayParameterResolver.php @@ -34,26 +34,26 @@ final class ArrayParameterResolver implements ChainableParameterResolverInterfac */ private $resolver; - public function __construct(ParameterResolverInterface $resolver = null) + public function __construct(?ParameterResolverInterface $resolver = null) { $this->resolver = $resolver; } - + public function withResolver(ParameterResolverInterface $resolver): self { return new self($resolver); } - + public function canResolve(Parameter $parameter): bool { return is_array($parameter->getValue()); } - + public function resolve( Parameter $unresolvedArrayParameter, ParameterBag $unresolvedParameters, ParameterBag $resolvedParameters, - ResolvingContext $context = null + ?ResolvingContext $context = null ): ParameterBag { if (null === $this->resolver) { throw ResolverNotFoundExceptionFactory::createUnexpectedCall(__METHOD__); @@ -62,7 +62,7 @@ public function resolve( $context = ResolvingContext::createFrom($context, $unresolvedArrayParameter->getKey()); $resolvedArray = []; - /* @var array $unresolvedArray */ + /** @var array $unresolvedArray */ $unresolvedArray = $unresolvedArrayParameter->getValue(); foreach ($unresolvedArray as $index => $unresolvedValue) { // Iterate over all the values of the array to resolve each of them @@ -70,17 +70,15 @@ public function resolve( new Parameter((string) $index, $unresolvedValue), $unresolvedParameters, $resolvedParameters, - $context + $context, ); $resolvedArray[$index] = $resolvedParameters->get((string) $index); $resolvedParameters = $resolvedParameters->without((string) $index); } - $resolvedParameters = $resolvedParameters->with( - $unresolvedArrayParameter->withValue($resolvedArray) + return $resolvedParameters->with( + $unresolvedArrayParameter->withValue($resolvedArray), ); - - return $resolvedParameters; } } diff --git a/src/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolver.php b/src/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolver.php index 838557830..d59574bab 100644 --- a/src/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolver.php +++ b/src/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolver.php @@ -51,7 +51,7 @@ public function __construct(ChainableParameterResolverInterface $resolver, int $ $this->limit = $limit; } - + public function withResolver(ParameterResolverInterface $resolver) { $decoratedResolver = $this->resolver; @@ -61,7 +61,7 @@ public function withResolver(ParameterResolverInterface $resolver) return new self($decoratedResolver); } - + public function canResolve(Parameter $parameter): bool { return $this->resolver->canResolve($parameter); @@ -79,8 +79,8 @@ public function resolve( Parameter $parameter, ParameterBag $unresolvedParameters, ParameterBag $resolvedParameters, - ResolvingContext $context = null, - ParameterBag $previousResult = null, + ?ResolvingContext $context = null, + ?ParameterBag $previousResult = null, int $counter = 1 ): ParameterBag { if (null === $previousResult) { @@ -97,7 +97,7 @@ public function resolve( $parameter->withValue($previousParameterValue), $unresolvedParameters, $resolvedParameters, - $context + $context, ); $newParameterValue = $newResult->get($parameterKey); $result = $this->mergeResults($previousResult, $newResult); @@ -125,7 +125,7 @@ private function mergeResults(ParameterBag $previous, ParameterBag $new): Parame { foreach ($previous as $key => $value) { $new = $new->with( - new Parameter((string) $key, $value) + new Parameter((string) $key, $value), ); } diff --git a/src/Generator/Resolver/Parameter/Chainable/StaticParameterResolver.php b/src/Generator/Resolver/Parameter/Chainable/StaticParameterResolver.php index 9de357c42..610c3576e 100644 --- a/src/Generator/Resolver/Parameter/Chainable/StaticParameterResolver.php +++ b/src/Generator/Resolver/Parameter/Chainable/StaticParameterResolver.php @@ -24,7 +24,7 @@ final class StaticParameterResolver implements ChainableParameterResolverInterface { use IsAServiceTrait; - + public function canResolve(Parameter $parameter): bool { $value = $parameter->getValue(); diff --git a/src/Generator/Resolver/Parameter/Chainable/StringParameterResolver.php b/src/Generator/Resolver/Parameter/Chainable/StringParameterResolver.php index 0ef1f00bb..2d1da7371 100644 --- a/src/Generator/Resolver/Parameter/Chainable/StringParameterResolver.php +++ b/src/Generator/Resolver/Parameter/Chainable/StringParameterResolver.php @@ -28,24 +28,24 @@ final class StringParameterResolver implements ChainableParameterResolverInterfa { use IsAServiceTrait; - const PATTERN = '/<{(?[^<{]+?)}>/'; - const SINGLE_PARAMETER_PATTERN = '/^<{(?(?(?=\{)^[\>]|.)+)}>$/'; + public const PATTERN = '/<{(?[^<{]+?)}>/'; + public const SINGLE_PARAMETER_PATTERN = '/^<{(?(?(?=\{)^[\>]|.)+)}>$/'; /** * @var ParameterResolverInterface|null */ private $resolver; - public function __construct(ParameterResolverInterface $resolver = null) + public function __construct(?ParameterResolverInterface $resolver = null) { $this->resolver = $resolver; } - + public function withResolver(ParameterResolverInterface $resolver) { return new self($resolver); } - + public function canResolve(Parameter $parameter): bool { return is_string($parameter->getValue()); @@ -58,7 +58,7 @@ public function resolve( Parameter $parameter, ParameterBag $unresolvedParameters, ParameterBag $resolvedParameters, - ResolvingContext $context = null + ?ResolvingContext $context = null ): ParameterBag { $context = ResolvingContext::createFrom($context, $parameter->getKey()); @@ -73,23 +73,23 @@ static function ($match) use ($self, $context, $unresolvedParameters, &$resolved $key, $unresolvedParameters, $resolvedParameters, - $context + $context, ); return $resolvedParameters->get($key); }, - $parameter->getValue() + $parameter->getValue(), ); return $resolvedParameters->with($parameter->withValue($value)); } /** - * @param Parameter $parameter Parameter being resolved - * @param string $key Key of the parameter that need to be resolved to resolve $parameter + * @param Parameter $parameter Parameter being resolved + * @param string $key Key of the parameter that need to be resolved to resolve $parameter */ private function resolveStringKey( - ParameterResolverInterface $resolver = null, + ?ParameterResolverInterface $resolver = null, Parameter $parameter, string $key, ParameterBag $unresolvedParameters, @@ -115,7 +115,7 @@ private function resolveStringKey( new Parameter($key, $unresolvedParameters->get($key)), $unresolvedParameters, $resolvedParameters, - $context + $context, ); } } diff --git a/src/Generator/Resolver/Parameter/ParameterResolverRegistry.php b/src/Generator/Resolver/Parameter/ParameterResolverRegistry.php index 059caaf20..92d8dfe31 100644 --- a/src/Generator/Resolver/Parameter/ParameterResolverRegistry.php +++ b/src/Generator/Resolver/Parameter/ParameterResolverRegistry.php @@ -49,19 +49,19 @@ public function __construct(array $resolvers) $this->resolvers = $resolvers; } - + public function resolve( Parameter $parameter, ParameterBag $unresolvedParameters, ParameterBag $injectedParameters, - ResolvingContext $context = null + ?ResolvingContext $context = null ): ParameterBag { foreach ($this->resolvers as $resolver) { if ($resolver->canResolve($parameter)) { return $resolver->resolve($parameter, $unresolvedParameters, $injectedParameters, $context); } } - + throw ResolverNotFoundExceptionFactory::createForParameter($parameter->getKey()); } } diff --git a/src/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolver.php b/src/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolver.php index c94292e33..bf668c46a 100644 --- a/src/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolver.php +++ b/src/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolver.php @@ -33,10 +33,10 @@ public function __construct(ParameterBagResolverInterface $decoratedResolver) { $this->resolver = $decoratedResolver; } - + public function resolve( ParameterBag $unresolvedParameters, - ParameterBag $injectedParameters = null + ?ParameterBag $injectedParameters = null ): ParameterBag { if (null === $injectedParameters) { $injectedParameters = new ParameterBag(); diff --git a/src/Generator/Resolver/Parameter/SimpleParameterBagResolver.php b/src/Generator/Resolver/Parameter/SimpleParameterBagResolver.php index 6f1742b53..288049e10 100644 --- a/src/Generator/Resolver/Parameter/SimpleParameterBagResolver.php +++ b/src/Generator/Resolver/Parameter/SimpleParameterBagResolver.php @@ -36,10 +36,10 @@ public function __construct(ParameterResolverInterface $decoratedResolver) { $this->resolver = $decoratedResolver; } - + public function resolve( ParameterBag $unresolvedParameters, - ParameterBag $injectedParameters = null + ?ParameterBag $injectedParameters = null ): ParameterBag { $resolvedParameters = $injectedParameters ?? new ParameterBag(); foreach ($unresolvedParameters as $key => $value) { @@ -52,7 +52,7 @@ public function resolve( new Parameter($key, $value), $unresolvedParameters, $resolvedParameters, - $context + $context, ); } diff --git a/src/Generator/Resolver/ParameterBagResolverInterface.php b/src/Generator/Resolver/ParameterBagResolverInterface.php index 4652a124b..bc5cfdff8 100644 --- a/src/Generator/Resolver/ParameterBagResolverInterface.php +++ b/src/Generator/Resolver/ParameterBagResolverInterface.php @@ -24,8 +24,7 @@ interface ParameterBagResolverInterface * External parameters can be injected in the process; It is assumed that injected parameters are already resolved * and they will be included in the resulting parameter bag. * - * * @throws ResolutionThrowable */ - public function resolve(ParameterBag $unresolvedParameters, ParameterBag $injectedParameters = null): ParameterBag; + public function resolve(ParameterBag $unresolvedParameters, ?ParameterBag $injectedParameters = null): ParameterBag; } diff --git a/src/Generator/Resolver/ParameterResolverInterface.php b/src/Generator/Resolver/ParameterResolverInterface.php index f7ab20d3a..100836b11 100644 --- a/src/Generator/Resolver/ParameterResolverInterface.php +++ b/src/Generator/Resolver/ParameterResolverInterface.php @@ -26,7 +26,7 @@ interface ParameterResolverInterface /** * Resolves a parameter value. * - * @param Parameter $parameter Unresolved parameter + * @param Parameter $parameter Unresolved parameter * * @throws ResolutionThrowable * diff --git a/src/Generator/Resolver/ResolvingContext.php b/src/Generator/Resolver/ResolvingContext.php index 3788dbfdd..895b2a45d 100644 --- a/src/Generator/Resolver/ResolvingContext.php +++ b/src/Generator/Resolver/ResolvingContext.php @@ -26,7 +26,7 @@ final class ResolvingContext */ private $resolving = []; - public function __construct(string $key = null) + public function __construct(?string $key = null) { if (null !== $key) { $this->add($key); @@ -37,7 +37,7 @@ public function __construct(string $key = null) * Returns the existing instance if is an object or create a new one otherwise. It also ensure that the key will be * added also it won't increment the counter if already present. */ - public static function createFrom(self $resolving = null, string $key): self + public static function createFrom(?self $resolving = null, string $key): self { $instance = $resolving ?? new self(); if (false === $instance->has($key)) { @@ -56,8 +56,7 @@ public function add(string $key): void { $this->resolving[$key] = array_key_exists($key, $this->resolving) ? $this->resolving[$key] + 1 - : 1 - ; + : 1; } /** diff --git a/src/Generator/Resolver/Value/Chainable/ArrayValueResolver.php b/src/Generator/Resolver/Value/Chainable/ArrayValueResolver.php index 583a3feb2..a543f399c 100644 --- a/src/Generator/Resolver/Value/Chainable/ArrayValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/ArrayValueResolver.php @@ -34,16 +34,16 @@ final class ArrayValueResolver implements ChainableValueResolverInterface, Value */ private $resolver; - public function __construct(ValueResolverInterface $resolver = null) + public function __construct(?ValueResolverInterface $resolver = null) { $this->resolver = $resolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($resolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof ArrayValue; diff --git a/src/Generator/Resolver/Value/Chainable/DynamicArrayValueResolver.php b/src/Generator/Resolver/Value/Chainable/DynamicArrayValueResolver.php index 69bcb63a0..e0f0f1b9d 100644 --- a/src/Generator/Resolver/Value/Chainable/DynamicArrayValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/DynamicArrayValueResolver.php @@ -35,16 +35,16 @@ final class DynamicArrayValueResolver implements ChainableValueResolverInterface */ private $resolver; - public function __construct(ValueResolverInterface $resolver = null) + public function __construct(?ValueResolverInterface $resolver = null) { $this->resolver = $resolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($resolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof DynamicArrayValue; @@ -80,7 +80,7 @@ public function resolve( } $array = []; - for ($i = 0; $i < $quantifier; $i++) { + for ($i = 0; $i < $quantifier; ++$i) { $result = $this->resolver->resolve($element, $fixture, $fixtureSet, $scope, $context); $array[] = $result->getValue(); diff --git a/src/Generator/Resolver/Value/Chainable/EvaluatedValueResolver.php b/src/Generator/Resolver/Value/Chainable/EvaluatedValueResolver.php index db017ab9e..990ef4723 100644 --- a/src/Generator/Resolver/Value/Chainable/EvaluatedValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/EvaluatedValueResolver.php @@ -29,7 +29,7 @@ final class EvaluatedValueResolver implements ChainableValueResolverInterface { use IsAServiceTrait; - + public function canResolve(ValueInterface $value): bool { return $value instanceof EvaluatedValue; @@ -68,10 +68,10 @@ public function resolve( // closure. $evaluateExpression = static function ($_expression) use ($_scope) { foreach ($_scope as $_scopeVariableName => $_scopeVariableValue) { - $$_scopeVariableName = $_scopeVariableValue; + ${$_scopeVariableName} = $_scopeVariableValue; } - return eval("return $_expression;"); + return eval("return {$_expression};"); }; try { diff --git a/src/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolver.php b/src/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolver.php index 75c94b1c8..291edde47 100644 --- a/src/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolver.php @@ -38,7 +38,7 @@ public function __construct(FakerGenerator $fakerGenerator) { $this->generatorFactory = new GeneratorFactory($fakerGenerator); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof ResolvedFunctionCallValue; @@ -62,7 +62,7 @@ public function resolve( return new ResolvedValueWithFixtureSet( $generator->format($formatter, $value->getArguments()), - $fixtureSet + $fixtureSet, ); } @@ -78,7 +78,7 @@ private function getGenerator(GeneratorFactory $factory, string $formatter) if (2 === $size) { return [ $factory->createOrReturnExistingInstance($explodedFormatter[0]), - $explodedFormatter[1] + $explodedFormatter[1], ]; } diff --git a/src/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolver.php b/src/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolver.php index 6b4673d6e..1be074d8a 100644 --- a/src/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolver.php +++ b/src/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolver.php @@ -39,16 +39,16 @@ final class FixtureMethodCallReferenceResolver implements ChainableValueResolver */ private $argumentResolver; - public function __construct(ValueResolverInterface $resolver = null) + public function __construct(?ValueResolverInterface $resolver = null) { $this->argumentResolver = $resolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($resolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof FixtureMethodCallValue; @@ -89,7 +89,7 @@ public function resolve( /** @var ResolvedFixtureSet $fixtureSet */ [$instance, $fixtureSet] = [ $fixtureReferenceResult->getValue(), - $fixtureReferenceResult->getSet() + $fixtureReferenceResult->getSet(), ]; try { @@ -104,7 +104,7 @@ public function resolve( return new ResolvedValueWithFixtureSet( $resolvedValue, - $fixtureSet + $fixtureSet, ); } } diff --git a/src/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolver.php b/src/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolver.php index 11d0f24d0..93b4f8e08 100644 --- a/src/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolver.php +++ b/src/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolver.php @@ -46,17 +46,17 @@ final class FixturePropertyReferenceResolver implements ChainableValueResolverIn */ private $resolver; - public function __construct(PropertyAccessorInterface $propertyAccessor, ValueResolverInterface $resolver = null) + public function __construct(PropertyAccessorInterface $propertyAccessor, ?ValueResolverInterface $resolver = null) { $this->propertyAccessor = $propertyAccessor; $this->resolver = $resolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($this->propertyAccessor, $resolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof FixturePropertyValue; @@ -86,7 +86,7 @@ public function resolve( /** @var ResolvedFixtureSet $fixtureSet */ [$instance, $fixtureSet] = [ $fixtureReferenceResult->getValue(), - $fixtureReferenceResult->getSet() + $fixtureReferenceResult->getSet(), ]; try { @@ -99,7 +99,7 @@ public function resolve( return new ResolvedValueWithFixtureSet( $propertyValue, - $fixtureSet + $fixtureSet, ); } } diff --git a/src/Generator/Resolver/Value/Chainable/FixtureReferenceResolver.php b/src/Generator/Resolver/Value/Chainable/FixtureReferenceResolver.php index 194a36d64..a33d4f218 100644 --- a/src/Generator/Resolver/Value/Chainable/FixtureReferenceResolver.php +++ b/src/Generator/Resolver/Value/Chainable/FixtureReferenceResolver.php @@ -46,16 +46,16 @@ final class FixtureReferenceResolver implements ChainableValueResolverInterface, */ private $incompleteObjects = []; - public function __construct(ObjectGeneratorInterface $generator = null) + public function __construct(?ObjectGeneratorInterface $generator = null) { $this->generator = $generator; } - + public function withObjectGenerator(ObjectGeneratorInterface $generator): self { return new self($generator); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof FixtureReferenceValue; @@ -105,7 +105,7 @@ private function resolveReferredFixture( string $referredFixtureId, ResolvedFixtureSet $fixtureSet, GenerationContext $context, - bool $passIncompleteObject = null + ?bool $passIncompleteObject = null ): ResolvedValueWithFixtureSet { if ($fixtureSet->getObjects()->has($referredFixture)) { $referredObject = $fixtureSet->getObjects()->get($referredFixture); @@ -118,7 +118,7 @@ private function resolveReferredFixture( return new ResolvedValueWithFixtureSet( $referredObject->getInstance(), - $fixtureSet + $fixtureSet, ); } } @@ -137,14 +137,14 @@ private function resolveReferredFixture( $context->markIsResolvingFixture($referredFixtureId); $objects = $this->generator->generate($referredFixture, $fixtureSet, $context); - $fixtureSet = $fixtureSet->withObjects($objects); + $fixtureSet = $fixtureSet->withObjects($objects); // Restore the context $needsCompleteGeneration ? $context->markAsNeedsCompleteGeneration() : $context->unmarkAsNeedsCompleteGeneration(); return new ResolvedValueWithFixtureSet( $fixtureSet->getObjects()->get($referredFixture)->getInstance(), - $fixtureSet + $fixtureSet, ); } catch (CircularReferenceException $exception) { if (false === $needsCompleteGeneration diff --git a/src/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolver.php b/src/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolver.php index b84046d03..8287fb1c3 100644 --- a/src/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolver.php +++ b/src/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolver.php @@ -40,18 +40,18 @@ final class FixtureWildcardReferenceResolver implements ChainableValueResolverIn private $resolver; /** @private */ - const IDS_BY_PATTERN_CACHE_KEY = self::class; + public const IDS_BY_PATTERN_CACHE_KEY = self::class; - public function __construct(ValueResolverInterface $resolver = null) + public function __construct(?ValueResolverInterface $resolver = null) { $this->resolver = $resolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($resolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof FixtureMatchReferenceValue; @@ -84,7 +84,7 @@ public function resolve( $fixture, $fixtureSet, $scope, - $context + $context, ); } @@ -126,14 +126,14 @@ private function findSuitableIds(string $pattern, ResolvedFixtureSet $fixtureSet $fixtureKeys = array_flip( preg_grep( $pattern, - array_keys($fixtureSet->getFixtures()->toArray()) - ) + array_keys($fixtureSet->getFixtures()->toArray()), + ), ); $objectKeys = array_flip( preg_grep( $pattern, - array_keys($fixtureSet->getObjects()->toArray()) - ) + array_keys($fixtureSet->getObjects()->toArray()), + ), ); return array_keys($fixtureKeys + $objectKeys); diff --git a/src/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolver.php b/src/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolver.php index 09f05c10b..f2f610417 100644 --- a/src/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolver.php +++ b/src/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolver.php @@ -43,17 +43,17 @@ final class FunctionCallArgumentResolver implements ChainableValueResolverInterf */ private $argumentResolver; - public function __construct(ValueResolverInterface $decoratedResolver, ValueResolverInterface $argumentResolver = null) + public function __construct(ValueResolverInterface $decoratedResolver, ?ValueResolverInterface $argumentResolver = null) { $this->resolver = $decoratedResolver; $this->argumentResolver = $argumentResolver; } - + public function withValueResolver(ValueResolverInterface $argumentsResolver): self { return new self($this->resolver, $argumentsResolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof FunctionCallValue; @@ -88,7 +88,7 @@ public function resolve( $fixture, $fixtureSet, $scope, - $context + $context, ); } } diff --git a/src/Generator/Resolver/Value/Chainable/ListValueResolver.php b/src/Generator/Resolver/Value/Chainable/ListValueResolver.php index 32566f39e..e23c9bec7 100644 --- a/src/Generator/Resolver/Value/Chainable/ListValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/ListValueResolver.php @@ -35,16 +35,16 @@ final class ListValueResolver implements ChainableValueResolverInterface, ValueR */ private $resolver; - public function __construct(ValueResolverInterface $resolver = null) + public function __construct(?ValueResolverInterface $resolver = null) { $this->resolver = $resolver; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($resolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof ListValue; @@ -88,7 +88,7 @@ public function resolve( return new ResolvedValueWithFixtureSet( implode('', $values), - $fixtureSet + $fixtureSet, ); } } diff --git a/src/Generator/Resolver/Value/Chainable/OptionalValueResolver.php b/src/Generator/Resolver/Value/Chainable/OptionalValueResolver.php index ef6224f72..7110fa37e 100644 --- a/src/Generator/Resolver/Value/Chainable/OptionalValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/OptionalValueResolver.php @@ -14,7 +14,6 @@ namespace Nelmio\Alice\Generator\Resolver\Value\Chainable; use Faker\Generator as FakerGenerator; -use function mt_rand; use Nelmio\Alice\Definition\Value\OptionalValue; use Nelmio\Alice\Definition\ValueInterface; use Nelmio\Alice\FixtureInterface; @@ -28,6 +27,7 @@ use Nelmio\Alice\Throwable\Exception\Generator\Resolver\ResolverNotFoundExceptionFactory; use Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException; use Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueExceptionFactory; +use function mt_rand; final class OptionalValueResolver implements ChainableValueResolverInterface, ValueResolverAwareInterface { @@ -43,17 +43,17 @@ final class OptionalValueResolver implements ChainableValueResolverInterface, Va */ private $faker; - public function __construct(ValueResolverInterface $resolver = null, FakerGenerator $faker = null) + public function __construct(?ValueResolverInterface $resolver = null, ?FakerGenerator $faker = null) { $this->resolver = $resolver; $this->faker = $faker; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($resolver, $this->faker); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof OptionalValue; @@ -100,11 +100,10 @@ private function resolveRealValue(ValueInterface $value, int $quantifier) { // TODO: keeping mt_rand for BC purposes. The generator should be made // non-nullable in 4.x and mt_rand usage removed - $random = null !== $this->faker ? $this->faker->numberBetween(0, 99) : mt_rand(0, 99); + $random = null !== $this->faker ? $this->faker->numberBetween(0, 99) : random_int(0, 99); return ($random < $quantifier) ? $value->getFirstMember() // @phpstan-ignore-line - : $value->getSecondMember() // @phpstan-ignore-line - ; + : $value->getSecondMember(); // @phpstan-ignore-line } } diff --git a/src/Generator/Resolver/Value/Chainable/ParameterValueResolver.php b/src/Generator/Resolver/Value/Chainable/ParameterValueResolver.php index 24c30c8bc..5053b3a7a 100644 --- a/src/Generator/Resolver/Value/Chainable/ParameterValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/ParameterValueResolver.php @@ -27,7 +27,7 @@ final class ParameterValueResolver implements ChainableValueResolverInterface { use IsAServiceTrait; - + public function canResolve(ValueInterface $value): bool { return $value instanceof ParameterValue; @@ -53,7 +53,7 @@ public function resolve( return new ResolvedValueWithFixtureSet( $parameters->get($parameterKey), - $fixtureSet + $fixtureSet, ); } } diff --git a/src/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolver.php b/src/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolver.php index 8ad67bf6f..ef79e676f 100644 --- a/src/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolver.php @@ -38,15 +38,15 @@ final class PhpFunctionCallValueResolver implements ChainableValueResolverInterf private $functionBlacklist; /** - * @param string[] $functionBlacklist List of PHP native function that will be skipped, i.e. will be - * considered as non existent + * @param string[] $functionBlacklist List of PHP native function that will be skipped, i.e. will be + * considered as non existent */ public function __construct(array $functionBlacklist, ValueResolverInterface $decoratedResolver) { $this->functionBlacklist = array_flip($functionBlacklist); $this->resolver = $decoratedResolver; } - + public function canResolve(ValueInterface $value): bool { return $value instanceof ResolvedFunctionCallValue; @@ -73,7 +73,7 @@ public function resolve( return new ResolvedValueWithFixtureSet( $functionName(...$arguments), - $fixtureSet + $fixtureSet, ); } } diff --git a/src/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolver.php b/src/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolver.php index 46b8e833f..cfb916919 100644 --- a/src/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolver.php +++ b/src/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolver.php @@ -40,27 +40,25 @@ public function __construct(ChainableValueResolverInterface $decoratedResolver) { $this->decoratedResolver = $decoratedResolver; } - + public function withObjectGenerator(ObjectGeneratorInterface $generator): self { $decoratedResolver = ($this->decoratedResolver instanceof ObjectGeneratorAwareInterface) ? $this->decoratedResolver->withObjectGenerator($generator) - : $this->decoratedResolver - ; + : $this->decoratedResolver; return new self($decoratedResolver); } - + public function withValueResolver(ValueResolverInterface $resolver): self { $decoratedResolver = ($this->decoratedResolver instanceof ValueResolverAwareInterface) ? $this->decoratedResolver->withValueResolver($resolver) - : $this->decoratedResolver - ; + : $this->decoratedResolver; return new self($decoratedResolver); } - + public function canResolve(ValueInterface $value): bool { return $this->decoratedResolver->canResolve($value); @@ -81,7 +79,7 @@ public function resolve( if ('self' === $value->getValue()) { return new ResolvedValueWithFixtureSet( $fixtureSet->getObjects()->get($fixture)->getInstance(), - $fixtureSet + $fixtureSet, ); } diff --git a/src/Generator/Resolver/Value/Chainable/UniqueValueResolver.php b/src/Generator/Resolver/Value/Chainable/UniqueValueResolver.php index c8b9dd42f..211ddee41 100644 --- a/src/Generator/Resolver/Value/Chainable/UniqueValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/UniqueValueResolver.php @@ -48,7 +48,7 @@ final class UniqueValueResolver implements ChainableValueResolverInterface, Valu */ private $limit; - public function __construct(UniqueValuesPool $pool, ValueResolverInterface $resolver = null, int $limit = 150) + public function __construct(UniqueValuesPool $pool, ?ValueResolverInterface $resolver = null, int $limit = 150) { $this->pool = $pool; $this->resolver = $resolver; @@ -58,12 +58,12 @@ public function __construct(UniqueValuesPool $pool, ValueResolverInterface $reso $this->limit = $limit; } - + public function withValueResolver(ValueResolverInterface $resolver): self { return new self($this->pool, $resolver); } - + public function canResolve(ValueInterface $value): bool { return $value instanceof UniqueValue; @@ -94,7 +94,7 @@ public function resolve( $fixture, $fixtureSet, $scope, - $context + $context, ); if ($this->pool->has($generatedValue)) { diff --git a/src/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolver.php b/src/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolver.php index 2b902f34d..56fbe6dcf 100644 --- a/src/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolver.php +++ b/src/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolver.php @@ -47,32 +47,30 @@ final class UnresolvedFixtureReferenceIdResolver implements ChainableValueResolv */ private $resolver; - public function __construct(ChainableValueResolverInterface $decoratedResolver, ValueResolverInterface $resolver = null) + public function __construct(ChainableValueResolverInterface $decoratedResolver, ?ValueResolverInterface $resolver = null) { $this->decoratedResolver = $decoratedResolver; $this->resolver = $resolver; } - + public function withObjectGenerator(ObjectGeneratorInterface $generator): self { $decoratedResolver = ($this->decoratedResolver instanceof ObjectGeneratorAwareInterface) ? $this->decoratedResolver->withObjectGenerator($generator) - : $this->decoratedResolver - ; + : $this->decoratedResolver; return new self($decoratedResolver, $this->resolver); } - + public function withValueResolver(ValueResolverInterface $resolver): self { $decoratedResolver = ($this->decoratedResolver instanceof ValueResolverAwareInterface) ? $this->decoratedResolver->withValueResolver($resolver) - : $this->decoratedResolver - ; + : $this->decoratedResolver; return new self($decoratedResolver, $resolver); } - + public function canResolve(ValueInterface $value): bool { return $this->decoratedResolver->canResolve($value); @@ -100,7 +98,7 @@ public function resolve( $fixture, $fixtureSet, $scope, - $context + $context, ); return $this->decoratedResolver->resolve( @@ -108,7 +106,7 @@ public function resolve( $fixture, $fixtureSet, $scope, - $context + $context, ); } diff --git a/src/Generator/Resolver/Value/Chainable/ValueForCurrentValueResolver.php b/src/Generator/Resolver/Value/Chainable/ValueForCurrentValueResolver.php index a68b4261f..f4a0f602c 100644 --- a/src/Generator/Resolver/Value/Chainable/ValueForCurrentValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/ValueForCurrentValueResolver.php @@ -27,7 +27,7 @@ final class ValueForCurrentValueResolver implements ChainableValueResolverInterface { use IsAServiceTrait; - + public function canResolve(ValueInterface $value): bool { return $value instanceof ValueForCurrentValue; @@ -52,7 +52,7 @@ public function resolve( $valueForCurrent->getId(), $valueForCurrent->getClassName(), $valueForCurrent->getSpecs(), - $fixtureSet->getObjects()->get($valueForCurrent)->getInstance() + $fixtureSet->getObjects()->get($valueForCurrent)->getInstance(), ); } else { $valueForCurrent = $fixtureSet->getFixtures()->get($fixture->getId()); @@ -60,7 +60,7 @@ public function resolve( return new ResolvedValueWithFixtureSet( $valueForCurrent, - $fixtureSet + $fixtureSet, ); } } diff --git a/src/Generator/Resolver/Value/Chainable/VariableValueResolver.php b/src/Generator/Resolver/Value/Chainable/VariableValueResolver.php index 73676aa50..8828010b6 100644 --- a/src/Generator/Resolver/Value/Chainable/VariableValueResolver.php +++ b/src/Generator/Resolver/Value/Chainable/VariableValueResolver.php @@ -27,7 +27,7 @@ final class VariableValueResolver implements ChainableValueResolverInterface { use IsAServiceTrait; - + public function canResolve(ValueInterface $value): bool { return $value instanceof VariableValue; @@ -49,7 +49,7 @@ public function resolve( if (array_key_exists($variableName, $scope)) { return new ResolvedValueWithFixtureSet( $scope[$variableName], - $fixtureSet + $fixtureSet, ); } diff --git a/src/Generator/Resolver/Value/ValueResolverRegistry.php b/src/Generator/Resolver/Value/ValueResolverRegistry.php index 3aac94f8c..891bd0d48 100644 --- a/src/Generator/Resolver/Value/ValueResolverRegistry.php +++ b/src/Generator/Resolver/Value/ValueResolverRegistry.php @@ -38,10 +38,10 @@ final class ValueResolverRegistry implements ValueResolverInterface, ObjectGener /** * @param ChainableValueResolverInterface[] $resolvers */ - public function __construct(array $resolvers, ObjectGeneratorInterface $generator = null) + public function __construct(array $resolvers, ?ObjectGeneratorInterface $generator = null) { $this->resolvers = ( - function (ObjectGeneratorInterface $generator = null, ChainableValueResolverInterface ...$resolvers) { + function (?ObjectGeneratorInterface $generator = null, ChainableValueResolverInterface ...$resolvers) { foreach ($resolvers as $index => $resolver) { if ($resolver instanceof ValueResolverAwareInterface) { $resolvers[$index] = $resolver = $resolver->withValueResolver($this); @@ -57,7 +57,7 @@ function (ObjectGeneratorInterface $generator = null, ChainableValueResolverInte } )($generator, ...$resolvers); } - + public function withObjectGenerator(ObjectGeneratorInterface $generator) { return new self($this->resolvers, $generator); diff --git a/src/Generator/ValueResolverInterface.php b/src/Generator/ValueResolverInterface.php index 95f60912e..efb33b5d4 100644 --- a/src/Generator/ValueResolverInterface.php +++ b/src/Generator/ValueResolverInterface.php @@ -23,8 +23,8 @@ interface ValueResolverInterface * Resolves a value, i.e. determine the final value. Once resolved, the value will be ready to be passed to the * object. * - * @param FixtureInterface $fixture Fixture to which belongs the arguments. - * @param array $scope List of variables accessible while resolving the arguments. + * @param FixtureInterface $fixture Fixture to which belongs the arguments. + * @param array $scope List of variables accessible while resolving the arguments. * * @throws ResolutionThrowable */ diff --git a/src/GeneratorInterface.php b/src/GeneratorInterface.php index 301dfebf9..dd9686133 100644 --- a/src/GeneratorInterface.php +++ b/src/GeneratorInterface.php @@ -20,7 +20,6 @@ interface GeneratorInterface /** * Generates a list of parameters and objects from the given set of data. * - * * @throws GenerationThrowable * * @return ObjectSet Contains the parameters and objects built from the loaded and injected ones. diff --git a/src/Loader/NativeLoader.php b/src/Loader/NativeLoader.php index 05cbcc51b..ff7a424dd 100644 --- a/src/Loader/NativeLoader.php +++ b/src/Loader/NativeLoader.php @@ -176,43 +176,43 @@ * methods can be added in minor versions, which could make your application break if you are extending this class and * have a method with the same name. * - * @method DataLoaderInterface getDataLoader() - * @method FileLoaderInterface getFileLoader() - * @method FilesLoaderInterface getFilesLoader() - * @method FixtureBuilderInterface getFixtureBuilder() - * @method GeneratorInterface getGenerator() - * @method ParserInterface getParser() - * @method DenormalizerInterface getDenormalizer() - * @method FixtureBagDenormalizerInterface getFixtureBagDenormalizer() - * @method FixtureDenormalizerInterface getFixtureDenormalizer() - * @method FlagParserInterface getFlagParser() - * @method ConstructorDenormalizerInterface getConstructorDenormalizer() - * @method PropertyDenormalizerInterface getPropertyDenormalizer() - * @method CallsDenormalizerInterface getCallsDenormalizer() - * @method ArgumentsDenormalizerInterface getArgumentsDenormalizer() - * @method ValueDenormalizerInterface getValueDenormalizer() + * @method DataLoaderInterface getDataLoader() + * @method FileLoaderInterface getFileLoader() + * @method FilesLoaderInterface getFilesLoader() + * @method FixtureBuilderInterface getFixtureBuilder() + * @method GeneratorInterface getGenerator() + * @method ParserInterface getParser() + * @method DenormalizerInterface getDenormalizer() + * @method FixtureBagDenormalizerInterface getFixtureBagDenormalizer() + * @method FixtureDenormalizerInterface getFixtureDenormalizer() + * @method FlagParserInterface getFlagParser() + * @method ConstructorDenormalizerInterface getConstructorDenormalizer() + * @method PropertyDenormalizerInterface getPropertyDenormalizer() + * @method CallsDenormalizerInterface getCallsDenormalizer() + * @method ArgumentsDenormalizerInterface getArgumentsDenormalizer() + * @method ValueDenormalizerInterface getValueDenormalizer() * @method ExpressionLanguageParserInterface getExpressionLanguageParser() - * @method LexerInterface getLexer() - * @method TokenParserInterface getExpressionLanguageTokenParser() - * @method ObjectGeneratorInterface getObjectGenerator() - * @method FixtureSetResolverInterface getFixtureSetResolver() - * @method ParameterBagResolverInterface getParameterResolver() - * @method ValueResolverInterface getValueResolver() - * @method FakerGenerator getFakerGenerator() - * @method InstantiatorInterface getInstantiator() - * @method HydratorInterface getHydrator() - * @method PropertyHydratorInterface getPropertyHydrator() - * @method PropertyAccessorInterface getPropertyAccessor() - * @method CallerInterface getCaller() - * @method CallProcessorInterface getCallProcessor() - * @method NamedArgumentsResolver getNamedArgumentsResolver() + * @method LexerInterface getLexer() + * @method TokenParserInterface getExpressionLanguageTokenParser() + * @method ObjectGeneratorInterface getObjectGenerator() + * @method FixtureSetResolverInterface getFixtureSetResolver() + * @method ParameterBagResolverInterface getParameterResolver() + * @method ValueResolverInterface getValueResolver() + * @method FakerGenerator getFakerGenerator() + * @method InstantiatorInterface getInstantiator() + * @method HydratorInterface getHydrator() + * @method PropertyHydratorInterface getPropertyHydrator() + * @method PropertyAccessorInterface getPropertyAccessor() + * @method CallerInterface getCaller() + * @method CallProcessorInterface getCallProcessor() + * @method NamedArgumentsResolver getNamedArgumentsResolver() */ class NativeLoader implements FilesLoaderInterface, FileLoaderInterface, DataLoaderInterface { use IsAServiceTrait; /** @protected */ - const LOCALE = 'en_US'; + public const LOCALE = 'en_US'; private $previous = ''; @@ -241,24 +241,24 @@ class NativeLoader implements FilesLoaderInterface, FileLoaderInterface, DataLoa */ private $dataLoader; - public function __construct(FakerGenerator $fakerGenerator = null) + public function __construct(?FakerGenerator $fakerGenerator = null) { $this->fakerGenerator = $fakerGenerator ?? $this->getFakerGenerator(); $this->dataLoader = $this->getDataLoader(); $this->fileLoader = $this->getFileLoader(); $this->filesLoader = $this->getFilesLoader(); } - + public function loadFiles(array $files, array $parameters = [], array $objects = []): ObjectSet { return $this->filesLoader->loadFiles($files, $parameters, $objects); } - + public function loadFile(string $file, array $parameters = [], array $objects = []): ObjectSet { return $this->fileLoader->loadFile($file, $parameters, $objects); } - + public function loadData(array $data, array $parameters = [], array $objects = []): ObjectSet { return $this->dataLoader->loadData($data, $parameters, $objects); @@ -268,7 +268,7 @@ protected function createDataLoader(): DataLoaderInterface { return new SimpleDataLoader( $this->getFixtureBuilder(), - $this->getGenerator() + $this->getGenerator(), ); } @@ -276,7 +276,7 @@ protected function createFileLoader(): FileLoaderInterface { return new SimpleFileLoader( $this->getParser(), - $this->dataLoader + $this->dataLoader, ); } @@ -284,14 +284,14 @@ protected function createFilesLoader(): FilesLoaderInterface { return new SimpleFilesLoader( $this->getParser(), - $this->dataLoader + $this->dataLoader, ); } protected function createFixtureBuilder(): FixtureBuilderInterface { return new SimpleBuilder( - $this->getDenormalizer() + $this->getDenormalizer(), ); } @@ -299,7 +299,7 @@ protected function createGenerator(): GeneratorInterface { return new DoublePassGenerator( $this->getFixtureSetResolver(), - $this->getObjectGenerator() + $this->getObjectGenerator(), ); } @@ -315,8 +315,8 @@ protected function createParser(): ParserInterface $registry, new DefaultFileLocator(), new DefaultIncludeProcessor( - new DefaultFileLocator() - ) + new DefaultFileLocator(), + ), ); } @@ -324,7 +324,7 @@ protected function createDenormalizer(): DenormalizerInterface { return new SimpleDenormalizer( new SimpleParameterBagDenormalizer(), - $this->getFixtureBagDenormalizer() + $this->getFixtureBagDenormalizer(), ); } @@ -332,7 +332,7 @@ protected function createFixtureBagDenormalizer(): FixtureBagDenormalizerInterfa { return new SimpleFixtureBagDenormalizer( $this->getFixtureDenormalizer(), - $this->getFlagParser() + $this->getFlagParser(), ); } @@ -346,28 +346,28 @@ protected function createFixtureDenormalizer(): FixtureDenormalizerInterface new SimpleSpecificationsDenormalizer( $this->getConstructorDenormalizer(), $this->getPropertyDenormalizer(), - $this->getCallsDenormalizer() - ) + $this->getCallsDenormalizer(), + ), ), new SimpleCollectionDenormalizer( new CollectionDenormalizerWithTemporaryFixture( - new NullListNameDenormalizer() - ) + new NullListNameDenormalizer(), + ), ), new SimpleCollectionDenormalizer( new CollectionDenormalizerWithTemporaryFixture( - new NullRangeNameDenormalizer() - ) + new NullRangeNameDenormalizer(), + ), ), new ReferenceRangeNameDenormalizer( new SimpleSpecificationsDenormalizer( $this->getConstructorDenormalizer(), $this->getPropertyDenormalizer(), - $this->getCallsDenormalizer() - ) - ) - ] - ) + $this->getCallsDenormalizer(), + ), + ), + ], + ), ); } @@ -388,10 +388,10 @@ protected function createConstructorDenormalizer(): ConstructorDenormalizerInter { return new LegacyConstructorDenormalizer( new ConstructorDenormalizer( - $this->getArgumentsDenormalizer() + $this->getArgumentsDenormalizer(), ), new FactoryDenormalizer( - $this->getCallsDenormalizer() + $this->getCallsDenormalizer(), ), ); } @@ -399,7 +399,7 @@ protected function createConstructorDenormalizer(): ConstructorDenormalizerInter protected function createPropertyDenormalizer(): PropertyDenormalizerInterface { return new SimplePropertyDenormalizer( - $this->getValueDenormalizer() + $this->getValueDenormalizer(), ); } @@ -407,19 +407,19 @@ protected function createCallsDenormalizer(): CallsDenormalizerInterface { return new CallsWithFlagsDenormalizer( new FunctionDenormalizer( - $this->getArgumentsDenormalizer() + $this->getArgumentsDenormalizer(), ), [ new ConfiguratorFlagHandler(), new OptionalFlagHandler(), - ] + ], ); } protected function createArgumentsDenormalizer(): ArgumentsDenormalizerInterface { return new SimpleArgumentsDenormalizer( - $this->getValueDenormalizer() + $this->getValueDenormalizer(), ); } @@ -427,8 +427,8 @@ protected function createValueDenormalizer(): ValueDenormalizerInterface { return new UniqueValueDenormalizer( new SimpleValueDenormalizer( - $this->getExpressionLanguageParser() - ) + $this->getExpressionLanguageParser(), + ), ); } @@ -438,9 +438,9 @@ protected function createExpressionLanguageParser(): ExpressionLanguageParserInt new StringMergerParser( new SimpleParser( $this->getLexer(), - $this->getExpressionLanguageTokenParser() - ) - ) + $this->getExpressionLanguageTokenParser(), + ), + ), ); } @@ -452,12 +452,12 @@ protected function createLexer(): LexerInterface new FunctionLexer( new StringThenReferenceLexer( new SubPatternsLexer( - new ReferenceLexer() - ) - ) - ) - ) - ) + new ReferenceLexer(), + ), + ), + ), + ), + ), ); } @@ -472,7 +472,7 @@ protected function createExpressionLanguageTokenParser(): TokenParserInterface new FixtureMethodReferenceTokenParser(), new FixtureRangeReferenceTokenParser(), new IdentityTokenParser( - new FunctionTokenParser($argumentEscaper) + new FunctionTokenParser($argumentEscaper), ), new MethodReferenceTokenParser(), new OptionalTokenParser(), @@ -484,8 +484,8 @@ protected function createExpressionLanguageTokenParser(): TokenParserInterface new StringTokenParser($argumentEscaper), new TolerantFunctionTokenParser( new IdentityTokenParser( - new FunctionTokenParser($argumentEscaper) - ) + new FunctionTokenParser($argumentEscaper), + ), ), new VariableTokenParser(), new WildcardReferenceTokenParser(), @@ -499,8 +499,8 @@ protected function createObjectGenerator(): ObjectGeneratorInterface $this->getValueResolver(), $this->getInstantiator(), $this->getHydrator(), - $this->getCaller() - ) + $this->getCaller(), + ), ); } @@ -509,8 +509,8 @@ protected function createFixtureSetResolver(): FixtureSetResolverInterface return new RemoveConflictingObjectsResolver( new SimpleFixtureSetResolver( $this->getParameterResolver(), - new TemplateFixtureBagResolver() - ) + new TemplateFixtureBagResolver(), + ), ); } @@ -523,7 +523,7 @@ protected function createParameterResolver(): ParameterBagResolverInterface ]); return new RemoveConflictingParametersParameterBagResolver( - new SimpleParameterBagResolver($registry) + new SimpleParameterBagResolver($registry), ); } @@ -536,24 +536,24 @@ protected function createValueResolver(): ValueResolverInterface new FunctionCallArgumentResolver( new PhpFunctionCallValueResolver( $this->getBlacklistedFunctions(), - new FakerFunctionCallValueResolver($this->fakerGenerator) - ) + new FakerFunctionCallValueResolver($this->fakerGenerator), + ), ), new FixturePropertyReferenceResolver( - $this->getPropertyAccessor() + $this->getPropertyAccessor(), ), new FixtureMethodCallReferenceResolver(), new UnresolvedFixtureReferenceIdResolver( new SelfFixtureReferenceResolver( - new FixtureReferenceResolver() - ) + new FixtureReferenceResolver(), + ), ), new FixtureWildcardReferenceResolver(), new ListValueResolver(), new OptionalValueResolver(null, $this->getFakerGenerator()), new ParameterValueResolver(), new UniqueValueResolver( - new UniqueValuesPool() + new UniqueValuesPool(), ), new ValueForCurrentValueResolver(), new VariableValueResolver(), @@ -590,8 +590,8 @@ protected function createInstantiator(): InstantiatorInterface new NullConstructorInstantiator(), new NoMethodCallInstantiator(), new StaticFactoryInstantiator($namedArgumentsResolver), - ]) - ) + ]), + ), ); } @@ -603,14 +603,14 @@ private function createNamedArgumentsResolver(): NamedArgumentsResolver protected function createHydrator(): HydratorInterface { return new SimpleHydrator( - $this->getPropertyHydrator() + $this->getPropertyHydrator(), ); } protected function createPropertyHydrator(): PropertyHydratorInterface { return new SymfonyPropertyAccessorHydrator( - $this->getPropertyAccessor() + $this->getPropertyAccessor(), ); } @@ -619,7 +619,7 @@ protected function createPropertyAccessor(): PropertyAccessorInterface return new StdPropertyAccessor( PropertyAccess::createPropertyAccessorBuilder() ->enableMagicCall() - ->getPropertyAccessor() + ->getPropertyAccessor(), ); } @@ -655,7 +655,7 @@ public function __call(string $method, array $arguments) return $this->cache[$method]; } - if (0 !== strpos($method, 'get')) { + if (0 !== mb_strpos($method, 'get')) { throw BadMethodCallExceptionFactory::createForUnknownMethod($method); } @@ -666,7 +666,7 @@ public function __call(string $method, array $arguments) $this->previous = $realMethod; - $service = $this->$realMethod(...$arguments); + $service = $this->{$realMethod}(...$arguments); $this->cache[$method] = $service; return $service; diff --git a/src/Loader/SimpleDataLoader.php b/src/Loader/SimpleDataLoader.php index bb5901626..78bd6ae00 100644 --- a/src/Loader/SimpleDataLoader.php +++ b/src/Loader/SimpleDataLoader.php @@ -38,7 +38,7 @@ public function __construct(FixtureBuilderInterface $fixtureBuilder, GeneratorIn $this->builder = $fixtureBuilder; $this->generator = $generator; } - + public function loadData(array $data, array $parameters = [], array $objects = []): ObjectSet { $fixtureSet = $this->builder->build($data, $parameters, $objects); diff --git a/src/Loader/SimpleFileLoader.php b/src/Loader/SimpleFileLoader.php index 769b3b40f..9e9d82246 100644 --- a/src/Loader/SimpleFileLoader.php +++ b/src/Loader/SimpleFileLoader.php @@ -38,7 +38,7 @@ public function __construct(ParserInterface $parser, DataLoaderInterface $dataLo $this->parser = $parser; $this->dataLoader = $dataLoader; } - + public function loadFile(string $file, array $parameters = [], array $objects = []): ObjectSet { $data = $this->parser->parse($file); diff --git a/src/Loader/SimpleFilesLoader.php b/src/Loader/SimpleFilesLoader.php index e1ca1e29f..e89a5bfe5 100644 --- a/src/Loader/SimpleFilesLoader.php +++ b/src/Loader/SimpleFilesLoader.php @@ -45,7 +45,7 @@ public function __construct(ParserInterface $parser, DataLoaderInterface $dataLo $this->dataMerger = new IncludeDataMerger(); $this->dataLoader = $dataLoader; } - + public function loadFiles(array $files, array $parameters = [], array $objects = []): ObjectSet { $data = array_reduce( @@ -55,7 +55,7 @@ function (array $data, string $file): array { return $this->dataMerger->mergeInclude($data, $fileData); }, - [] + [], ); return $this->dataLoader->loadData($data, $parameters, $objects); diff --git a/src/ObjectBag.php b/src/ObjectBag.php index b7b5ced22..9b6674df2 100644 --- a/src/ObjectBag.php +++ b/src/ObjectBag.php @@ -50,7 +50,7 @@ public function __construct(array $objects = []) } $this->objects[$id] = new CompleteObject( - new SimpleObject($id, $object) + new SimpleObject($id, $object), ); $this->array[$id] = $object; } @@ -78,7 +78,6 @@ public function without($objectOrFixture): self { $clone = clone $this; unset($clone->objects[$objectOrFixture->getId()], $clone->array[$objectOrFixture->getId()]); - return $clone; } @@ -94,10 +93,10 @@ public function mergeWith(self $objects): self $clone->objects[$reference] = $object; $clone->array[$reference] = $object->getInstance(); } - + return $clone; } - + public function has(FixtureIdInterface $fixture): bool { return isset($this->objects[$fixture->getId()]); @@ -111,13 +110,13 @@ public function get(FixtureIdInterface $fixture): ObjectInterface if ($this->has($fixture)) { return $this->objects[$fixture->getId()]; } - + throw ObjectNotFoundExceptionFactory::create( $fixture->getId(), - $fixture instanceof FixtureInterface ? $fixture->getClassName() : 'no class given' + $fixture instanceof FixtureInterface ? $fixture->getClassName() : 'no class given', ); } - + public function count(): int { return count($this->objects); diff --git a/src/Parameter.php b/src/Parameter.php index 93bf6cf92..3f87e728d 100644 --- a/src/Parameter.php +++ b/src/Parameter.php @@ -23,9 +23,8 @@ final class Parameter */ private $key; - private $value; - + public function __construct(string $key, $value) { $this->key = $key; @@ -36,15 +35,15 @@ public function withValue($value): self { $clone = clone $this; $clone->value = deep_clone($value); - + return $clone; } - + public function getKey(): string { return $this->key; } - + public function getValue() { return deep_clone($this->value); diff --git a/src/ParameterBag.php b/src/ParameterBag.php index 765b9a7a1..681ccc047 100644 --- a/src/ParameterBag.php +++ b/src/ParameterBag.php @@ -53,12 +53,12 @@ public function with(Parameter $parameter): self return $clone; } - + public function without(string $key): self { $clone = clone $this; unset($clone->parameters[$key]); - + return $clone; } @@ -78,12 +78,12 @@ public function get(string $key) throw ParameterNotFoundExceptionFactory::create($key); } - + public function getIterator(): Traversable { return new ArrayIterator($this->parameters); } - + public function count(): int { return count($this->parameters); diff --git a/src/Parser/Chainable/JsonParser.php b/src/Parser/Chainable/JsonParser.php index 7fc11532d..437636c18 100644 --- a/src/Parser/Chainable/JsonParser.php +++ b/src/Parser/Chainable/JsonParser.php @@ -25,7 +25,7 @@ final class JsonParser implements ChainableParserInterface use IsAServiceTrait; private const REGEX = '/.{1,}\.json$/i'; - + public function canParse(string $file): bool { if (false === stream_is_local($file)) { diff --git a/src/Parser/Chainable/PhpParser.php b/src/Parser/Chainable/PhpParser.php index 3e1e68315..2cbe9595e 100644 --- a/src/Parser/Chainable/PhpParser.php +++ b/src/Parser/Chainable/PhpParser.php @@ -23,8 +23,8 @@ final class PhpParser implements ChainableParserInterface use IsAServiceTrait; /** @interval */ - const REGEX = '/.+\.php[7]?$/i'; - + public const REGEX = '/.+\.php[7]?$/i'; + public function canParse(string $file): bool { if (false === stream_is_local($file)) { diff --git a/src/Parser/Chainable/YamlParser.php b/src/Parser/Chainable/YamlParser.php index 8bafddca3..20ff971af 100644 --- a/src/Parser/Chainable/YamlParser.php +++ b/src/Parser/Chainable/YamlParser.php @@ -28,7 +28,7 @@ final class YamlParser implements ChainableParserInterface use IsAServiceTrait; /** @interval */ - const REGEX = '/.{1,}\.ya?ml$/i'; + public const REGEX = '/.{1,}\.ya?ml$/i'; /** * @var SymfonyYamlParser @@ -39,7 +39,7 @@ public function __construct(SymfonyYamlParser $yamlParser) { $this->yamlParser = $yamlParser; } - + public function canParse(string $file): bool { if (false === stream_is_local($file)) { diff --git a/src/Parser/IncludeProcessor/DefaultIncludeProcessor.php b/src/Parser/IncludeProcessor/DefaultIncludeProcessor.php index f0ea881fc..d489ddbf7 100644 --- a/src/Parser/IncludeProcessor/DefaultIncludeProcessor.php +++ b/src/Parser/IncludeProcessor/DefaultIncludeProcessor.php @@ -13,13 +13,13 @@ namespace Nelmio\Alice\Parser\IncludeProcessor; -use function array_reverse; use Nelmio\Alice\FileLocatorInterface; use Nelmio\Alice\IsAServiceTrait; use Nelmio\Alice\Parser\IncludeProcessorInterface; use Nelmio\Alice\ParserInterface; use Nelmio\Alice\Throwable\Error\TypeErrorFactory; use Nelmio\Alice\Throwable\Exception\InvalidArgumentExceptionFactory; +use function array_reverse; final class DefaultIncludeProcessor implements IncludeProcessorInterface { @@ -46,7 +46,7 @@ public function __construct(FileLocatorInterface $fileLocator) $this->fileLocator = $fileLocator; $this->dataMerger = new IncludeDataMerger(); } - + public function process(ParserInterface $parser, string $file, array $data): array { $file = $this->fileLocator->locate($file); @@ -110,7 +110,7 @@ private function retrieveIncludeData(ParserInterface $parser, string $file, arra throw TypeErrorFactory::createForInvalidIncludedFilesInData($includeFile, $file); } - if (0 === strlen($includeFile)) { + if ('' === $includeFile) { throw InvalidArgumentExceptionFactory::createForEmptyIncludedFileInData($file); } diff --git a/src/Parser/IncludeProcessor/IncludeDataMerger.php b/src/Parser/IncludeProcessor/IncludeDataMerger.php index 54176478d..886521a0d 100644 --- a/src/Parser/IncludeProcessor/IncludeDataMerger.php +++ b/src/Parser/IncludeProcessor/IncludeDataMerger.php @@ -36,8 +36,7 @@ public function mergeInclude(array $data, array $includeData): array && is_array($fixtures) ) ? array_merge($includeData[$class], $fixtures) - : $fixtures - ; + : $fixtures; } return $includeData; diff --git a/src/Parser/ParserRegistry.php b/src/Parser/ParserRegistry.php index 6ed26fd90..a45022d11 100644 --- a/src/Parser/ParserRegistry.php +++ b/src/Parser/ParserRegistry.php @@ -31,9 +31,7 @@ final class ParserRegistry implements ParserInterface */ public function __construct(array $parsers) { - $this->parsers = (static function (ChainableParserInterface ...$parsers) { - return $parsers; - })(...$parsers); + $this->parsers = (static fn (ChainableParserInterface ...$parsers) => $parsers)(...$parsers); } /** diff --git a/src/Parser/RuntimeCacheParser.php b/src/Parser/RuntimeCacheParser.php index db03133c4..5f0137806 100644 --- a/src/Parser/RuntimeCacheParser.php +++ b/src/Parser/RuntimeCacheParser.php @@ -55,7 +55,7 @@ public function __construct(ParserInterface $parser, FileLocatorInterface $fileL $this->fileLocator = $fileLocator; $this->includeProcessor = $includeProcessor; } - + public function parse(string $file): array { try { diff --git a/src/PropertyAccess/ReflectionPropertyAccessor.php b/src/PropertyAccess/ReflectionPropertyAccessor.php index 7f0695b16..15f0e40bb 100644 --- a/src/PropertyAccess/ReflectionPropertyAccessor.php +++ b/src/PropertyAccess/ReflectionPropertyAccessor.php @@ -35,7 +35,7 @@ public function __construct(PropertyAccessorInterface $decoratedPropertyAccessor { $this->decoratedPropertyAccessor = $decoratedPropertyAccessor; } - + public function setValue(&$objectOrArray, $propertyPath, $value): void { try { @@ -46,7 +46,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value): void throw $exception; } - if ($propertyReflectionProperty->getDeclaringClass()->getName() !== get_class($objectOrArray)) { + if ($propertyReflectionProperty->getDeclaringClass()->getName() !== $objectOrArray::class) { $propertyReflectionProperty->setAccessible(true); $propertyReflectionProperty->setValue($objectOrArray, $value); @@ -55,17 +55,17 @@ public function setValue(&$objectOrArray, $propertyPath, $value): void } $setPropertyClosure = Closure::bind( - function ($object) use ($propertyPath, $value): void { + static function ($object) use ($propertyPath, $value): void { $object->{$propertyPath} = $value; }, $objectOrArray, - $objectOrArray + $objectOrArray, ); $setPropertyClosure($objectOrArray); } } - + public function getValue($objectOrArray, $propertyPath): mixed { try { @@ -76,29 +76,27 @@ public function getValue($objectOrArray, $propertyPath): mixed throw $exception; } - if ($propertyReflectionProperty->getDeclaringClass()->getName() !== get_class($objectOrArray)) { + if ($propertyReflectionProperty->getDeclaringClass()->getName() !== $objectOrArray::class) { $propertyReflectionProperty->setAccessible(true); return $propertyReflectionProperty->getValue($objectOrArray); } $getPropertyClosure = Closure::bind( - function ($object) use ($propertyPath) { - return $object->{$propertyPath}; - }, + static fn ($object) => $object->{$propertyPath}, + $objectOrArray, $objectOrArray, - $objectOrArray ); return $getPropertyClosure($objectOrArray); } } - + public function isWritable($objectOrArray, $propertyPath): bool { return $this->decoratedPropertyAccessor->isWritable($objectOrArray, $propertyPath) || $this->propertyExists($objectOrArray, $propertyPath); } - + public function isReadable($objectOrArray, $propertyPath): bool { return $this->decoratedPropertyAccessor->isReadable($objectOrArray, $propertyPath) || $this->propertyExists($objectOrArray, $propertyPath); @@ -121,7 +119,7 @@ private function getPropertyReflectionProperty($objectOrArray, $propertyPath) return null; } - $reflectionClass = (new ReflectionClass(get_class($objectOrArray))); + $reflectionClass = (new ReflectionClass($objectOrArray::class)); while ($reflectionClass instanceof ReflectionClass) { if ($reflectionClass->hasProperty($propertyPath) && false === $reflectionClass->getProperty($propertyPath)->isStatic() diff --git a/src/PropertyAccess/StdPropertyAccessor.php b/src/PropertyAccess/StdPropertyAccessor.php index b114c0a0d..66c2247b0 100644 --- a/src/PropertyAccess/StdPropertyAccessor.php +++ b/src/PropertyAccess/StdPropertyAccessor.php @@ -31,7 +31,7 @@ public function __construct(PropertyAccessorInterface $decoratedPropertyAccessor { $this->decoratedPropertyAccessor = $decoratedPropertyAccessor; } - + public function setValue(&$objectOrArray, $propertyPath, $value): void { if ($objectOrArray instanceof stdClass) { @@ -42,33 +42,31 @@ public function setValue(&$objectOrArray, $propertyPath, $value): void $this->decoratedPropertyAccessor->setValue($objectOrArray, $propertyPath, $value); } - + public function getValue($objectOrArray, $propertyPath): mixed { if (false === $objectOrArray instanceof stdClass) { return $this->decoratedPropertyAccessor->getValue($objectOrArray, $propertyPath); } - if (false === isset($objectOrArray->$propertyPath)) { + if (false === isset($objectOrArray->{$propertyPath})) { throw NoSuchPropertyExceptionFactory::createForUnreadablePropertyFromStdClass($propertyPath); } - return $objectOrArray->$propertyPath; + return $objectOrArray->{$propertyPath}; } - + public function isWritable($objectOrArray, $propertyPath): bool { return ($objectOrArray instanceof stdClass) ? true - : $this->decoratedPropertyAccessor->isWritable($objectOrArray, $propertyPath) - ; + : $this->decoratedPropertyAccessor->isWritable($objectOrArray, $propertyPath); } - + public function isReadable($objectOrArray, $propertyPath): bool { return ($objectOrArray instanceof stdClass) - ? isset($objectOrArray->$propertyPath) - : $this->decoratedPropertyAccessor->isReadable($objectOrArray, $propertyPath) - ; + ? isset($objectOrArray->{$propertyPath}) + : $this->decoratedPropertyAccessor->isReadable($objectOrArray, $propertyPath); } } diff --git a/src/Throwable/Error/TypeErrorFactory.php b/src/Throwable/Error/TypeErrorFactory.php index ff37ffe2f..e076b012d 100644 --- a/src/Throwable/Error/TypeErrorFactory.php +++ b/src/Throwable/Error/TypeErrorFactory.php @@ -29,8 +29,8 @@ public static function createForDynamicArrayQuantifier($quantifier): TypeError sprintf( 'Expected quantifier to be either an integer or a "%s". Got "%s" instead.', ValueInterface::class, - is_object($quantifier) ? get_class($quantifier) : gettype($quantifier) - ) + is_object($quantifier) ? $quantifier::class : gettype($quantifier), + ), ); } @@ -40,8 +40,8 @@ public static function createForDynamicArrayElement($element): TypeError sprintf( 'Expected element to be either string, an array or a "%s". Got "%s" instead.', ValueInterface::class, - is_object($element) ? get_class($element) : gettype($element) - ) + is_object($element) ? $element::class : gettype($element), + ), ); } @@ -51,8 +51,8 @@ public static function createForOptionalValueQuantifier($quantifier): TypeError sprintf( 'Expected quantifier to be either a scalar value or an instance of "%s". Got "%s" instead.', ValueInterface::class, - is_object($quantifier) ? get_class($quantifier) : gettype($quantifier) - ) + is_object($quantifier) ? $quantifier::class : gettype($quantifier), + ), ); } @@ -62,8 +62,8 @@ public static function createForOptionalValueFirstMember($firstMember): TypeErro sprintf( 'Expected first member to be either a string or an instance of "%s". Got "%s" instead.', ValueInterface::class, - is_object($firstMember) ? get_class($firstMember) : gettype($firstMember) - ) + is_object($firstMember) ? $firstMember::class : gettype($firstMember), + ), ); } @@ -73,8 +73,8 @@ public static function createForOptionalValueSecondMember($secondMember): TypeEr sprintf( 'Expected second member to be either null, a string or an instance of "%s". Got "%s" instead.', ValueInterface::class, - is_object($secondMember) ? get_class($secondMember) : gettype($secondMember) - ) + is_object($secondMember) ? $secondMember::class : gettype($secondMember), + ), ); } @@ -84,8 +84,8 @@ public static function createForInvalidParameterKey($parameterKey): TypeError sprintf( 'Expected parameter key to be either a string or an instance of "%s". Got "%s" instead.', ValueInterface::class, - is_object($parameterKey) ? get_class($parameterKey) : gettype($parameterKey) - ) + is_object($parameterKey) ? $parameterKey::class : gettype($parameterKey), + ), ); } @@ -96,8 +96,8 @@ public static function createForInvalidDenormalizerType(int $index, $denormalize 'Expected denormalizer %d to be a "%s". Got "%s" instead.', $index, ChainableFixtureDenormalizerInterface::class, - is_object($denormalizer) ? get_class($denormalizer) : gettype($denormalizer) - ) + is_object($denormalizer) ? $denormalizer::class : gettype($denormalizer), + ), ); } @@ -106,8 +106,8 @@ public static function createForInvalidSpecificationBagMethodCall($methodCall): return new TypeError( sprintf( 'Expected method call value to be an array. Got "%s" instead.', - gettype($methodCall) - ) + gettype($methodCall), + ), ); } @@ -116,8 +116,8 @@ public static function createForInvalidSpecificationBagMethodCallName($unparsedM return new TypeError( sprintf( 'Expected method name. Got "%s" instead.', - gettype($unparsedMethod) - ) + gettype($unparsedMethod), + ), ); } @@ -126,8 +126,8 @@ public static function createForInvalidFixtureBagParameters($fixturesParameters) return new TypeError( sprintf( 'Expected parameters to be an array. Got "%s" instead.', - is_object($fixturesParameters) ? get_class($fixturesParameters) : gettype($fixturesParameters) - ) + is_object($fixturesParameters) ? $fixturesParameters::class : gettype($fixturesParameters), + ), ); } @@ -138,8 +138,8 @@ public static function createForInvalidIncludeStatementInData($include, string $ 'Expected include statement to be either null or an array of files to include. Got "%s" instead ' .'in file "%s".', gettype($include), - $file - ) + $file, + ), ); } @@ -149,8 +149,8 @@ public static function createForInvalidIncludedFilesInData($includeFile, string sprintf( 'Expected elements of include statement to be file names. Got "%s" instead in file "%s".', gettype($includeFile), - $file - ) + $file, + ), ); } @@ -159,8 +159,8 @@ public static function createForInvalidFixtureFileReturnedData(string $file): Ty return new TypeError( sprintf( 'The file "%s" must return a PHP array.', - $file - ) + $file, + ), ); } @@ -170,8 +170,8 @@ public static function createForInvalidChainableParameterResolver($resolver): Ty sprintf( 'Expected resolvers to be "%s" objects. Got "%s" instead.', ParameterResolverInterface::class, - is_object($resolver)? get_class($resolver) : $resolver - ) + is_object($resolver) ? $resolver::class : $resolver, + ), ); } diff --git a/src/Throwable/Exception/BadMethodCallExceptionFactory.php b/src/Throwable/Exception/BadMethodCallExceptionFactory.php index 5c7ee6540..e85423081 100644 --- a/src/Throwable/Exception/BadMethodCallExceptionFactory.php +++ b/src/Throwable/Exception/BadMethodCallExceptionFactory.php @@ -25,8 +25,8 @@ public static function createForUnknownMethod(string $method): BadMethodCallExce return new BadMethodCallException( sprintf( 'Unknown method "%s".', - $method - ) + $method, + ), ); } diff --git a/src/Throwable/Exception/FileLocator/FileNotFoundException.php b/src/Throwable/Exception/FileLocator/FileNotFoundException.php index 127025b58..4bbe1f08e 100644 --- a/src/Throwable/Exception/FileLocator/FileNotFoundException.php +++ b/src/Throwable/Exception/FileLocator/FileNotFoundException.php @@ -27,8 +27,8 @@ public static function createForNonExistentFile(string $file): static return new static( sprintf( 'The file "%s" does not exist.', - $file - ) + $file, + ), ); } } diff --git a/src/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactory.php b/src/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactory.php index 6898c4238..51546053a 100644 --- a/src/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactory.php +++ b/src/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactory.php @@ -30,15 +30,15 @@ public static function createForUndenormalizableFactory(): UnexpectedValueExcept return new UnexpectedValueException('Could not denormalize the given factory.'); } - public static function createForUnparsableValue(string $value, int $code = 0, Throwable $previous = null): UnexpectedValueException + public static function createForUnparsableValue(string $value, int $code = 0, ?Throwable $previous = null): UnexpectedValueException { return new UnexpectedValueException( sprintf( 'Could not parse value "%s".', - $value + $value, ), $code, - $previous + $previous, ); } @@ -47,20 +47,20 @@ public static function createDenormalizerNotFoundForFixture(string $fixtureId): return new DenormalizerNotFoundException( sprintf( 'No suitable fixture denormalizer found to handle the fixture with the reference "%s".', - $fixtureId - ) + $fixtureId, + ), ); } - public static function createDenormalizerNotFoundUnexpectedCall(string $method, int $code = 0, Throwable $previous = null): DenormalizerNotFoundException + public static function createDenormalizerNotFoundUnexpectedCall(string $method, int $code = 0, ?Throwable $previous = null): DenormalizerNotFoundException { return new DenormalizerNotFoundException( sprintf( 'Expected method "%s" to be called only if it has a denormalizer.', - $method + $method, ), $code, - $previous + $previous, ); } diff --git a/src/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactory.php b/src/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactory.php index 323e41e1e..d8b014b31 100644 --- a/src/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactory.php +++ b/src/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactory.php @@ -23,8 +23,8 @@ public static function createForNoParserFoundForElement(string $element): FlagPa return new FlagParserNotFoundException( sprintf( 'No suitable flag parser found to handle the element "%s".', - $element - ) + $element, + ), ); } @@ -33,8 +33,8 @@ public static function createForExpectedMethodToBeCalledIfHasAParser(string $met return new FlagParserNotFoundException( sprintf( 'Expected method "%s" to be called only if it has a flag parser.', - $method - ) + $method, + ), ); } diff --git a/src/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactory.php b/src/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactory.php index ceb781f98..957ae2837 100644 --- a/src/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactory.php +++ b/src/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactory.php @@ -27,8 +27,8 @@ public static function createForNoParserFoundForToken(Token $token): ParserNotFo sprintf( 'No suitable token parser found to handle the token "%s" (type: %s).', $token->getValue(), - $token->getType() - ) + $token->getType(), + ), ); } @@ -37,21 +37,21 @@ public static function createForExpectedMethodCallOnlyIfHasAParser(string $metho return new ParserNotFoundException( sprintf( 'Expected method "%s" to be called only if it has a parser.', - $method - ) + $method, + ), ); } - public static function createForUnparsableToken(Token $token, int $code = 0, Throwable $previous = null): ParseException + public static function createForUnparsableToken(Token $token, int $code = 0, ?Throwable $previous = null): ParseException { return new ParseException( sprintf( 'Could not parse the token "%s" (type: %s).', $token->getValue(), - $token->getType() + $token->getType(), ), $code, - $previous + $previous, ); } @@ -60,8 +60,8 @@ public static function createForMalformedFunction(string $value): MalformedFunct return new MalformedFunctionException( sprintf( 'The value "%s" contains an unclosed function.', - $value - ) + $value, + ), ); } @@ -70,8 +70,8 @@ public static function createForCouldNotLexValue(string $value): LexException return new LexException( sprintf( 'Could not lex the value "%s".', - $value - ) + $value, + ), ); } diff --git a/src/Throwable/Exception/FixtureNotFoundExceptionFactory.php b/src/Throwable/Exception/FixtureNotFoundExceptionFactory.php index 599952c83..95a8be76a 100644 --- a/src/Throwable/Exception/FixtureNotFoundExceptionFactory.php +++ b/src/Throwable/Exception/FixtureNotFoundExceptionFactory.php @@ -23,8 +23,8 @@ public static function create(string $id): FixtureNotFoundException return new FixtureNotFoundException( sprintf( 'Could not find the fixture "%s".', - $id - ) + $id, + ), ); } @@ -33,8 +33,8 @@ public static function createWildcard(string $wildcard): FixtureNotFoundExceptio return new FixtureNotFoundException( sprintf( 'Could not find fixtures matching wildcard "%s*".', - $wildcard - ) + $wildcard, + ), ); } diff --git a/src/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactory.php b/src/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactory.php index 360d17f2a..2c0ba7bb9 100644 --- a/src/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactory.php @@ -25,8 +25,8 @@ public static function createForNoProcessorFoundForMethodCall(MethodCallInterfac return new ProcessorNotFoundException( sprintf( 'No suitable processor found to handle the method call "%s".', - $methodCall - ) + $methodCall, + ), ); } diff --git a/src/Throwable/Exception/Generator/Context/CachedValueNotFound.php b/src/Throwable/Exception/Generator/Context/CachedValueNotFound.php index d87012718..50530d6f8 100644 --- a/src/Throwable/Exception/Generator/Context/CachedValueNotFound.php +++ b/src/Throwable/Exception/Generator/Context/CachedValueNotFound.php @@ -23,8 +23,8 @@ public static function create(string $key): self return new self( sprintf( 'No value with the key "%s" was found in the cache.', - $key - ) + $key, + ), ); } } diff --git a/src/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactory.php b/src/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactory.php index 5e797454a..1c680b41d 100644 --- a/src/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactory.php @@ -33,10 +33,10 @@ public static function create( 'Could not hydrate the property "%s" of the object "%s" (class: %s).', $property->getName(), $object->getId(), - get_class($object->getInstance()) + get_class($object->getInstance()), ), $code, - $previous + $previous, ); } @@ -44,17 +44,17 @@ public static function createForInaccessibleProperty( ObjectInterface $object, Property $property, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ): InaccessiblePropertyException { return new InaccessiblePropertyException( sprintf( 'Could not access to the property "%s" of the object "%s" (class: %s).', $property->getName(), $object->getId(), - get_class($object->getInstance()) + get_class($object->getInstance()), ), $code, - $previous + $previous, ); } @@ -62,17 +62,17 @@ public static function createForInvalidProperty( ObjectInterface $object, Property $property, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ): InvalidArgumentException { return new InvalidArgumentException( sprintf( 'Invalid value given for the property "%s" of the object "%s" (class: %s).', $property->getName(), $object->getId(), - get_class($object->getInstance()) + get_class($object->getInstance()), ), $code, - $previous + $previous, ); } @@ -80,17 +80,17 @@ public static function createForCouldNotHydrateObjectWithProperty( ObjectInterface $object, Property $property, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ): NoSuchPropertyException { return new NoSuchPropertyException( sprintf( 'Could not hydrate the property "%s" of the object "%s" (class: %s).', $property->getName(), $object->getId(), - get_class($object->getInstance()) + get_class($object->getInstance()), ), $code, - $previous + $previous, ); } diff --git a/src/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactory.php b/src/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactory.php index 1bd51d6b2..ba503bb8a 100644 --- a/src/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactory.php @@ -26,10 +26,10 @@ public static function create(FixtureInterface $fixture, int $code, Throwable $p return new InstantiationException( sprintf( 'Could not instantiate fixture "%s".', - $fixture->getId() + $fixture->getId(), ), $code, - $previous + $previous, ); } @@ -39,8 +39,8 @@ public static function createForNonPublicConstructor(FixtureInterface $fixture): sprintf( 'Could not instantiate "%s", the constructor of "%s" is not public.', $fixture->getId(), - $fixture->getClassName() - ) + $fixture->getClassName(), + ), ); } @@ -49,23 +49,23 @@ public static function createForConstructorIsMissingMandatoryParameters(FixtureI return new InstantiationException( sprintf( 'Could not instantiate "%s", the constructor has mandatory parameters but no parameters have been given.', - $fixture->getId() - ) + $fixture->getId(), + ), ); } public static function createForCouldNotGetConstructorData( FixtureInterface $fixture, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ): InstantiationException { return new InstantiationException( sprintf( 'Could not get the necessary data on the constructor to instantiate "%s".', - $fixture->getId() + $fixture->getId(), ), $code, - $previous + $previous, ); } @@ -75,8 +75,8 @@ public static function createForInvalidInstanceType(FixtureInterface $fixture, ? sprintf( 'Instantiated fixture was expected to be an instance of "%s". Got "%s" instead.', $fixture->getClassName(), - $instance ? get_class($instance) : 'null' - ) + $instance ? $instance::class : 'null', + ), ); } @@ -85,8 +85,8 @@ public static function createForInstantiatorNotFoundForFixture(FixtureInterface return new InstantiatorNotFoundException( sprintf( 'No suitable instantiator found for the fixture "%s".', - $fixture->getId() - ) + $fixture->getId(), + ), ); } diff --git a/src/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactory.php b/src/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactory.php index ff7b4e46e..b41ff6b05 100644 --- a/src/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactory.php +++ b/src/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactory.php @@ -23,8 +23,8 @@ public static function createUnexpectedCall(string $method): ObjectGeneratorNotF return new ObjectGeneratorNotFoundException( sprintf( 'Expected method "%s" to be called only if it has a generator.', - $method - ) + $method, + ), ); } diff --git a/src/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactory.php index ffd656458..7113aa37b 100644 --- a/src/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactory.php @@ -24,8 +24,8 @@ public static function createForParameter(string $key, array $resolving): Circul sprintf( 'Circular reference detected for the parameter "%s" while resolving ["%s"].', $key, - implode('", "', array_keys($resolving)) - ) + implode('", "', array_keys($resolving)), + ), ); } diff --git a/src/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactory.php index f8e2c4376..1e3c43b7b 100644 --- a/src/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactory.php @@ -23,8 +23,8 @@ public static function create(string $id): FixtureNotFoundException return new FixtureNotFoundException( sprintf( 'Could not find the fixture "%s".', - $id - ) + $id, + ), ); } diff --git a/src/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactory.php index 42462bea2..dcb32fbb6 100644 --- a/src/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactory.php @@ -26,17 +26,17 @@ public static function createForFixture( FixtureInterface $fixture, FixtureMethodCallValue $value, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ): NoSuchMethodException { return new NoSuchMethodException( sprintf( 'Could not find the method "%s" of the object "%s" (class: %s).', $value->getFunctionCall()->getName(), $fixture->getId(), - $fixture->getClassName() + $fixture->getClassName(), ), $code, - $previous + $previous, ); } diff --git a/src/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactory.php index 174b84f14..5311b57dc 100644 --- a/src/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactory.php @@ -26,17 +26,17 @@ public static function createForFixture( FixtureInterface $fixture, FixturePropertyValue $value, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ): NoSuchPropertyException { return new NoSuchPropertyException( sprintf( 'Could not find the property "%s" of the object "%s" (class: %s).', $value->getProperty(), $fixture->getId(), - $fixture->getClassName() + $fixture->getClassName(), ), $code, - $previous + $previous, ); } diff --git a/src/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactory.php index c8bc9b6f1..454f08250 100644 --- a/src/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactory.php @@ -24,8 +24,8 @@ public static function create(int $limit, string $key): RecursionLimitReachedExc sprintf( 'Recursion limit (%d tries) reached while resolving the parameter "%s"', $limit, - $key - ) + $key, + ), ); } diff --git a/src/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactory.php index 45500ed5b..28e84c4ad 100644 --- a/src/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactory.php @@ -25,8 +25,8 @@ public static function createForParameter(string $parameterKey): ResolverNotFoun return new ResolverNotFoundException( sprintf( 'No resolver found to resolve parameter "%s".', - $parameterKey - ) + $parameterKey, + ), ); } @@ -35,8 +35,8 @@ public static function createForValue(ValueInterface $value): ResolverNotFoundEx return new ResolverNotFoundException( sprintf( 'No resolver found to resolve value "%s".', - $value - ) + $value, + ), ); } @@ -45,8 +45,8 @@ public static function createUnexpectedCall(string $method): ResolverNotFoundExc return new ResolverNotFoundException( sprintf( 'Expected method "%s" to be called only if it has a resolver.', - $method - ) + $method, + ), ); } diff --git a/src/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactory.php index 1d0a602f3..a9188bea0 100644 --- a/src/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactory.php @@ -26,8 +26,8 @@ public static function create(UniqueValue $value, int $limit): UniqueValueGenera sprintf( 'Could not generate a unique value after %d attempts for "%s".', $limit, - $value->getId() - ) + $value->getId(), + ), ); } diff --git a/src/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactory.php index 48a135dd9..ade8f4ddc 100644 --- a/src/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactory.php @@ -25,7 +25,7 @@ public static function createFromResolutionThrowable(ResolutionThrowable $previo return new UnresolvableValueDuringGenerationException( 'Could not resolve value during the generation process.', 0, - $previous + $previous, ); } diff --git a/src/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactory.php b/src/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactory.php index f4d3b76d8..8af700ccb 100644 --- a/src/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactory.php +++ b/src/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactory.php @@ -21,66 +21,66 @@ */ final class UnresolvableValueExceptionFactory { - public static function create(ValueInterface $value, int $code = 0, Throwable $previous = null): UnresolvableValueException + public static function create(ValueInterface $value, int $code = 0, ?Throwable $previous = null): UnresolvableValueException { return new UnresolvableValueException( null === $previous || '' === trim($previous->getMessage()) ? sprintf( 'Could not resolve value "%s".', - $value + $value, ) : sprintf( 'Could not resolve value "%s": %s', $value, - $previous->getMessage() + $previous->getMessage(), ), $code, - $previous + $previous, ); } - public static function createForInvalidReferenceId(ValueInterface $value, $result, int $code = 0, Throwable $previous = null): UnresolvableValueException + public static function createForInvalidReferenceId(ValueInterface $value, $result, int $code = 0, ?Throwable $previous = null): UnresolvableValueException { return new UnresolvableValueException( sprintf( 'Expected fixture reference value "%s" to be resolved into a string. Got "%s" instead.', $value, is_object($result) - ? get_class($result) - : sprintf('(%s) %s', gettype($result), $result) + ? $result::class + : sprintf('(%s) %s', gettype($result), $result), ), $code, - $previous + $previous, ); } - public static function createForCouldNotEvaluateExpression(ValueInterface $value, int $code = 0, Throwable $previous = null): UnresolvableValueException + public static function createForCouldNotEvaluateExpression(ValueInterface $value, int $code = 0, ?Throwable $previous = null): UnresolvableValueException { return new UnresolvableValueException( null === $previous || '' === trim($previous->getMessage()) ? sprintf( 'Could not evaluate the expression "%s".', - $value->__toString() + $value->__toString(), ) : sprintf( 'Could not evaluate the expression "%s": %s', $value->__toString(), - $previous->getMessage() + $previous->getMessage(), ), $code, - $previous + $previous, ); } - public static function createForCouldNotFindVariable(ValueInterface $value, int $code = 0, Throwable $previous = null): UnresolvableValueException + public static function createForCouldNotFindVariable(ValueInterface $value, int $code = 0, ?Throwable $previous = null): UnresolvableValueException { return new UnresolvableValueException( sprintf( 'Could not find a variable "%s".', - $value->__toString() + $value->__toString(), ), $code, - $previous + $previous, ); } @@ -89,8 +89,8 @@ public static function createForCouldNotFindParameter(string $parameterKey): Unr return new UnresolvableValueException( sprintf( 'Could not find the parameter "%s".', - $parameterKey - ) + $parameterKey, + ), ); } @@ -102,9 +102,9 @@ public static function createForInvalidResolvedQuantifierTypeForOptionalValue(Va return new UnresolvableValueException( sprintf( 'Expected the quantifier "%s" for the optional value to be resolved into a string, got "%s" instead.', - get_class($quantifier), - is_object($resolvedQuantifier) ? get_class($resolvedQuantifier) : gettype($resolvedQuantifier) - ) + $quantifier::class, + is_object($resolvedQuantifier) ? $resolvedQuantifier::class : gettype($resolvedQuantifier), + ), ); } @@ -113,8 +113,8 @@ public static function createForNoFixtureOrObjectMatchingThePattern(ValueInterfa return new UnresolvableValueException( sprintf( 'Could not find a fixture or object ID matching the pattern "%s".', - $value->__toString() - ) + $value->__toString(), + ), ); } diff --git a/src/Throwable/Exception/InvalidArgumentExceptionFactory.php b/src/Throwable/Exception/InvalidArgumentExceptionFactory.php index 8c9ccfcf4..3e45ee05f 100644 --- a/src/Throwable/Exception/InvalidArgumentExceptionFactory.php +++ b/src/Throwable/Exception/InvalidArgumentExceptionFactory.php @@ -30,8 +30,8 @@ public static function createForInvalidReferenceType(string $reference): Invalid sprintf( 'Expected reference to be either a string or a "%s" instance, got "%s" instead.', ValueInterface::class, - $reference - ) + $reference, + ), ); } @@ -41,8 +41,8 @@ public static function createForReferenceKeyMismatch(string $id1, string $id2): sprintf( 'Reference key mismatch, the keys "%s" and "%s" refers to the same fixture but the keys are different.', $id1, - $id2 - ) + $id2, + ), ); } @@ -52,8 +52,8 @@ public static function createForFlagBagKeyMismatch(FixtureInterface $fixture, Fl sprintf( 'Expected the fixture ID and the flags key to be the same. Got "%s" and "%s" instead.', $fixture->getId(), - $flags->getKey() - ) + $flags->getKey(), + ), ); } @@ -66,8 +66,8 @@ public static function createForInvalidSeedConfigurationValue($seed): InvalidArg sprintf( 'Expected value to be either null or a strictly positive integer but got "%s" ' .'instead.', - $seed - ) + $seed, + ), ); } @@ -76,8 +76,8 @@ public static function createForExpectedConfigurationStringValue($value): Invali return new InvalidArgumentException( sprintf( 'Expected a string value but got "%s" instead.', - gettype($value) - ) + gettype($value), + ), ); } @@ -86,8 +86,8 @@ public static function createForExpectedConfigurationPositiveIntegerValue(int $v return new InvalidArgumentException( sprintf( 'Expected a strictly positive integer but got "%s" instead.', - $value - ) + $value, + ), ); } @@ -96,8 +96,8 @@ public static function createForExpectedConfigurationArrayOfStringValue($value): return new InvalidArgumentException( sprintf( 'Expected an array of strings but got "%s" element in the array instead.', - gettype($value) - ) + gettype($value), + ), ); } @@ -106,8 +106,8 @@ public static function createForRedundantUniqueValue(string $id): InvalidArgumen return new InvalidArgumentException( sprintf( 'Cannot create a unique value of a unique value for value "%s".', - $id - ) + $id, + ), ); } @@ -116,8 +116,8 @@ public static function createForInvalidExpressionLanguageTokenType(string $type) return new InvalidArgumentException( sprintf( 'Expected type to be a known token type but got "%s".', - $type - ) + $type, + ), ); } @@ -126,8 +126,8 @@ public static function createForInvalidExpressionLanguageToken(string $value): I return new InvalidArgumentException( sprintf( 'Invalid token "%s" found.', - $value - ) + $value, + ), ); } @@ -136,8 +136,8 @@ public static function createForNoIncludeStatementInData(string $file): InvalidA return new InvalidArgumentException( sprintf( 'Could not find any include statement in the file "%s".', - $file - ) + $file, + ), ); } @@ -147,20 +147,20 @@ public static function createForEmptyIncludedFileInData(string $file): InvalidAr sprintf( 'Expected elements of include statement to be file names. Got empty string instead in file ' .'"%s".', - $file - ) + $file, + ), ); } - public static function createForFileCouldNotBeFound(string $file, int $code = 0, Throwable $previous = null): InvalidArgumentException + public static function createForFileCouldNotBeFound(string $file, int $code = 0, ?Throwable $previous = null): InvalidArgumentException { return new InvalidArgumentException( sprintf( 'The file "%s" could not be found.', - $file + $file, ), $code, - $previous + $previous, ); } @@ -169,8 +169,8 @@ public static function createForInvalidLimitValue(int $limit): InvalidArgumentEx return new InvalidArgumentException( sprintf( 'Expected limit value to be a strictly positive integer, got "%d" instead.', - $limit - ) + $limit, + ), ); } @@ -179,8 +179,8 @@ public static function createForInvalidLimitValueForRecursiveCalls(int $limit): return new InvalidArgumentException( sprintf( 'Expected limit for recursive calls to be of at least 2. Got "%d" instead.', - $limit - ) + $limit, + ), ); } @@ -189,8 +189,8 @@ public static function createForInvalidFakerFormatter(string $formatter): Invali return new InvalidArgumentException( sprintf( 'Invalid faker formatter "%s" found.', - $formatter - ) + $formatter, + ), ); } @@ -200,8 +200,8 @@ public static function createForFixtureExtendingANonTemplateFixture(FixtureInter sprintf( 'Fixture "%s" extends "%2$s" but "%2$s" is not a template.', $fixture->getId(), - $fixtureId - ) + $fixtureId, + ), ); } @@ -210,8 +210,8 @@ public static function createForUnsupportedTypeForIdenticalValuesCheck($value): return new InvalidArgumentException( sprintf( 'Unsupported type "%s": cannot determine if two values of this type are identical.', - gettype($value) - ) + gettype($value), + ), ); } @@ -220,8 +220,8 @@ public static function createForInvalidConstructorMethod(string $method): Invali return new InvalidArgumentException( sprintf( 'Invalid constructor method "%s".', - $method - ) + $method, + ), ); } @@ -230,8 +230,8 @@ public static function createForInvalidOptionalFlagBoundaries(int $percentage): return new InvalidArgumentException( sprintf( 'Expected optional flag to be an integer element of [0;100]. Got "%d" instead.', - $percentage - ) + $percentage, + ), ); } @@ -242,8 +242,8 @@ public static function createForInvalidDynamicArrayQuantifier(FixtureInterface $ 'Expected quantifier to be a positive integer. Got "%d" for "%s", check you dynamic arrays ' .'declarations (e.g. "x @user*").', $quantifier, - $fixture->getId() - ) + $fixture->getId(), + ), ); } diff --git a/src/Throwable/Exception/LogicExceptionFactory.php b/src/Throwable/Exception/LogicExceptionFactory.php index 86a999566..f38ebdd90 100644 --- a/src/Throwable/Exception/LogicExceptionFactory.php +++ b/src/Throwable/Exception/LogicExceptionFactory.php @@ -25,8 +25,8 @@ public static function createForUncallableMethod(string $method): LogicException return new LogicException( sprintf( 'By its nature, "%s()" should not be called.', - $method - ) + $method, + ), ); } @@ -36,15 +36,15 @@ public static function createForCannotDenormalizerForChainableFixtureBuilderDeno sprintf( 'As a chainable denormalizer, "%s" should be called only if "::canDenormalize() returns true. Got ' .'false instead.', - $method - ) + $method, + ), ); } public static function createForCannotHaveBothConstructorAndFactory(): LogicException { return new LogicException( - 'Cannot use the fixture property "__construct" and "__factory" together.' + 'Cannot use the fixture property "__construct" and "__factory" together.', ); } } diff --git a/src/Throwable/Exception/NoValueForCurrentExceptionFactory.php b/src/Throwable/Exception/NoValueForCurrentExceptionFactory.php index f2ca1e76b..27278e364 100644 --- a/src/Throwable/Exception/NoValueForCurrentExceptionFactory.php +++ b/src/Throwable/Exception/NoValueForCurrentExceptionFactory.php @@ -25,8 +25,8 @@ public static function create(FixtureInterface $fixture): NoValueForCurrentExcep return new NoValueForCurrentException( sprintf( 'No value for \'\' found for the fixture "%s".', - $fixture->getId() - ) + $fixture->getId(), + ), ); } diff --git a/src/Throwable/Exception/ObjectNotFoundExceptionFactory.php b/src/Throwable/Exception/ObjectNotFoundExceptionFactory.php index a93f131c0..6bdb4e4ea 100644 --- a/src/Throwable/Exception/ObjectNotFoundExceptionFactory.php +++ b/src/Throwable/Exception/ObjectNotFoundExceptionFactory.php @@ -24,8 +24,8 @@ public static function create(string $id, string $className): ObjectNotFoundExce sprintf( 'Could not find the object "%s" of the class "%s".', $id, - $className - ) + $className, + ), ); } diff --git a/src/Throwable/Exception/ParameterNotFoundExceptionFactory.php b/src/Throwable/Exception/ParameterNotFoundExceptionFactory.php index 0b6cc562c..89809fe2b 100644 --- a/src/Throwable/Exception/ParameterNotFoundExceptionFactory.php +++ b/src/Throwable/Exception/ParameterNotFoundExceptionFactory.php @@ -25,8 +25,8 @@ public static function create(string $key): ParameterNotFoundException return new ParameterNotFoundException( sprintf( 'Could not find the parameter "%s".', - $key - ) + $key, + ), ); } @@ -36,8 +36,8 @@ public static function createForWhenResolvingParameter(string $key, Parameter $p sprintf( 'Could not find the parameter "%s" when resolving "%s".', $key, - $parameter->getKey() - ) + $parameter->getKey(), + ), ); } diff --git a/src/Throwable/Exception/Parser/ParseExceptionFactory.php b/src/Throwable/Exception/Parser/ParseExceptionFactory.php index a7d35236d..f16bb1b05 100644 --- a/src/Throwable/Exception/Parser/ParseExceptionFactory.php +++ b/src/Throwable/Exception/Parser/ParseExceptionFactory.php @@ -25,44 +25,44 @@ public static function createForParserNoFoundForFile(string $file): ParserNotFou return new ParserNotFoundException( sprintf( 'No suitable parser found for the file "%s".', - $file - ) + $file, + ), ); } - public static function createForUnparsableFile(string $file, int $code = 0, Throwable $previous = null): UnparsableFileException + public static function createForUnparsableFile(string $file, int $code = 0, ?Throwable $previous = null): UnparsableFileException { return new UnparsableFileException( sprintf( 'Could not parse the file "%s".', - $file + $file, ), $code, - $previous + $previous, ); } - public static function createForInvalidYaml(string $file, int $code = 0, Throwable $previous = null): UnparsableFileException + public static function createForInvalidYaml(string $file, int $code = 0, ?Throwable $previous = null): UnparsableFileException { return new UnparsableFileException( sprintf( 'The file "%s" does not contain valid YAML.', - $file + $file, ), $code, - $previous + $previous, ); } - public static function createForInvalidJson(string $file, int $code = 0, Throwable $previous = null): UnparsableFileException + public static function createForInvalidJson(string $file, int $code = 0, ?Throwable $previous = null): UnparsableFileException { return new UnparsableFileException( sprintf( 'The file "%s" does not contain valid JSON.', - $file + $file, ), $code, - $previous + $previous, ); } diff --git a/src/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactory.php b/src/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactory.php index a41959456..3aca1e51d 100644 --- a/src/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactory.php +++ b/src/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactory.php @@ -25,8 +25,8 @@ public static function createForUnreadablePropertyFromStdClass(string $propertyP return new NoSuchPropertyException( sprintf( 'Cannot read property "%s" from stdClass.', - $propertyPath - ) + $propertyPath, + ), ); } diff --git a/src/deep_clone.php b/src/deep_clone.php index 29c864d5e..5fc2bea22 100644 --- a/src/deep_clone.php +++ b/src/deep_clone.php @@ -18,6 +18,7 @@ if (false === function_exists('Nelmio\Alice\deep_clone')) { /** * Deep clone the given value. + * @param mixed $value */ function deep_clone($value) { diff --git a/tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php b/tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php index c4b7f6ca5..8bfd78e63 100644 --- a/tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php +++ b/tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php @@ -21,6 +21,7 @@ * @coversNothing * * @group integration + * @internal */ class CheckBundleDependenciesPassTest extends TestCase { diff --git a/tests/Bridge/Symfony/DependencyInjection/ConfigurationTest.php b/tests/Bridge/Symfony/DependencyInjection/ConfigurationTest.php index ef1de537b..377baf861 100644 --- a/tests/Bridge/Symfony/DependencyInjection/ConfigurationTest.php +++ b/tests/Bridge/Symfony/DependencyInjection/ConfigurationTest.php @@ -22,6 +22,7 @@ * @covers \Nelmio\Alice\Bridge\Symfony\DependencyInjection\Configuration * * @group integration + * @internal */ class ConfigurationTest extends TestCase { @@ -39,7 +40,7 @@ public function testDefaultValues(): void ]; $actual = $processor->processConfiguration($configuration, []); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testOverriddeValues(): void @@ -64,10 +65,10 @@ public function testOverriddeValues(): void 'loading_limit' => 50, 'max_unique_values_retry' => 15, ], - ] + ], ); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testLocaleMustBeAStringValues(): void @@ -83,8 +84,8 @@ public function testLocaleMustBeAStringValues(): void [ 'nelmio_alice' => [ 'locale' => false, - ] - ] + ], + ], ); } @@ -105,11 +106,11 @@ public function testSeedCanBeNull(): void [ 'nelmio_alice' => [ 'seed' => null, - ] - ] + ], + ], ); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testFunctionsBlacklistMustAnArray(): void @@ -125,8 +126,8 @@ public function testFunctionsBlacklistMustAnArray(): void [ 'nelmio_alice' => [ 'functions_blacklist' => 'string', - ] - ] + ], + ], ); } @@ -143,8 +144,8 @@ public function testFunctionsBlacklistMustBeStrings(): void [ 'nelmio_alice' => [ 'functions_blacklist' => [true], - ] - ] + ], + ], ); } @@ -161,8 +162,8 @@ public function testMaxUniqueValuesRetryMustBeAStrictlyPositiveValues(): void [ 'nelmio_alice' => [ 'max_unique_values_retry' => 0, - ] - ] + ], + ], ); } @@ -179,8 +180,8 @@ public function testLoadingLimitMustBeAnInteger(): void [ 'nelmio_alice' => [ 'loading_limit' => false, - ] - ] + ], + ], ); } @@ -197,8 +198,8 @@ public function testLoadingLimitMustBeAStrictlyPositiveValues(): void [ 'nelmio_alice' => [ 'loading_limit' => 0, - ] - ] + ], + ], ); } @@ -215,8 +216,8 @@ public function testMaxUniqueValuesRetryMustBeAnInteger(): void [ 'nelmio_alice' => [ 'max_unique_values_retry' => false, - ] - ] + ], + ], ); } @@ -234,7 +235,7 @@ public function testConfigurationParametersAreInjectedAsParameters(): void ]; foreach ($expected as $parameterName => $value) { - static::assertEquals($value, $kernel->getContainer()->getParameter($parameterName)); + self::assertEquals($value, $kernel->getContainer()->getParameter($parameterName)); } $kernel->shutdown(); diff --git a/tests/Bridge/Symfony/DependencyInjection/DynamicServicesConfigurationTest.php b/tests/Bridge/Symfony/DependencyInjection/DynamicServicesConfigurationTest.php index 2cf4df109..aede71756 100644 --- a/tests/Bridge/Symfony/DependencyInjection/DynamicServicesConfigurationTest.php +++ b/tests/Bridge/Symfony/DependencyInjection/DynamicServicesConfigurationTest.php @@ -27,6 +27,7 @@ * @coversNothing * * @group integration + * @internal */ class DynamicServicesConfigurationTest extends TestCase { @@ -34,7 +35,7 @@ class DynamicServicesConfigurationTest extends TestCase * @var AppKernel */ private $kernel; - + protected function setUp(): void { $this->kernel = KernelFactory::createKernel( @@ -42,7 +43,7 @@ protected function setUp(): void ); $this->kernel->boot(); } - + protected function tearDown(): void { if (null !== $this->kernel) { @@ -55,11 +56,11 @@ public function testResolverUsesTheLimitIsDefinedInTheConfiguration(): void /** @var RecursiveParameterResolver $resolver */ $resolver = $this->kernel->getContainer()->get('nelmio_alice.generator.resolver.parameter.chainable.recursive_parameter_resolver'); - static::assertInstanceOf(RecursiveParameterResolver::class, $resolver); + self::assertInstanceOf(RecursiveParameterResolver::class, $resolver); $limitRefl = (new ReflectionClass(RecursiveParameterResolver::class))->getProperty('limit'); $limitRefl->setAccessible(true); - static::assertEquals(50, $limitRefl->getValue($resolver)); + self::assertEquals(50, $limitRefl->getValue($resolver)); } public function testUniqueValueResolverUsesTheLimitIsDefinedInTheConfiguration(): void @@ -67,11 +68,11 @@ public function testUniqueValueResolverUsesTheLimitIsDefinedInTheConfiguration() /** @var UniqueValueResolver $resolver */ $resolver = $this->kernel->getContainer()->get('nelmio_alice.generator.resolver.value.chainable.unique_value_resolver'); - static::assertInstanceOf(UniqueValueResolver::class, $resolver); + self::assertInstanceOf(UniqueValueResolver::class, $resolver); $limitRefl = (new ReflectionClass(UniqueValueResolver::class))->getProperty('limit'); $limitRefl->setAccessible(true); - static::assertEquals(15, $limitRefl->getValue($resolver)); + self::assertEquals(15, $limitRefl->getValue($resolver)); } public function testUniqueValueResolverUsesTheSeedAndLocaleIsDefinedInTheConfiguration(): void @@ -79,7 +80,7 @@ public function testUniqueValueResolverUsesTheSeedAndLocaleIsDefinedInTheConfigu /** @var FakerGenerator $generator */ $generator = $this->kernel->getContainer()->get('nelmio_alice.faker.generator'); - static::assertInstanceOf(FakerGenerator::class, $generator); + self::assertInstanceOf(FakerGenerator::class, $generator); $this->assertGeneratorLocaleIs('fr_FR', $generator); $this->assertHasAliceProvider($generator); } @@ -89,7 +90,7 @@ private function assertGeneratorLocaleIs(string $locale, FakerGenerator $generat $providers = $generator->getProviders(); $regex = sprintf('/^Faker\\\Provider\\\%s\\\.*/', $locale); foreach ($providers as $provider) { - if (preg_match($regex, get_class($provider))) { + if (preg_match($regex, $provider::class)) { return; } } diff --git a/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php b/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php index dcd20cd45..c323508ff 100644 --- a/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php +++ b/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php @@ -20,6 +20,7 @@ * @group integration * * @coversNothing + * @internal */ class LexerIntegrationTest extends CoreLexerIntegrationTest { diff --git a/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php b/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php index e015d597f..4e9b5c85e 100644 --- a/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php +++ b/tests/Bridge/Symfony/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php @@ -20,6 +20,7 @@ * @group integration * * @coversNothing + * @internal */ class ParserIntegrationTest extends CoreParserIntegrationTest { diff --git a/tests/Bridge/Symfony/Generator/Resolver/ParameterResolverIntegrationTest.php b/tests/Bridge/Symfony/Generator/Resolver/ParameterResolverIntegrationTest.php index 5a363fbeb..77e66cbf0 100644 --- a/tests/Bridge/Symfony/Generator/Resolver/ParameterResolverIntegrationTest.php +++ b/tests/Bridge/Symfony/Generator/Resolver/ParameterResolverIntegrationTest.php @@ -19,6 +19,7 @@ * @group integration * * @coversNothing + * @internal */ class ParameterResolverIntegrationTest extends \Nelmio\Alice\Generator\Resolver\ParameterResolverIntegrationTest { diff --git a/tests/Bridge/Symfony/Loader/LoaderIntegrationTest.php b/tests/Bridge/Symfony/Loader/LoaderIntegrationTest.php index 3ba0e1a83..13b785eb3 100644 --- a/tests/Bridge/Symfony/Loader/LoaderIntegrationTest.php +++ b/tests/Bridge/Symfony/Loader/LoaderIntegrationTest.php @@ -22,6 +22,7 @@ * @group integration * * @coversNothing + * @internal */ class LoaderIntegrationTest extends CoreLoaderIntegrationTest { @@ -29,26 +30,26 @@ class LoaderIntegrationTest extends CoreLoaderIntegrationTest * @var KernelInterface */ private static $kernel; - + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); static::$kernel = KernelFactory::createKernel(); } - + protected function setUp(): void { static::$kernel->boot(); $this->nonIsolatedLoader = $this->loader = new NonIsolatedSymfonyLoader(static::$kernel->getContainer()); } - + protected function tearDown(): void { static::$kernel->shutdown(); } - + public static function tearDownAfterClass(): void { static::$kernel = null; diff --git a/tests/DeepCloneTest.php b/tests/DeepCloneTest.php index 6a2c4b34f..bd277a860 100644 --- a/tests/DeepCloneTest.php +++ b/tests/DeepCloneTest.php @@ -20,17 +20,19 @@ /** * @covers ::\Nelmio\Alice\deep_clone + * @internal */ class DeepCloneTest extends TestCase { /** * @dataProvider provideScalarValues + * @param mixed $value */ public function testDeepCloneScalarsReturnsScalar($value): void { $clone = deep_clone($value); - static::assertEquals($value, $clone); + self::assertEquals($value, $clone); } public function testDeepCloneObjects(): void @@ -87,9 +89,7 @@ public function testDeepCloneClosure(): void $foo = new stdClass(); $bar = new stdClass(); - $c1 = static function () use ($foo) { - return $foo; - }; + $c1 = static fn () => $foo; $foo->name = 'foo'; $foo->bar = $bar; @@ -99,11 +99,11 @@ public function testDeepCloneClosure(): void $fooClone = deep_clone($c1)(); - static::assertSame($foo, $fooClone); - static::assertSame($bar, $fooClone->bar); + self::assertSame($foo, $fooClone); + self::assertSame($bar, $fooClone->bar); } - public function provideScalarValues() + public function provideScalarValues(): iterable { return [ [null], @@ -122,7 +122,7 @@ public function provideScalarValues() private function assertEqualsButNotSame($expected, $value): void { - static::assertEquals($expected, $value); - static::assertNotSame($expected, $value); + self::assertEquals($expected, $value); + self::assertNotSame($expected, $value); } } diff --git a/tests/Definition/Fixture/FixtureIdTest.php b/tests/Definition/Fixture/FixtureIdTest.php index 85c19432a..bd81c5876 100644 --- a/tests/Definition/Fixture/FixtureIdTest.php +++ b/tests/Definition/Fixture/FixtureIdTest.php @@ -18,17 +18,18 @@ /** * @covers \Nelmio\Alice\Definition\Fixture\FixtureId + * @internal */ class FixtureIdTest extends TestCase { public function testIsAFixtureId(): void { - static::assertTrue(is_a(FixtureId::class, FixtureIdInterface::class, true)); + self::assertTrue(is_a(FixtureId::class, FixtureIdInterface::class, true)); } public function testAccessor(): void { $id = new FixtureId('foo'); - static::assertEquals('foo', $id->getId()); + self::assertEquals('foo', $id->getId()); } } diff --git a/tests/Definition/Fixture/SimpleFixtureTest.php b/tests/Definition/Fixture/SimpleFixtureTest.php index 17df080a2..89e01c6c5 100644 --- a/tests/Definition/Fixture/SimpleFixtureTest.php +++ b/tests/Definition/Fixture/SimpleFixtureTest.php @@ -22,19 +22,20 @@ /** * @covers \Nelmio\Alice\Definition\Fixture\SimpleFixture + * @internal */ class SimpleFixtureTest extends TestCase { public function testIsAFixtureId(): void { - static::assertTrue(is_a(SimpleFixture::class, FixtureIdInterface::class, true)); + self::assertTrue(is_a(SimpleFixture::class, FixtureIdInterface::class, true)); } public function testIsAFixture(): void { - static::assertTrue(is_a(SimpleFixture::class, FixtureInterface::class, true)); + self::assertTrue(is_a(SimpleFixture::class, FixtureInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $reference = 'user0'; @@ -43,26 +44,26 @@ public function testReadAccessorsReturnPropertiesValues(): void $fixture = new SimpleFixture($reference, $className, $specs); - static::assertEquals($reference, $fixture->getId()); - static::assertEquals($className, $fixture->getClassName()); - static::assertEquals($specs, $fixture->getSpecs()); + self::assertEquals($reference, $fixture->getId()); + self::assertEquals($className, $fixture->getClassName()); + self::assertEquals($specs, $fixture->getSpecs()); try { $fixture->getValueForCurrent(); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (NoValueForCurrentException $exception) { - static::assertEquals( + self::assertEquals( 'No value for \'\' found for the fixture "user0".', - $exception->getMessage() + $exception->getMessage(), ); } $fixture = new SimpleFixture($reference, $className, $specs, 'alice'); - static::assertEquals($reference, $fixture->getId()); - static::assertEquals($className, $fixture->getClassName()); - static::assertEquals($specs, $fixture->getSpecs()); - static::assertEquals('alice', $fixture->getValueForCurrent()); + self::assertEquals($reference, $fixture->getId()); + self::assertEquals($className, $fixture->getClassName()); + self::assertEquals($specs, $fixture->getSpecs()); + self::assertEquals('alice', $fixture->getValueForCurrent()); } public function testWithersReturnNewModifiedInstance(): void @@ -75,10 +76,10 @@ public function testWithersReturnNewModifiedInstance(): void $fixture = new SimpleFixture($reference, $className, $specs); $newFixture = $fixture->withSpecs($newSpecs); - static::assertInstanceOf(SimpleFixture::class, $newFixture); - static::assertNotSame($fixture, $newFixture); + self::assertInstanceOf(SimpleFixture::class, $newFixture); + self::assertNotSame($fixture, $newFixture); - static::assertEquals($specs, $fixture->getSpecs()); - static::assertEquals($newSpecs, $newFixture->getSpecs()); + self::assertEquals($specs, $fixture->getSpecs()); + self::assertEquals($newSpecs, $newFixture->getSpecs()); } } diff --git a/tests/Definition/Fixture/SimpleFixtureWithFlagsTest.php b/tests/Definition/Fixture/SimpleFixtureWithFlagsTest.php index 3892e8bd3..4ca30bd81 100644 --- a/tests/Definition/Fixture/SimpleFixtureWithFlagsTest.php +++ b/tests/Definition/Fixture/SimpleFixtureWithFlagsTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\Definition\Fixture\SimpleFixtureWithFlags + * @internal */ class SimpleFixtureWithFlagsTest extends TestCase { @@ -31,7 +32,7 @@ class SimpleFixtureWithFlagsTest extends TestCase public function testIsAFixtureWithFlags(): void { - static::assertTrue(is_a(SimpleFixtureWithFlags::class, FixtureWithFlagsInterface::class, true)); + self::assertTrue(is_a(SimpleFixtureWithFlags::class, FixtureWithFlagsInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -53,11 +54,11 @@ public function testReadAccessorsReturnPropertiesValues(): void $fixture = new SimpleFixtureWithFlags($decoratedFixture, $flags); - static::assertEquals($reference, $fixture->getId()); - static::assertEquals($className, $fixture->getClassName()); - static::assertEquals($specs, $fixture->getSpecs()); - static::assertEquals($valueForCurrent, $fixture->getValueForCurrent()); - static::assertEquals($flags, $fixture->getFlags()); + self::assertEquals($reference, $fixture->getId()); + self::assertEquals($className, $fixture->getClassName()); + self::assertEquals($specs, $fixture->getSpecs()); + self::assertEquals($valueForCurrent, $fixture->getValueForCurrent()); + self::assertEquals($flags, $fixture->getFlags()); $decoratedFixtureProphecy->getId()->shouldHaveBeenCalledTimes(2); $decoratedFixtureProphecy->getClassName()->shouldHaveBeenCalledTimes(1); @@ -88,13 +89,13 @@ public function testWithersReturnNewModifiedInstance(): void $fixture = new SimpleFixtureWithFlags($decoratedFixture, $flags); $newFixture = $fixture->withSpecs($newSpecs); - static::assertInstanceOf(SimpleFixtureWithFlags::class, $newFixture); - static::assertNotSame($fixture, $newFixture); + self::assertInstanceOf(SimpleFixtureWithFlags::class, $newFixture); + self::assertNotSame($fixture, $newFixture); - static::assertEquals($specs, $fixture->getSpecs()); - static::assertEquals($flags, $fixture->getFlags()); - static::assertEquals($newSpecs, $newFixture->getSpecs()); - static::assertEquals($flags, $newFixture->getFlags()); + self::assertEquals($specs, $fixture->getSpecs()); + self::assertEquals($flags, $fixture->getFlags()); + self::assertEquals($newSpecs, $newFixture->getSpecs()); + self::assertEquals($flags, $newFixture->getFlags()); } public function testThrowsAnExceptionIfFixtureIdAndFlagKeyMistmatch(): void diff --git a/tests/Definition/Fixture/TemplatingFixtureTest.php b/tests/Definition/Fixture/TemplatingFixtureTest.php index 0174486a0..b82daa504 100644 --- a/tests/Definition/Fixture/TemplatingFixtureTest.php +++ b/tests/Definition/Fixture/TemplatingFixtureTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\Definition\Fixture\TemplatingFixture + * @internal */ class TemplatingFixtureTest extends TestCase { @@ -32,9 +33,9 @@ class TemplatingFixtureTest extends TestCase public function testIsAFixture(): void { - static::assertTrue(is_a(TemplatingFixture::class, FixtureInterface::class, true)); + self::assertTrue(is_a(TemplatingFixture::class, FixtureInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $reference = 'user0'; @@ -56,20 +57,19 @@ public function testReadAccessorsReturnPropertiesValues(): void $flags = (new FlagBag($reference)) ->withFlag($flag1) - ->withFlag($flag2) - ; + ->withFlag($flag2); $fixtureWithFlags = new SimpleFixtureWithFlags($decoratedFixture, $flags); $fixture = new TemplatingFixture($fixtureWithFlags); - static::assertEquals($reference, $fixture->getId()); - static::assertEquals($className, $fixture->getClassName()); - static::assertEquals($specs, $fixture->getSpecs()); - static::assertEquals($valueForCurrent, $fixture->getValueForCurrent()); - static::assertTrue($fixture->isATemplate()); - static::assertTrue($fixture->extendsFixtures()); - static::assertEquals([new FixtureReference('user_base')], $fixture->getExtendedFixturesReferences()); - static::assertEquals($flags, $fixture->getFlags()); + self::assertEquals($reference, $fixture->getId()); + self::assertEquals($className, $fixture->getClassName()); + self::assertEquals($specs, $fixture->getSpecs()); + self::assertEquals($valueForCurrent, $fixture->getValueForCurrent()); + self::assertTrue($fixture->isATemplate()); + self::assertTrue($fixture->extendsFixtures()); + self::assertEquals([new FixtureReference('user_base')], $fixture->getExtendedFixturesReferences()); + self::assertEquals($flags, $fixture->getFlags()); $decoratedFixtureProphecy->getId()->shouldHaveBeenCalledTimes(2); $decoratedFixtureProphecy->getClassName()->shouldHaveBeenCalledTimes(1); @@ -101,10 +101,10 @@ public function testWithersReturnNewModifiedInstance(): void $fixture = new TemplatingFixture($fixtureWithFlags); $newFixture = $fixture->withSpecs($newSpecs); - static::assertInstanceOf(TemplatingFixture::class, $newFixture); - static::assertNotSame($fixture, $newFixture); + self::assertInstanceOf(TemplatingFixture::class, $newFixture); + self::assertNotSame($fixture, $newFixture); - static::assertEquals($specs, $fixture->getSpecs()); - static::assertEquals($newSpecs, $newFixture->getSpecs()); + self::assertEquals($specs, $fixture->getSpecs()); + self::assertEquals($newSpecs, $newFixture->getSpecs()); } } diff --git a/tests/Definition/Fixture/TemplatingTest.php b/tests/Definition/Fixture/TemplatingTest.php index 9c4196e1e..3e1a96373 100644 --- a/tests/Definition/Fixture/TemplatingTest.php +++ b/tests/Definition/Fixture/TemplatingTest.php @@ -23,15 +23,16 @@ /** * @covers \Nelmio\Alice\Definition\Fixture\Templating + * @internal */ class TemplatingTest extends TestCase { /** - * @depends \Nelmio\Alice\Definition\ServiceReference\FixtureReferenceTest::testIsImmutable + * @depends test\Nelmio\Alice\Definition\ServiceReference\FixtureReferenceTest::testIsImmutable */ public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } /** @@ -41,10 +42,10 @@ public function testDetectTemplateFlags(SimpleFixtureWithFlags $fixture, bool $i { $templating = new Templating($fixture); - static::assertEquals($isATemplate, $templating->isATemplate()); - static::assertEquals($extendsFixtures, $templating->extendsFixtures()); - static::assertEquals($extendedFixtures, $templating->getExtendedFixtures()); - static::assertCount(count($extendedFixtures), $templating->getExtendedFixtures()); + self::assertEquals($isATemplate, $templating->isATemplate()); + self::assertEquals($extendsFixtures, $templating->extendsFixtures()); + self::assertEquals($extendedFixtures, $templating->getExtendedFixtures()); + self::assertCount(count($extendedFixtures), $templating->getExtendedFixtures()); } /** @@ -58,8 +59,8 @@ public function testExtendedFixturesOrderIsInversed(): void $this->createFixtureWithFlags( (new FlagBag('')) ->withFlag(new ExtendFlag(new FixtureReference('user_base0'))) - ->withFlag(new ExtendFlag(new FixtureReference('user_base1'))) - ) + ->withFlag(new ExtendFlag(new FixtureReference('user_base1'))), + ), ); $expected = [ @@ -68,13 +69,13 @@ public function testExtendedFixturesOrderIsInversed(): void ]; $actual = $templating->getExtendedFixtures(); - static::assertCount(count($expected), $actual); + self::assertCount(count($expected), $actual); foreach ($expected as $index => $expectedReference) { - static::assertEquals($expectedReference, $actual[$index]); + self::assertEquals($expectedReference, $actual[$index]); } } - public function provideFlags() + public function provideFlags(): iterable { $emptyFlagBag = new FlagBag('user0'); yield 'empty flagbag' => [ @@ -102,8 +103,7 @@ public function provideFlags() $extendsFlagBag = $emptyFlagBag ->withFlag(new ExtendFlag(new FixtureReference('user_base0'))) - ->withFlag(new ExtendFlag(new FixtureReference('user_base1'))) - ; + ->withFlag(new ExtendFlag(new FixtureReference('user_base1'))); yield 'flagbag with extends' => [ $this->createFixtureWithFlags($extendsFlagBag), false, @@ -118,8 +118,7 @@ public function provideFlags() ->withFlag(new TemplateFlag()) ->withFlag(new ExtendFlag(new FixtureReference('user_base0'))) ->withFlag(new ExtendFlag(new FixtureReference('user_base1'))) - ->withFlag(new DummyFlag()) - ; + ->withFlag(new DummyFlag()); yield 'flagbag with template, extends and non templating flags' => [ $this->createFixtureWithFlags($templateAndExtendsFlagBag), true, @@ -137,9 +136,9 @@ private function createFixtureWithFlags(FlagBag $flags): SimpleFixtureWithFlags new SimpleFixture( $flags->getKey(), 'Dummy', - SpecificationBagFactory::create() + SpecificationBagFactory::create(), ), - $flags + $flags, ); } } diff --git a/tests/Definition/Flag/ConfiguratorFlagTest.php b/tests/Definition/Flag/ConfiguratorFlagTest.php index 351fe0ce6..8c6c38c48 100644 --- a/tests/Definition/Flag/ConfiguratorFlagTest.php +++ b/tests/Definition/Flag/ConfiguratorFlagTest.php @@ -18,18 +18,19 @@ /** * @covers \Nelmio\Alice\Definition\Flag\ConfiguratorFlag + * @internal */ class ConfiguratorFlagTest extends TestCase { public function testIsAFlag(): void { - static::assertTrue(is_a(ConfiguratorFlag::class, FlagInterface::class, true)); + self::assertTrue(is_a(ConfiguratorFlag::class, FlagInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void { $flag = new ConfiguratorFlag(); - static::assertEquals('configurator', $flag->__toString()); + self::assertEquals('configurator', $flag->__toString()); } } diff --git a/tests/Definition/Flag/ExtendFlagTest.php b/tests/Definition/Flag/ExtendFlagTest.php index 6b432d9f5..e85c49a28 100644 --- a/tests/Definition/Flag/ExtendFlagTest.php +++ b/tests/Definition/Flag/ExtendFlagTest.php @@ -19,12 +19,13 @@ /** * @covers \Nelmio\Alice\Definition\Flag\ExtendFlag + * @internal */ class ExtendFlagTest extends TestCase { public function testIsAFlag(): void { - static::assertTrue(is_a(ExtendFlag::class, FlagInterface::class, true)); + self::assertTrue(is_a(ExtendFlag::class, FlagInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -32,7 +33,7 @@ public function testReadAccessorsReturnPropertiesValues(): void $reference = new FixtureReference('Nelmio\Alice\EntityUser#user_base'); $flag = new ExtendFlag($reference); - static::assertEquals($reference, $flag->getExtendedFixture()); - static::assertEquals('extends Nelmio\Alice\EntityUser#user_base', $flag->__toString()); + self::assertEquals($reference, $flag->getExtendedFixture()); + self::assertEquals('extends Nelmio\Alice\EntityUser#user_base', $flag->__toString()); } } diff --git a/tests/Definition/Flag/OptionalFlagTest.php b/tests/Definition/Flag/OptionalFlagTest.php index 47ef34ec5..0f908effa 100644 --- a/tests/Definition/Flag/OptionalFlagTest.php +++ b/tests/Definition/Flag/OptionalFlagTest.php @@ -19,42 +19,43 @@ /** * @covers \Nelmio\Alice\Definition\Flag\OptionalFlag + * @internal */ class OptionalFlagTest extends TestCase { public function testIsAFlag(): void { - static::assertTrue(is_a(OptionalFlag::class, FlagInterface::class, true)); + self::assertTrue(is_a(OptionalFlag::class, FlagInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void { $flag = new OptionalFlag(50); - static::assertEquals(50, $flag->getPercentage()); - static::assertEquals('%?', $flag->__toString()); + self::assertEquals(50, $flag->getPercentage()); + self::assertEquals('%?', $flag->__toString()); } /** * @dataProvider providePercentageValues */ - public function testThrowsExceptionIfPercentageValueIsInvalid(int $percentage, string $expectedMessage = null): void + public function testThrowsExceptionIfPercentageValueIsInvalid(int $percentage, ?string $expectedMessage = null): void { try { new OptionalFlag($percentage); if (null !== $expectedMessage) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } } catch (InvalidArgumentException $exception) { if (null === $expectedMessage) { - static::fail('Was not expecting exception to be thrown.'); + self::fail('Was not expecting exception to be thrown.'); } - static::assertEquals($expectedMessage, $exception->getMessage()); + self::assertEquals($expectedMessage, $exception->getMessage()); } } - public function providePercentageValues() + public function providePercentageValues(): iterable { yield 'negative value' => [ -1, diff --git a/tests/Definition/Flag/TemplateFlagTest.php b/tests/Definition/Flag/TemplateFlagTest.php index de877b0c1..1b4373b72 100644 --- a/tests/Definition/Flag/TemplateFlagTest.php +++ b/tests/Definition/Flag/TemplateFlagTest.php @@ -18,17 +18,18 @@ /** * @covers \Nelmio\Alice\Definition\Flag\TemplateFlag + * @internal */ class TemplateFlagTest extends TestCase { public function testIsAFlag(): void { - static::assertTrue(is_a(TemplateFlag::class, FlagInterface::class, true)); + self::assertTrue(is_a(TemplateFlag::class, FlagInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void { $flag = new TemplateFlag(); - static::assertEquals('template', $flag->__toString()); + self::assertEquals('template', $flag->__toString()); } } diff --git a/tests/Definition/Flag/UniqueFlagTest.php b/tests/Definition/Flag/UniqueFlagTest.php index d6610700e..8848287d4 100644 --- a/tests/Definition/Flag/UniqueFlagTest.php +++ b/tests/Definition/Flag/UniqueFlagTest.php @@ -18,18 +18,19 @@ /** * @covers \Nelmio\Alice\Definition\Flag\UniqueFlag + * @internal */ class UniqueFlagTest extends TestCase { public function testIsAFlag(): void { - static::assertTrue(is_a(UniqueFlag::class, FlagInterface::class, true)); + self::assertTrue(is_a(UniqueFlag::class, FlagInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void { $flag = new UniqueFlag(); - static::assertEquals('unique', $flag->__toString()); + self::assertEquals('unique', $flag->__toString()); } } diff --git a/tests/Definition/FlagBagTest.php b/tests/Definition/FlagBagTest.php index 49d2be6a0..037705bb0 100644 --- a/tests/Definition/FlagBagTest.php +++ b/tests/Definition/FlagBagTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\Definition\FlagBag + * @internal */ class FlagBagTest extends TestCase { @@ -35,7 +36,7 @@ public function testReadAccessorsReturnPropertiesValues(): void { $bag = new FlagBag('user0'); - static::assertEquals('user0', $bag->getKey()); + self::assertEquals('user0', $bag->getKey()); } public function testIsImmutable(): void @@ -43,12 +44,12 @@ public function testIsImmutable(): void $bag = (new FlagBag(''))->withFlag($flag = new MutableFlag('foo', new stdClass())); $flag->getObject()->foo = 'bar'; - static::assertEquals( + self::assertEquals( (new FlagBag(''))->withFlag($flag = new MutableFlag('foo', new stdClass())), - $bag + $bag, ); - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } public function testAddingAFlagCreatesANewModifiedInstance(): void @@ -57,12 +58,11 @@ public function testAddingAFlagCreatesANewModifiedInstance(): void $bag1 = new FlagBag('user0'); $bag2 = $bag1->withFlag($flag); - static::assertInstanceOf(FlagBag::class, $bag1); - static::assertNotSame($bag1, $bag2); - - static::assertCount(0, $bag1); - static::assertCount(1, $bag2); + self::assertInstanceOf(FlagBag::class, $bag1); + self::assertNotSame($bag1, $bag2); + self::assertCount(0, $bag1); + self::assertCount(1, $bag2); // Mutate injected value $flag->setStringValue('flag1'); @@ -75,9 +75,9 @@ public function testAddingAFlagCreatesANewModifiedInstance(): void $flag->getObject()->foo = 'bar'; } - static::assertEquals( + self::assertEquals( (new FlagBag('user0'))->withFlag(new MutableFlag('flag0', new stdClass())), - $bag2 + $bag2, ); } @@ -87,25 +87,24 @@ public function testCanCreateANewFlagBagWithADifferentKey(): void ->withFlag( new MutableFlag( 'flag0', - new stdClass() - ) - ) - ; + new stdClass(), + ), + ); $bag2 = $bag1->withKey('user2'); - static::assertInstanceOf(FlagBag::class, $bag1); - static::assertNotSame($bag1, $bag2); + self::assertInstanceOf(FlagBag::class, $bag1); + self::assertNotSame($bag1, $bag2); - static::assertCount(1, $bag1); - static::assertCount(1, $bag2); + self::assertCount(1, $bag1); + self::assertCount(1, $bag2); - static::assertEquals( + self::assertEquals( (new FlagBag('user0'))->withFlag(new MutableFlag('flag0', new stdClass())), - $bag1 + $bag1, ); - static::assertEquals( + self::assertEquals( (new FlagBag('user2'))->withFlag(new MutableFlag('flag0', new stdClass())), - $bag2 + $bag2, ); } @@ -115,21 +114,21 @@ public function testMergingTwoBagsCreatesANewModifiedInstance(): void $bag2 = (new FlagBag('bag2'))->withFlag($flag2 = new MutableFlag('flag2', new stdClass())); $mergedBag = $bag1->mergeWith($bag2); - static::assertInstanceOf(FlagBag::class, $mergedBag); + self::assertInstanceOf(FlagBag::class, $mergedBag); - static::assertEquals( + self::assertEquals( (new FlagBag('bag1'))->withFlag($flag1), - $bag1 + $bag1, ); - static::assertEquals( + self::assertEquals( (new FlagBag('bag2'))->withFlag(new MutableFlag('flag2', new stdClass())), - $bag2 + $bag2, ); - static::assertEquals( + self::assertEquals( (new FlagBag('bag1')) ->withFlag(new MutableFlag('flag1', new stdClass())) ->withFlag(new MutableFlag('flag2', new stdClass())), - $mergedBag + $mergedBag, ); } @@ -137,69 +136,67 @@ public function testCanMergeTwoBagsWithoutOverridingExistingValues(): void { $firstBag = (new FlagBag('first')) ->withFlag(new ElementWithToStringFlag('first_foo', 'foo')) - ->withFlag(new ElementFlag('foz')) - ; + ->withFlag(new ElementFlag('foz')); $secondBag = (new FlagBag('second')) ->withFlag(new ElementWithToStringFlag('second_foo', 'foo')) - ->withFlag(new ElementFlag('baz')) - ; + ->withFlag(new ElementFlag('baz')); $mergeFirstWithSecondWithOverriding = $firstBag->mergeWith($secondBag); $mergeFirstWithSecondWithoutOverriding = $firstBag->mergeWith($secondBag, false); $mergeSecondWithFirstWithOverriding = $secondBag->mergeWith($firstBag); $mergeSecondWithFirstWithoutOverriding = $secondBag->mergeWith($firstBag, false); - static::assertEquals( + self::assertEquals( (new FlagBag('first')) ->withFlag(new ElementWithToStringFlag('first_foo', 'foo')) ->withFlag(new ElementFlag('foz')), - $firstBag + $firstBag, ); - static::assertEquals( + self::assertEquals( (new FlagBag('second')) ->withFlag(new ElementWithToStringFlag('second_foo', 'foo')) ->withFlag(new ElementFlag('baz')), - $secondBag + $secondBag, ); - static::assertEquals( + self::assertEquals( (new FlagBag('first')) ->withFlag(new ElementWithToStringFlag('second_foo', 'foo')) ->withFlag(new ElementFlag('foz')) ->withFlag(new ElementFlag('baz')), - $mergeFirstWithSecondWithOverriding + $mergeFirstWithSecondWithOverriding, ); - static::assertEquals( + self::assertEquals( (new FlagBag('first')) ->withFlag(new ElementWithToStringFlag('first_foo', 'foo')) ->withFlag(new ElementFlag('foz')) ->withFlag(new ElementFlag('baz')), - $mergeFirstWithSecondWithoutOverriding + $mergeFirstWithSecondWithoutOverriding, ); - static::assertEquals( + self::assertEquals( (new FlagBag('second')) ->withFlag(new ElementFlag('baz')) ->withFlag(new ElementWithToStringFlag('first_foo', 'foo')) ->withFlag(new ElementFlag('foz')), - $mergeSecondWithFirstWithOverriding + $mergeSecondWithFirstWithOverriding, ); - static::assertEquals( + self::assertEquals( (new FlagBag('second')) ->withFlag(new ElementFlag('baz')) ->withFlag(new ElementWithToStringFlag('second_foo', 'foo')) ->withFlag(new ElementFlag('foz')), - $mergeSecondWithFirstWithoutOverriding + $mergeSecondWithFirstWithoutOverriding, ); } public function testIsCountable(): void { $flags = new FlagBag('user0'); - static::assertCount(0, $flags); + self::assertCount(0, $flags); $flags = $flags->withFlag(new DummyFlag()); - static::assertCount(1, $flags); + self::assertCount(1, $flags); } public function testDoesNotDuplicateFlags(): void @@ -208,10 +205,9 @@ public function testDoesNotDuplicateFlags(): void ->withFlag(new DummyFlag()) ->withFlag(new DummyFlag()) ->withFlag(new AnotherDummyFlag()) - ->withFlag(new AnotherDummyFlag()) - ; + ->withFlag(new AnotherDummyFlag()); - static::assertCount(2, $flags); + self::assertCount(2, $flags); } public function testIsIterable(): void @@ -221,15 +217,14 @@ public function testIsIterable(): void $flags = (new FlagBag('user0')) ->withFlag($flag1) - ->withFlag($flag2) - ; + ->withFlag($flag2); $this->assertSameFlags( [ $flag1, $flag2, ], - $flags + $flags, ); } @@ -240,15 +235,14 @@ public function testCanAccumulateExtendFlags(): void $flags = (new FlagBag('user0')) ->withFlag($extendFlag1) - ->withFlag($extendFlag2) - ; + ->withFlag($extendFlag2); $this->assertSameFlags( [ $extendFlag1, $extendFlag2, ], - $flags + $flags, ); } @@ -259,14 +253,13 @@ public function testCannotAccumulateOptionalFlags(): void $flags = (new FlagBag('user0')) ->withFlag($optionalFlag1) - ->withFlag($optionalFlag2) - ; + ->withFlag($optionalFlag2); $this->assertSameFlags( [ $optionalFlag2, ], - $flags + $flags, ); } @@ -277,14 +270,13 @@ public function testCannotAccumulateTemplateFlags(): void $flags = (new FlagBag('user0')) ->withFlag($templateFlag1) - ->withFlag($templateFlag2) - ; + ->withFlag($templateFlag2); $this->assertSameFlags( [ $templateFlag2, ], - $flags + $flags, ); } @@ -295,14 +287,13 @@ public function testCannotAccumulateUniqueFlags(): void $flags = (new FlagBag('user0')) ->withFlag($uniqueFlag1) - ->withFlag($uniqueFlag2) - ; + ->withFlag($uniqueFlag2); $this->assertSameFlags( [ $uniqueFlag2, ], - $flags + $flags, ); } @@ -313,6 +304,6 @@ private function assertSameFlags(array $expected, FlagBag $actual): void $flags[$key] = $value; } - static::assertEquals($expected, $flags); + self::assertEquals($expected, $flags); } } diff --git a/tests/Definition/MethodCall/ConfiguratorMethodCallTest.php b/tests/Definition/MethodCall/ConfiguratorMethodCallTest.php index be17f401a..c5a400132 100644 --- a/tests/Definition/MethodCall/ConfiguratorMethodCallTest.php +++ b/tests/Definition/MethodCall/ConfiguratorMethodCallTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\Definition\MethodCall\ConfiguratorMethodCall + * @internal */ class ConfiguratorMethodCallTest extends TestCase { @@ -30,9 +31,9 @@ class ConfiguratorMethodCallTest extends TestCase public function testIsAMethodCall(): void { - static::assertTrue(is_a(ConfiguratorMethodCall::class, MethodCallInterface::class, true)); + self::assertTrue(is_a(ConfiguratorMethodCall::class, MethodCallInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $caller = new InstantiatedReference('user.factory'); @@ -51,11 +52,11 @@ public function testReadAccessorsReturnPropertiesValues(): void $definition = new ConfiguratorMethodCall($methodCall); - static::assertEquals($caller, $definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); - static::assertEquals($stringValue, $definition->__toString()); - static::assertSame($methodCall, $definition->getOriginalMethodCall()); + self::assertEquals($caller, $definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); + self::assertEquals($stringValue, $definition->__toString()); + self::assertSame($methodCall, $definition->getOriginalMethodCall()); $methodCallProphecy->getCaller()->shouldHaveBeenCalledTimes(1); $methodCallProphecy->getMethod()->shouldHaveBeenCalledTimes(1); @@ -69,7 +70,7 @@ public function testIsMutable(): void 'mutate', [ $arg0 = new stdClass(), - ] + ], ); $definition = new ConfiguratorMethodCall($caller); @@ -84,16 +85,16 @@ public function testIsMutable(): void // @phpstan-ignore-next-line $definition->getArguments()[0]->foz = 'baz'; - static::assertEquals('mutated', $definition->getCaller()->getId()); - static::assertEquals('dummy', $definition->getMethod()); - static::assertEquals( + self::assertEquals('mutated', $definition->getCaller()->getId()); + self::assertEquals('dummy', $definition->getMethod()); + self::assertEquals( [ StdClassFactory::create([ 'foo' => 'bar', 'foz' => 'baz', ]), ], - $definition->getArguments() + $definition->getArguments(), ); } @@ -108,12 +109,12 @@ public function testCanCreateANewInstanceWithArguments(): void ]; $newDefinition = $definition->withArguments($newArguments); - static::assertInstanceOf(ConfiguratorMethodCall::class, $newDefinition); + self::assertInstanceOf(ConfiguratorMethodCall::class, $newDefinition); - static::assertEquals( + self::assertEquals( new SimpleMethodCall('getUsername', $newArguments), - $definition->getOriginalMethodCall() + $definition->getOriginalMethodCall(), ); - static::assertSame($newArguments, $newDefinition->getArguments()); + self::assertSame($newArguments, $newDefinition->getArguments()); } } diff --git a/tests/Definition/MethodCall/MethodCallWithReferenceTest.php b/tests/Definition/MethodCall/MethodCallWithReferenceTest.php index 84b13444b..f3e127677 100644 --- a/tests/Definition/MethodCall/MethodCallWithReferenceTest.php +++ b/tests/Definition/MethodCall/MethodCallWithReferenceTest.php @@ -23,14 +23,15 @@ /** * @covers \Nelmio\Alice\Definition\MethodCall\MethodCallWithReference + * @internal */ class MethodCallWithReferenceTest extends TestCase { public function testIsAMethodCall(): void { - static::assertTrue(is_a(MethodCallWithReference::class, MethodCallInterface::class, true)); + self::assertTrue(is_a(MethodCallWithReference::class, MethodCallInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $caller = new InstantiatedReference('user.factory'); @@ -39,25 +40,25 @@ public function testReadAccessorsReturnPropertiesValues(): void $definition = new MethodCallWithReference($caller, $method, $arguments); - static::assertEquals($caller, $definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); - static::assertEquals('user.factory->setUsername', $definition->__toString()); + self::assertEquals($caller, $definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); + self::assertEquals('user.factory->setUsername', $definition->__toString()); $definition = new MethodCallWithReference($caller, $method, null); - static::assertEquals($caller, $definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertNull($definition->getArguments()); - static::assertEquals('user.factory->setUsername', $definition->__toString()); + self::assertEquals($caller, $definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertNull($definition->getArguments()); + self::assertEquals('user.factory->setUsername', $definition->__toString()); $caller = new StaticReference('Dummy'); $definition = new MethodCallWithReference($caller, $method, null); - static::assertEquals($caller, $definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertNull($definition->getArguments()); - static::assertEquals('Dummy::setUsername', $definition->__toString()); + self::assertEquals($caller, $definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertNull($definition->getArguments()); + self::assertEquals('Dummy::setUsername', $definition->__toString()); } public function testIsMutable(): void @@ -82,15 +83,15 @@ public function testIsMutable(): void // @phpstan-ignore-next-line $arguments[0]->foz = 'baz'; - static::assertEquals(new MutableReference(), $definition->getCaller()); - static::assertEquals( + self::assertEquals(new MutableReference(), $definition->getCaller()); + self::assertEquals( [ StdClassFactory::create([ 'foo' => 'bar', 'foz' => 'baz', ]), ], - $definition->getArguments() + $definition->getArguments(), ); } @@ -104,15 +105,15 @@ public function testCanCreateANewInstanceWithNoArguments(): void $newArguments = null; $newDefinition = $definition->withArguments($newArguments); - static::assertInstanceOf(MethodCallWithReference::class, $newDefinition); + self::assertInstanceOf(MethodCallWithReference::class, $newDefinition); - static::assertEquals($caller, $definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); + self::assertEquals($caller, $definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); - static::assertEquals($caller, $newDefinition->getCaller()); - static::assertEquals($method, $newDefinition->getMethod()); - static::assertEquals($newArguments, $newDefinition->getArguments()); + self::assertEquals($caller, $newDefinition->getCaller()); + self::assertEquals($method, $newDefinition->getMethod()); + self::assertEquals($newArguments, $newDefinition->getArguments()); } public function testCanCreateANewInstanceWithArguments(): void @@ -130,19 +131,19 @@ public function testCanCreateANewInstanceWithArguments(): void // Mutate argument before reading it $arg0->foo = 'bar'; - static::assertInstanceOf(MethodCallWithReference::class, $newDefinition); + self::assertInstanceOf(MethodCallWithReference::class, $newDefinition); - static::assertEquals($caller, $definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); + self::assertEquals($caller, $definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); - static::assertEquals($caller, $newDefinition->getCaller()); - static::assertEquals($method, $newDefinition->getMethod()); - static::assertEquals( + self::assertEquals($caller, $newDefinition->getCaller()); + self::assertEquals($method, $newDefinition->getMethod()); + self::assertEquals( [ StdClassFactory::create(['foo' => 'bar']), ], - $newDefinition->getArguments() + $newDefinition->getArguments(), ); } } diff --git a/tests/Definition/MethodCall/NoMethodCallTest.php b/tests/Definition/MethodCall/NoMethodCallTest.php index 058f35c8f..ef2d2346b 100644 --- a/tests/Definition/MethodCall/NoMethodCallTest.php +++ b/tests/Definition/MethodCall/NoMethodCallTest.php @@ -19,19 +19,20 @@ /** * @covers \Nelmio\Alice\Definition\MethodCall\NoMethodCall + * @internal */ class NoMethodCallTest extends TestCase { public function testIsAMethodCall(): void { - static::assertTrue(is_a(NoMethodCall::class, MethodCallInterface::class, true)); + self::assertTrue(is_a(NoMethodCall::class, MethodCallInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void { $call = new NoMethodCall(); - static::assertEquals('none', $call->__toString()); + self::assertEquals('none', $call->__toString()); } public function testCannotCreateNewInstanceWithNewArguments(): void diff --git a/tests/Definition/MethodCall/OptionalMethodCallTest.php b/tests/Definition/MethodCall/OptionalMethodCallTest.php index 1963aa8e2..830a61afa 100644 --- a/tests/Definition/MethodCall/OptionalMethodCallTest.php +++ b/tests/Definition/MethodCall/OptionalMethodCallTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\Definition\MethodCall\OptionalMethodCall + * @internal */ class OptionalMethodCallTest extends TestCase { @@ -31,9 +32,9 @@ class OptionalMethodCallTest extends TestCase public function testIsAMethodCall(): void { - static::assertTrue(is_a(OptionalMethodCall::class, MethodCallInterface::class, true)); + self::assertTrue(is_a(OptionalMethodCall::class, MethodCallInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $caller = new InstantiatedReference('user.factory'); @@ -54,12 +55,12 @@ public function testReadAccessorsReturnPropertiesValues(): void $definition = new OptionalMethodCall($methodCall, $flag); - static::assertEquals($caller, $definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); - static::assertEquals($percentage, $definition->getPercentage()); - static::assertEquals($stringValue, $definition->__toString()); - static::assertSame($methodCall, $definition->getOriginalMethodCall()); + self::assertEquals($caller, $definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); + self::assertEquals($percentage, $definition->getPercentage()); + self::assertEquals($stringValue, $definition->__toString()); + self::assertSame($methodCall, $definition->getOriginalMethodCall()); $methodCallProphecy->getCaller()->shouldHaveBeenCalledTimes(1); $methodCallProphecy->getMethod()->shouldHaveBeenCalledTimes(1); @@ -73,7 +74,7 @@ public function testIsMutable(): void 'mutate', [ $arg0 = new stdClass(), - ] + ], ); $flag = new OptionalFlag(30); @@ -89,16 +90,16 @@ public function testIsMutable(): void // @phpstan-ignore-next-line $definition->getArguments()[0]->foz = 'baz'; - static::assertEquals('mutated', $definition->getCaller()->getId()); - static::assertEquals('dummy', $definition->getMethod()); - static::assertEquals( + self::assertEquals('mutated', $definition->getCaller()->getId()); + self::assertEquals('dummy', $definition->getMethod()); + self::assertEquals( [ StdClassFactory::create([ 'foo' => 'bar', 'foz' => 'baz', ]), ], - $definition->getArguments() + $definition->getArguments(), ); } @@ -111,17 +112,17 @@ public function testCanCreateANewInstanceWithNoArguments(): void $newArguments = null; $newDefinition = $definition->withArguments($newArguments); - static::assertInstanceOf(OptionalMethodCall::class, $newDefinition); + self::assertInstanceOf(OptionalMethodCall::class, $newDefinition); - static::assertEquals($methodCall->getCaller(), $definition->getCaller()); - static::assertEquals(30, $definition->getPercentage()); - static::assertEquals($methodCall->getMethod(), $definition->getMethod()); - static::assertEquals($methodCall->getArguments(), $definition->getArguments()); + self::assertEquals($methodCall->getCaller(), $definition->getCaller()); + self::assertEquals(30, $definition->getPercentage()); + self::assertEquals($methodCall->getMethod(), $definition->getMethod()); + self::assertEquals($methodCall->getArguments(), $definition->getArguments()); - static::assertEquals($methodCall->getCaller(), $newDefinition->getCaller()); - static::assertEquals(30, $newDefinition->getPercentage()); - static::assertEquals($methodCall->getMethod(), $newDefinition->getMethod()); - static::assertEquals($newArguments, $newDefinition->getArguments()); + self::assertEquals($methodCall->getCaller(), $newDefinition->getCaller()); + self::assertEquals(30, $newDefinition->getPercentage()); + self::assertEquals($methodCall->getMethod(), $newDefinition->getMethod()); + self::assertEquals($newArguments, $newDefinition->getArguments()); } public function testCanCreateANewInstanceWithArguments(): void @@ -137,21 +138,21 @@ public function testCanCreateANewInstanceWithArguments(): void // Mutate arguments before reading it $arg0->foo = 'bar'; - static::assertInstanceOf(OptionalMethodCall::class, $newDefinition); + self::assertInstanceOf(OptionalMethodCall::class, $newDefinition); - static::assertEquals($methodCall->getCaller(), $definition->getCaller()); - static::assertEquals(30, $definition->getPercentage()); - static::assertEquals($methodCall->getMethod(), $definition->getMethod()); - static::assertEquals($methodCall->getArguments(), $definition->getArguments()); + self::assertEquals($methodCall->getCaller(), $definition->getCaller()); + self::assertEquals(30, $definition->getPercentage()); + self::assertEquals($methodCall->getMethod(), $definition->getMethod()); + self::assertEquals($methodCall->getArguments(), $definition->getArguments()); - static::assertEquals($methodCall->getCaller(), $newDefinition->getCaller()); - static::assertEquals(30, $newDefinition->getPercentage()); - static::assertEquals($methodCall->getMethod(), $newDefinition->getMethod()); - static::assertEquals( + self::assertEquals($methodCall->getCaller(), $newDefinition->getCaller()); + self::assertEquals(30, $newDefinition->getPercentage()); + self::assertEquals($methodCall->getMethod(), $newDefinition->getMethod()); + self::assertEquals( [ StdClassFactory::create(['foo' => 'bar']), ], - $newDefinition->getArguments() + $newDefinition->getArguments(), ); } } diff --git a/tests/Definition/MethodCall/SimpleMethodCallTest.php b/tests/Definition/MethodCall/SimpleMethodCallTest.php index b339d7bdc..123aa7078 100644 --- a/tests/Definition/MethodCall/SimpleMethodCallTest.php +++ b/tests/Definition/MethodCall/SimpleMethodCallTest.php @@ -20,14 +20,15 @@ /** * @covers \Nelmio\Alice\Definition\MethodCall\SimpleMethodCall + * @internal */ class SimpleMethodCallTest extends TestCase { public function testIsAMethodCall(): void { - static::assertTrue(is_a(SimpleMethodCall::class, MethodCallInterface::class, true)); + self::assertTrue(is_a(SimpleMethodCall::class, MethodCallInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $method = 'setUsername'; @@ -35,17 +36,17 @@ public function testReadAccessorsReturnPropertiesValues(): void $definition = new SimpleMethodCall($method, $arguments); - static::assertNull($definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); - static::assertEquals($method, $definition->__toString()); + self::assertNull($definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); + self::assertEquals($method, $definition->__toString()); $definition = new SimpleMethodCall($method, null); - static::assertNull($definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertNull($definition->getArguments()); - static::assertEquals($method, $definition->__toString()); + self::assertNull($definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertNull($definition->getArguments()); + self::assertEquals($method, $definition->__toString()); } public function testIsMutable(): void @@ -62,14 +63,14 @@ public function testIsMutable(): void // @phpstan-ignore-next-line $definition->getArguments()[0]->foz = 'baz'; - static::assertEquals( + self::assertEquals( [ StdClassFactory::create([ 'foo' => 'bar', 'foz' => 'baz', ]), ], - $definition->getArguments() + $definition->getArguments(), ); } @@ -82,17 +83,17 @@ public function testCanCreateANewInstanceWithNoArguments(): void $newArguments = [new stdClass()]; $newDefinition = $definition->withArguments($newArguments); - static::assertInstanceOf(SimpleMethodCall::class, $newDefinition); + self::assertInstanceOf(SimpleMethodCall::class, $newDefinition); - static::assertNull($definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); - static::assertEquals($method, $definition->__toString()); + self::assertNull($definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); + self::assertEquals($method, $definition->__toString()); - static::assertNull($newDefinition->getCaller()); - static::assertEquals($method, $newDefinition->getMethod()); - static::assertEquals($newArguments, $newDefinition->getArguments()); - static::assertEquals($method, $newDefinition->__toString()); + self::assertNull($newDefinition->getCaller()); + self::assertEquals($method, $newDefinition->getMethod()); + self::assertEquals($newArguments, $newDefinition->getArguments()); + self::assertEquals($method, $newDefinition->__toString()); } public function testCanCreateANewInstanceWithArguments(): void @@ -109,23 +110,23 @@ public function testCanCreateANewInstanceWithArguments(): void // Mutate before reading values $arg0->foo = 'bar'; - static::assertInstanceOf(SimpleMethodCall::class, $newDefinition); + self::assertInstanceOf(SimpleMethodCall::class, $newDefinition); - static::assertNull($definition->getCaller()); - static::assertEquals($method, $definition->getMethod()); - static::assertEquals($arguments, $definition->getArguments()); - static::assertEquals($method, $definition->__toString()); + self::assertNull($definition->getCaller()); + self::assertEquals($method, $definition->getMethod()); + self::assertEquals($arguments, $definition->getArguments()); + self::assertEquals($method, $definition->__toString()); - static::assertNull($newDefinition->getCaller()); - static::assertEquals($method, $newDefinition->getMethod()); - static::assertEquals( + self::assertNull($newDefinition->getCaller()); + self::assertEquals($method, $newDefinition->getMethod()); + self::assertEquals( [ StdClassFactory::create([ 'foo' => 'bar', ]), ], - $newDefinition->getArguments() + $newDefinition->getArguments(), ); - static::assertEquals($method, $newDefinition->__toString()); + self::assertEquals($method, $newDefinition->__toString()); } } diff --git a/tests/Definition/MethodCallBagTest.php b/tests/Definition/MethodCallBagTest.php index 8e93db0bd..0040357c9 100644 --- a/tests/Definition/MethodCallBagTest.php +++ b/tests/Definition/MethodCallBagTest.php @@ -21,6 +21,7 @@ /** * @covers \Nelmio\Alice\Definition\MethodCallBag + * @internal */ class MethodCallBagTest extends TestCase { @@ -28,7 +29,7 @@ class MethodCallBagTest extends TestCase * @var ReflectionProperty */ private $propRefl; - + protected function setUp(): void { $refl = new ReflectionClass(MethodCallBag::class); @@ -47,25 +48,25 @@ public function testAddingACallCreatesANewBagWithTheAddedInstance(): void $bag1 = $bag->with($methodCall1); $bag2 = $bag1->with($methodCall2); - static::assertInstanceOf(MethodCallBag::class, $bag1); - static::assertNotSame($bag, $bag1); + self::assertInstanceOf(MethodCallBag::class, $bag1); + self::assertNotSame($bag, $bag1); - static::assertSame( + self::assertSame( [], - $this->propRefl->getValue($bag) + $this->propRefl->getValue($bag), ); - static::assertSame( + self::assertSame( [ $methodCall1, ], - $this->propRefl->getValue($bag1) + $this->propRefl->getValue($bag1), ); - static::assertSame( + self::assertSame( [ $methodCall1, $methodCall2, ], - $this->propRefl->getValue($bag2) + $this->propRefl->getValue($bag2), ); } @@ -80,18 +81,18 @@ public function testStackCalls(): void $bag1 = (new MethodCallBag())->with($methodCall1); $bag2 = $bag1->with($methodCall2); - static::assertSame( + self::assertSame( [ $methodCall1, ], - $this->propRefl->getValue($bag1) + $this->propRefl->getValue($bag1), ); - static::assertSame( + self::assertSame( [ $methodCall1, $methodCall2, ], - $this->propRefl->getValue($bag2) + $this->propRefl->getValue($bag2), ); } @@ -108,47 +109,45 @@ public function testMergeTwoBags(): void $bagA = (new MethodCallBag()) ->with($callA1) - ->with($callA2) - ; + ->with($callA2); $bagB = (new MethodCallBag()) ->with($callB1) - ->with($callB2) - ; + ->with($callB2); $bag = $bagA->mergeWith($bagB); - static::assertInstanceOf(MethodCallBag::class, $bag); - static::assertSame( + self::assertInstanceOf(MethodCallBag::class, $bag); + self::assertSame( [ $callA1, $callA2, ], - $this->propRefl->getValue($bagA) + $this->propRefl->getValue($bagA), ); - static::assertSame( + self::assertSame( [ $callB1, $callB2, ], - $this->propRefl->getValue($bagB) + $this->propRefl->getValue($bagB), ); - static::assertSame( + self::assertSame( [ $callB1, $callB2, $callA1, $callA2, ], - $this->propRefl->getValue($bag) + $this->propRefl->getValue($bag), ); } public function testIsEmpty(): void { $bag = new MethodCallBag(); - static::assertTrue($bag->isEmpty()); + self::assertTrue($bag->isEmpty()); $bag = $bag->with(new FakeMethodCall()); - static::assertFalse($bag->isEmpty()); + self::assertFalse($bag->isEmpty()); } } diff --git a/tests/Definition/Object/CompleteObjectTest.php b/tests/Definition/Object/CompleteObjectTest.php index 4c2930576..63cb3f03e 100644 --- a/tests/Definition/Object/CompleteObjectTest.php +++ b/tests/Definition/Object/CompleteObjectTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\Definition\Object\CompleteObject + * @internal */ class CompleteObjectTest extends TestCase { @@ -30,7 +31,7 @@ class CompleteObjectTest extends TestCase public function testIsAnObject(): void { - static::assertTrue(is_a(CompleteObject::class, ObjectInterface::class, true)); + self::assertTrue(is_a(CompleteObject::class, ObjectInterface::class, true)); } public function testDecoratesAnObject(): void @@ -43,11 +44,11 @@ public function testDecoratesAnObject(): void $object = new CompleteObject($decoratedObject); - static::assertEquals('dummy', $object->getId()); + self::assertEquals('dummy', $object->getId()); $decoratedObjectProphecy->getId()->shouldHaveBeenCalledTimes(1); $decoratedObjectProphecy->getInstance()->shouldHaveBeenCalledTimes(0); - static::assertEquals(new stdClass(), $object->getInstance()); + self::assertEquals(new stdClass(), $object->getInstance()); $decoratedObjectProphecy->getId()->shouldHaveBeenCalledTimes(1); $decoratedObjectProphecy->getInstance()->shouldHaveBeenCalledTimes(1); } @@ -65,21 +66,20 @@ public function testDelegatesImmutabilityToTheDecoratedObject(): void $instance->fao = 'bor'; $clone->getInstance()->faz = 'boz'; - static::assertEquals( + self::assertEquals( StdClassFactory::create([ 'foo' => 'bar', 'foz' => 'baz', 'fao' => 'bor', 'faz' => 'boz', ]), - $object->getInstance() + $object->getInstance(), ); - static::assertEquals( + self::assertEquals( $object->getInstance(), - $clone->getInstance() + $clone->getInstance(), ); - // Case where the decorated object is partially immutable: cloning does create a new instance $decoratedObject = new ImmutableByCloneObject('dummy', $instance = new stdClass()); @@ -91,24 +91,23 @@ public function testDelegatesImmutabilityToTheDecoratedObject(): void $instance->fao = 'bor'; $clone->getInstance()->faz = 'boz'; - static::assertEquals( + self::assertEquals( StdClassFactory::create([ 'foo' => 'bar', 'foz' => 'baz', 'fao' => 'bor', ]), - $object->getInstance() + $object->getInstance(), ); - static::assertEquals( + self::assertEquals( StdClassFactory::create([ 'foo' => 'bar', 'foz' => 'baz', 'faz' => 'boz', ]), - $clone->getInstance() + $clone->getInstance(), ); - // Case where the decorated object is truly immutable $decoratedObject = new ImmutableObject('dummy', $instance = new stdClass()); @@ -120,8 +119,8 @@ public function testDelegatesImmutabilityToTheDecoratedObject(): void $instance->fao = 'bor'; $clone->getInstance()->faz = 'boz'; - static::assertEquals(new stdClass(), $object->getInstance()); - static::assertEquals(new stdClass(), $clone->getInstance()); + self::assertEquals(new stdClass(), $object->getInstance()); + self::assertEquals(new stdClass(), $clone->getInstance()); } public function testCannotCreateANewInstance(): void diff --git a/tests/Definition/Object/SimpleObjectTest.php b/tests/Definition/Object/SimpleObjectTest.php index 9041df9db..c276959a8 100644 --- a/tests/Definition/Object/SimpleObjectTest.php +++ b/tests/Definition/Object/SimpleObjectTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\Definition\Object\SimpleObject + * @internal */ class SimpleObjectTest extends TestCase { @@ -29,7 +30,7 @@ class SimpleObjectTest extends TestCase * @var ReflectionProperty */ private $propRefl; - + protected function setUp(): void { $this->propRefl = (new ReflectionClass(SimpleObject::class))->getProperty('instance'); @@ -38,7 +39,7 @@ protected function setUp(): void public function testIsAnObject(): void { - static::assertTrue(is_a(SimpleObject::class, ObjectInterface::class, true)); + self::assertTrue(is_a(SimpleObject::class, ObjectInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -48,8 +49,8 @@ public function testReadAccessorsReturnPropertiesValues(): void $object = new SimpleObject($reference, $instance); - static::assertEquals($reference, $object->getId()); - static::assertEquals($instance, $object->getInstance()); + self::assertEquals($reference, $object->getId()); + self::assertEquals($instance, $object->getInstance()); } public function testIsNotImmutable(): void @@ -68,7 +69,7 @@ public function testIsNotImmutable(): void $expected = StdClassFactory::create(['foo' => 'bar', 'ping' => 'pong']); $actual = $object->getInstance(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testNamedConstructor(): void @@ -82,7 +83,7 @@ public function testNamedConstructor(): void $originalNewInstance = clone $newInstance; $newObject = $object->withInstance($newInstance); - static::assertEquals(new SimpleObject($reference, $originalInstance), $object); - static::assertEquals(new SimpleObject($reference, $originalNewInstance), $newObject); + self::assertEquals(new SimpleObject($reference, $originalInstance), $object); + self::assertEquals(new SimpleObject($reference, $originalNewInstance), $newObject); } } diff --git a/tests/Definition/PropertyBagTest.php b/tests/Definition/PropertyBagTest.php index 9f52f4533..3d7984334 100644 --- a/tests/Definition/PropertyBagTest.php +++ b/tests/Definition/PropertyBagTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\Definition\PropertyBag + * @internal */ class PropertyBagTest extends TestCase { @@ -26,7 +27,7 @@ class PropertyBagTest extends TestCase * @var ReflectionProperty */ private $propRefl; - + protected function setUp(): void { $refl = new ReflectionClass(PropertyBag::class); @@ -43,9 +44,9 @@ public function testWithersReturnNewModifiedInstance(): void $bag = new PropertyBag(); $newBag = $bag->with($property); - static::assertInstanceOf(PropertyBag::class, $newBag); - static::assertSame([], $this->propRefl->getValue($bag)); - static::assertSame(['username' => $property], $this->propRefl->getValue($newBag)); + self::assertInstanceOf(PropertyBag::class, $newBag); + self::assertSame([], $this->propRefl->getValue($bag)); + self::assertSame(['username' => $property], $this->propRefl->getValue($newBag)); } /** @@ -61,37 +62,35 @@ public function testMergeTwoBags(): void $bagA = (new PropertyBag()) ->with($propertyA1) - ->with($propertyA2) - ; + ->with($propertyA2); $bagB = (new PropertyBag()) ->with($propertyB1) - ->with($propertyB2) - ; + ->with($propertyB2); $bag = $bagA->mergeWith($bagB); - static::assertInstanceOf(PropertyBag::class, $bag); - static::assertSame( + self::assertInstanceOf(PropertyBag::class, $bag); + self::assertSame( [ 'username' => $propertyA1, 'owner' => $propertyA2, ], - $this->propRefl->getValue($bagA) + $this->propRefl->getValue($bagA), ); - static::assertSame( + self::assertSame( [ 'username' => $propertyB1, 'mail' => $propertyB2, ], - $this->propRefl->getValue($bagB) + $this->propRefl->getValue($bagB), ); - static::assertSame( + self::assertSame( [ 'username' => $propertyA1, 'mail' => $propertyB2, 'owner' => $propertyA2, ], - $this->propRefl->getValue($bag) + $this->propRefl->getValue($bag), ); } @@ -102,44 +101,43 @@ public function testIsIterable(): void $bag = (new PropertyBag()) ->with($property1) - ->with($property2) - ; + ->with($property2); $array = []; foreach ($bag as $index => $property) { $array[$index] = $property; } - static::assertSame( + self::assertSame( [ $property1, $property2, ], - $array + $array, ); } public function testIsCountable(): void { $bag = new PropertyBag(); - static::assertCount(0, $bag); + self::assertCount(0, $bag); $bag = $bag->with(new Property('foo', 'bar')); - static::assertCount(1, $bag); + self::assertCount(1, $bag); $bag = $bag->with(new Property('foo', 'baz')); - static::assertCount(1, $bag); + self::assertCount(1, $bag); $bag = $bag->with(new Property('ping', 'pong')); - static::assertCount(2, $bag); + self::assertCount(2, $bag); } public function testIsEmpty(): void { $bag = new PropertyBag(); - static::assertTrue($bag->isEmpty()); + self::assertTrue($bag->isEmpty()); $bag = $bag->with(new Property('foo', null)); - static::assertFalse($bag->isEmpty()); + self::assertFalse($bag->isEmpty()); } } diff --git a/tests/Definition/PropertyTest.php b/tests/Definition/PropertyTest.php index 3578c3d15..79fd126b6 100644 --- a/tests/Definition/PropertyTest.php +++ b/tests/Definition/PropertyTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\Definition\Property + * @internal */ class PropertyTest extends TestCase { @@ -28,8 +29,8 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new stdClass(); $definition = new Property($property, $value); - static::assertEquals($property, $definition->getName()); - static::assertEquals($value, $definition->getValue()); + self::assertEquals($property, $definition->getName()); + self::assertEquals($value, $definition->getValue()); } public function testIsMutable(): void @@ -46,7 +47,7 @@ public function testIsMutable(): void $expected = StdClassFactory::create(['foo' => 'bar', 'ping' => 'pong']); $actual = $definition->getValue(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testWithersReturnNewModifiedInstance(): void @@ -55,13 +56,13 @@ public function testWithersReturnNewModifiedInstance(): void $definition = new Property($name, 'foo'); $newDefinition = $definition->withValue(new stdClass()); - static::assertEquals( + self::assertEquals( new Property($name, 'foo'), - $definition + $definition, ); - static::assertEquals( + self::assertEquals( new Property($name, new stdClass()), - $newDefinition + $newDefinition, ); } } diff --git a/tests/Definition/RangeNameTest.php b/tests/Definition/RangeNameTest.php index 4e201833b..41114b784 100644 --- a/tests/Definition/RangeNameTest.php +++ b/tests/Definition/RangeNameTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Definition\RangeName + * @internal */ class RangeNameTest extends TestCase { @@ -27,15 +28,15 @@ public function testReadAccessorsReturnPropertiesValues(array $input, array $exp { $name = 'user'; [$from, $to] = $input; - + $range = new RangeName($name, $from, $to); - - static::assertEquals($name, $range->getName()); - static::assertEquals($expected[0], $range->getFrom()); - static::assertEquals($expected[1], $range->getTo()); + + self::assertEquals($name, $range->getName()); + self::assertEquals($expected[0], $range->getFrom()); + self::assertEquals($expected[1], $range->getTo()); } - public function provideRanges() + public function provideRanges(): iterable { yield [ [10, 11], diff --git a/tests/Definition/ServiceReference/FixtureReferenceTest.php b/tests/Definition/ServiceReference/FixtureReferenceTest.php index 7b38d8ff3..c3430277d 100644 --- a/tests/Definition/ServiceReference/FixtureReferenceTest.php +++ b/tests/Definition/ServiceReference/FixtureReferenceTest.php @@ -18,12 +18,13 @@ /** * @covers \Nelmio\Alice\Definition\ServiceReference\FixtureReference + * @internal */ class FixtureReferenceTest extends TestCase { public function testIsAReference(): void { - static::assertTrue(is_a(FixtureReference::class, ServiceReferenceInterface::class, true)); + self::assertTrue(is_a(FixtureReference::class, ServiceReferenceInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -31,11 +32,11 @@ public function testReadAccessorsReturnPropertiesValues(): void $id = 'user_base'; $definition = new FixtureReference($id); - static::assertEquals($id, $definition->getId()); + self::assertEquals($id, $definition->getId()); } public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } } diff --git a/tests/Definition/ServiceReference/InstantiatedReferenceTest.php b/tests/Definition/ServiceReference/InstantiatedReferenceTest.php index e5d159fa1..52cd165e3 100644 --- a/tests/Definition/ServiceReference/InstantiatedReferenceTest.php +++ b/tests/Definition/ServiceReference/InstantiatedReferenceTest.php @@ -18,19 +18,20 @@ /** * @covers \Nelmio\Alice\Definition\ServiceReference\InstantiatedReference + * @internal */ class InstantiatedReferenceTest extends TestCase { public function testIsAReference(): void { - static::assertTrue(is_a(InstantiatedReference::class, ServiceReferenceInterface::class, true)); + self::assertTrue(is_a(InstantiatedReference::class, ServiceReferenceInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $reference = 'nelmio.alice.user_factory'; $definition = new InstantiatedReference($reference); - - static::assertEquals($reference, $definition->getId()); + + self::assertEquals($reference, $definition->getId()); } } diff --git a/tests/Definition/ServiceReference/StaticReferenceTest.php b/tests/Definition/ServiceReference/StaticReferenceTest.php index 3274e3154..c36c72766 100644 --- a/tests/Definition/ServiceReference/StaticReferenceTest.php +++ b/tests/Definition/ServiceReference/StaticReferenceTest.php @@ -18,19 +18,20 @@ /** * @covers \Nelmio\Alice\Definition\ServiceReference\StaticReference + * @internal */ class StaticReferenceTest extends TestCase { public function testIsAReference(): void { - static::assertTrue(is_a(StaticReference::class, ServiceReferenceInterface::class, true)); + self::assertTrue(is_a(StaticReference::class, ServiceReferenceInterface::class, true)); } - + public function testReadAccessorsReturnPropertiesValues(): void { $reference = 'Nelmio\User\UserFactory'; $definition = new StaticReference($reference); - - static::assertEquals($reference, $definition->getId()); + + self::assertEquals($reference, $definition->getId()); } } diff --git a/tests/Definition/SpecificationBagTest.php b/tests/Definition/SpecificationBagTest.php index 706ac0b4d..255a3d1e4 100644 --- a/tests/Definition/SpecificationBagTest.php +++ b/tests/Definition/SpecificationBagTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Definition\SpecificationBag + * @internal */ class SpecificationBagTest extends TestCase { @@ -28,16 +29,16 @@ public function testReadAccessorsReturnPropertiesValues(): void $calls = new MethodCallBag(); $bag = new SpecificationBag($constructor, $properties, $calls); - static::assertEquals($constructor, $bag->getConstructor()); - static::assertEquals($properties, $bag->getProperties()); - static::assertEquals($calls, $bag->getMethodCalls()); + self::assertEquals($constructor, $bag->getConstructor()); + self::assertEquals($properties, $bag->getProperties()); + self::assertEquals($calls, $bag->getMethodCalls()); $constructor = null; $bag = new SpecificationBag($constructor, $properties, $calls); - static::assertEquals($constructor, $bag->getConstructor()); - static::assertEquals($properties, $bag->getProperties()); - static::assertEquals($calls, $bag->getMethodCalls()); + self::assertEquals($constructor, $bag->getConstructor()); + self::assertEquals($properties, $bag->getProperties()); + self::assertEquals($calls, $bag->getMethodCalls()); } public function testWithersReturnNewModifiedInstance(): void @@ -50,15 +51,15 @@ public function testWithersReturnNewModifiedInstance(): void $newConstructor = new FakeMethodCall(); $newBag = $bag->withConstructor($newConstructor); - static::assertInstanceOf(SpecificationBag::class, $newBag); + self::assertInstanceOf(SpecificationBag::class, $newBag); - static::assertEquals($constructor, $bag->getConstructor()); - static::assertEquals($calls, $bag->getMethodCalls()); - static::assertEquals($properties, $bag->getProperties()); + self::assertEquals($constructor, $bag->getConstructor()); + self::assertEquals($calls, $bag->getMethodCalls()); + self::assertEquals($properties, $bag->getProperties()); - static::assertEquals(new FakeMethodCall(), $newBag->getConstructor()); - static::assertEquals($calls, $newBag->getMethodCalls()); - static::assertEquals($properties, $newBag->getProperties()); + self::assertEquals(new FakeMethodCall(), $newBag->getConstructor()); + self::assertEquals($calls, $newBag->getMethodCalls()); + self::assertEquals($properties, $newBag->getProperties()); } public function testMergeTwoBags(): void @@ -74,12 +75,10 @@ public function testMergeTwoBags(): void $propertiesA = (new PropertyBag()) ->with($propertyA1) - ->with($propertyA2) - ; + ->with($propertyA2); $propertiesB = (new PropertyBag()) ->with($propertyB1) - ->with($propertyB2) - ; + ->with($propertyB2); $callA1 = new SimpleMethodCall('setUsername', []); $callA2 = new SimpleMethodCall('setOwner', []); @@ -89,27 +88,25 @@ public function testMergeTwoBags(): void $callsA = (new MethodCallBag()) ->with($callA1) - ->with($callA2) - ; + ->with($callA2); $callsB = (new MethodCallBag()) ->with($callB1) - ->with($callB2) - ; + ->with($callB2); $bagA = new SpecificationBag($constructorA, $propertiesA, $callsA); $bagB = new SpecificationBag($constructorB, $propertiesB, $callsB); $bag = $bagA->mergeWith($bagB); - static::assertInstanceOf(SpecificationBag::class, $bag); - static::assertEquals($constructorA, $bagA->getConstructor()); - static::assertEquals($propertiesA, $bagA->getProperties()); - static::assertEquals($callsA, $bagA->getMethodCalls()); + self::assertInstanceOf(SpecificationBag::class, $bag); + self::assertEquals($constructorA, $bagA->getConstructor()); + self::assertEquals($propertiesA, $bagA->getProperties()); + self::assertEquals($callsA, $bagA->getMethodCalls()); - static::assertEquals($constructorB, $bagB->getConstructor()); - static::assertEquals($propertiesB, $bagB->getProperties()); - static::assertEquals($callsB, $bagB->getMethodCalls()); + self::assertEquals($constructorB, $bagB->getConstructor()); + self::assertEquals($propertiesB, $bagB->getProperties()); + self::assertEquals($callsB, $bagB->getMethodCalls()); - static::assertEquals($constructorA, $bag->getConstructor()); + self::assertEquals($constructorA, $bag->getConstructor()); } /** @@ -124,9 +121,9 @@ public function testMergeTwoBags1(): void $bagB = new SpecificationBag($constructorB, new PropertyBag(), new MethodCallBag()); $bag = $bagA->mergeWith($bagB); - static::assertEquals($constructorA, $bagA->getConstructor()); - static::assertEquals($constructorB, $bagB->getConstructor()); - static::assertEquals($constructorA, $bag->getConstructor()); + self::assertEquals($constructorA, $bagA->getConstructor()); + self::assertEquals($constructorB, $bagB->getConstructor()); + self::assertEquals($constructorA, $bag->getConstructor()); } /** @@ -141,8 +138,8 @@ public function testMergeTwoBags2(): void $bagB = new SpecificationBag($constructorB, new PropertyBag(), new MethodCallBag()); $bag = $bagA->mergeWith($bagB); - static::assertEquals($constructorA, $bagA->getConstructor()); - static::assertEquals($constructorB, $bagB->getConstructor()); - static::assertEquals($constructorA, $bag->getConstructor()); + self::assertEquals($constructorA, $bagA->getConstructor()); + self::assertEquals($constructorB, $bagB->getConstructor()); + self::assertEquals($constructorA, $bag->getConstructor()); } } diff --git a/tests/Definition/Value/ArrayValueTest.php b/tests/Definition/Value/ArrayValueTest.php index 284be19d4..e7b0534ff 100644 --- a/tests/Definition/Value/ArrayValueTest.php +++ b/tests/Definition/Value/ArrayValueTest.php @@ -19,12 +19,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\ArrayValue + * @internal */ class ArrayValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(ArrayValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(ArrayValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnValues(): void @@ -32,12 +33,12 @@ public function testReadAccessorsReturnValues(): void $list = []; $value = new ArrayValue($list); - static::assertEquals($list, $value->getValue()); + self::assertEquals($list, $value->getValue()); $list = [new stdClass()]; $value = new ArrayValue($list); - static::assertEquals($list, $value->getValue()); + self::assertEquals($list, $value->getValue()); } public function testIsImmutable(): void @@ -52,20 +53,20 @@ public function testIsImmutable(): void // Mutate retrieved value $value->getValue()[0]->foo = 'baz'; - static::assertEquals( + self::assertEquals( [ new stdClass(), ], - $value->getValue() + $value->getValue(), ); } public function testCanBeCastedIntoAString(): void { $value = new ArrayValue([]); - static::assertEquals("array (\n)", (string) $value); + self::assertEquals("array (\n)", (string) $value); $value = new ArrayValue(['foo', 'bar']); - static::assertEquals("array (\n 0 => 'foo',\n 1 => 'bar',\n)", (string) $value); + self::assertEquals("array (\n 0 => 'foo',\n 1 => 'bar',\n)", (string) $value); } } diff --git a/tests/Definition/Value/DynamicArrayValueTest.php b/tests/Definition/Value/DynamicArrayValueTest.php index 7cbe727f2..33c67c28e 100644 --- a/tests/Definition/Value/DynamicArrayValueTest.php +++ b/tests/Definition/Value/DynamicArrayValueTest.php @@ -20,37 +20,44 @@ /** * @covers \Nelmio\Alice\Definition\Value\DynamicArrayValue + * @internal */ class DynamicArrayValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(UniqueValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(UniqueValue::class, ValueInterface::class, true)); } /** * @dataProvider provideInputTypes + * @param mixed $quantifier + * @param mixed $element + * @param mixed $errorMessage */ public function testThrowsErrorIfInvalidInputType($quantifier, $element, $errorMessage): void { try { new DynamicArrayValue($quantifier, $element); - static::fail('Expected error to be thrown.'); + self::fail('Expected error to be thrown.'); } catch (TypeError $error) { - static::assertEquals($errorMessage, $error->getMessage()); + self::assertEquals($errorMessage, $error->getMessage()); } } /** * @dataProvider provideValues + * @param mixed $quantifier + * @param mixed $element + * @param mixed $expectedQuantifier */ public function testReadAccessorsReturnPropertiesValues($quantifier, $element, $expectedQuantifier): void { $value = new DynamicArrayValue($quantifier, $element); - static::assertEquals($expectedQuantifier, $value->getQuantifier()); - static::assertEquals($element, $value->getElement()); - static::assertEquals([$expectedQuantifier, $element], $value->getValue()); + self::assertEquals($expectedQuantifier, $value->getQuantifier()); + self::assertEquals($element, $value->getElement()); + self::assertEquals([$expectedQuantifier, $element], $value->getValue()); } public function testIsImmutable(): void @@ -69,68 +76,68 @@ public function testIsImmutable(): void // @phpstan-ignore-next-line $value->getElement()->setValue('e2'); - static::assertEquals(new MutableValue('q0'), $value->getQuantifier()); - static::assertEquals(new MutableValue('e0'), $value->getElement()); - static::assertEquals( + self::assertEquals(new MutableValue('q0'), $value->getQuantifier()); + self::assertEquals(new MutableValue('e0'), $value->getElement()); + self::assertEquals( [ new MutableValue('q0'), new MutableValue('e0'), ], - $value->getValue() + $value->getValue(), ); } public function testCanBeCastedIntoAString(): void { $value = new DynamicArrayValue(10, 'foo'); - static::assertEquals('10x foo', (string) $value); + self::assertEquals('10x foo', (string) $value); $value = new DynamicArrayValue(new DummyValue('10'), new DummyValue('foo')); - static::assertEquals('10x foo', (string) $value); + self::assertEquals('10x foo', (string) $value); } - public function provideInputTypes() + public function provideInputTypes(): iterable { yield 'null/array' => [ null, 'dummy_element', 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' - .'"NULL" instead.' + .'"NULL" instead.', ]; yield 'bool/array' => [ true, 'dummy_element', 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' - .'"boolean" instead.' + .'"boolean" instead.', ]; yield 'string/array' => [ '', 'dummy_element', 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' - .'"string" instead.' + .'"string" instead.', ]; yield 'float/array' => [ .5, 'dummy_element', 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' - .'"double" instead.' + .'"double" instead.', ]; yield 'array/array' => [ [], 'dummy_element', 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' - .'"array" instead.' + .'"array" instead.', ]; yield 'object/array' => [ new stdClass(), 'dummy_element', 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' - .'"stdClass" instead.' + .'"stdClass" instead.', ]; yield 'closure/array' => [ @@ -138,35 +145,35 @@ static function (): void { }, 'dummy_element', 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' - .'"Closure" instead.' + .'"Closure" instead.', ]; yield 'int/null' => [ -1, null, 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' - .'"NULL" instead.' + .'"NULL" instead.', ]; yield 'int/bool' => [ -1, true, 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' - .'"boolean" instead.' + .'"boolean" instead.', ]; yield 'int/float' => [ -1, .5, 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' - .'"double" instead.' + .'"double" instead.', ]; yield 'int/int' => [ 1, 1, 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' - .'"integer" instead.' + .'"integer" instead.', ]; yield 'int/closure' => [ @@ -174,18 +181,18 @@ static function (): void { static function (): void { }, 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' - .'"Closure" instead.' + .'"Closure" instead.', ]; yield 'int/non value interface object' => [ -1, new stdClass(), 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' - .'"stdClass" instead.' + .'"stdClass" instead.', ]; } - public function provideValues() + public function provideValues(): iterable { yield 'int value' => [-1, 'string', -1]; yield 'object value' => [new FakeValue(), new FakeValue(), new FakeValue()]; diff --git a/tests/Definition/Value/EvaluatedValueTest.php b/tests/Definition/Value/EvaluatedValueTest.php index f47a642e2..b1d3db612 100644 --- a/tests/Definition/Value/EvaluatedValueTest.php +++ b/tests/Definition/Value/EvaluatedValueTest.php @@ -18,12 +18,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\EvaluatedValue + * @internal */ class EvaluatedValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(EvaluatedValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(EvaluatedValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -31,13 +32,13 @@ public function testReadAccessorsReturnPropertiesValues(): void $expression = '"Hello"." "."world!"'; $value = new EvaluatedValue($expression); - static::assertEquals($expression, $value->getValue()); + self::assertEquals($expression, $value->getValue()); } public function testCanBeCastedIntoAString(): void { $value = new EvaluatedValue('"Hello"." "."world!"'); - static::assertEquals('"Hello"." "."world!"', $value); + self::assertEquals('"Hello"." "."world!"', $value); } } diff --git a/tests/Definition/Value/FixtureMatchReferenceValueTest.php b/tests/Definition/Value/FixtureMatchReferenceValueTest.php index ac12c8107..0579f8ed2 100644 --- a/tests/Definition/Value/FixtureMatchReferenceValueTest.php +++ b/tests/Definition/Value/FixtureMatchReferenceValueTest.php @@ -18,12 +18,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\FixtureMatchReferenceValue + * @internal */ class FixtureMatchReferenceValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(FixtureMatchReferenceValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(FixtureMatchReferenceValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -31,7 +32,7 @@ public function testReadAccessorsReturnPropertiesValues(): void $regex = '/dummy/'; $value = new FixtureMatchReferenceValue($regex); - static::assertEquals($regex, $value->getValue()); + self::assertEquals($regex, $value->getValue()); } public function testCanMatchAgainstValues(): void @@ -39,8 +40,8 @@ public function testCanMatchAgainstValues(): void $regex = '/^d/'; $value = new FixtureMatchReferenceValue($regex); - static::assertTrue($value->match('d')); - static::assertFalse($value->match('a')); + self::assertTrue($value->match('d')); + self::assertFalse($value->match('a')); } public function testCanCreateAReferenceForWildcards(): void @@ -48,18 +49,18 @@ public function testCanCreateAReferenceForWildcards(): void $expected = new FixtureMatchReferenceValue('/^user.*/'); $actual = FixtureMatchReferenceValue::createWildcardReference('user'); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCanBeCastedIntoAString(): void { $value = FixtureMatchReferenceValue::createWildcardReference('dummy'); - static::assertEquals('@(regex: /^dummy.*/)', (string) $value); + self::assertEquals('@(regex: /^dummy.*/)', (string) $value); } public function testReferenceIsRegexEscaped(): void { $value = FixtureMatchReferenceValue::createWildcardReference('du/m*m+y.ref[ere]n(c)e'); - static::assertEquals('/^du\\/m\\*m\\+y\\.ref\\[ere\\]n\\(c\\)e.*/', $value->getValue()); + self::assertEquals('/^du\\/m\\*m\\+y\\.ref\\[ere\\]n\\(c\\)e.*/', $value->getValue()); } } diff --git a/tests/Definition/Value/FixtureMethodCallValueTest.php b/tests/Definition/Value/FixtureMethodCallValueTest.php index d812bcf35..4c6df5e8a 100644 --- a/tests/Definition/Value/FixtureMethodCallValueTest.php +++ b/tests/Definition/Value/FixtureMethodCallValueTest.php @@ -18,12 +18,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\FixtureMethodCallValue + * @internal */ class FixtureMethodCallValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(FixtureMethodCallValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(FixtureMethodCallValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -33,32 +34,32 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new FixtureMethodCallValue($reference, $function); - static::assertEquals($reference, $value->getReference()); - static::assertEquals($function, $value->getFunctionCall()); - static::assertEquals([$reference, $function], $value->getValue()); + self::assertEquals($reference, $value->getReference()); + self::assertEquals($function, $value->getFunctionCall()); + self::assertEquals([$reference, $function], $value->getValue()); } /** - * @depends \Nelmio\Alice\Definition\ServiceReference\FixtureReferenceTest::testIsImmutable - * @depends \Nelmio\Alice\Definition\Value\FunctionCallValueTest::testIsImmutable + * @depends test\Nelmio\Alice\Definition\ServiceReference\FixtureReferenceTest::testIsImmutable + * @depends test\Nelmio\Alice\Definition\Value\FunctionCallValueTest::testIsImmutable */ public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } public function testCanBeCastedIntoAString(): void { $value = new FixtureMethodCallValue( new FixtureReferenceValue('dummy'), - new FunctionCallValue('foo') + new FunctionCallValue('foo'), ); - static::assertEquals('@dummy->foo()', (string) $value); + self::assertEquals('@dummy->foo()', (string) $value); $value = new FixtureMethodCallValue( new FixtureReferenceValue('dummy'), - new FunctionCallValue('foo', ['bar']) + new FunctionCallValue('foo', ['bar']), ); - static::assertEquals("@dummy->foo(array (\n 0 => 'bar',\n))", (string) $value); + self::assertEquals("@dummy->foo(array (\n 0 => 'bar',\n))", (string) $value); } } diff --git a/tests/Definition/Value/FixturePropertyValueTest.php b/tests/Definition/Value/FixturePropertyValueTest.php index 5acdf9b23..2ac35e203 100644 --- a/tests/Definition/Value/FixturePropertyValueTest.php +++ b/tests/Definition/Value/FixturePropertyValueTest.php @@ -18,12 +18,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\FixturePropertyValue + * @internal */ class FixturePropertyValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(FixturePropertyValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(FixturePropertyValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -33,26 +34,26 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new FixturePropertyValue($reference, $property); - static::assertEquals($reference, $value->getReference()); - static::assertEquals($property, $value->getProperty()); - static::assertEquals([$reference, $property], $value->getValue()); + self::assertEquals($reference, $value->getReference()); + self::assertEquals($property, $value->getProperty()); + self::assertEquals([$reference, $property], $value->getValue()); } /** - * @depends \Nelmio\Alice\Definition\Value\FixtureReferenceValueTest::testIsImmutable + * @depends test\Nelmio\Alice\Definition\Value\FixtureReferenceValueTest::testIsImmutable */ public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } public function testCanBeCastedIntoAString(): void { $value = new FixturePropertyValue( new FixtureReferenceValue('dummy'), - 'foo' + 'foo', ); - static::assertEquals('@dummy->foo', (string) $value); + self::assertEquals('@dummy->foo', (string) $value); } } diff --git a/tests/Definition/Value/FixtureReferenceValueTest.php b/tests/Definition/Value/FixtureReferenceValueTest.php index 87dc13c90..3fab8c3e0 100644 --- a/tests/Definition/Value/FixtureReferenceValueTest.php +++ b/tests/Definition/Value/FixtureReferenceValueTest.php @@ -20,12 +20,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\FixtureReferenceValue + * @internal */ class FixtureReferenceValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(FixtureReferenceValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(FixtureReferenceValue::class, ValueInterface::class, true)); } public function testCanBeInstantiatedWithOnlyAStringOrAValue(): void @@ -36,73 +37,73 @@ public function testCanBeInstantiatedWithOnlyAStringOrAValue(): void try { new FixtureReferenceValue(null); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got' .' "null" instead.', - $exception->getMessage() + $exception->getMessage(), ); } try { new FixtureReferenceValue(true); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got' .' "boolean" instead.', - $exception->getMessage() + $exception->getMessage(), ); } try { new FixtureReferenceValue(10); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got' .' "integer" instead.', - $exception->getMessage() + $exception->getMessage(), ); } try { new FixtureReferenceValue(.5); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got' .' "double" instead.', - $exception->getMessage() + $exception->getMessage(), ); } try { new FixtureReferenceValue([]); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got' .' "array" instead.', - $exception->getMessage() + $exception->getMessage(), ); } try { new FixtureReferenceValue(new stdClass()); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got' .' "stdClass" instead.', - $exception->getMessage() + $exception->getMessage(), ); } try { new FixtureReferenceValue( static function (): void { - } + }, ); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got' .' "Closure" instead.', - $exception->getMessage() + $exception->getMessage(), ); } } @@ -111,20 +112,20 @@ public function testReadAccessorsReturnPropertiesValues(): void { $value = new FixtureReferenceValue('user0'); - static::assertEquals('user0', $value->getValue()); + self::assertEquals('user0', $value->getValue()); } public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } public function testCanBeCastedIntoAString(): void { $value = new FixtureReferenceValue(''); - static::assertEquals('@', (string) $value); + self::assertEquals('@', (string) $value); $value = new FixtureReferenceValue('user0'); - static::assertEquals('@user0', (string) $value); + self::assertEquals('@user0', (string) $value); } } diff --git a/tests/Definition/Value/FunctionCallValueTest.php b/tests/Definition/Value/FunctionCallValueTest.php index 0a9a0e73a..6879115ec 100644 --- a/tests/Definition/Value/FunctionCallValueTest.php +++ b/tests/Definition/Value/FunctionCallValueTest.php @@ -19,12 +19,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\FunctionCallValue + * @internal */ class FunctionCallValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(FunctionCallValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(FunctionCallValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -34,9 +35,9 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new FunctionCallValue($name, $arguments); - static::assertEquals($name, $value->getName()); - static::assertEquals($arguments, $value->getArguments()); - static::assertEquals([$name, $arguments], $value->getValue()); + self::assertEquals($name, $value->getName()); + self::assertEquals($arguments, $value->getArguments()); + self::assertEquals([$name, $arguments], $value->getValue()); } public function testIsImmutable(): void @@ -52,27 +53,27 @@ public function testIsImmutable(): void // Mutate returned value $value->getArguments()[0]->foo = 'baz'; - static::assertEquals( + self::assertEquals( [ new stdClass(), ], - $value->getArguments() + $value->getArguments(), ); - static::assertEquals( + self::assertEquals( [ 'setUsername', [new stdClass()], ], - $value->getValue() + $value->getValue(), ); } public function testCanBeCastedIntoAString(): void { $value = new FunctionCallValue('foo'); - static::assertEquals('', (string) $value); + self::assertEquals('', (string) $value); $value = new FunctionCallValue('foo', ['bar']); - static::assertEquals(" 'bar',\n))>", (string) $value); + self::assertEquals(" 'bar',\n))>", (string) $value); } } diff --git a/tests/Definition/Value/ListValueTest.php b/tests/Definition/Value/ListValueTest.php index 8c13a9da9..eb820efce 100644 --- a/tests/Definition/Value/ListValueTest.php +++ b/tests/Definition/Value/ListValueTest.php @@ -19,12 +19,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\ListValue + * @internal */ class ListValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(ListValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(ListValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -32,12 +33,12 @@ public function testReadAccessorsReturnPropertiesValues(): void $list = []; $value = new ListValue($list); - static::assertEquals($list, $value->getValue()); + self::assertEquals($list, $value->getValue()); $list = [new stdClass()]; $value = new ListValue($list); - static::assertEquals($list, $value->getValue()); + self::assertEquals($list, $value->getValue()); } public function testIsImmutable(): void @@ -53,17 +54,17 @@ public function testIsImmutable(): void // @phpstan-ignore-next-line $value->getValue()[0]->foo = 'baz'; - static::assertEquals( + self::assertEquals( [ new stdClass(), ], - $value->getValue() + $value->getValue(), ); } public function testCanBeCastedIntoAString(): void { $value = new ListValue(['a', 'b', new DummyValue('c')]); - static::assertEquals('abc', (string) $value); + self::assertEquals('abc', (string) $value); } } diff --git a/tests/Definition/Value/NestedValueTest.php b/tests/Definition/Value/NestedValueTest.php index f81f886ff..08f374c3a 100644 --- a/tests/Definition/Value/NestedValueTest.php +++ b/tests/Definition/Value/NestedValueTest.php @@ -19,12 +19,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\NestedValue + * @internal */ class NestedValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(NestedValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(NestedValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -32,12 +33,12 @@ public function testReadAccessorsReturnPropertiesValues(): void $list = []; $value = new NestedValue($list); - static::assertEquals($list, $value->getValue()); + self::assertEquals($list, $value->getValue()); $list = [new stdClass()]; $value = new NestedValue($list); - static::assertEquals($list, $value->getValue()); + self::assertEquals($list, $value->getValue()); } public function testIsNotImmutable(): void @@ -46,11 +47,11 @@ public function testIsNotImmutable(): void $arg0 = new stdClass(), ]); - static::assertSame($arg0, $value->getValue()[0]); + self::assertSame($arg0, $value->getValue()[0]); } public function testCanBeCastedIntoAString(): void { - static::assertEquals("(nested) array (\n)", (string) (new NestedValue([]))); + self::assertEquals("(nested) array (\n)", (string) (new NestedValue([]))); } } diff --git a/tests/Definition/Value/OptionalValueTest.php b/tests/Definition/Value/OptionalValueTest.php index 6e2924a46..993156010 100644 --- a/tests/Definition/Value/OptionalValueTest.php +++ b/tests/Definition/Value/OptionalValueTest.php @@ -20,24 +20,29 @@ /** * @covers \Nelmio\Alice\Definition\Value\OptionalValue + * @internal */ class OptionalValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(OptionalValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(OptionalValue::class, ValueInterface::class, true)); } /** * @dataProvider provideInputValues + * @param mixed $quantifier + * @param mixed $firstMember + * @param mixed $secondMember + * @param mixed $errorMessage */ public function testThrowsErrorIfInvalidTypeGiven($quantifier, $firstMember, $secondMember, $errorMessage): void { try { new OptionalValue($quantifier, $firstMember, $secondMember); - static::fail('Expected error to be thrown.'); + self::fail('Expected error to be thrown.'); } catch (TypeError $error) { - static::assertEquals($errorMessage, $error->getMessage()); + self::assertEquals($errorMessage, $error->getMessage()); } } @@ -49,10 +54,10 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new OptionalValue($quantifier, $firstMember, $secondMember); - static::assertEquals($quantifier, $value->getQuantifier()); - static::assertEquals($firstMember, $value->getFirstMember()); - static::assertEquals($secondMember, $value->getSecondMember()); - static::assertEquals([$quantifier, $firstMember, $secondMember], $value->getValue()); + self::assertEquals($quantifier, $value->getQuantifier()); + self::assertEquals($firstMember, $value->getFirstMember()); + self::assertEquals($secondMember, $value->getSecondMember()); + self::assertEquals([$quantifier, $firstMember, $secondMember], $value->getValue()); $quantifier = new FakeValue(); $firstMember = new FakeValue(); @@ -60,10 +65,10 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new OptionalValue($quantifier, $firstMember, $secondMember); - static::assertEquals($quantifier, $value->getQuantifier()); - static::assertEquals($firstMember, $value->getFirstMember()); - static::assertEquals($secondMember, $value->getSecondMember()); - static::assertEquals([$quantifier, $firstMember, $secondMember], $value->getValue()); + self::assertEquals($quantifier, $value->getQuantifier()); + self::assertEquals($firstMember, $value->getFirstMember()); + self::assertEquals($secondMember, $value->getSecondMember()); + self::assertEquals([$quantifier, $firstMember, $secondMember], $value->getValue()); $quantifier = '100'; $firstMember = new FakeValue(); @@ -71,10 +76,10 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new OptionalValue($quantifier, $firstMember, $secondMember); - static::assertEquals(100, $value->getQuantifier()); - static::assertEquals($firstMember, $value->getFirstMember()); - static::assertEquals($secondMember, $value->getSecondMember()); - static::assertEquals([$quantifier, $firstMember, $secondMember], $value->getValue()); + self::assertEquals(100, $value->getQuantifier()); + self::assertEquals($firstMember, $value->getFirstMember()); + self::assertEquals($secondMember, $value->getSecondMember()); + self::assertEquals([$quantifier, $firstMember, $secondMember], $value->getValue()); } public function testIsImmutable(): void @@ -94,32 +99,32 @@ public function testIsImmutable(): void $value->getFirstMember()->setValue('f2'); // @phpstan-ignore-line $value->getSecondMember()->setValue('s2'); // @phpstan-ignore-line - static::assertNotSame(new MutableValue('q0'), $value->getQuantifier()); - static::assertNotSame(new MutableValue('f0'), $value->getFirstMember()); - static::assertNotSame(new MutableValue('s0'), $value->getSecondMember()); - static::assertNotSame( + self::assertNotSame(new MutableValue('q0'), $value->getQuantifier()); + self::assertNotSame(new MutableValue('f0'), $value->getFirstMember()); + self::assertNotSame(new MutableValue('s0'), $value->getSecondMember()); + self::assertNotSame( [ new MutableValue('q0'), new MutableValue('f0'), new MutableValue('s0'), ], - $value->getValue() + $value->getValue(), ); } public function testCanBeCastedIntoAString(): void { $value = new OptionalValue(10, 'foo'); - static::assertEquals('10%? foo : null', (string) $value); + self::assertEquals('10%? foo : null', (string) $value); $value = new OptionalValue(10, 'foo', 'bar'); - static::assertEquals('10%? foo : bar', (string) $value); + self::assertEquals('10%? foo : bar', (string) $value); $value = new OptionalValue(new DummyValue('10'), new DummyValue('foo')); - static::assertEquals('10%? foo : null', (string) $value); + self::assertEquals('10%? foo : null', (string) $value); } - public function provideInputValues() + public function provideInputValues(): iterable { yield 'null/string/string' => [ null, diff --git a/tests/Definition/Value/ParameterValueTest.php b/tests/Definition/Value/ParameterValueTest.php index d71fa0814..038628d09 100644 --- a/tests/Definition/Value/ParameterValueTest.php +++ b/tests/Definition/Value/ParameterValueTest.php @@ -20,24 +20,27 @@ /** * @covers \Nelmio\Alice\Definition\Value\ParameterValue + * @internal */ class ParameterValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(ParameterValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(ParameterValue::class, ValueInterface::class, true)); } /** * @dataProvider provideInputValues + * @param mixed $value + * @param mixed $errorMessage */ public function testThrowsErrorIfInvalidTypeGiven($value, $errorMessage): void { try { new ParameterValue($value); - static::fail('Expected error to be thrown.'); + self::fail('Expected error to be thrown.'); } catch (TypeError $error) { - static::assertEquals($errorMessage, $error->getMessage()); + self::assertEquals($errorMessage, $error->getMessage()); } } @@ -46,12 +49,12 @@ public function testReadAccessorsReturnPropertiesValues(): void $parameterKey = 'dummy_param'; $value = new ParameterValue($parameterKey); - static::assertEquals($parameterKey, $value->getValue()); + self::assertEquals($parameterKey, $value->getValue()); $parameterKey = new FakeValue(); $value = new ParameterValue($parameterKey); - static::assertEquals($parameterKey, $value->getValue()); + self::assertEquals($parameterKey, $value->getValue()); } public function testIsImmutable(): void @@ -65,21 +68,21 @@ public function testIsImmutable(): void // Mutate returned value $value->getValue()->setValue('v2'); - static::assertNotSame(new MutableValue('v0'), $value->getValue()); + self::assertNotSame(new MutableValue('v0'), $value->getValue()); } public function testCanBeCastedIntoAString(): void { $value = new ParameterValue('foo'); - static::assertEquals('<{foo}>', $value); + self::assertEquals('<{foo}>', $value); $value = new ParameterValue( - new DummyValue('foo') + new DummyValue('foo'), ); - static::assertEquals('<{foo}>', $value); + self::assertEquals('<{foo}>', $value); } - public function provideInputValues() + public function provideInputValues(): iterable { yield 'null' => [ null, diff --git a/tests/Definition/Value/ResolvedFunctionCallValueTest.php b/tests/Definition/Value/ResolvedFunctionCallValueTest.php index 4cf8f3da1..1dd29633a 100644 --- a/tests/Definition/Value/ResolvedFunctionCallValueTest.php +++ b/tests/Definition/Value/ResolvedFunctionCallValueTest.php @@ -19,12 +19,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\ResolvedFunctionCallValue + * @internal */ class ResolvedFunctionCallValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(ResolvedFunctionCallValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(ResolvedFunctionCallValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -34,9 +35,9 @@ public function testReadAccessorsReturnPropertiesValues(): void $value = new ResolvedFunctionCallValue($name, $arguments); - static::assertEquals($name, $value->getName()); - static::assertEquals($arguments, $value->getArguments()); - static::assertEquals([$name, $arguments], $value->getValue()); + self::assertEquals($name, $value->getName()); + self::assertEquals($arguments, $value->getArguments()); + self::assertEquals([$name, $arguments], $value->getValue()); } public function testIsMutable(): void @@ -49,30 +50,30 @@ public function testIsMutable(): void // Mutate injected value $arg0->foo = 'bar'; - static::assertEquals($arg0->foo, $value->getArguments()[0]->foo); - static::assertSame($arg0, $value->getArguments()[0]); + self::assertEquals($arg0->foo, $value->getArguments()[0]->foo); + self::assertSame($arg0, $value->getArguments()[0]); - static::assertNotEquals( + self::assertNotEquals( [ new stdClass(), ], - $value->getArguments() + $value->getArguments(), ); - static::assertNotEquals( + self::assertNotEquals( [ 'setUsername', [new stdClass()], ], - $value->getValue() + $value->getValue(), ); } public function testCanBeCastedIntoAString(): void { $value = new ResolvedFunctionCallValue('foo'); - static::assertEquals('', (string) $value); + self::assertEquals('', (string) $value); $value = new ResolvedFunctionCallValue('foo', ['bar']); - static::assertEquals(" 'bar',\n))>", (string) $value); + self::assertEquals(" 'bar',\n))>", (string) $value); } } diff --git a/tests/Definition/Value/UniqueValueTest.php b/tests/Definition/Value/UniqueValueTest.php index 994655047..980a175ad 100644 --- a/tests/Definition/Value/UniqueValueTest.php +++ b/tests/Definition/Value/UniqueValueTest.php @@ -15,22 +15,24 @@ use InvalidArgumentException; use Nelmio\Alice\Definition\ValueInterface; -use const PHP_VERSION_ID; use PHPUnit\Framework\TestCase; use stdClass; +use const PHP_VERSION_ID; /** * @covers \Nelmio\Alice\Definition\Value\UniqueValue + * @internal */ class UniqueValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(UniqueValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(UniqueValue::class, ValueInterface::class, true)); } /** * @dataProvider provideValues + * @param mixed $value */ public function testReadAccessorsReturnPropertiesValues($value): void { @@ -38,8 +40,8 @@ public function testReadAccessorsReturnPropertiesValues($value): void $definition = new UniqueValue($id, $value); - static::assertEquals($id, $definition->getId()); - static::assertEquals($value, $definition->getValue()); + self::assertEquals($id, $definition->getId()); + self::assertEquals($value, $definition->getValue()); } public function testCannotCreateUniqueOfUniqueValue(): void @@ -56,7 +58,7 @@ public function testIsImmutable(): void { $id = 'Nelmio\Entity\User#user0#username'; $value = [ - $arg0 = new stdClass() + $arg0 = new stdClass(), ]; $definition = new UniqueValue($id, $value); @@ -66,7 +68,7 @@ public function testIsImmutable(): void // Mutate returned value $definition->getValue()[0]->foo = 'baz'; - static::assertEquals([new stdClass()], $definition->getValue()); + self::assertEquals([new stdClass()], $definition->getValue()); } public function testImmutableFactories(): void @@ -79,17 +81,17 @@ public function testImmutableFactories(): void $original = new UniqueValue($id, $value); $clone = $original->withValue($newValue); - static::assertInstanceOf(UniqueValue::class, $clone); - static::assertEquals($id, $original->getId()); - static::assertEquals($id, $clone->getId()); - static::assertEquals($value, $original->getValue()); - static::assertEquals($newValue, $clone->getValue()); + self::assertInstanceOf(UniqueValue::class, $clone); + self::assertEquals($id, $original->getId()); + self::assertEquals($id, $clone->getId()); + self::assertEquals($value, $original->getValue()); + self::assertEquals($newValue, $clone->getValue()); } public function testCanBeCastedIntoAString(): void { $value = new UniqueValue('', 'foo'); - static::assertEquals('(unique) \'foo\'', (string) $value); + self::assertEquals('(unique) \'foo\'', (string) $value); $value = new UniqueValue('', new stdClass()); @@ -98,13 +100,13 @@ public function testCanBeCastedIntoAString(): void } else { $expectedStdClass = "(unique) stdClass::__set_state(array(\n))"; } - static::assertEquals($expectedStdClass, (string) $value); + self::assertEquals($expectedStdClass, (string) $value); $value = new UniqueValue('', new DummyValue('foo')); - static::assertEquals('(unique) foo', (string) $value); + self::assertEquals('(unique) foo', (string) $value); } - public function provideValues() + public function provideValues(): iterable { yield 'null value' => [null]; yield 'string value' => ['azerty']; diff --git a/tests/Definition/Value/ValueForCurrentValueTest.php b/tests/Definition/Value/ValueForCurrentValueTest.php index 3f9e92889..f4f14be46 100644 --- a/tests/Definition/Value/ValueForCurrentValueTest.php +++ b/tests/Definition/Value/ValueForCurrentValueTest.php @@ -18,23 +18,24 @@ /** * @covers \Nelmio\Alice\Definition\Value\ValueForCurrentValue + * @internal */ class ValueForCurrentValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(ValueForCurrentValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(ValueForCurrentValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void { $value = new ValueForCurrentValue(); - static::assertEquals('current', $value->getValue()); + self::assertEquals('current', $value->getValue()); } public function testCanBeCastedIntoAString(): void { $value = new ValueForCurrentValue(); - static::assertEquals('current', $value); + self::assertEquals('current', $value); } } diff --git a/tests/Definition/Value/VariableValueTest.php b/tests/Definition/Value/VariableValueTest.php index d341bdea7..de994ce2e 100644 --- a/tests/Definition/Value/VariableValueTest.php +++ b/tests/Definition/Value/VariableValueTest.php @@ -18,12 +18,13 @@ /** * @covers \Nelmio\Alice\Definition\Value\VariableValue + * @internal */ class VariableValueTest extends TestCase { public function testIsAValue(): void { - static::assertTrue(is_a(VariableValue::class, ValueInterface::class, true)); + self::assertTrue(is_a(VariableValue::class, ValueInterface::class, true)); } public function testReadAccessorsReturnPropertiesValues(): void @@ -31,13 +32,13 @@ public function testReadAccessorsReturnPropertiesValues(): void $variable = 'username'; $value = new VariableValue($variable); - static::assertEquals($variable, $value->getValue()); + self::assertEquals($variable, $value->getValue()); } public function testCanBeCastedIntoAString(): void { $value = new VariableValue('username'); - static::assertEquals('$username', $value); + self::assertEquals('$username', $value); } } diff --git a/tests/Faker/GeneratorFactoryTest.php b/tests/Faker/GeneratorFactoryTest.php index 9808ff4f5..73a15af2b 100644 --- a/tests/Faker/GeneratorFactoryTest.php +++ b/tests/Faker/GeneratorFactoryTest.php @@ -23,6 +23,7 @@ * @covers \Nelmio\Alice\Faker\GeneratorFactory * * @group integration + * @internal */ class GeneratorFactoryTest extends TestCase { @@ -32,11 +33,11 @@ public function testAssertGeneratorLocaleMethod(): void try { $this->assertGeneratorLocaleIs('fr_FR', FakerFactory::create()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (Exception $exception) { - static::assertEquals( + self::assertEquals( 'Generator has not been initialised with the locale "fr_FR".', - $exception->getMessage() + $exception->getMessage(), ); } @@ -54,7 +55,7 @@ public function testIfALocaleIsGivenThenCreatesANewGeneratorWithThisLocaleAndThe $expected = FakerFactory::create('fr_FR'); $expected->addProvider(new DummyProvider()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** @@ -75,9 +76,9 @@ public function testEachGeneratorCreatedIsCached(): void { $factory = new GeneratorFactory(FakerFactory::create()); - static::assertSame( + self::assertSame( + $factory->createOrReturnExistingInstance('fr_FR'), $factory->createOrReturnExistingInstance('fr_FR'), - $factory->createOrReturnExistingInstance('fr_FR') ); } @@ -85,9 +86,9 @@ public function testCreatingGeneratorWithInvalidLocaleFallsbackOnFakerDefaultLoc { $factory = new GeneratorFactory(FakerFactory::create()); - static::assertEquals( + self::assertEquals( $factory->createOrReturnExistingInstance('unknown'), - $factory->createOrReturnExistingInstance('en_US') + $factory->createOrReturnExistingInstance('en_US'), ); } @@ -96,7 +97,7 @@ public function testCanReturnDecoratedGenerator(): void $generator = FakerFactory::create(); $factory = new GeneratorFactory($generator); - static::assertSame($generator, $factory->getSeedGenerator()); + self::assertSame($generator, $factory->getSeedGenerator()); } private function assertGeneratorLocaleIs(string $locale, FakerGenerator $generator): void @@ -104,7 +105,7 @@ private function assertGeneratorLocaleIs(string $locale, FakerGenerator $generat $providers = $generator->getProviders(); $regex = sprintf('/^Faker\\\Provider\\\%s\\\.*/', $locale); foreach ($providers as $provider) { - if (preg_match($regex, get_class($provider))) { + if (preg_match($regex, $provider::class)) { return; } } diff --git a/tests/Faker/Provider/AliceProviderTest.php b/tests/Faker/Provider/AliceProviderTest.php index fd11576e8..6db6ff6c6 100644 --- a/tests/Faker/Provider/AliceProviderTest.php +++ b/tests/Faker/Provider/AliceProviderTest.php @@ -20,15 +20,16 @@ /** * @covers \Nelmio\Alice\Faker\Provider\AliceProvider + * @internal */ class AliceProviderTest extends TestCase { public function testIdentityReturnsTheValueUnchanged(): void { - $value = $expected ='foo'; + $value = $expected = 'foo'; $actual = AliceProvider::identity($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCurrentReturnsFixtureCurrentValue(): void @@ -38,7 +39,7 @@ public function testCurrentReturnsFixtureCurrentValue(): void $actual = AliceProvider::current($fixture); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCurrentThrowsAnExceptionIfFixtureHasNoCurrentValue(): void @@ -47,14 +48,14 @@ public function testCurrentThrowsAnExceptionIfFixtureHasNoCurrentValue(): void try { AliceProvider::current($fixture); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (NoValueForCurrentException $exception) { - static::assertEquals( + self::assertEquals( 'No value for \'\' found for the fixture "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } } diff --git a/tests/FileLocator/DefaultFileLocatorTest.php b/tests/FileLocator/DefaultFileLocatorTest.php index a1d978a4a..098a07778 100644 --- a/tests/FileLocator/DefaultFileLocatorTest.php +++ b/tests/FileLocator/DefaultFileLocatorTest.php @@ -20,6 +20,7 @@ /** * @covers \Nelmio\Alice\FileLocator\DefaultFileLocator + * @internal */ class DefaultFileLocatorTest extends TestCase { @@ -27,7 +28,7 @@ class DefaultFileLocatorTest extends TestCase * @var DefaultFileLocator */ private $locator; - + protected function setUp(): void { $this->locator = new DefaultFileLocator(); @@ -35,11 +36,12 @@ protected function setUp(): void public function testIsAFileLocator(): void { - static::assertTrue(is_a(DefaultFileLocator::class, FileLocatorInterface::class, true)); + self::assertTrue(is_a(DefaultFileLocator::class, FileLocatorInterface::class, true)); } /** * @dataProvider provideAbsolutePaths + * @param mixed $path */ public function testCanDetectAbsolutePaths($path): void { @@ -47,22 +49,22 @@ public function testCanDetectAbsolutePaths($path): void $methodReflection = $reflectionObject->getMethod('isAbsolutePath'); $methodReflection->setAccessible(true); - static::assertTrue( + self::assertTrue( $methodReflection->invoke($this->locator, $path), - '->isAbsolutePath() returns true for an absolute path' + '->isAbsolutePath() returns true for an absolute path', ); } public function testCanLocateFiles(): void { - static::assertEquals( + self::assertEquals( __FILE__, - $this->locator->locate('DefaultFileLocatorTest.php', __DIR__) + $this->locator->locate('DefaultFileLocatorTest.php', __DIR__), ); - static::assertEquals( + self::assertEquals( __FILE__, - $this->locator->locate(__DIR__.DIRECTORY_SEPARATOR.'DefaultFileLocatorTest.php') + $this->locator->locate(__DIR__.DIRECTORY_SEPARATOR.'DefaultFileLocatorTest.php'), ); } @@ -90,7 +92,7 @@ public function testLocatingFileThrowsExceptionIfTheFileDoesNotExistsInAbsoluteP $this->locator->locate(__DIR__.'/Fixtures/foobar.xml'); } - public function provideAbsolutePaths() + public function provideAbsolutePaths(): iterable { return [ ['/foo.xml'], diff --git a/tests/FixtureBagTest.php b/tests/FixtureBagTest.php index b13e04cd8..1006e587d 100644 --- a/tests/FixtureBagTest.php +++ b/tests/FixtureBagTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\FixtureBag + * @internal */ class FixtureBagTest extends TestCase { @@ -32,7 +33,7 @@ class FixtureBagTest extends TestCase * @var ReflectionProperty */ private $propRefl; - + protected function setUp(): void { $propRelf = (new ReflectionClass(FixtureBag::class))->getProperty('fixtures'); @@ -46,18 +47,18 @@ public function testReadAccessorsReturnPropertiesValues(): void $fixture = new DummyFixture('foo'); $bag = (new FixtureBag())->with($fixture); - static::assertTrue($bag->has('foo')); - static::assertFalse($bag->has('bar')); + self::assertTrue($bag->has('foo')); + self::assertFalse($bag->has('bar')); - static::assertEquals($fixture, $bag->get('foo')); + self::assertEquals($fixture, $bag->get('foo')); try { $bag->get('bar'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (FixtureNotFoundException $exception) { - static::assertEquals( + self::assertEquals( 'Could not find the fixture "bar".', - $exception->getMessage() + $exception->getMessage(), ); } } @@ -74,10 +75,10 @@ public function testIsImmutable(): void // @phpstan-ignore-next-line $bag->get('foo')->setSpecs(SpecificationBagFactory::create(new NoMethodCall())); - static::assertEquals( + self::assertEquals( (new FixtureBag()) ->with(new MutableFixture('foo', 'Nelmio\Alice\Entity\User', SpecificationBagFactory::create())), - $bag + $bag, ); } @@ -89,17 +90,17 @@ public function testWithersReturnNewModifiedInstance(): void $newBag = $bag->with($fixture); $newBagEmptied = $newBag->without($fixture); - static::assertInstanceOf(FixtureBag::class, $newBag); - static::assertNotSame($newBag, $bag); + self::assertInstanceOf(FixtureBag::class, $newBag); + self::assertNotSame($newBag, $bag); - static::assertEquals(new FixtureBag(), $bag); + self::assertEquals(new FixtureBag(), $bag); $this->assertSameFixtures( [ 'foo' => $fixture, ], - $newBag + $newBag, ); - static::assertEquals(new FixtureBag(), $newBagEmptied); + self::assertEquals(new FixtureBag(), $newBagEmptied); } public function testIfTwoFixturesWithTheSameIdIsAddedThenTheFirstOneWillBeOverridden(): void @@ -109,20 +110,19 @@ public function testIfTwoFixturesWithTheSameIdIsAddedThenTheFirstOneWillBeOverri $bag = (new FixtureBag()) ->with($fixture1) - ->with($fixture2) - ; + ->with($fixture2); $this->assertNotSameFixtures( [ 'foo' => $fixture1, ], - $bag + $bag, ); $this->assertSameFixtures( [ 'foo' => $fixture2, ], - $bag + $bag, ); } @@ -135,30 +135,29 @@ public function testMergeBagsWillReturnANewInstanceWithTheMergedFixtures(): void $bag1 = (new FixtureBag())->with($fixture1); $bag2 = (new FixtureBag()) ->with($fixture2) - ->with($fixture3) - ; + ->with($fixture3); $bag3 = $bag1->mergeWith($bag2); - static::assertInstanceOf(FixtureBag::class, $bag2); + self::assertInstanceOf(FixtureBag::class, $bag2); $this->assertSameFixtures( [ 'foo' => $fixture1, ], - $bag1 + $bag1, ); $this->assertSameFixtures( [ 'foo' => $fixture2, 'bar' => $fixture3, ], - $bag2 + $bag2, ); $this->assertSameFixtures( [ 'foo' => $fixture2, 'bar' => $fixture3, ], - $bag3 + $bag3, ); } @@ -169,15 +168,14 @@ public function testIsIterable(): void $bag = (new FixtureBag()) ->with($fixture1) - ->with($fixture2) - ; + ->with($fixture2); $fixtures = []; foreach ($bag as $key => $value) { $fixtures[$key] = $value; } - static::assertSame($fixtures, $this->propRefl->getValue($bag)); + self::assertSame($fixtures, $this->propRefl->getValue($bag)); } public function testToArray(): void @@ -187,25 +185,24 @@ public function testToArray(): void $bag = (new FixtureBag()) ->with($fixture1) - ->with($fixture2) - ; + ->with($fixture2); - static::assertEquals( + self::assertEquals( [ 'foo' => $fixture1, 'bar' => $fixture2, ], - $bag->toArray() + $bag->toArray(), ); } private function assertSameFixtures(array $expected, FixtureBag $actual): void { - static::assertEquals($expected, $this->propRefl->getValue($actual)); + self::assertEquals($expected, $this->propRefl->getValue($actual)); } private function assertNotSameFixtures(array $expected, FixtureBag $actual): void { - static::assertNotEquals($expected, $this->propRefl->getValue($actual)); + self::assertNotEquals($expected, $this->propRefl->getValue($actual)); } } diff --git a/tests/FixtureBuilder/BareFixtureSetTest.php b/tests/FixtureBuilder/BareFixtureSetTest.php index 9da0d9643..8396f9d2f 100644 --- a/tests/FixtureBuilder/BareFixtureSetTest.php +++ b/tests/FixtureBuilder/BareFixtureSetTest.php @@ -21,6 +21,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\BareFixtureSet + * @internal */ class BareFixtureSetTest extends TestCase { @@ -28,19 +29,19 @@ public function testReadAccessorsReturnPropertiesValues(): void { $set = new BareFixtureSet( $parameters = (new ParameterBag())->with(new Parameter('foo', 'bar')), - $fixtures = (new FixtureBag())->with(new DummyFixture('foo')) + $fixtures = (new FixtureBag())->with(new DummyFixture('foo')), ); - static::assertEquals($parameters, $set->getParameters()); - static::assertEquals($fixtures, $set->getFixtures()); + self::assertEquals($parameters, $set->getParameters()); + self::assertEquals($fixtures, $set->getFixtures()); } /** - * @depends \Nelmio\Alice\ParameterBagTest::testIsImmutable - * @depends \Nelmio\Alice\FixtureBagTest::testIsImmutable + * @depends test\Nelmio\Alice\ParameterBagTest::testIsImmutable + * @depends test\Nelmio\Alice\FixtureBagTest::testIsImmutable */ public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ChainableDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ChainableDenormalizerTest.php index 0c55ef152..87079d8b2 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ChainableDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ChainableDenormalizerTest.php @@ -35,7 +35,7 @@ abstract class ChainableDenormalizerTest extends TestCase public function testIsABuilderMethod(): void { - static::assertInstanceOf(ChainableFixtureDenormalizerInterface::class, $this->denormalizer); + self::assertInstanceOf(ChainableFixtureDenormalizerInterface::class, $this->denormalizer); } abstract public function testCanBuildSimpleFixtures($name); @@ -62,25 +62,25 @@ public function assertCanBuild(string $fixtureId): void { $actual = $this->denormalizer->canDenormalize($fixtureId); - static::assertTrue($actual); + self::assertTrue($actual); } public function assertCannotBuild(string $fixtureId): void { $actual = $this->denormalizer->canDenormalize($fixtureId); - static::assertFalse($actual); + self::assertFalse($actual); } public function assertBuiltResultIsTheSame(string $fixtureId, array $expected): void { - static::assertTrue($this->denormalizer->canDenormalize($fixtureId)); + self::assertTrue($this->denormalizer->canDenormalize($fixtureId)); $actual = $this->denormalizer->denormalize( new FixtureBag(), 'Dummy', $fixtureId, [], - new FlagBag('') + new FlagBag(''), ); $expectedFixtures = new FixtureBag(); @@ -88,12 +88,12 @@ public function assertBuiltResultIsTheSame(string $fixtureId, array $expected): $expectedFixtures = $expectedFixtures->with($item); } - static::assertEquals($expectedFixtures, $actual); + self::assertEquals($expectedFixtures, $actual); } public function markAsInvalidCase(): void { - static::assertTrue(true, 'Invalid scenario'); + self::assertTrue(true, 'Invalid scenario'); } public function createDummyDenormalizer(): FixtureDenormalizerInterface @@ -102,11 +102,8 @@ public function createDummyDenormalizer(): FixtureDenormalizerInterface $decoratedDenormalizerProphecy ->denormalize(Argument::cetera()) ->will( - function ($args) { - return $args[0]->with(FixtureFactory::create($args[2], '')); - } - ) - ; + static fn ($args) => $args[0]->with(FixtureFactory::create($args[2], '')), + ); return $decoratedDenormalizerProphecy->reveal(); } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizerTest.php index 24995ffec..3c89a2e02 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullListNameDenormalizerTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\NullListNameDenormalizer + * @internal */ class NullListNameDenormalizerTest extends ChainableDenormalizerTest { @@ -33,12 +34,12 @@ protected function setUp(): void public function testIsACollectionDenormalizer(): void { - static::assertTrue(is_a(NullListNameDenormalizer::class, CollectionDenormalizer::class, true)); + self::assertTrue(is_a(NullListNameDenormalizer::class, CollectionDenormalizer::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(NullListNameDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(NullListNameDenormalizer::class))->isCloneable()); } public function testDenormalizesListToBuildFixtures(): void @@ -52,11 +53,11 @@ public function testDenormalizesListToBuildFixtures(): void 'user_alice', $className, SpecificationBagFactory::create(), - 'alice' + 'alice', ), - new FlagBag('user_alice') - ) - ) + new FlagBag('user_alice'), + ), + ), ) ->with( new TemplatingFixture( @@ -65,13 +66,12 @@ public function testDenormalizesListToBuildFixtures(): void 'user_bob', $className, SpecificationBagFactory::create(), - 'bob' + 'bob', ), - new FlagBag('user_bob') - ) - ) - ) - ; + new FlagBag('user_bob'), + ), + ), + ); $reference = 'user_{alice, bob}'; $specs = [ 'username' => '', @@ -81,11 +81,12 @@ public function testDenormalizesListToBuildFixtures(): void $denormalizer = new NullListNameDenormalizer(); $actual = $denormalizer->denormalize($fixtures, $className, $reference, $specs, $flags); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } /** * @dataProvider provideSimpleFixtures + * @param mixed $name */ public function testCanBuildSimpleFixtures($name): void { @@ -94,6 +95,7 @@ public function testCanBuildSimpleFixtures($name): void /** * @dataProvider provideListFixtures + * @param mixed $name */ public function testCanBuildListFixtures($name): void { @@ -102,6 +104,7 @@ public function testCanBuildListFixtures($name): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name */ public function testCanBuildMalformedListFixtures($name): void { @@ -110,6 +113,7 @@ public function testCanBuildMalformedListFixtures($name): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name */ public function testCanBuildSegmentFixtures($name): void { @@ -118,6 +122,7 @@ public function testCanBuildSegmentFixtures($name): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name */ public function testCanBuildMalformedSegmentFixtures($name): void { @@ -126,6 +131,8 @@ public function testCanBuildMalformedSegmentFixtures($name): void /** * @dataProvider provideSimpleFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSimpleFixtures($name, $expected): void { @@ -134,6 +141,8 @@ public function testBuildSimpleFixtures($name, $expected): void /** * @dataProvider provideListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildListFixtures($name, $expected): void { @@ -142,6 +151,8 @@ public function testBuildListFixtures($name, $expected): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedListFixtures($name, $expected): void { @@ -150,6 +161,8 @@ public function testBuildMalformedListFixtures($name, $expected): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSegmentFixtures($name, $expected): void { @@ -158,6 +171,8 @@ public function testBuildSegmentFixtures($name, $expected): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedSegmentFixtures($name, $expected): void { diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizerTest.php index fae495f45..6762c1fa6 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/NullRangeNameDenormalizerTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\NullRangeNameDenormalizer + * @internal */ class NullRangeNameDenormalizerTest extends ChainableDenormalizerTest { @@ -34,12 +35,12 @@ protected function setUp(): void public function testIsAChainableDenormalizer(): void { - static::assertTrue(is_a(NullRangeNameDenormalizer::class, ChainableFixtureDenormalizerInterface::class, true)); + self::assertTrue(is_a(NullRangeNameDenormalizer::class, ChainableFixtureDenormalizerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(NullRangeNameDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(NullRangeNameDenormalizer::class))->isCloneable()); } public function testDenormalizesListToBuildFixtures(): void @@ -53,11 +54,11 @@ public function testDenormalizesListToBuildFixtures(): void 'user1', $className, SpecificationBagFactory::create(), - 'alice' + 'alice', ), - new FlagBag('user1') - ) - ) + new FlagBag('user1'), + ), + ), ) ->with( new TemplatingFixture( @@ -66,13 +67,12 @@ public function testDenormalizesListToBuildFixtures(): void 'user2', $className, SpecificationBagFactory::create(), - 'bob' + 'bob', ), - new FlagBag('user2') - ) - ) - ) - ; + new FlagBag('user2'), + ), + ), + ); $reference = 'user{1..2}'; $specs = [ 'username' => '', @@ -82,7 +82,7 @@ public function testDenormalizesListToBuildFixtures(): void $denormalizer = new NullListNameDenormalizer(); $actual = $denormalizer->denormalize($fixtures, $className, $reference, $specs, $flags); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testDenormalizesListWithStepToBuildFixtures(): void @@ -96,13 +96,12 @@ public function testDenormalizesListWithStepToBuildFixtures(): void 'user1', $className, SpecificationBagFactory::create(), - 'alice' + 'alice', ), - new FlagBag('user1') - ) - ) - ) - ; + new FlagBag('user1'), + ), + ), + ); $reference = 'user{1..2, 2}'; $specs = [ 'username' => '', @@ -112,11 +111,12 @@ public function testDenormalizesListWithStepToBuildFixtures(): void $denormalizer = new NullListNameDenormalizer(); $actual = $denormalizer->denormalize($fixtures, $className, $reference, $specs, $flags); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } /** * @dataProvider provideSimpleFixtures + * @param mixed $name */ public function testCanBuildSimpleFixtures($name): void { @@ -125,6 +125,7 @@ public function testCanBuildSimpleFixtures($name): void /** * @dataProvider provideListFixtures + * @param mixed $name */ public function testCanBuildListFixtures($name): void { @@ -133,6 +134,7 @@ public function testCanBuildListFixtures($name): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name */ public function testCanBuildMalformedListFixtures($name): void { @@ -141,6 +143,7 @@ public function testCanBuildMalformedListFixtures($name): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name */ public function testCanBuildSegmentFixtures($name): void { @@ -149,6 +152,7 @@ public function testCanBuildSegmentFixtures($name): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name */ public function testCanBuildMalformedSegmentFixtures($name): void { @@ -157,6 +161,8 @@ public function testCanBuildMalformedSegmentFixtures($name): void /** * @dataProvider provideSimpleFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSimpleFixtures($name, $expected): void { @@ -165,6 +171,8 @@ public function testBuildSimpleFixtures($name, $expected): void /** * @dataProvider provideListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildListFixtures($name, $expected): void { @@ -173,6 +181,8 @@ public function testBuildListFixtures($name, $expected): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedListFixtures($name, $expected): void { @@ -181,6 +191,8 @@ public function testBuildMalformedListFixtures($name, $expected): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSegmentFixtures($name, $expected): void { @@ -189,6 +201,8 @@ public function testBuildSegmentFixtures($name, $expected): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedSegmentFixtures($name, $expected): void { diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizerTest.php index 1e80b93e6..6681eb85e 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/ReferenceRangeNameDenormalizerTest.php @@ -36,6 +36,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\ReferenceRangeNameDenormalizer + * @internal */ class ReferenceRangeNameDenormalizerTest extends ChainableDenormalizerTest { @@ -45,18 +46,18 @@ protected function setUp(): void { $this->denormalizer = new ReferenceRangeNameDenormalizer( new DummySpecificationBagDenormalizer(), - new DummyFlagParser() + new DummyFlagParser(), ); } public function testIsAChainableDenormalizer(): void { - static::assertTrue(is_a(ReferenceRangeNameDenormalizer::class, ChainableFixtureDenormalizerInterface::class, true)); + self::assertTrue(is_a(ReferenceRangeNameDenormalizer::class, ChainableFixtureDenormalizerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ReferenceRangeNameDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ReferenceRangeNameDenormalizer::class))->isCloneable()); } public function testCannotDenormalizeFixtureIfHasNoFlagParser(): void @@ -79,10 +80,10 @@ public function testTemplateFlagsAreProperlyParsed(): void new SimpleFixture( 'userDetails', 'Nelmio\Alice\Entity\UserDetails', - new SpecificationBag(null, new PropertyBag(), new MethodCallBag()) + new SpecificationBag(null, new PropertyBag(), new MethodCallBag()), ), - new FlagBag('userDetails') - ) + new FlagBag('userDetails'), + ), ); $fixtures = (new FixtureBag())->with($valueForCurrent); @@ -96,8 +97,7 @@ public function testTemplateFlagsAreProperlyParsed(): void $flagParserProphecy = $this->prophesize(FlagParserInterface::class); $flagParserProphecy ->parse($reference) - ->willReturn($parsedFlags) - ; + ->willReturn($parsedFlags); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -105,8 +105,7 @@ public function testTemplateFlagsAreProperlyParsed(): void $expectedSpecs = new SpecificationBag(null, new PropertyBag(), new MethodCallBag()); $specsDenormalizerProphecy ->denormalize(Argument::type(SimpleFixture::class), $flagParser, $specs) - ->willReturn($expectedSpecs) - ; + ->willReturn($expectedSpecs); /** @var SpecificationsDenormalizerInterface $specsDenormalizer */ $specsDenormalizer = $specsDenormalizerProphecy->reveal(); @@ -120,14 +119,14 @@ public function testTemplateFlagsAreProperlyParsed(): void $fixtureName, $className, $expectedSpecs, - $valueForCurrent + $valueForCurrent, ), - $parsedFlags - ) - ) + $parsedFlags, + ), + ), ); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); $specsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -140,10 +139,10 @@ public function testWildcardIsProperlyParsed(): void new SimpleFixture( 'userDetails1', 'Nelmio\Alice\Entity\UserDetails', - new SpecificationBag(null, new PropertyBag(), new MethodCallBag()) + new SpecificationBag(null, new PropertyBag(), new MethodCallBag()), ), - new FlagBag('userDetails1') - ) + new FlagBag('userDetails1'), + ), ); $userDetails2 = new TemplatingFixture( @@ -151,10 +150,10 @@ public function testWildcardIsProperlyParsed(): void new SimpleFixture( 'userDetails2', 'Nelmio\Alice\Entity\UserDetails', - new SpecificationBag(null, new PropertyBag(), new MethodCallBag()) + new SpecificationBag(null, new PropertyBag(), new MethodCallBag()), ), - new FlagBag('userDetails2') - ) + new FlagBag('userDetails2'), + ), ); $fixtures = (new FixtureBag())->with($userDetails1)->with($userDetails2); @@ -171,8 +170,7 @@ public function testWildcardIsProperlyParsed(): void $flagParserProphecy = $this->prophesize(FlagParserInterface::class); $flagParserProphecy ->parse($reference) - ->willReturn($parsedFlags) - ; + ->willReturn($parsedFlags); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -180,8 +178,7 @@ public function testWildcardIsProperlyParsed(): void $expectedSpecs = new SpecificationBag(null, new PropertyBag(), new MethodCallBag()); $specsDenormalizerProphecy ->denormalize(Argument::type(SimpleFixture::class), $flagParser, $specs) - ->willReturn($expectedSpecs) - ; + ->willReturn($expectedSpecs); /** @var SpecificationsDenormalizerInterface $specsDenormalizer */ $specsDenormalizer = $specsDenormalizerProphecy->reveal(); @@ -195,11 +192,11 @@ public function testWildcardIsProperlyParsed(): void $fixtureName1, $className, $expectedSpecs, - $userDetails1 + $userDetails1, ), - $fixtureFlags1 - ) - ) + $fixtureFlags1, + ), + ), )->with( new TemplatingFixture( new SimpleFixtureWithFlags( @@ -207,14 +204,14 @@ public function testWildcardIsProperlyParsed(): void $fixtureName2, $className, $expectedSpecs, - $userDetails2 + $userDetails2, ), - $fixtureFlags2 - ) - ) + $fixtureFlags2, + ), + ), ); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); $specsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(2); @@ -232,8 +229,7 @@ public function testWildcardWithNoMatchesThrowsFixtureNotFoundException(): void $flagParserProphecy = $this->prophesize(FlagParserInterface::class); $flagParserProphecy ->parse($reference) - ->willReturn($parsedFlags) - ; + ->willReturn($parsedFlags); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -254,6 +250,7 @@ public function testWildcardWithNoMatchesThrowsFixtureNotFoundException(): void /** * @dataProvider provideSimpleFixtures + * @param mixed $name */ public function testCanBuildSimpleFixtures($name): void { @@ -262,6 +259,7 @@ public function testCanBuildSimpleFixtures($name): void /** * @dataProvider provideListFixtures + * @param mixed $name */ public function testCanBuildListFixtures($name): void { @@ -270,6 +268,7 @@ public function testCanBuildListFixtures($name): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name */ public function testCanBuildMalformedListFixtures($name): void { @@ -278,6 +277,7 @@ public function testCanBuildMalformedListFixtures($name): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name */ public function testCanBuildSegmentFixtures($name): void { @@ -286,6 +286,7 @@ public function testCanBuildSegmentFixtures($name): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name */ public function testCanBuildMalformedSegmentFixtures($name): void { @@ -294,6 +295,8 @@ public function testCanBuildMalformedSegmentFixtures($name): void /** * @dataProvider provideSimpleFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSimpleFixtures($name, $expected): void { @@ -302,6 +305,8 @@ public function testBuildSimpleFixtures($name, $expected): void /** * @dataProvider provideListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildListFixtures($name, $expected): void { @@ -310,6 +315,8 @@ public function testBuildListFixtures($name, $expected): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedListFixtures($name, $expected): void { @@ -318,6 +325,8 @@ public function testBuildMalformedListFixtures($name, $expected): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSegmentFixtures($name, $expected): void { @@ -326,6 +335,8 @@ public function testBuildSegmentFixtures($name, $expected): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedSegmentFixtures($name, $expected): void { diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizerTest.php index 609ad436f..28befe1cb 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizerTest.php @@ -35,27 +35,28 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\SimpleDenormalizer + * @internal */ class SimpleDenormalizerTest extends ChainableDenormalizerTest { use ProphecyTrait; - + protected function setUp(): void { $this->denormalizer = new SimpleDenormalizer( new DummySpecificationBagDenormalizer(), - new DummyFlagParser() + new DummyFlagParser(), ); } public function testIsAChainableDenormalizer(): void { - static::assertTrue(is_a(SimpleDenormalizer::class, ChainableFixtureDenormalizerInterface::class, true)); + self::assertTrue(is_a(SimpleDenormalizer::class, ChainableFixtureDenormalizerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleDenormalizer::class))->isCloneable()); } public function testCannotDenormalizeFixtureIfHasNoFlagParser(): void @@ -84,8 +85,7 @@ public function testDenormalizesValuesToCreateANewFixtureObjectAndAddItToTheList $flagParserProphecy = $this->prophesize(FlagParserInterface::class); $flagParserProphecy ->parse($reference) - ->willReturn(new FlagBag('user_base')) - ; + ->willReturn(new FlagBag('user_base')); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -93,8 +93,7 @@ public function testDenormalizesValuesToCreateANewFixtureObjectAndAddItToTheList $expectedSpecs = new SpecificationBag(null, new PropertyBag(), new MethodCallBag()); $specsDenormalizerProphecy ->denormalize(Argument::type(SimpleFixture::class), $flagParser, $specs) - ->willReturn($expectedSpecs) - ; + ->willReturn($expectedSpecs); /** @var SpecificationsDenormalizerInterface $specsDenormalizer */ $specsDenormalizer = $specsDenormalizerProphecy->reveal(); @@ -107,14 +106,14 @@ public function testDenormalizesValuesToCreateANewFixtureObjectAndAddItToTheList new SimpleFixture( $reference, $className, - $expectedSpecs + $expectedSpecs, ), - new FlagBag('user_base') - ) - ) + new FlagBag('user_base'), + ), + ), ); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); $specsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -134,9 +133,8 @@ public function testDenormalizationRemovesFlagsInIds(): void $flagParserProphecy ->parse($reference) ->willReturn( - (new FlagBag('user_base'))->withFlag(new TemplateFlag()) - ) - ; + (new FlagBag('user_base'))->withFlag(new TemplateFlag()), + ); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -144,8 +142,7 @@ public function testDenormalizationRemovesFlagsInIds(): void $expectedSpecs = new SpecificationBag(null, new PropertyBag(), new MethodCallBag()); $specsDenormalizerProphecy ->denormalize(Argument::type(SimpleFixture::class), $flagParser, $specs) - ->willReturn($expectedSpecs) - ; + ->willReturn($expectedSpecs); /** @var SpecificationsDenormalizerInterface $specsDenormalizer */ $specsDenormalizer = $specsDenormalizerProphecy->reveal(); @@ -158,16 +155,16 @@ public function testDenormalizationRemovesFlagsInIds(): void new SimpleFixture( 'user_base', $className, - $expectedSpecs + $expectedSpecs, ), (new FlagBag('user_base')) ->withFlag(new ElementFlag('injected_flag')) - ->withFlag(new TemplateFlag()) - ) - ) + ->withFlag(new TemplateFlag()), + ), + ), ); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); $specsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -175,6 +172,7 @@ public function testDenormalizationRemovesFlagsInIds(): void /** * @dataProvider provideSimpleFixtures + * @param mixed $name */ public function testCanBuildSimpleFixtures($name): void { @@ -183,6 +181,7 @@ public function testCanBuildSimpleFixtures($name): void /** * @dataProvider provideListFixtures + * @param mixed $name */ public function testCanBuildListFixtures($name): void { @@ -191,6 +190,7 @@ public function testCanBuildListFixtures($name): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name */ public function testCanBuildMalformedListFixtures($name): void { @@ -199,6 +199,7 @@ public function testCanBuildMalformedListFixtures($name): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name */ public function testCanBuildSegmentFixtures($name): void { @@ -207,6 +208,7 @@ public function testCanBuildSegmentFixtures($name): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name */ public function testCanBuildMalformedSegmentFixtures($name): void { @@ -215,6 +217,8 @@ public function testCanBuildMalformedSegmentFixtures($name): void /** * @dataProvider provideSimpleFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSimpleFixtures($name, $expected): void { @@ -223,6 +227,8 @@ public function testBuildSimpleFixtures($name, $expected): void /** * @dataProvider provideListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildListFixtures($name, $expected): void { @@ -231,6 +237,8 @@ public function testBuildListFixtures($name, $expected): void /** * @dataProvider provideMalformedListFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedListFixtures($name, $expected): void { @@ -239,6 +247,8 @@ public function testBuildMalformedListFixtures($name, $expected): void /** * @dataProvider provideSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildSegmentFixtures($name, $expected): void { @@ -247,6 +257,8 @@ public function testBuildSegmentFixtures($name, $expected): void /** * @dataProvider provideMalformedSegmentFixtures + * @param mixed $name + * @param mixed $expected */ public function testBuildMalformedSegmentFixtures($name, $expected): void { diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistryTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistryTest.php index 5d34b5363..57bc18c3e 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistryTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistryTest.php @@ -33,6 +33,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\FixtureDenormalizerRegistry + * @internal */ class FixtureDenormalizerRegistryTest extends TestCase { @@ -42,7 +43,7 @@ class FixtureDenormalizerRegistryTest extends TestCase * @var ReflectionProperty */ private $propRefl; - + protected function setUp(): void { $propRelf = (new ReflectionClass(FixtureDenormalizerRegistry::class))->getProperty('denormalizers'); @@ -53,7 +54,7 @@ protected function setUp(): void public function testIsADenormalizer(): void { - static::assertTrue(is_a(FixtureDenormalizerRegistry::class, FixtureDenormalizerInterface::class, true)); + self::assertTrue(is_a(FixtureDenormalizerRegistry::class, FixtureDenormalizerInterface::class, true)); } public function testOnlyAcceptsChainableFixtureDenormalizers(): void @@ -62,23 +63,23 @@ public function testOnlyAcceptsChainableFixtureDenormalizers(): void try { new FixtureDenormalizerRegistry($flagParser, [new stdClass()]); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (TypeError $error) { - static::assertEquals( + self::assertEquals( 'Expected denormalizer 0 to be a "'.ChainableFixtureDenormalizerInterface::class.'". Got ' .'"stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); } try { new FixtureDenormalizerRegistry($flagParser, [1]); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (TypeError $error) { - static::assertEquals( + self::assertEquals( 'Expected denormalizer 0 to be a "'.ChainableFixtureDenormalizerInterface::class.'". Got ' .'"integer" instead.', - $error->getMessage() + $error->getMessage(), ); } } @@ -103,16 +104,16 @@ public function testInjectsParserInParserAwareDenormalizersAndItselfInDenormaliz $chainableDenormalizer1, $flagParserAwareDenormalizer, $denormalizerAwareDenormalizer, - ] + ], ); $actualDenormalizers = $this->propRefl->getValue($denormalizer); - static::assertCount(3, $actualDenormalizers); - static::assertSame($chainableDenormalizer1, $actualDenormalizers[0]); - static::assertNotSame($flagParserAwareDenormalizer, $actualDenormalizers[1]); - static::assertNull($flagParserAwareDenormalizer->parser); - static::assertNotNull($actualDenormalizers[1]->parser); - static::assertSame($denormalizer, $denormalizerAwareDenormalizer->denormalizer); + self::assertCount(3, $actualDenormalizers); + self::assertSame($chainableDenormalizer1, $actualDenormalizers[0]); + self::assertNotSame($flagParserAwareDenormalizer, $actualDenormalizers[1]); + self::assertNull($flagParserAwareDenormalizer->parser); + self::assertNotNull($actualDenormalizers[1]->parser); + self::assertSame($denormalizer, $denormalizerAwareDenormalizer->denormalizer); } public function testUsesTheFirstSuitableDenormalizer(): void @@ -156,11 +157,11 @@ public function testUsesTheFirstSuitableDenormalizer(): void $chainableDenormalizer1, $chainableDenormalizer2, $chainableDenormalizer3, - ] + ], ); $actual = $denormalizer->denormalize($builtFixtures, $className, $reference, $specs, $flags); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $chainableDenormalizer1Prophecy->canDenormalize(Argument::any())->shouldHaveBeenCalledTimes(1); $chainableDenormalizer2Prophecy->canDenormalize(Argument::any())->shouldHaveBeenCalledTimes(1); $chainableDenormalizer2Prophecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/Reference.php b/tests/FixtureBuilder/Denormalizer/Fixture/Reference.php index 44f4d4b4c..439aea1ec 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/Reference.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/Reference.php @@ -41,7 +41,7 @@ private function __construct() 'user100.or_something/else', [ FixtureFactory::create('user100.or_something/else', null), - ] + ], ], 'simple with flag' => [ 'user (dummy_flag)', @@ -258,7 +258,7 @@ public static function create(string $id, $valueForCurrent) $id, 'Dummy', SpecificationBagFactory::create(), - $valueForCurrent + $valueForCurrent, ); } @@ -270,10 +270,10 @@ public static function createTemplating(string $id, $valueForCurrent) $id, 'Dummy', SpecificationBagFactory::create(), - $valueForCurrent + $valueForCurrent, ), - new FlagBag($id) - ) + new FlagBag($id), + ), ); } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizerTest.php index f64888fa0..bd96320c6 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizerTest.php @@ -27,6 +27,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SimpleFixtureBagDenormalizer + * @internal */ class SimpleFixtureBagDenormalizerTest extends TestCase { @@ -34,12 +35,12 @@ class SimpleFixtureBagDenormalizerTest extends TestCase public function testIsAFixtureBagDenormalizer(): void { - static::assertTrue(is_a(SimpleFixtureBagDenormalizer::class, FixtureBagDenormalizerInterface::class, true)); + self::assertTrue(is_a(SimpleFixtureBagDenormalizer::class, FixtureBagDenormalizerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleFixtureBagDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleFixtureBagDenormalizer::class))->isCloneable()); } public function testDenormalizesASetOfDataIntoAFixtureBag(): void @@ -83,13 +84,11 @@ public function testDenormalizesASetOfDataIntoAFixtureBag(): void $userFlags = (new FlagBag('Nelmio\Alice\Entity\User'))->withFlag(new ElementFlag('dummy_flag')); $flagParserProphecy ->parse('Nelmio\Entity\User (dummy_flag)') - ->willReturn($userFlags) - ; + ->willReturn($userFlags); $ownerFlags = new FlagBag('Nelmio\Entity\Owner'); $flagParserProphecy ->parse('Nelmio\Entity\Owner') - ->willReturn(new FlagBag('Nelmio\Entity\Owner')) - ; + ->willReturn(new FlagBag('Nelmio\Entity\Owner')); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -102,12 +101,11 @@ public function testDenormalizesASetOfDataIntoAFixtureBag(): void 'Nelmio\Alice\Entity\User', 'user_alice', [ - 'username' => 'alice' + 'username' => 'alice', ], - $userFlags + $userFlags, ) - ->willReturn($bag1) - ; + ->willReturn($bag1); $bag2 = $bag1->with($fixture2); $fixtureDenormalizerProphecy ->denormalize( @@ -115,12 +113,11 @@ public function testDenormalizesASetOfDataIntoAFixtureBag(): void 'Nelmio\Alice\Entity\User', 'user_bob', [ - 'username' => 'bob' + 'username' => 'bob', ], - $userFlags + $userFlags, ) - ->willReturn($bag2) - ; + ->willReturn($bag2); $bag3 = $bag2->with($fixture3); $fixtureDenormalizerProphecy ->denormalize( @@ -128,10 +125,9 @@ public function testDenormalizesASetOfDataIntoAFixtureBag(): void 'Nelmio\Entity\Owner', 'owner1', [], - $ownerFlags + $ownerFlags, ) - ->willReturn($bag3) - ; + ->willReturn($bag3); $bag4 = $bag3->with($fixture4); $fixtureDenormalizerProphecy ->denormalize( @@ -139,17 +135,16 @@ public function testDenormalizesASetOfDataIntoAFixtureBag(): void 'Nelmio\Entity\Owner', 'owner2', [], - $ownerFlags + $ownerFlags, ) - ->willReturn($bag4) - ; + ->willReturn($bag4); /** @var FixtureDenormalizerInterface $fixtureDenormalizer */ $fixtureDenormalizer = $fixtureDenormalizerProphecy->reveal(); $denormalizer = new SimpleFixtureBagDenormalizer($fixtureDenormalizer, $flagParser); $actual = $denormalizer->denormalize($data); - static::assertSame($bag4, $actual); + self::assertSame($bag4, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); $fixtureDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(4); @@ -165,8 +160,7 @@ public function testThrowsAnExceptionIfInvalidRawDataFixtureSetGiven(): void $userFlags = new FlagBag('Nelmio\Alice\Entity\User'); $flagParserProphecy ->parse('Nelmio\Entity\User') - ->willReturn($userFlags) - ; + ->willReturn($userFlags); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -175,11 +169,11 @@ public function testThrowsAnExceptionIfInvalidRawDataFixtureSetGiven(): void try { $denormalizer->denormalize($data); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InvalidArgumentException $exception) { - static::assertSame( + self::assertSame( 'Expected an array for the class "Nelmio\Entity\User", found "string" instead.', - $exception->getMessage() + $exception->getMessage(), ); } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizerTest.php index a4aa45805..ca72e2a4f 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Arguments/SimpleArgumentsDenormalizerTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Arguments\SimpleArgumentsDenormalizer + * @internal */ class SimpleArgumentsDenormalizerTest extends TestCase { @@ -32,7 +33,7 @@ class SimpleArgumentsDenormalizerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleArgumentsDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleArgumentsDenormalizer::class))->isCloneable()); } public function testParsesStringKeys(): void @@ -47,17 +48,14 @@ public function testParsesStringKeys(): void $flagParserProphecy ->parse('2 (dummy_flag)') ->willReturn( - $arg2Flags = (new FlagBag('2'))->withFlag(new ElementFlag('dummy_flag')) - ) - ; + $arg2Flags = (new FlagBag('2'))->withFlag(new ElementFlag('dummy_flag')), + ); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); $valueDenormalizerProphecy = $this->prophesize(ValueDenormalizerInterface::class); $valueDenormalizerProphecy->denormalize(Argument::cetera())->will( - function ($args) { - return $args[2]; - } + static fn ($args) => $args[2], ); /** @var ValueDenormalizerInterface $valueDenormalizer */ $valueDenormalizer = $valueDenormalizerProphecy->reveal(); @@ -83,21 +81,18 @@ public function testDenormalizesEachArgument(): void $flagParserProphecy ->parse(Argument::any()) ->will( - function ($args) { + static function ($args) { preg_match('/(?.+?)\s\(.+\)/', $args[0], $matches); return new FlagBag($matches['val']); - } - ) - ; + }, + ); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); $valueDenormalizerProphecy = $this->prophesize(ValueDenormalizerInterface::class); $valueDenormalizerProphecy->denormalize(Argument::cetera())->will( - function ($args) { - return $args[2]; - } + static fn ($args) => $args[2], ); /** @var ValueDenormalizerInterface $valueDenormalizer */ $valueDenormalizer = $valueDenormalizerProphecy->reveal(); @@ -105,7 +100,7 @@ function ($args) { $denormalizer = new SimpleArgumentsDenormalizer($valueDenormalizer); $result = $denormalizer->denormalize($fixture, $flagParser, $arguments); - static::assertEquals( + self::assertEquals( [ 0 => '', 'foo' => '', @@ -113,7 +108,7 @@ function ($args) { 3 => 1000, 4 => 500, ], - $result + $result, ); $valueDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(5); diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizerTest.php index ec7a1030d..aa071dd6c 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/CallsWithFlagsDenormalizerTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Calls\CallsWithFlagsDenormalizer + * @internal */ class CallsWithFlagsDenormalizerTest extends TestCase { @@ -37,7 +38,7 @@ class CallsWithFlagsDenormalizerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(CallsWithFlagsDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(CallsWithFlagsDenormalizer::class))->isCloneable()); } public function testCannotAcceptInvalidMethodHandlers(): void @@ -48,7 +49,7 @@ public function testCannotAcceptInvalidMethodHandlers(): void new FakeCallsDenormalizer(), [ new stdClass(), - ] + ], ); } @@ -73,19 +74,18 @@ public function testDenomalizeTheCallsWithoutAnyMethodHandler(): void $fixture, $flagParser, 'parsed_method', - $unparsedArguments + $unparsedArguments, ) ->willReturn( - $expected = new FakeMethodCall() - ) - ; + $expected = new FakeMethodCall(), + ); /** @var CallsDenormalizerInterface $callsDenormalizer */ $callsDenormalizer = $callsDenormalizerProphecy->reveal(); $denormalizer = new CallsWithFlagsDenormalizer($callsDenormalizer, []); $actual = $denormalizer->denormalize($fixture, $flagParser, $unparsedMethod, $unparsedArguments); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); $callsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -107,16 +107,15 @@ public function testDenormalizesMethodMethodHandlers(): void ->willReturn( $flags = (new FlagBag('parsed_method')) ->withFlag( - $dummyFlag = new DummyFlag() + $dummyFlag = new DummyFlag(), ) ->withFlag( - $elem1Flag = new ElementFlag('elem1') + $elem1Flag = new ElementFlag('elem1'), ) ->withFlag( - $elem2Flag = new ElementFlag('elem2') - ) - ) - ; + $elem2Flag = new ElementFlag('elem2'), + ), + ); /** @var FlagParserInterface $flagParser */ $flagParser = $flagParserProphecy->reveal(); @@ -126,43 +125,37 @@ public function testDenormalizesMethodMethodHandlers(): void $fixture, $flagParser, 'parsed_method', - $unparsedArguments + $unparsedArguments, ) ->willReturn( - $denormalizedCall = new FakeMethodCall() - ) - ; + $denormalizedCall = new FakeMethodCall(), + ); /** @var CallsDenormalizerInterface $callsDenormalizer */ $callsDenormalizer = $callsDenormalizerProphecy->reveal(); - $returnMethodUnchanged = function (array $args) { - return $args[0]; - }; + $returnMethodUnchanged = static fn (array $args) => $args[0]; $dummyFlagMethodHandlerProphecy = $this->prophesize(MethodFlagHandler::class); $dummyFlagMethodHandlerProphecy ->handleMethodFlags( $denormalizedCall, - $dummyFlag + $dummyFlag, ) ->willReturn( - $methodAfterDummyFlagMethodHandler = new SimpleMethodCall('method_after_dummy_flag_method_handler') - ) - ; + $methodAfterDummyFlagMethodHandler = new SimpleMethodCall('method_after_dummy_flag_method_handler'), + ); $dummyFlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterDummyFlagMethodHandler, - $elem1Flag + $elem1Flag, ) - ->will($returnMethodUnchanged) - ; + ->will($returnMethodUnchanged); $dummyFlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterDummyFlagMethodHandler, - $elem2Flag + $elem2Flag, ) - ->will($returnMethodUnchanged) - ; + ->will($returnMethodUnchanged); /** @var MethodFlagHandler $dummyFlagMethodHandler */ $dummyFlagMethodHandler = $dummyFlagMethodHandlerProphecy->reveal(); @@ -170,26 +163,23 @@ public function testDenormalizesMethodMethodHandlers(): void $elem1FlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterDummyFlagMethodHandler, - $dummyFlag + $dummyFlag, ) - ->will($returnMethodUnchanged) - ; + ->will($returnMethodUnchanged); $elem1FlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterDummyFlagMethodHandler, - $elem1Flag + $elem1Flag, ) ->willReturn( - $methodAfterElem1FlagMethodHandler = new SimpleMethodCall('method_after_elem1_flag_method_handler') - ) - ; + $methodAfterElem1FlagMethodHandler = new SimpleMethodCall('method_after_elem1_flag_method_handler'), + ); $elem1FlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterElem1FlagMethodHandler, - $elem2Flag + $elem2Flag, ) - ->will($returnMethodUnchanged) - ; + ->will($returnMethodUnchanged); /** @var MethodFlagHandler $elem1FlagMethodHandler */ $elem1FlagMethodHandler = $elem1FlagMethodHandlerProphecy->reveal(); @@ -197,24 +187,21 @@ public function testDenormalizesMethodMethodHandlers(): void $elem2FlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterElem1FlagMethodHandler, - $dummyFlag + $dummyFlag, ) - ->will($returnMethodUnchanged) - ; + ->will($returnMethodUnchanged); $elem2FlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterElem1FlagMethodHandler, - $elem1Flag + $elem1Flag, ) - ->will($returnMethodUnchanged) - ; + ->will($returnMethodUnchanged); $elem2FlagMethodHandlerProphecy ->handleMethodFlags( $methodAfterElem1FlagMethodHandler, - $elem2Flag + $elem2Flag, ) - ->will($returnMethodUnchanged) - ; + ->will($returnMethodUnchanged); /** @var MethodFlagHandler $elem2FlagMethodHandler */ $elem2FlagMethodHandler = $elem2FlagMethodHandlerProphecy->reveal(); @@ -226,11 +213,11 @@ public function testDenormalizesMethodMethodHandlers(): void $dummyFlagMethodHandler, $elem1FlagMethodHandler, $elem2FlagMethodHandler, - ] + ], ); $actual = $denormalizer->denormalize($fixture, $flagParser, $unparsedMethod, $unparsedArguments); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizerTest.php index 822eae2ae..923c43fed 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/FunctionDenormalizerTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Calls\FunctionDenormalizer + * @internal */ class FunctionDenormalizerTest extends TestCase { @@ -37,7 +38,7 @@ class FunctionDenormalizerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FunctionDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FunctionDenormalizer::class))->isCloneable()); } public function testDenormalizesASimpleMethodCall(): void @@ -55,8 +56,7 @@ public function testDenormalizesASimpleMethodCall(): void $argumentsDenormalizerProphecy = $this->prophesize(ArgumentsDenormalizerInterface::class); $argumentsDenormalizerProphecy ->denormalize($fixture, $flagParser, $unparsedArguments) - ->willReturn($parsedArguments = [new stdClass()]) - ; + ->willReturn($parsedArguments = [new stdClass()]); /** @var ArgumentsDenormalizerInterface $argumentsDenormalizer */ $argumentsDenormalizer = $argumentsDenormalizerProphecy->reveal(); @@ -65,9 +65,7 @@ public function testDenormalizesASimpleMethodCall(): void $denormalizer = new FunctionDenormalizer($argumentsDenormalizer); $actual = $denormalizer->denormalize($fixture, $flagParser, $method, $unparsedArguments); - static::assertEquals($expected, $actual); - - + self::assertEquals($expected, $actual); $argumentsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -86,22 +84,21 @@ public function testCanDenormalizeStaticFactoriesConstructor(): void $argumentsDenormalizerProphecy = $this->prophesize(ArgumentsDenormalizerInterface::class); $argumentsDenormalizerProphecy ->denormalize($fixture, $flagParser, $unparsedArguments) - ->willReturn($parsedArguments = [new stdClass()]) - ; + ->willReturn($parsedArguments = [new stdClass()]); /** @var ArgumentsDenormalizerInterface $argumentsDenormalizer */ $argumentsDenormalizer = $argumentsDenormalizerProphecy->reveal(); $expected = new MethodCallWithReference( new StaticReference('Nelmio\Entity\UserFactory'), 'create', - $parsedArguments + $parsedArguments, ); $denormalizer = new FunctionDenormalizer($argumentsDenormalizer); $actual = $denormalizer->denormalize($fixture, $flagParser, $method, $unparsedArguments); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCanDenormalizeNonStaticFactoryConstructor(): void @@ -118,22 +115,21 @@ public function testCanDenormalizeNonStaticFactoryConstructor(): void $argumentsDenormalizerProphecy = $this->prophesize(ArgumentsDenormalizerInterface::class); $argumentsDenormalizerProphecy ->denormalize($fixture, $flagParser, $unparsedArguments) - ->willReturn($parsedArguments = [new stdClass()]) - ; + ->willReturn($parsedArguments = [new stdClass()]); /** @var ArgumentsDenormalizerInterface $argumentsDenormalizer */ $argumentsDenormalizer = $argumentsDenormalizerProphecy->reveal(); $expected = new MethodCallWithReference( new InstantiatedReference('nelmio.entity.user_factory'), 'create', - $parsedArguments + $parsedArguments, ); $denormalizer = new FunctionDenormalizer($argumentsDenormalizer); $actual = $denormalizer->denormalize($fixture, $flagParser, $method, $unparsedArguments); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsExceptionIfInvalidConstructor(): void diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandlerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandlerTest.php index beac6c794..dc9100c46 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandlerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/ConfiguratorFlagHandlerTest.php @@ -22,12 +22,13 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Calls\MethodFlagHandler\ConfiguratorFlagHandler + * @internal */ class ConfiguratorFlagHandlerTest extends TestCase { public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ConfiguratorFlagHandler::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ConfiguratorFlagHandler::class))->isCloneable()); } public function testCreatesAnOptionalCallIfFlagIsAnOptionalFlagIs(): void @@ -40,7 +41,7 @@ public function testCreatesAnOptionalCallIfFlagIsAnOptionalFlagIs(): void $actual = $handler->handleMethodFlags($call, new ConfiguratorFlag()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testLeavesTheFunctionUnchangedIfFlagIsNotAnOptionalFlag(): void @@ -55,6 +56,6 @@ public function testLeavesTheFunctionUnchangedIfFlagIsNotAnOptionalFlag(): void $actual = $handler->handleMethodFlags($call, $flag); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandlerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandlerTest.php index 2d294b62f..984f16459 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandlerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Calls/MethodFlagHandler/OptionalFlagHandlerTest.php @@ -22,12 +22,13 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Calls\MethodFlagHandler\OptionalFlagHandler + * @internal */ class OptionalFlagHandlerTest extends TestCase { public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(OptionalFlagHandler::class))->isCloneable()); + self::assertFalse((new ReflectionClass(OptionalFlagHandler::class))->isCloneable()); } public function testCreatesAnOptionalCallIfFlagIsAnOptionalFlagIs(): void @@ -42,7 +43,7 @@ public function testCreatesAnOptionalCallIfFlagIsAnOptionalFlagIs(): void $actual = $handler->handleMethodFlags($call, $flag); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testLeavesTheFunctionUnchangedIfFlagIsNotAnOptionalFlag(): void @@ -57,6 +58,6 @@ public function testLeavesTheFunctionUnchangedIfFlagIsNotAnOptionalFlag(): void $actual = $handler->handleMethodFlags($call, $flag); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizerTest.php index 5218655ad..e45765103 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/ConstructorDenormalizerTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Constructor\ConstructorDenormalizer + * @internal */ class ConstructorDenormalizerTest extends TestCase { @@ -31,7 +32,7 @@ class ConstructorDenormalizerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ConstructorDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ConstructorDenormalizer::class))->isCloneable()); } public function testDenormalizesInputAsAConstructorMethod(): void @@ -43,21 +44,20 @@ public function testDenormalizesInputAsAConstructorMethod(): void $argumentsDenormalizerProphecy = $this->prophesize(ArgumentsDenormalizerInterface::class); $argumentsDenormalizerProphecy ->denormalize($fixture, $flagParser, $arguments) - ->willReturn($arguments) - ; + ->willReturn($arguments); /** @var ArgumentsDenormalizerInterface $argumentsDenormalizer */ $argumentsDenormalizer = $argumentsDenormalizerProphecy->reveal(); $expected = new SimpleMethodCall( '__construct', - ['foo', 'bar'] + ['foo', 'bar'], ); $denormalizer = new ConstructorDenormalizer($argumentsDenormalizer); $actual = $denormalizer->denormalize($fixture, $flagParser, $arguments); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $argumentsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizerTest.php index 68cf73aca..993fecd0b 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/FactoryDenormalizerTest.php @@ -26,6 +26,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Constructor\FactoryDenormalizer + * @internal */ class FactoryDenormalizerTest extends TestCase { @@ -33,7 +34,7 @@ class FactoryDenormalizerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FactoryDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FactoryDenormalizer::class))->isCloneable()); } public function testCannotDenormalizeEmptyFactory(): void @@ -43,7 +44,7 @@ public function testCannotDenormalizeEmptyFactory(): void $flagParser = new FakeFlagParser(); $denormalizer = new FactoryDenormalizer( - new FakeCallsDenormalizer() + new FakeCallsDenormalizer(), ); $this->expectException(UnexpectedValueException::class); @@ -62,7 +63,7 @@ public function testCannotDenormalizeFactoryWithMultipleNames(): void $flagParser = new FakeFlagParser(); $denormalizer = new FactoryDenormalizer( - new FakeCallsDenormalizer() + new FakeCallsDenormalizer(), ); $this->expectException(UnexpectedValueException::class); @@ -80,7 +81,7 @@ public function testCannotDenormalizeFactoryWithNoFactoryName(): void $flagParser = new FakeFlagParser(); $denormalizer = new FactoryDenormalizer( - new FakeCallsDenormalizer() + new FakeCallsDenormalizer(), ); $this->expectException(UnexpectedValueException::class); @@ -113,12 +114,11 @@ public function testCanDenormalizeASimpleFactory(): void $fixture, $flagParser, 'Nelmio\Alice\Entity\User::create', - $unparsedArguments + $unparsedArguments, ) ->willReturn( - $expected = new FakeMethodCall() - ) - ; + $expected = new FakeMethodCall(), + ); /** @var CallsDenormalizerInterface $callsDenormalizer */ $callsDenormalizer = $callsDenormalizerProphecy->reveal(); @@ -126,7 +126,7 @@ public function testCanDenormalizeASimpleFactory(): void $actual = $denormalizer->denormalize($fixture, $flagParser, $factory); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCanDenormalizeAStaticFactory(): void @@ -135,7 +135,7 @@ public function testCanDenormalizeAStaticFactory(): void 'Nelmio\Entity\UserFactory::create' => $arguments = [ '', '1 (unique)' => '', - ] + ], ]; $fixture = new FakeFixture(); @@ -147,12 +147,11 @@ public function testCanDenormalizeAStaticFactory(): void $fixture, $flagParser, 'Nelmio\Entity\UserFactory::create', - $arguments + $arguments, ) ->willReturn( - $expected = new FakeMethodCall() - ) - ; + $expected = new FakeMethodCall(), + ); /** @var CallsDenormalizerInterface $callsDenormalizer */ $callsDenormalizer = $callsDenormalizerProphecy->reveal(); @@ -160,7 +159,7 @@ public function testCanDenormalizeAStaticFactory(): void $actual = $denormalizer->denormalize($fixture, $flagParser, $constructor); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCanDenormalizeANonStaticFactory(): void @@ -169,7 +168,7 @@ public function testCanDenormalizeANonStaticFactory(): void '@nelmio.entity.user_factory::create' => $arguments = [ '', '1 (unique)' => '', - ] + ], ]; $fixture = new FakeFixture(); @@ -181,12 +180,11 @@ public function testCanDenormalizeANonStaticFactory(): void $fixture, $flagParser, '@nelmio.entity.user_factory::create', - $arguments + $arguments, ) ->willReturn( - $expected = new FakeMethodCall() - ) - ; + $expected = new FakeMethodCall(), + ); /** @var CallsDenormalizerInterface $callsDenormalizer */ $callsDenormalizer = $callsDenormalizerProphecy->reveal(); @@ -194,6 +192,6 @@ public function testCanDenormalizeANonStaticFactory(): void $actual = $denormalizer->denormalize($fixture, $flagParser, $constructor); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LLegacyConstructorDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LLegacyConstructorDenormalizerTest.php index 96f141472..71125adb9 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LLegacyConstructorDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Constructor/LLegacyConstructorDenormalizerTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Constructor\LegacyConstructorDenormalizer + * @internal */ class LLegacyConstructorDenormalizerTest extends TestCase { @@ -31,7 +32,7 @@ class LLegacyConstructorDenormalizerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(LegacyConstructorDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(LegacyConstructorDenormalizer::class))->isCloneable()); } public function testDenormalizesConstructorWithTheDecoratedFactoryDenormalizer(): void @@ -46,9 +47,8 @@ public function testDenormalizesConstructorWithTheDecoratedFactoryDenormalizer() $factoryDenormalizerProphecy ->denormalize($fixture, $flagParser, $constructor) ->willReturn( - $expected = new FakeMethodCall() - ) - ; + $expected = new FakeMethodCall(), + ); /** @var ConstructorDenormalizerInterface $factoryDenormalizer */ $factoryDenormalizer = $factoryDenormalizerProphecy->reveal(); @@ -56,7 +56,7 @@ public function testDenormalizesConstructorWithTheDecoratedFactoryDenormalizer() $actual = $denormalizer->denormalize($fixture, $flagParser, $constructor); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testDenormalizesConstructorWithTheDecoratedConstructorDenormalizerIfCannotDenormalizeWithTheFactoryDenormalizer(): void @@ -68,16 +68,14 @@ public function testDenormalizesConstructorWithTheDecoratedConstructorDenormaliz $constructorDenormalizerProphecy = $this->prophesize(ConstructorDenormalizerInterface::class); $constructorDenormalizerProphecy ->denormalize($fixture, $flagParser, $constructor) - ->willReturn($expected = new FakeMethodCall()) - ; + ->willReturn($expected = new FakeMethodCall()); /** @var ConstructorDenormalizerInterface $constructorDenormalizer */ $constructorDenormalizer = $constructorDenormalizerProphecy->reveal(); $factoryDenormalizerProphecy = $this->prophesize(ConstructorDenormalizerInterface::class); $factoryDenormalizerProphecy ->denormalize($fixture, $flagParser, $constructor) - ->willThrow(UnexpectedValueException::class) - ; + ->willThrow(UnexpectedValueException::class); /** @var ConstructorDenormalizerInterface $factoryDenormalizer */ $factoryDenormalizer = $factoryDenormalizerProphecy->reveal(); @@ -85,6 +83,6 @@ public function testDenormalizesConstructorWithTheDecoratedConstructorDenormaliz $actual = $denormalizer->denormalize($fixture, $flagParser, $constructor); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizerTest.php index 8a7c6d13d..d05a4e157 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizerTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Property\SimplePropertyDenormalizer + * @internal */ class SimplePropertyDenormalizerTest extends TestCase { @@ -31,7 +32,7 @@ class SimplePropertyDenormalizerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimplePropertyDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimplePropertyDenormalizer::class))->isCloneable()); } public function testDenormalizesValueBeforeReturningProperty(): void @@ -51,7 +52,7 @@ public function testDenormalizesValueBeforeReturningProperty(): void $denormalizer = new SimplePropertyDenormalizer($valueDenormalizer); $actual = $denormalizer->denormalize($fixture, $name, $value, $flags); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $valueDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizerTest.php index 8b0020762..5a0281c2b 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizerTest.php @@ -36,6 +36,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\SimpleSpecificationsDenormalizer + * @internal */ class SimpleSpecificationsDenormalizerTest extends TestCase { @@ -54,13 +55,13 @@ public function testCanDenormalizeEmptySpecs(): void $expected = new SpecificationBag( null, new PropertyBag(), - new MethodCallBag() + new MethodCallBag(), ); $denormalizer = new SimpleSpecificationsDenormalizer(new FakeConstructorDenormalizer(), new FakePropertyDenormalizer(), new FakeCallsDenormalizer()); $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCanDenormalizeConstructor(): void @@ -68,7 +69,7 @@ public function testCanDenormalizeConstructor(): void $fixture = new FakeFixture(); $specs = [ '__construct' => $construct = [ - 'foo' + 'foo', ], ]; $flagParser = new FakeFlagParser(); @@ -79,23 +80,22 @@ public function testCanDenormalizeConstructor(): void ->willReturn( $constructor = new SimpleMethodCall( '__construct', - ['foo'] - ) - ) - ; + ['foo'], + ), + ); /** @var ConstructorDenormalizerInterface $constructorDenormalizer */ $constructorDenormalizer = $constructorDenormalizerProphecy->reveal(); $expected = new SpecificationBag( $constructor, new PropertyBag(), - new MethodCallBag() + new MethodCallBag(), ); $denormalizer = new SimpleSpecificationsDenormalizer($constructorDenormalizer, new FakePropertyDenormalizer(), new FakeCallsDenormalizer()); $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $constructorDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -116,23 +116,22 @@ public function testCanDenormalizeFactory(): void ->willReturn( $constructor = new SimpleMethodCall( 'create', - ['foo'] - ) - ) - ; + ['foo'], + ), + ); /** @var ConstructorDenormalizerInterface $constructorDenormalizer */ $constructorDenormalizer = $constructorDenormalizerProphecy->reveal(); $expected = new SpecificationBag( $constructor, new PropertyBag(), - new MethodCallBag() + new MethodCallBag(), ); $denormalizer = new SimpleSpecificationsDenormalizer($constructorDenormalizer, new FakePropertyDenormalizer(), new FakeCallsDenormalizer()); $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $constructorDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -158,23 +157,22 @@ public function testUsingAFactoryWithConstructIsDeprecated(): void ->willReturn( $constructor = new SimpleMethodCall( 'create', - ['foo', 'bar'] - ) - ) - ; + ['foo', 'bar'], + ), + ); /** @var ConstructorDenormalizerInterface $constructorDenormalizer */ $constructorDenormalizer = $constructorDenormalizerProphecy->reveal(); $expected = new SpecificationBag( $constructor, new PropertyBag(), - new MethodCallBag() + new MethodCallBag(), ); $denormalizer = new SimpleSpecificationsDenormalizer($constructorDenormalizer, new FakePropertyDenormalizer(), new FakeCallsDenormalizer()); $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $constructorDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -182,13 +180,13 @@ public function testUsingAFactoryWithConstructIsDeprecated(): void public function testCannotProceedWithInvalidProperty(): void { $unparsedSpecs = [ - 'foo' + 'foo', ]; $denormalizer = new SimpleSpecificationsDenormalizer( new FakeConstructorDenormalizer(), new FakePropertyDenormalizer(), - new FakeCallsDenormalizer() + new FakeCallsDenormalizer(), ); $this->expectException(InvalidArgumentException::class); @@ -202,7 +200,7 @@ public function testCannotDenormalizeAnInvalidFactory(): void $fixture = new FakeFixture(); $specs = [ '__construct' => $construct = [ - 'foo' + 'foo', ], '__factory' => $factory = [ 'create' => [ @@ -218,14 +216,12 @@ public function testCannotDenormalizeAnInvalidFactory(): void ->willReturn( $constructor = new SimpleMethodCall( '__construct', - ['foo'] - ) - ) - ; + ['foo'], + ), + ); $constructorDenormalizerProphecy ->denormalize($fixture, $flagParser, $factory) - ->shouldNotBeCalled() - ; + ->shouldNotBeCalled(); /** @var ConstructorDenormalizerInterface $constructorDenormalizer */ $constructorDenormalizer = $constructorDenormalizerProphecy->reveal(); @@ -253,10 +249,9 @@ public function testCannotDenormalizeAFactoryAndAConstructor(): void ->willReturn( $constructor = new SimpleMethodCall( '__construct', - [] - ) - ) - ; + [], + ), + ); /** @var ConstructorDenormalizerInterface $constructorDenormalizer */ $constructorDenormalizer = $constructorDenormalizerProphecy->reveal(); @@ -277,13 +272,13 @@ public function testCanDenormalizeTheNoConstructor(): void $expected = new SpecificationBag( new NoMethodCall(), new PropertyBag(), - new MethodCallBag() + new MethodCallBag(), ); $denormalizer = new SimpleSpecificationsDenormalizer(new FakeConstructorDenormalizer(), new FakePropertyDenormalizer(), new FakeCallsDenormalizer()); $actual = $denormalizer->denormalize(new FakeFixture(), new FakeFlagParser(), $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCanDenormalizeProperties(): void @@ -303,12 +298,10 @@ public function testCanDenormalizeProperties(): void $propertyDenormalizerProphecy = $this->prophesize(PropertyDenormalizerInterface::class); $propertyDenormalizerProphecy ->denormalize($fixture, 'parsed_username', '', $usernameFlags) - ->willReturn($usernameProp = new Property('username', '')) - ; + ->willReturn($usernameProp = new Property('username', '')); $propertyDenormalizerProphecy ->denormalize($fixture, 'parsed_name', 'bob', $nameFlags) - ->willReturn($nameProp = new Property('name', 'bob')) - ; + ->willReturn($nameProp = new Property('name', 'bob')); /** @var PropertyDenormalizerInterface $propertyDenormalizer */ $propertyDenormalizer = $propertyDenormalizerProphecy->reveal(); @@ -317,13 +310,13 @@ public function testCanDenormalizeProperties(): void (new PropertyBag()) ->with($usernameProp) ->with($nameProp), - new MethodCallBag() + new MethodCallBag(), ); $denormalizer = new SimpleSpecificationsDenormalizer(new FakeConstructorDenormalizer(), $propertyDenormalizer, new FakeCallsDenormalizer()); $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); $propertyDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(2); @@ -347,21 +340,20 @@ public function testCanDenormalizeCalls(): void $callsDenormalizerProphecy = $this->prophesize(CallsDenormalizerInterface::class); $callsDenormalizerProphecy ->denormalize($fixture, $flagParser, 'setLocation', $setLocationArgs) - ->willReturn($call = new NoMethodCall()) - ; + ->willReturn($call = new NoMethodCall()); /** @var CallsDenormalizerInterface $callsDenormalizer */ $callsDenormalizer = $callsDenormalizerProphecy->reveal(); $expected = new SpecificationBag( null, new PropertyBag(), - (new MethodCallBag())->with($call) + (new MethodCallBag())->with($call), ); $denormalizer = new SimpleSpecificationsDenormalizer(new FakeConstructorDenormalizer(), new FakePropertyDenormalizer(), $callsDenormalizer); $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $callsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -371,7 +363,7 @@ public function testCanDenormalizeCompleteSpecs(): void $fixture = new FakeFixture(); $specs = [ '__construct' => $construct = [ - '' + '', ], 'username' => '', 'name' => 'bob', @@ -397,30 +389,26 @@ public function testCanDenormalizeCompleteSpecs(): void ->willReturn( $constructor = new SimpleMethodCall( '__construct', - [''] - ) - ) - ; + [''], + ), + ); /** @var ConstructorDenormalizerInterface $constructorDenormalizer */ $constructorDenormalizer = $constructorDenormalizerProphecy->reveal(); $propertyDenormalizerProphecy = $this->prophesize(PropertyDenormalizerInterface::class); $propertyDenormalizerProphecy ->denormalize($fixture, 'parsed_username', '', $usernameFlags) - ->willReturn($usernameProp = new Property('username', '')) - ; + ->willReturn($usernameProp = new Property('username', '')); $propertyDenormalizerProphecy ->denormalize($fixture, 'parsed_name', 'bob', $nameFlags) - ->willReturn($nameProp = new Property('name', 'bob')) - ; + ->willReturn($nameProp = new Property('name', 'bob')); /** @var PropertyDenormalizerInterface $propertyDenormalizer */ $propertyDenormalizer = $propertyDenormalizerProphecy->reveal(); $callsDenormalizerProphecy = $this->prophesize(CallsDenormalizerInterface::class); $callsDenormalizerProphecy ->denormalize($fixture, $flagParser, 'setLocation', $setLocationArgs) - ->willReturn($call = new NoMethodCall()) - ; + ->willReturn($call = new NoMethodCall()); /** @var CallsDenormalizerInterface $callsDenormalizer */ $callsDenormalizer = $callsDenormalizerProphecy->reveal(); @@ -429,13 +417,13 @@ public function testCanDenormalizeCompleteSpecs(): void (new PropertyBag()) ->with($usernameProp) ->with($nameProp), - (new MethodCallBag())->with($call) + (new MethodCallBag())->with($call), ); $denormalizer = new SimpleSpecificationsDenormalizer($constructorDenormalizer, $propertyDenormalizer, $callsDenormalizer); $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); $constructorDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -447,7 +435,7 @@ public function testDenormalizeInvalidCalls(): void { $specs = [ '__calls' => [ - 'invalid value' + 'invalid value', ], ]; diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizerTest.php index 899d7a881..c94ab6f20 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizerTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Value\SimpleValueDenormalizer + * @internal */ class SimpleValueDenormalizerTest extends TestCase { @@ -35,12 +36,12 @@ class SimpleValueDenormalizerTest extends TestCase public function testIsAValueDenormalizer(): void { - static::assertTrue(is_a(SimpleValueDenormalizer::class, ValueDenormalizerInterface::class, true)); + self::assertTrue(is_a(SimpleValueDenormalizer::class, ValueDenormalizerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleValueDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleValueDenormalizer::class))->isCloneable()); } public function testReturnsParsedValueIfValueIsAString(): void @@ -55,7 +56,7 @@ public function testReturnsParsedValueIfValueIsAString(): void $denormalizer = new SimpleValueDenormalizer($parser); $actual = $denormalizer->denormalize(new FakeFixture(), new FlagBag(''), $value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $parserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -81,7 +82,7 @@ public function testIfTheValueIsAnArrayThenAppliesItselfRecursivelyToArrays(): v $denormalizer = new SimpleValueDenormalizer($parser); $actual = $denormalizer->denormalize(new FakeFixture(), new FlagBag(''), $value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $parserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); } @@ -93,7 +94,7 @@ public function testReturnsUnchangedValueIfTheValueIsNotAStringOrAnArray(): void $denormalizer = new SimpleValueDenormalizer(new FakeParser()); $actual = $denormalizer->denormalize(new FakeFixture(), new FlagBag(''), $value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testWhenParserThrowsExceptionDenormalizerAExceptionIsThrown(): void @@ -102,9 +103,8 @@ public function testWhenParserThrowsExceptionDenormalizerAExceptionIsThrown(): v $parserProphecy ->parse(Argument::any()) ->willThrow( - $thrownException = new RootParseException('hello world', 10) - ) - ; + $thrownException = new RootParseException('hello world', 10), + ); /** @var ParserInterface $parser */ $parser = $parserProphecy->reveal(); @@ -112,14 +112,14 @@ public function testWhenParserThrowsExceptionDenormalizerAExceptionIsThrown(): v try { $denormalizer->denormalize(new FakeFixture(), null, 'foo'); - static::fail('Expected throwable to be thrown.'); + self::fail('Expected throwable to be thrown.'); } catch (DenormalizationThrowable $throwable) { - static::assertEquals( + self::assertEquals( 'Could not parse value "foo".', - $throwable->getMessage() + $throwable->getMessage(), ); - static::assertEquals(0, $throwable->getCode()); - static::assertEquals($thrownException, $throwable->getPrevious()); + self::assertEquals(0, $throwable->getCode()); + self::assertEquals($thrownException, $throwable->getPrevious()); } } } diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php index bb5e841bf..2f5dc1ace 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php @@ -33,6 +33,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Value\UniqueValueDenormalizer + * @internal */ class UniqueValueDenormalizerTest extends TestCase { @@ -40,12 +41,12 @@ class UniqueValueDenormalizerTest extends TestCase public function testIsAValueDenormalizer(): void { - static::assertTrue(is_a(UniqueValueDenormalizer::class, ValueDenormalizerInterface::class, true)); + self::assertTrue(is_a(UniqueValueDenormalizer::class, ValueDenormalizerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(UniqueValueDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(UniqueValueDenormalizer::class))->isCloneable()); } public function testReturnsParsedValueIfNoUniqueFlagsHasBeenFound(): void @@ -57,15 +58,14 @@ public function testReturnsParsedValueIfNoUniqueFlagsHasBeenFound(): void $decoratedDenormalizerProphecy = $this->prophesize(ValueDenormalizerInterface::class); $decoratedDenormalizerProphecy ->denormalize($fixture, $flags, $value) - ->willReturn($expected = 'denormalized_value') - ; + ->willReturn($expected = 'denormalized_value'); /** @var ValueDenormalizerInterface $decoratedDenormalizer */ $decoratedDenormalizer = $decoratedDenormalizerProphecy->reveal(); $denormalizer = new UniqueValueDenormalizer($decoratedDenormalizer); $actual = $denormalizer->denormalize($fixture, $flags, $value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -79,17 +79,16 @@ public function testReturnsUniqueValueIfUniqueFlagsFound(): void $decoratedDenormalizerProphecy = $this->prophesize(ValueDenormalizerInterface::class); $decoratedDenormalizerProphecy ->denormalize($fixture, $flags, $value) - ->willReturn('denormalized_value') - ; + ->willReturn('denormalized_value'); /** @var ValueDenormalizerInterface $decoratedDenormalizer */ $decoratedDenormalizer = $decoratedDenormalizerProphecy->reveal(); $denormalizer = new UniqueValueDenormalizer($decoratedDenormalizer); $result = $denormalizer->denormalize($fixture, $flags, $value); - static::assertInstanceOf(UniqueValue::class, $result); - static::assertStringStartsWith('Dummy#', $result->getId()); - static::assertEquals('denormalized_value', $result->getValue()); + self::assertInstanceOf(UniqueValue::class, $result); + self::assertStringStartsWith('Dummy#', $result->getId()); + self::assertEquals('denormalized_value', $result->getValue()); $decoratedDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -104,20 +103,19 @@ public function testIfParsedValueIsDynamicArrayThenUniqueFlagAppliesToItsElement $decoratedDenormalizerProphecy = $this->prophesize(ValueDenormalizerInterface::class); $decoratedDenormalizerProphecy ->denormalize($fixture, $flags, $value) - ->willReturn($denormalizedValue) - ; + ->willReturn($denormalizedValue); /** @var ValueDenormalizerInterface $decoratedDenormalizer */ $decoratedDenormalizer = $decoratedDenormalizerProphecy->reveal(); $denormalizer = new UniqueValueDenormalizer($decoratedDenormalizer); $result = $denormalizer->denormalize($fixture, $flags, $value); - static::assertInstanceOf(DynamicArrayValue::class, $result); + self::assertInstanceOf(DynamicArrayValue::class, $result); /** @var DynamicArrayValue $result */ - static::assertEquals(10, $result->getQuantifier()); - static::assertInstanceOf(UniqueValue::class, $result->getElement()); - static::assertStringStartsWith('Dummy#', $result->getElement()->getId()); - static::assertEquals('parsed_value', $result->getElement()->getValue()); + self::assertEquals(10, $result->getQuantifier()); + self::assertInstanceOf(UniqueValue::class, $result->getElement()); + self::assertStringStartsWith('Dummy#', $result->getElement()->getId()); + self::assertEquals('parsed_value', $result->getElement()->getValue()); } public function testThrowsAnExceptionIsATemporaryFixtureWithAUniqueValue(): void @@ -130,8 +128,7 @@ public function testThrowsAnExceptionIsATemporaryFixtureWithAUniqueValue(): void $decoratedDenormalizerProphecy = $this->prophesize(ValueDenormalizerInterface::class); $decoratedDenormalizerProphecy ->denormalize($fixture, $flags, $value) - ->willReturn($denormalizedValue) - ; + ->willReturn($denormalizedValue); /** @var ValueDenormalizerInterface $decoratedDenormalizer */ $decoratedDenormalizer = $decoratedDenormalizerProphecy->reveal(); @@ -153,23 +150,22 @@ public function testIfParsedValueIsArrayValueThenUniqueFlagAppliesToItsElementIn $decoratedDenormalizerProphecy = $this->prophesize(ValueDenormalizerInterface::class); $decoratedDenormalizerProphecy ->denormalize($fixture, $flags, $value) - ->willReturn($denormalizedValue) - ; + ->willReturn($denormalizedValue); /** @var ValueDenormalizerInterface $decoratedDenormalizer */ $decoratedDenormalizer = $decoratedDenormalizerProphecy->reveal(); $denormalizer = new UniqueValueDenormalizer($decoratedDenormalizer); $result = $denormalizer->denormalize($fixture, $flags, $value); - static::assertInstanceOf(ArrayValue::class, $result); + self::assertInstanceOf(ArrayValue::class, $result); /** @var ArrayValue $result */ - static::assertInstanceOf(UniqueValue::class, $result->getValue()[0]); - static::assertStringStartsWith('Dummy#', $result->getValue()[0]->getId()); - static::assertEquals('foo', $result->getValue()[0]->getValue()); + self::assertInstanceOf(UniqueValue::class, $result->getValue()[0]); + self::assertStringStartsWith('Dummy#', $result->getValue()[0]->getId()); + self::assertEquals('foo', $result->getValue()[0]->getValue()); - static::assertInstanceOf(UniqueValue::class, $result->getValue()[1]); - static::assertStringStartsWith('Dummy#', $result->getValue()[1]->getId()); - static::assertEquals('bar', $result->getValue()[1]->getValue()); + self::assertInstanceOf(UniqueValue::class, $result->getValue()[1]); + self::assertStringStartsWith('Dummy#', $result->getValue()[1]->getId()); + self::assertEquals('bar', $result->getValue()[1]->getValue()); } public function provideValues() diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParserTest.php b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParserTest.php index ae3f7e8bd..2b4978439 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParserTest.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ConfiguratorFlagParserTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParser\Chainable\ConfiguratorFlagParser + * @internal */ class ConfiguratorFlagParserTest extends FlagParserTestCase { @@ -29,13 +30,13 @@ protected function setUp(): void public function testIsAChainableFlagParser(): void { - static::assertTrue(is_a(ConfiguratorFlagParser::class, ChainableFlagParserInterface::class, true)); + self::assertTrue(is_a(ConfiguratorFlagParser::class, ChainableFlagParserInterface::class, true)); } /** * @dataProvider provideConfigurators */ - public function testCanParseConfigurators(string $element, FlagBag $expected = null): void + public function testCanParseConfigurators(string $element, ?FlagBag $expected = null): void { $this->assertCanParse($element, $expected); } diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParserTest.php b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParserTest.php index 51b5111fd..9a0430591 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParserTest.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/ExtendFlagParserTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParser\Chainable\ExtendFlagParser + * @internal */ class ExtendFlagParserTest extends FlagParserTestCase { @@ -29,13 +30,13 @@ protected function setUp(): void public function testIsAChainableFlagParser(): void { - static::assertTrue(is_a(ExtendFlagParser::class, ChainableFlagParserInterface::class, true)); + self::assertTrue(is_a(ExtendFlagParser::class, ChainableFlagParserInterface::class, true)); } /** * @dataProvider provideExtends */ - public function testCanParseExtends(string $element, FlagBag $expected = null): void + public function testCanParseExtends(string $element, ?FlagBag $expected = null): void { $this->assertCanParse($element, $expected); } diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParserTest.php b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParserTest.php index f875d1b77..ff3db956d 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParserTest.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/OptionalFlagParserTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParser\Chainable\OptionalFlagParser + * @internal */ class OptionalFlagParserTest extends FlagParserTestCase { @@ -29,13 +30,13 @@ protected function setUp(): void public function testIsAChainableFlagParser(): void { - static::assertTrue(is_a(OptionalFlagParser::class, ChainableFlagParserInterface::class, true)); + self::assertTrue(is_a(OptionalFlagParser::class, ChainableFlagParserInterface::class, true)); } /** * @dataProvider provideOptionals */ - public function testCanParseOptionals(string $element, FlagBag $expected = null): void + public function testCanParseOptionals(string $element, ?FlagBag $expected = null): void { $this->assertCanParse($element, $expected); } diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParserTest.php b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParserTest.php index c892285d4..3f7d22f90 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParserTest.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/TemplateFlagParserTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParser\Chainable\TemplateFlagParser + * @internal */ class TemplateFlagParserTest extends FlagParserTestCase { @@ -29,13 +30,13 @@ protected function setUp(): void public function testIsAChainableFlagParser(): void { - static::assertTrue(is_a(TemplateFlagParser::class, ChainableFlagParserInterface::class, true)); + self::assertTrue(is_a(TemplateFlagParser::class, ChainableFlagParserInterface::class, true)); } /** * @dataProvider provideTemplates */ - public function testCanParseTemplates(string $element, FlagBag $expected = null): void + public function testCanParseTemplates(string $element, ?FlagBag $expected = null): void { $this->assertCanParse($element, $expected); } diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParserTest.php b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParserTest.php index 826099bb0..8a6252171 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParserTest.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/Chainable/UniqueFlagParserTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParser\Chainable\UniqueFlagParser + * @internal */ class UniqueFlagParserTest extends FlagParserTestCase { @@ -29,13 +30,13 @@ protected function setUp(): void public function testIsAChainableFlagParser(): void { - static::assertTrue(is_a(UniqueFlagParser::class, ChainableFlagParserInterface::class, true)); + self::assertTrue(is_a(UniqueFlagParser::class, ChainableFlagParserInterface::class, true)); } /** * @dataProvider provideUniques */ - public function testCanParseUniques(string $element, FlagBag $expected = null): void + public function testCanParseUniques(string $element, ?FlagBag $expected = null): void { $this->assertCanParse($element, $expected); } diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParserTest.php b/tests/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParserTest.php index 1ec06e040..be52e9e4c 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParserTest.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/ElementFlagParserTest.php @@ -21,11 +21,12 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParser\ElementFlagParser + * @internal */ class ElementFlagParserTest extends FlagParserTestCase { use ProphecyTrait; - + protected function setUp(): void { $this->parser = new ElementFlagParser(new ElementParser()); @@ -33,7 +34,7 @@ protected function setUp(): void public function testIsAFlagParser(): void { - static::assertTrue(is_a(ElementFlagParser::class, FlagParserInterface::class, true)); + self::assertTrue(is_a(ElementFlagParser::class, FlagParserInterface::class, true)); } public function testIfNoFlagIsFoundThenReturnsEmptyFlagBag(): void @@ -44,7 +45,7 @@ public function testIfNoFlagIsFoundThenReturnsEmptyFlagBag(): void $parser = new ElementFlagParser(new FakeFlagParser()); $actual = $parser->parse($element); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testIfAFlagIsFoundThenParsesItWithDecoratedParserBeforeReturningTheFlags(): void @@ -55,38 +56,35 @@ public function testIfAFlagIsFoundThenParsesItWithDecoratedParserBeforeReturning $decoratedParserProphecy ->parse('flag1') ->willReturn( - (new FlagBag(''))->withFlag(new ElementFlag('flag1')) - ) - ; + (new FlagBag(''))->withFlag(new ElementFlag('flag1')), + ); $decoratedParserProphecy ->parse('flag2') ->willReturn( - (new FlagBag(''))->withFlag(new ElementFlag('flag2'))->withFlag(new ElementFlag('additional flag')) - ) - ; + (new FlagBag(''))->withFlag(new ElementFlag('flag2'))->withFlag(new ElementFlag('additional flag')), + ); /** @var FlagParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); $expected = (new FlagBag('dummy')) ->withFlag(new ElementFlag('flag1')) ->withFlag(new ElementFlag('flag2')) - ->withFlag(new ElementFlag('additional flag')) - ; + ->withFlag(new ElementFlag('additional flag')); $parser = new ElementFlagParser($decoratedParser); $actual = $parser->parse($element); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** * @dataProvider provideElements */ - public function testCanParseElements(string $element, FlagBag $expected = null): void + public function testCanParseElements(string $element, ?FlagBag $expected = null): void { $actual = $this->parser->parse($element); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** @@ -96,7 +94,7 @@ public function testCannotParseMalformedElements(string $element): void { try { $this->parser->parse($element); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (RuntimeException $exception) { // expected } diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistryTest.php b/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistryTest.php index 987b8dcc8..1d3c2ad04 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistryTest.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserRegistryTest.php @@ -26,6 +26,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\FlagParser\FlagParserRegistry + * @internal */ class FlagParserRegistryTest extends TestCase { @@ -33,12 +34,12 @@ class FlagParserRegistryTest extends TestCase public function testIsAFlagParser(): void { - static::assertTrue(is_a(FlagParserRegistry::class, FlagParserInterface::class, true)); + self::assertTrue(is_a(FlagParserRegistry::class, FlagParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FlagParserRegistry::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FlagParserRegistry::class))->isCloneable()); } public function testThrowsAnExceptionIfAnInvalidParserInjected(): void @@ -77,7 +78,7 @@ public function testPicksTheFirstSuitableParser(): void $parser = new FlagParserRegistry([$parser1, $parser2, $parser3]); $actual = $parser->parse($element); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $parser1Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1); $parser2Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1); $parser2Prophecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserTestCase.php b/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserTestCase.php index 896797516..1671c28bf 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserTestCase.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/FlagParserTestCase.php @@ -28,13 +28,13 @@ abstract class FlagParserTestCase extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionObject($this->parser))->isCloneable()); + self::assertFalse((new ReflectionObject($this->parser))->isCloneable()); } /** * @dataProvider provideElements */ - public function testCanParseElements(string $element, FlagBag $expected = null): void + public function testCanParseElements(string $element, ?FlagBag $expected = null): void { $this->assertCannotParse($element); } @@ -50,7 +50,7 @@ public function testCannotParseMalformedElements(string $element): void /** * @dataProvider provideExtends */ - public function testCanParseExtends(string $element, FlagBag $expected = null): void + public function testCanParseExtends(string $element, ?FlagBag $expected = null): void { $this->assertCannotParse($element); } @@ -66,7 +66,7 @@ public function testCannotParseMalformedExtends(string $element): void /** * @dataProvider provideOptionals */ - public function testCanParseOptionals(string $element, FlagBag $expected = null): void + public function testCanParseOptionals(string $element, ?FlagBag $expected = null): void { $this->assertCannotParse($element); } @@ -82,7 +82,7 @@ public function testCannotParseMalformedOptionals(string $element): void /** * @dataProvider provideTemplates */ - public function testCanParseTemplates(string $element, FlagBag $expected = null): void + public function testCanParseTemplates(string $element, ?FlagBag $expected = null): void { $this->assertCannotParse($element); } @@ -90,7 +90,7 @@ public function testCanParseTemplates(string $element, FlagBag $expected = null) /** * @dataProvider provideUniques */ - public function testCanParseUniques(string $element, FlagBag $expected = null): void + public function testCanParseUniques(string $element, ?FlagBag $expected = null): void { $this->assertCannotParse($element); } @@ -98,7 +98,7 @@ public function testCanParseUniques(string $element, FlagBag $expected = null): /** * @dataProvider provideConfigurators */ - public function testCanParseConfigurators(string $element, FlagBag $expected = null): void + public function testCanParseConfigurators(string $element, ?FlagBag $expected = null): void { $this->assertCannotParse($element); } @@ -106,76 +106,76 @@ public function testCanParseConfigurators(string $element, FlagBag $expected = n public function assertCanParse(string $element, FlagBag $expected): void { if ($this->parser instanceof ChainableFlagParserInterface) { - static::assertTrue($this->parser->canParse($element)); + self::assertTrue($this->parser->canParse($element)); } $actual = $this->parser->parse($element); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function assertCannotParse(string $element): void { if ($this->parser instanceof ChainableFlagParserInterface) { $actual = $this->parser->canParse($element); - static::assertFalse($actual); + self::assertFalse($actual); return; } try { $this->parser->parse($element); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (LogicException $exception) { // expected } } - + public function markAsInvalidCase(): void { - static::markTestSkipped('Invalid scenario.'); + self::markTestSkipped('Invalid scenario.'); } - public function provideElements() + public function provideElements(): iterable { return Reference::getElements(); } - public function provideMalformedElements() + public function provideMalformedElements(): iterable { return Reference::getMalformedElements(); } - public function provideExtends() + public function provideExtends(): iterable { return Reference::getExtends(); } - public function provideMalformedExtends() + public function provideMalformedExtends(): iterable { return Reference::getMalformedExtends(); } - public function provideOptionals() + public function provideOptionals(): iterable { return Reference::getOptionals(); } - public function provideMalformedOptionals() + public function provideMalformedOptionals(): iterable { return Reference::getMalformedOptionals(); } - public function provideTemplates() + public function provideTemplates(): iterable { return Reference::getTemplates(); } - public function provideUniques() + public function provideUniques(): iterable { return Reference::getUniques(); } - public function provideConfigurators() + public function provideConfigurators(): iterable { return Reference::getConfigurators(); } diff --git a/tests/FixtureBuilder/Denormalizer/FlagParser/Reference.php b/tests/FixtureBuilder/Denormalizer/FlagParser/Reference.php index 5b32a303b..45a96b3d3 100644 --- a/tests/FixtureBuilder/Denormalizer/FlagParser/Reference.php +++ b/tests/FixtureBuilder/Denormalizer/FlagParser/Reference.php @@ -54,8 +54,7 @@ private function __construct() 'user (dummy_flag, another_dummy_flag)', (new FlagBag('user')) ->withFlag(new ElementFlag('dummy_flag')) - ->withFlag(new ElementFlag('another_dummy_flag')) - , + ->withFlag(new ElementFlag('another_dummy_flag')), ], 'with an index' => [ '0 (dummy_flag)', @@ -142,8 +141,7 @@ private function __construct() 'with 1 extend' => [ 'extends user_base', (new FlagBag('')) - ->withFlag(new ExtendFlag(new FixtureReference('user_base'))) - , + ->withFlag(new ExtendFlag(new FixtureReference('user_base'))), ], ], 'malformed-extend' => [ diff --git a/tests/FixtureBuilder/Denormalizer/Parameter/SimpleParameterBagDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Parameter/SimpleParameterBagDenormalizerTest.php index 9035f97e2..1d9ab7ded 100644 --- a/tests/FixtureBuilder/Denormalizer/Parameter/SimpleParameterBagDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Parameter/SimpleParameterBagDenormalizerTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\Parameter\SimpleParameterBagDenormalizer + * @internal */ class SimpleParameterBagDenormalizerTest extends TestCase { @@ -29,7 +30,7 @@ class SimpleParameterBagDenormalizerTest extends TestCase * @var SimpleParameterBagDenormalizer */ private $denormalizer; - + protected function setUp(): void { $this->denormalizer = new SimpleParameterBagDenormalizer(); @@ -37,12 +38,12 @@ protected function setUp(): void public function testIsAParameterBagDenormalizer(): void { - static::assertInstanceOf(ParameterBagDenormalizerInterface::class, $this->denormalizer); + self::assertInstanceOf(ParameterBagDenormalizerInterface::class, $this->denormalizer); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionObject($this->denormalizer))->isCloneable()); + self::assertFalse((new ReflectionObject($this->denormalizer))->isCloneable()); } /** @@ -52,7 +53,7 @@ public function testReturnsEmptyBagIfNoParametersHaveBeenDeclared(array $data): { $actual = $this->denormalizer->denormalize($data); - static::assertEquals(new ParameterBag(), $actual); + self::assertEquals(new ParameterBag(), $actual); } /** @@ -62,13 +63,13 @@ public function testThrowsExceptionIfParametersKeyIsNotAnArray(array $data, stri { try { $this->denormalizer->denormalize($data); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (TypeError $exception) { - static::assertEquals($expectedExceptionMessage, $exception->getMessage()); + self::assertEquals($expectedExceptionMessage, $exception->getMessage()); } } - public function provideDataWithNoParameters() + public function provideDataWithNoParameters(): iterable { yield 'no parameters' => [ [], @@ -87,7 +88,7 @@ public function provideDataWithNoParameters() ]; } - public function provideDataWithInvalidParameterKeys() + public function provideDataWithInvalidParameterKeys(): iterable { yield 'string value' => [ [ diff --git a/tests/FixtureBuilder/Denormalizer/SimpleDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/SimpleDenormalizerTest.php index 79314ca85..2f1473800 100644 --- a/tests/FixtureBuilder/Denormalizer/SimpleDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/SimpleDenormalizerTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\Denormalizer\SimpleDenormalizer + * @internal */ class SimpleDenormalizerTest extends TestCase { @@ -32,12 +33,12 @@ class SimpleDenormalizerTest extends TestCase public function testIsADenormalizer(): void { - static::assertTrue(is_a(SimpleDenormalizer::class, DenormalizerInterface::class, true)); + self::assertTrue(is_a(SimpleDenormalizer::class, DenormalizerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleDenormalizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleDenormalizer::class))->isCloneable()); } public function testReturnsADenormalizedSet(): void @@ -66,9 +67,8 @@ public function testReturnsADenormalizedSet(): void $parameterDenormalizerProphecy ->denormalize($data) ->willReturn( - $parameters = new ParameterBag(['foo' => 'bar']) - ) - ; + $parameters = new ParameterBag(['foo' => 'bar']), + ); /** @var ParameterBagDenormalizerInterface $parameterDenormalizer */ $parameterDenormalizer = $parameterDenormalizerProphecy->reveal(); @@ -76,9 +76,8 @@ public function testReturnsADenormalizedSet(): void $fixturesDenormalizerProphecy ->denormalize($fixturesData) ->willReturn( - $fixtures = (new FixtureBag())->with(new DummyFixture('foo')) - ) - ; + $fixtures = (new FixtureBag())->with(new DummyFixture('foo')), + ); /** @var FixtureBagDenormalizerInterface $fixturesDenormalizer */ $fixturesDenormalizer = $fixturesDenormalizerProphecy->reveal(); @@ -87,7 +86,7 @@ public function testReturnsADenormalizedSet(): void $denormalizer = new SimpleDenormalizer($parameterDenormalizer, $fixturesDenormalizer); $actual = $denormalizer->denormalize($data); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $parameterDenormalizerProphecy->denormalize(Argument::any())->shouldHaveBeenCalledTimes(1); $fixturesDenormalizerProphecy->denormalize(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexerTest.php index e74f49563..db9e8fa79 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/EmptyValueLexerTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\EmptyValueLexer + * @internal */ class EmptyValueLexerTest extends TestCase { @@ -31,12 +32,12 @@ class EmptyValueLexerTest extends TestCase public function testIsALexer(): void { - static::assertTrue(is_a(EmptyValueLexer::class, LexerInterface::class, true)); + self::assertTrue(is_a(EmptyValueLexer::class, LexerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(EmptyValueLexer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(EmptyValueLexer::class))->isCloneable()); } public function testLexEmptyStringIntoAnEmptyStringToken(): void @@ -49,8 +50,8 @@ public function testLexEmptyStringIntoAnEmptyStringToken(): void $lexer = new EmptyValueLexer(new FakeLexer()); $actual = $lexer->lex(''); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); } public function testHandOverTheLexificationToItsDecoratedLexerIfStringIsNotEmpty(): void @@ -65,8 +66,8 @@ public function testHandOverTheLexificationToItsDecoratedLexerIfStringIsNotEmpty $lexer = new EmptyValueLexer($decoratedLexer); $actual = $lexer->lex($value); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); $decoratedLexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexerTest.php index 04d9f1036..a8bdb285e 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexerTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\FunctionLexer + * @internal */ class FunctionLexerTest extends TestCase { @@ -32,7 +33,7 @@ class FunctionLexerTest extends TestCase * @var FunctionLexer */ private $lexer; - + protected function setUp(): void { $this->lexer = new FunctionLexer(new DummyLexer()); @@ -40,12 +41,12 @@ protected function setUp(): void public function testIsALexer(): void { - static::assertTrue(is_a(FunctionLexer::class, LexerInterface::class, true)); + self::assertTrue(is_a(FunctionLexer::class, LexerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FunctionLexer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FunctionLexer::class))->isCloneable()); } public function testTokenizeValueBeforePassingItToTheDecoratedLexer(): void @@ -57,17 +58,16 @@ public function testTokenizeValueBeforePassingItToTheDecoratedLexer(): void ->lex('') ->willReturn( $expected = [ - new Token('something', new TokenType(TokenType::FUNCTION_TYPE)) - ] - ) - ; + new Token('something', new TokenType(TokenType::FUNCTION_TYPE)), + ], + ); /** @var LexerInterface $decoratedLexer */ $decoratedLexer = $decoratedLexerProphecy->reveal(); $lexer = new FunctionLexer($decoratedLexer); $actual = $lexer->lex($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedLexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -81,17 +81,16 @@ public function testIfTheValueHasAlreadyBeenTokenizedThenItWillNotBeTokenizedAga ->lex($value) ->willReturn( $expected = [ - new Token('something', new TokenType(TokenType::FUNCTION_TYPE)) - ] - ) - ; + new Token('something', new TokenType(TokenType::FUNCTION_TYPE)), + ], + ); /** @var LexerInterface $decoratedLexer */ $decoratedLexer = $decoratedLexerProphecy->reveal(); $lexer = new FunctionLexer($decoratedLexer); $actual = $lexer->lex($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedLexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizerTest.php index b2b7e747d..2f7833bfc 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/FunctionTokenizerTest.php @@ -20,6 +20,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\FunctionTokenizer * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\FunctionTreeTokenizer + * @internal */ class FunctionTokenizerTest extends TestCase { @@ -27,7 +28,7 @@ class FunctionTokenizerTest extends TestCase * @var FunctionTokenizer */ private $tokenizer; - + protected function setUp(): void { $this->tokenizer = new FunctionTokenizer(); @@ -35,21 +36,23 @@ protected function setUp(): void public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FunctionTokenizer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FunctionTokenizer::class))->isCloneable()); } /** * @dataProvider provideValues + * @param mixed $value + * @param mixed $expected */ public function testTokenizeValues($value, $expected): void { try { $actual = $this->tokenizer->tokenize($value); if (null === $expected) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } catch (MalformedFunctionException $exception) { if (null !== $expected) { throw $exception; @@ -57,7 +60,7 @@ public function testTokenizeValues($value, $expected): void } } - public function provideValues() + public function provideValues(): iterable { yield 'non function' => [ 'foo', diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexerTest.php index 4e41ba980..9ac0bdf70 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/GlobalPatternsLexerTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\GlobalPatternsLexer + * @internal */ class GlobalPatternsLexerTest extends TestCase { @@ -32,12 +33,12 @@ class GlobalPatternsLexerTest extends TestCase public function testIsALexer(): void { - static::assertTrue(is_a(GlobalPatternsLexer::class, LexerInterface::class, true)); + self::assertTrue(is_a(GlobalPatternsLexer::class, LexerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(GlobalPatternsLexer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(GlobalPatternsLexer::class))->isCloneable()); } public function testLexValueToReturnAToken(): void @@ -49,8 +50,8 @@ public function testLexValueToReturnAToken(): void $lexer = new GlobalPatternsLexer(new FakeLexer()); $actual = $lexer->lex('10x @users'); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); } public function testHandOverTheLexificationToTheDecoratedLexerIfNoPatternsMatch(): void @@ -65,8 +66,8 @@ public function testHandOverTheLexificationToTheDecoratedLexerIfNoPatternsMatch( $lexer = new GlobalPatternsLexer($decoratedLexer); $actual = $lexer->lex($value); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); $decoratedLexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php index a174c0d3c..36bbaefb1 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/LexerIntegrationTest.php @@ -26,6 +26,7 @@ * @group integration * * @coversNothing + * @internal */ class LexerIntegrationTest extends TestCase { @@ -33,7 +34,7 @@ class LexerIntegrationTest extends TestCase * @var LexerInterface */ protected $lexer; - + protected function setUp(): void { $this->lexer = (new NativeLoader())->getLexer(); @@ -41,6 +42,7 @@ protected function setUp(): void /** * @dataProvider provideValues + * @param mixed $expected */ public function testCanLexValues(string $value, $expected): void { @@ -48,12 +50,12 @@ public function testCanLexValues(string $value, $expected): void $actual = $this->lexer->lex($value); if (null === $expected) { - static::fail( + self::fail( sprintf( 'Expected exception to be thrown for "%s", got "%s" instead.', $value, - var_export($actual, true) - ) + var_export($actual, true), + ), ); } } catch (InvalidArgumentException $exception) { @@ -70,14 +72,14 @@ public function testCanLexValues(string $value, $expected): void throw $exception; } - static::assertEquals($expected, $actual, var_export($actual, true)); - static::assertSameSize($expected, $actual); + self::assertEquals($expected, $actual, var_export($actual, true)); + self::assertSameSize($expected, $actual); } /** - * @link https://github.com/nelmio/alice/issues/377 + * @see https://github.com/nelmio/alice/issues/377 */ - public function provideValues() + public function provideValues(): iterable { // simple values yield 'empty string' => [ @@ -563,36 +565,36 @@ public function provideValues() '', [ new Token('', new TokenType(TokenType::FUNCTION_TYPE)), - ] + ], ]; yield '[Function] with windows type line break in single quoted string argument' => [ '', [ new Token('', new TokenType(TokenType::FUNCTION_TYPE)), - ] + ], ]; yield '[Function] with unix type line break in double quoted string argument' => [ '', [ - new Token('', new TokenType(TokenType::FUNCTION_TYPE)) - ] + new Token('', new TokenType(TokenType::FUNCTION_TYPE)), + ], ]; yield '[Function] with windows type line break in double quoted string argument' => [ '', [ - new Token('', new TokenType(TokenType::FUNCTION_TYPE)) - ] + new Token('', new TokenType(TokenType::FUNCTION_TYPE)), + ], ]; $arg = str_repeat('a', 2000); yield '[Function] with long argument' => [ '', [ - new Token('', new TokenType(TokenType::FUNCTION_TYPE)) - ] + new Token('', new TokenType(TokenType::FUNCTION_TYPE)), + ], ]; // Arrays @@ -985,7 +987,6 @@ public function provideValues() new Token('foo ', new TokenType(TokenType::STRING_TYPE)), new Token('@user0->username->value', new TokenType(TokenType::PROPERTY_REFERENCE_TYPE)), new Token(' bar', new TokenType(TokenType::STRING_TYPE)), - ], ]; yield '[Reference] with nested' => [ @@ -1002,7 +1003,6 @@ public function provideValues() new Token('@user0', new TokenType(TokenType::SIMPLE_REFERENCE_TYPE)), new Token('@user1', new TokenType(TokenType::SIMPLE_REFERENCE_TYPE)), new Token(' bar', new TokenType(TokenType::STRING_TYPE)), - ], ]; yield '[Reference] nominal range' => [ diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php index c8f511a94..fe78af986 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\ReferenceEscaperLexer + * @internal */ class ReferenceEscaperLexerTest extends TestCase { @@ -29,18 +30,18 @@ class ReferenceEscaperLexerTest extends TestCase public function testIsALexer(): void { - static::assertTrue(is_a(ReferenceEscaperLexer::class, LexerInterface::class, true)); + self::assertTrue(is_a(ReferenceEscaperLexer::class, LexerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ReferenceEscaperLexer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ReferenceEscaperLexer::class))->isCloneable()); } /** * @dataProvider provideValues */ - public function testEscapesStringBeforeHandlingItOverToTheDecoratedLexer(string $value, string $expectedEscapedValue = null): void + public function testEscapesStringBeforeHandlingItOverToTheDecoratedLexer(string $value, ?string $expectedEscapedValue = null): void { if (null === $expectedEscapedValue) { $expectedEscapedValue = $value; @@ -54,12 +55,12 @@ public function testEscapesStringBeforeHandlingItOverToTheDecoratedLexer(string $lexer = new ReferenceEscaperLexer($decoratedLexer); $actual = $lexer->lex($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedLexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); } - public function provideValues() + public function provideValues(): iterable { yield 'empty string' => ['']; diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexerTest.php index 99384eee8..7dbe2a0fa 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceLexerTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\ReferenceLexer + * @internal */ class ReferenceLexerTest extends TestCase { @@ -30,7 +31,7 @@ class ReferenceLexerTest extends TestCase * @var ReferenceLexer */ private $lexer; - + protected function setUp(): void { $this->lexer = new ReferenceLexer(); @@ -38,12 +39,12 @@ protected function setUp(): void public function testIsALexer(): void { - static::assertInstanceOf(LexerInterface::class, $this->lexer); + self::assertInstanceOf(LexerInterface::class, $this->lexer); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ReferenceLexer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ReferenceLexer::class))->isCloneable()); } public function testThrowsAnExceptionWhenAnInvalidValueIsGiven(): void @@ -61,7 +62,7 @@ public function testReturnsMatchingToken(string $value, array $expected): void { $actual = $this->lexer->lex($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testUsesTheRegexCachedGroupForTheTokenValue(): void @@ -71,7 +72,7 @@ public function testUsesTheRegexCachedGroupForTheTokenValue(): void $actual = $this->lexer->lex($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfNoMatchingPatternFound(): void @@ -82,7 +83,7 @@ public function testThrowsAnExceptionIfNoMatchingPatternFound(): void $this->lexer->lex('foo'); } - public function provideValues() + public function provideValues(): iterable { yield 'method reference' => [ $value = '@user->getUserName()', diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexerTest.php index 25263558f..b8e478080 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/StringThenReferenceLexerTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\StringThenReferenceLexer + * @internal */ class StringThenReferenceLexerTest extends TestCase { @@ -30,12 +31,12 @@ class StringThenReferenceLexerTest extends TestCase public function testIsALexer(): void { - static::assertTrue(is_a(StringThenReferenceLexer::class, LexerInterface::class, true)); + self::assertTrue(is_a(StringThenReferenceLexer::class, LexerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StringThenReferenceLexer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StringThenReferenceLexer::class))->isCloneable()); } public function testMergesNonEmptyStringFollowedByAReference(): void @@ -56,17 +57,16 @@ public function testMergesNonEmptyStringFollowedByAReference(): void new Token('55', new TokenType(TokenType::STRING_TYPE)), new Token('@example.com', new TokenType(TokenType::SIMPLE_REFERENCE_TYPE)), new Token(' bar', new TokenType(TokenType::STRING_TYPE)), - ] - ) - ; + ], + ); /** @var LexerInterface $decoratedLexer */ $decoratedLexer = $decoratedLexerProphecy->reveal(); $lexer = new StringThenReferenceLexer($decoratedLexer); $actual = $lexer->lex($value); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); $decoratedLexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexerTest.php index 4919d39ac..0cef035c5 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexerTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\SubPatternsLexer + * @internal */ class SubPatternsLexerTest extends TestCase { @@ -31,12 +32,12 @@ class SubPatternsLexerTest extends TestCase public function testIsALexer(): void { - static::assertTrue(is_a(SubPatternsLexer::class, LexerInterface::class, true)); + self::assertTrue(is_a(SubPatternsLexer::class, LexerInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SubPatternsLexer::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SubPatternsLexer::class))->isCloneable()); } public function testLexAValueToReturnAListOfTokens(): void @@ -48,8 +49,8 @@ public function testLexAValueToReturnAListOfTokens(): void $lexer = new SubPatternsLexer(new FakeLexer()); $actual = $lexer->lex('<{param}>'); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); } /** @@ -64,8 +65,8 @@ public function testLexAFunctionContainingLineBreaks(string $lineBreak): void $lexer = new SubPatternsLexer(new FakeLexer()); $actual = $lexer->lex(''); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); } public function testUsesDecoratedLexerToLexReferenceValues(): void @@ -83,8 +84,8 @@ public function testUsesDecoratedLexerToLexReferenceValues(): void $lexer = new SubPatternsLexer($referenceLexer); $actual = $lexer->lex($value); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); $referenceLexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -99,8 +100,8 @@ public function testReturnsAStringTokenIfCannotLexValue(): void $lexer = new SubPatternsLexer(new FakeLexer()); $actual = $lexer->lex($value); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionWhenAnInvalidValueIsGiven(): void @@ -113,7 +114,7 @@ public function testThrowsAnExceptionWhenAnInvalidValueIsGiven(): void $lexer->lex(''); } - public function lineBreaksProvider() + public function lineBreaksProvider(): iterable { return [ ['\n'], diff --git a/tests/FixtureBuilder/ExpressionLanguage/LexerParserSynchronizationTest.php b/tests/FixtureBuilder/ExpressionLanguage/LexerParserSynchronizationTest.php index 5a04977c3..8c9fcaa15 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/LexerParserSynchronizationTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/LexerParserSynchronizationTest.php @@ -19,6 +19,7 @@ /** * @coversNothing + * @internal */ class LexerParserSynchronizationTest extends TestCase { @@ -37,9 +38,9 @@ public function testProvidesAreSynchronized(): void } foreach ($lexerProviderKeys as $index => $lexerProviderKey) { - static::assertEquals($lexerProviderKey, $parserProviderKeys[$index]); + self::assertEquals($lexerProviderKey, $parserProviderKeys[$index]); } - static::assertCount(count($lexerProviderKeys), $parserProviderKeys); + self::assertCount(count($lexerProviderKeys), $parserProviderKeys); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParserTest.php index 6defdccea..cedfb07c3 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParserTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\FunctionFixtureReferenceParser + * @internal */ class FunctionFixtureReferenceParserTest extends TestCase { @@ -32,12 +33,12 @@ class FunctionFixtureReferenceParserTest extends TestCase public function testIsAParser(): void { - static::assertTrue(is_a(FunctionFixtureReferenceParser::class, ParserInterface::class, true)); + self::assertTrue(is_a(FunctionFixtureReferenceParser::class, ParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FunctionFixtureReferenceParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FunctionFixtureReferenceParser::class))->isCloneable()); } public function testIsInstantiatedWithAParser(): void @@ -58,7 +59,7 @@ public function testUsesTheDecoratedParserToParseTheGivenValueAndReturnsItsResul $parser = new FunctionFixtureReferenceParser($decoratedParser); $actual = $parser->parse($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -85,9 +86,8 @@ public function testIfTheValueReturnedIsAListValueThenIteratesOverEachValuesToHa new FakeValue(), new FixtureReferenceValue('hatter'), new FunctionCallValue('h'), - ]) - ) - ; + ]), + ); /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); @@ -97,7 +97,7 @@ public function testIfTheValueReturnedIsAListValueThenIteratesOverEachValuesToHa new ListValue([ 'bob', new FunctionCallValue('f'), - ]) + ]), ), new FakeValue(), new FunctionCallValue('i'), @@ -111,14 +111,14 @@ public function testIfTheValueReturnedIsAListValueThenIteratesOverEachValuesToHa new ListValue([ 'hatter', new FunctionCallValue('h'), - ]) + ]), ), ]); $parser = new FunctionFixtureReferenceParser($decoratedParser); $actual = $parser->parse($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -134,9 +134,8 @@ public function testIfNotFunctionFixtureReferenceIsFoundThenTheResultWillRemainU new ListValue([ new FakeValue(), new FakeValue(), - ]) - ) - ; + ]), + ); /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); @@ -148,13 +147,15 @@ public function testIfNotFunctionFixtureReferenceIsFoundThenTheResultWillRemainU $parser = new FunctionFixtureReferenceParser($decoratedParser); $actual = $parser->parse($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } /** * @dataProvider provideOneElementValues + * @param mixed $value + * @param mixed $expected */ public function testIfThereIsOnlyOneElementThenReturnTheElementInsteadOfAValueList($value, $expected): void { @@ -166,10 +167,10 @@ public function testIfThereIsOnlyOneElementThenReturnTheElementInsteadOfAValueLi $parser = new FunctionFixtureReferenceParser($decoratedParser); $actual = $parser->parse(''); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function provideOneElementValues() + public function provideOneElementValues(): iterable { yield 'one value' => [ new FakeValue(), @@ -187,7 +188,7 @@ public function provideOneElementValues() new FunctionCallValue('foo'), ]), new FixtureReferenceValue( - new FunctionCallValue('foo') + new FunctionCallValue('foo'), ), ]; } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php index dd575d25f..940d98604 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/ParserIntegrationTest.php @@ -13,7 +13,6 @@ namespace Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser; -use const DIRECTORY_SEPARATOR; use InvalidArgumentException; use Nelmio\Alice\Definition\MethodCall\IdentityFactory; use Nelmio\Alice\Definition\Value\ArrayValue; @@ -33,11 +32,13 @@ use Nelmio\Alice\Throwable\ExpressionLanguageParseThrowable; use PHPUnit\Framework\TestCase; use function str_repeat; +use const DIRECTORY_SEPARATOR; /** * @group integration * * @coversNothing + * @internal */ class ParserIntegrationTest extends TestCase { @@ -53,6 +54,7 @@ protected function setUp(): void /** * @dataProvider provideValues + * @param mixed $expected */ public function testParseValues(string $value, $expected): void { @@ -60,12 +62,12 @@ public function testParseValues(string $value, $expected): void $actual = $this->parser->parse($value); if (null === $expected) { - static::fail( + self::fail( sprintf( 'Expected exception to be thrown for "%s", got "%s" instead.', $value, - var_export($actual, true) - ) + var_export($actual, true), + ), ); } } catch (InvalidArgumentException $exception) { @@ -82,10 +84,10 @@ public function testParseValues(string $value, $expected): void throw $exception; } - static::assertEquals($expected, $actual, var_export($actual, true)); + self::assertEquals($expected, $actual, var_export($actual, true)); } - public function provideValues() + public function provideValues(): iterable { // Simple values yield 'empty string' => [ @@ -150,7 +152,7 @@ public function provideValues() new ListValue([ '@', new FunctionCallValue('foo'), - ]) + ]), ]; yield '[Escape character] double escape with reference' => [ '\\\\@', @@ -336,7 +338,7 @@ public function provideValues() 'f', [ new FunctionCallValue('g'), - ] + ], ), ]; yield '[Function] nominal surrounded' => [ @@ -376,7 +378,7 @@ public function provideValues() [ new VariableValue('foo'), new VariableValue('arg'), - ] + ], ), ]; yield '[Function] nominal with string arguments which contains quotes' => [ @@ -398,7 +400,7 @@ public function provideValues() '012', '+012', '-012', - ] + ], ), ]; yield '[Function] nominal with boolean arguments' => [ @@ -408,14 +410,14 @@ public function provideValues() [ true, false, - ] + ], ), ]; yield '[Function] nominal with null arguments' => [ '', new FunctionCallValue( 'function', - [null] + [null], ), ]; yield '[Function] nominal with numeric arguments' => [ @@ -432,7 +434,7 @@ public function provideValues() 10, 10, -10, - ] + ], ), ]; yield '[Function] nominal with array argument which contains string elements in quotes' => [ @@ -441,7 +443,7 @@ public function provideValues() 'function', [ new ArrayValue(['foo', 'bar']), - ] + ], ), ]; yield '[Function] unbalanced with arguments (1)' => [ @@ -478,14 +480,14 @@ public function provideValues() [ new VariableValue('foo'), new VariableValue('arg'), - ] + ], ), new FunctionCallValue( 'g', [ new VariableValue('baz'), new VariableValue('faz'), - ] + ], ), ]), ]; @@ -497,7 +499,7 @@ public function provideValues() [ new VariableValue('foo'), new VariableValue('arg'), - ] + ], ), ' ', new FunctionCallValue( @@ -505,7 +507,7 @@ public function provideValues() [ new VariableValue('baz'), new VariableValue('faz'), - ] + ], ), ]), ]; @@ -518,16 +520,16 @@ public function provideValues() 'g', [ new VariableValue('baz'), - ] + ], ), new VariableValue('arg'), - ] + ], ), ]; yield '[Function] nested functions with multiple arguments' => [ ', $arg)>', null, // Will fail because cannot guess that the first comma is for the nested function and not for the - // parent function. + // parent function. ]; yield '[Function] nominal surrounded with arguments' => [ 'foo bar', @@ -538,7 +540,7 @@ public function provideValues() [ new VariableValue('foo'), new VariableValue('arg'), - ] + ], ), ' bar', ]), @@ -563,7 +565,7 @@ public function provideValues() '-12 months', '', ',', - ] + ], ), ]; @@ -573,7 +575,7 @@ public function provideValues() 'function', [ 'foo\nbar', - ] + ], ), ]; @@ -583,7 +585,7 @@ public function provideValues() 'function', [ 'foo\\r\\nbar', - ] + ], ), ]; @@ -594,7 +596,7 @@ public function provideValues() [ // On windows if true DIRECTORY_SEPARATOR === '\\' ? 'foo\nbar' : 'foo'.PHP_EOL.'bar', - ] + ], ), ]; @@ -605,7 +607,7 @@ public function provideValues() [ // On windows if true DIRECTORY_SEPARATOR === '\\' ? 'foo'.PHP_EOL.'bar' : 'foo\r'.PHP_EOL.'bar', - ] + ], ), ]; @@ -617,7 +619,7 @@ public function provideValues() [ // On windows if true $args, - ] + ], ), ]; @@ -626,7 +628,7 @@ public function provideValues() '10x @user', new DynamicArrayValue( 10, - new FixtureReferenceValue('user') + new FixtureReferenceValue('user'), ), ]; yield '[Array] string array with negative number' => [ @@ -644,7 +646,7 @@ public function provideValues() new ListValue([ new FixtureReferenceValue('user'), ' bar', - ]) + ]), ), ]; yield '[Array] string array with P1' => [ @@ -658,13 +660,13 @@ public function provideValues() new ArrayValue([ new FixturePropertyValue( new FixtureReferenceValue('user'), - 'name' + 'name', ), new FixtureMethodCallValue( new FixtureReferenceValue('group'), - new FunctionCallValue('getName') + new FunctionCallValue('getName'), ), - ]) + ]), ), ]; yield '[Array] escaped array' => [ @@ -696,11 +698,11 @@ public function provideValues() new ArrayValue([ new FixturePropertyValue( new FixtureReferenceValue('user'), - 'name' + 'name', ), new FixtureMethodCallValue( new FixtureReferenceValue('group'), - new FunctionCallValue('getName') + new FunctionCallValue('getName'), ), ]), ]; @@ -710,7 +712,7 @@ public function provideValues() '80%? Y', new OptionalValue( '80', - 'Y' + 'Y', ), ]; yield '[Optional] with negative number' => [ @@ -719,22 +721,22 @@ public function provideValues() '-', new OptionalValue( '50', - 'Y' - ) + 'Y', + ), ]), ]; yield '[Optional] with float' => [ '0.5%? Y', new OptionalValue( '0.5', - 'Y' + 'Y', ), ]; yield '[Optional] with ' => [ '<{dummy}>%? Y', new OptionalValue( new ParameterValue('dummy'), - 'Y' + 'Y', ), ]; yield '[Optional] complete' => [ @@ -742,7 +744,7 @@ public function provideValues() new OptionalValue( '80', 'Y', - 'Z' + 'Z', ), ]; yield '[Optional] complete with superfluous space' => [ @@ -750,7 +752,7 @@ public function provideValues() new OptionalValue( '80', 'Y', - 'Z' + 'Z', ), ]; yield '[Optional] complete with negative number' => [ @@ -760,7 +762,7 @@ public function provideValues() new OptionalValue( '50', 'Y', - 'Z' + 'Z', ), ]), ]; @@ -769,15 +771,15 @@ public function provideValues() new OptionalValue( '0.5', 'Y', - 'Z' - ) + 'Z', + ), ]; yield '[Optional] complete with ' => [ '<{dummy}>%? Y: Z', new OptionalValue( new ParameterValue('dummy'), 'Y', - 'Z' + 'Z', ), ]; yield '[Optional] nominal with left member' => [ @@ -786,8 +788,8 @@ public function provideValues() 'foo ', new OptionalValue( '80', - 'Y' - ) + 'Y', + ), ]), ]; yield '[Optional] with negative number and left member' => [ @@ -796,8 +798,8 @@ public function provideValues() 'foo -', new OptionalValue( '50', - 'Y' - ) + 'Y', + ), ]), ]; yield '[Optional] with float and left member' => [ @@ -806,8 +808,8 @@ public function provideValues() 'foo ', new OptionalValue( '0.5', - 'Y' - ) + 'Y', + ), ]), ]; yield '[Optional] with and left member' => [ @@ -816,8 +818,8 @@ public function provideValues() 'foo ', new OptionalValue( new ParameterValue('dummy'), - 'Y' - ) + 'Y', + ), ]), ]; yield '[Optional] complete with left member' => [ @@ -827,8 +829,8 @@ public function provideValues() new OptionalValue( '80', 'Y', - 'Z' - ) + 'Z', + ), ]), ]; yield '[Optional] complete with negative number and left member' => [ @@ -838,8 +840,8 @@ public function provideValues() new OptionalValue( '50', 'Y', - 'Z' - ) + 'Z', + ), ]), ]; yield '[Optional] complete with float and left member' => [ @@ -849,8 +851,8 @@ public function provideValues() new OptionalValue( '0.5', 'Y', - 'Z' - ) + 'Z', + ), ]), ]; yield '[Optional] complete with and left member' => [ @@ -860,8 +862,8 @@ public function provideValues() new OptionalValue( new ParameterValue('dummy'), 'Y', - 'Z' - ) + 'Z', + ), ]), ]; yield '[Optional] without members' => [ @@ -880,7 +882,7 @@ public function provideValues() '80%? foo bar', new OptionalValue( '80', - 'foo bar' + 'foo bar', ), ]; yield '[Optional] with first member containing a space and second member' => [ @@ -888,7 +890,7 @@ public function provideValues() new OptionalValue( '80', 'foo bar', - 'baz' + 'baz', ), ]; yield '[Optional] with first member containing a space and second member too' => [ @@ -897,7 +899,7 @@ public function provideValues() new OptionalValue( '80', 'foo bar', - 'baz' + 'baz', ), ' faz', ]), @@ -908,7 +910,7 @@ public function provideValues() new OptionalValue( '80', 'foo', - 'bar' + 'bar', ), ' baz', ]), @@ -932,7 +934,7 @@ public function provideValues() new OptionalValue( '80', new ParameterValue('dummy'), - new FunctionCallValue('another') + new FunctionCallValue('another'), ), ' baz', ]), @@ -944,19 +946,19 @@ public function provideValues() new ListValue([ new FunctionCallValue( 'foo', - [] + [], ), ' -', new OptionalValue( '80', new ParameterValue('dum10'), - null + null, ), ]), 'y', - 'z' + 'z', ), - ' my>: \ ' + ' my>: \ ', ]), ]; @@ -988,9 +990,9 @@ public function provideValues() 'user0_', new FunctionCallValue( 'current', - [new ValueForCurrentValue()] - ) - ]) + [new ValueForCurrentValue()], + ), + ]), ), ]; yield '[Reference] escaped alone with strings' => [ @@ -1015,14 +1017,14 @@ public function provideValues() '@user0->username', new FixturePropertyValue( new FixtureReferenceValue('user0'), - 'username' + 'username', ), ]; yield '[Reference] wildcard with prop' => [ '@user*->username', new FixturePropertyValue( FixtureMatchReferenceValue::createWildcardReference('user'), - 'username' + 'username', ), ]; yield '[Reference] list with prop' => [ @@ -1032,7 +1034,7 @@ public function provideValues() new FixtureReferenceValue('useralice'), new FixtureReferenceValue('userbob'), ]), - 'username' + 'username', ), ]; yield '[Reference] range with prop' => [ @@ -1042,7 +1044,7 @@ public function provideValues() new FixtureReferenceValue('user1'), new FixtureReferenceValue('user2'), ]), - 'username' + 'username', ), ]; yield '[Reference] variable with prop' => [ @@ -1052,9 +1054,9 @@ public function provideValues() new ListValue([ 'user', new VariableValue('foo'), - ]) + ]), ), - 'username' + 'username', ), ]; yield '[Reference] left with prop' => [ @@ -1063,16 +1065,16 @@ public function provideValues() 'foo ', new FixturePropertyValue( new FixtureReferenceValue('user0'), - 'username' + 'username', ), - ]) + ]), ]; yield '[Reference] right with prop' => [ '@user0->username bar', new ListValue([ new FixturePropertyValue( new FixtureReferenceValue('user0'), - 'username' + 'username', ), ' bar', ]), @@ -1099,7 +1101,6 @@ public function provideValues() new FixtureReferenceValue('user0'), new FixtureReferenceValue('user1'), ' bar', - ]), ]; yield '[Reference] nominal range' => [ @@ -1138,9 +1139,9 @@ public function provideValues() new ListValue([ new FixturePropertyValue( new FixtureReferenceValue('user'), - 'username' + 'username', ), - '{1..2}' + '{1..2}', ]), ]; yield '[Reference] range-method' => [ @@ -1148,9 +1149,9 @@ public function provideValues() new ListValue([ new FixtureMethodCallValue( new FixtureReferenceValue('user'), - new FunctionCallValue('getUserName') + new FunctionCallValue('getUserName'), ), - '{1..2}' + '{1..2}', ]), ]; yield '[Reference] with nested with prop' => [ @@ -1167,12 +1168,12 @@ public function provideValues() 'foo ', new FixturePropertyValue( new FixtureReferenceValue('user0'), - 'username' + 'username', ), ' ', new FixturePropertyValue( new FixtureReferenceValue('user1'), - 'name' + 'name', ), ' bar', ]), @@ -1181,14 +1182,14 @@ public function provideValues() '@user0->getUserName()', new FixtureMethodCallValue( new FixtureReferenceValue('user0'), - new FunctionCallValue('getUserName') + new FunctionCallValue('getUserName'), ), ]; yield '[Reference] wildcard alone with function' => [ '@user*->getUserName()', new FixtureMethodCallValue( FixtureMatchReferenceValue::createWildcardReference('user'), - new FunctionCallValue('getUserName') + new FunctionCallValue('getUserName'), ), ]; yield '[Reference] function surrounded' => [ @@ -1197,7 +1198,7 @@ public function provideValues() 'foo ', new FixtureMethodCallValue( new FixtureReferenceValue('user0'), - new FunctionCallValue('getUserName') + new FunctionCallValue('getUserName'), ), ' bar', ]), @@ -1210,8 +1211,8 @@ public function provideValues() 'getUserName', [ new VariableValue('username'), - ] - ) + ], + ), ), ]; yield '[Reference] alone with function with arguments containing nested reference' => [ @@ -1252,7 +1253,7 @@ public function provideValues() new FixtureReferenceValue('useralice'), new FixtureReferenceValue('userbob'), ]), - new FunctionCallValue('getUserName', []) + new FunctionCallValue('getUserName', []), ), ]; yield '[Reference] surrounded list' => [ @@ -1271,8 +1272,8 @@ public function provideValues() new FixtureReferenceValue( new ListValue([ 'user0', - new VariableValue('foo') - ]) + new VariableValue('foo'), + ]), ), ]; yield '[Reference] reference function' => [ @@ -1280,8 +1281,8 @@ public function provideValues() new FixtureReferenceValue( new ListValue([ 'user0', - new FunctionCallValue('foo') - ]) + new FunctionCallValue('foo'), + ]), ), ]; yield '[Reference] reference which is entirely a function' => [ @@ -1290,7 +1291,7 @@ public function provideValues() new ListValue([ '', new FunctionCallValue('foo'), - ]) + ]), ), ]; yield '[Reference] surrounded reference function' => [ @@ -1300,8 +1301,8 @@ public function provideValues() new FixtureReferenceValue( new ListValue([ 'user0', - new FunctionCallValue('foo') - ]) + new FunctionCallValue('foo'), + ]), ), ' bar', ]), @@ -1316,9 +1317,9 @@ public function provideValues() [ new VariableValue('foo'), new VariableValue('bar'), - ] - ) - ]) + ], + ), + ]), ), ]; yield '[Reference] surrounded reference function with args' => [ @@ -1333,9 +1334,9 @@ public function provideValues() [ new VariableValue('foo'), new VariableValue('bar'), - ] - ) - ]) + ], + ), + ]), ), ' bar', ]), @@ -1363,8 +1364,8 @@ public function provideValues() new FixtureReferenceValue( new ListValue([ 'user0', - new FunctionCallValue('current', [new ValueForCurrentValue()]) - ]) + new FunctionCallValue('current', [new ValueForCurrentValue()]), + ]), ), ' bar', ]), @@ -1378,10 +1379,10 @@ public function provideValues() new FixtureReferenceValue( new ListValue([ 'user0', - new FunctionCallValue('current', [new ValueForCurrentValue()]) - ]) + new FunctionCallValue('current', [new ValueForCurrentValue()]), + ]), ), - 'prop' + 'prop', ), ' bar', ]), diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/SimpleParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/SimpleParserTest.php index e192e8652..d4fad6f54 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/SimpleParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/SimpleParserTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\SimpleParser + * @internal */ class SimpleParserTest extends TestCase { @@ -37,12 +38,12 @@ class SimpleParserTest extends TestCase public function testIsAParser(): void { - static::assertTrue(is_a(SimpleParser::class, ParserInterface::class, true)); + self::assertTrue(is_a(SimpleParser::class, ParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleParser::class))->isCloneable()); } public function testCanBeInstantiatedWithALexerAndAParser(): void @@ -55,7 +56,7 @@ public function testIfParserIsParserAwareThenItInjectsItselfToIt(): void $decoratedParser = new DummyChainableTokenParserAware(); $parser = new SimpleParser(new FakeLexer(), $decoratedParser); - static::assertSame($parser, $decoratedParser->parser); + self::assertSame($parser, $decoratedParser->parser); } public function testLexValueAndParsesEachTokenToReturnAValue(): void @@ -106,9 +107,9 @@ public function testIfTheLexProcessReturnsATokensSurroundedWithSpacesTheTrimsThe $parser = new SimpleParser($lexer, $tokenParser); $parsedValue = $parser->parse($value); - static::assertEquals( + self::assertEquals( 'parsed_foo', - $parsedValue + $parsedValue, ); } @@ -133,12 +134,12 @@ public function testIfTheLexProcessReturnsMultipleTokensThenTheValueReturnedWill $parser = new SimpleParser($lexer, $tokenParser); $parsedValue = $parser->parse($value); - static::assertEquals( + self::assertEquals( new ListValue([ new ParameterValue('parsed_foo'), 'parsed_bar', ]), - $parsedValue + $parsedValue, ); } @@ -161,9 +162,9 @@ public function testIfOnlyOneTokensFoundThenReturnsASimpleValue(): void $parser = new SimpleParser($lexer, $tokenParser); $parsedValue = $parser->parse($value); - static::assertEquals( + self::assertEquals( 'parsed_foo', - $parsedValue + $parsedValue, ); } @@ -188,9 +189,8 @@ public function testIfATokenIsParsedIntoANestedValueThenItsValuesAreMerged(): vo new NestedValue([ 'first', 'second', - ]) - ) - ; + ]), + ); $tokenParserProphecy->parse($token3)->willReturn('parsed_baz'); /** @var TokenParserInterface $tokenParser */ $tokenParser = $tokenParserProphecy->reveal(); @@ -205,7 +205,7 @@ public function testIfATokenIsParsedIntoANestedValueThenItsValuesAreMerged(): vo $parser = new SimpleParser($lexer, $tokenParser); $actual = $parser->parse($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $lexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1); $tokenParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(3); diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParserTest.php index c1ac8a2e8..5ac5e34aa 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParserTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\StringMergerParser + * @internal */ class StringMergerParserTest extends TestCase { @@ -30,12 +31,12 @@ class StringMergerParserTest extends TestCase public function testIsAParser(): void { - static::assertTrue(is_a(StringMergerParser::class, ParserInterface::class, true)); + self::assertTrue(is_a(StringMergerParser::class, ParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StringMergerParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StringMergerParser::class))->isCloneable()); } public function testIsInstantiatedWithAParser(): void @@ -56,7 +57,7 @@ public function testUsesTheDecoratedParserToParseTheGivenValueAndReturnsItsResul $parser = new StringMergerParser($decoratedParser); $actual = $parser->parse($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -79,9 +80,8 @@ public function testIfTheValueReturnedIsAListValueThenIteratesOverEachValuesToMe new FakeValue(), 'er', 'ty', - ]) - ) - ; + ]), + ); /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); @@ -97,7 +97,7 @@ public function testIfTheValueReturnedIsAListValueThenIteratesOverEachValuesToMe $parser = new StringMergerParser($decoratedParser); $actual = $parser->parse($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -117,9 +117,8 @@ public function testIfNotFunctionFixtureReferenceIsFoundThenTheResultWillRemainU 'qw', new FakeValue(), 'erty', - ]) - ) - ; + ]), + ); /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); @@ -135,13 +134,15 @@ public function testIfNotFunctionFixtureReferenceIsFoundThenTheResultWillRemainU $parser = new StringMergerParser($decoratedParser); $actual = $parser->parse($value); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } /** * @dataProvider provideOneElementValues + * @param mixed $parsedValue + * @param mixed $expected */ public function testIfThereIsOnlyOneElementThenReturnTheElementInsteadOfAValueList($parsedValue, $expected): void { @@ -153,10 +154,10 @@ public function testIfThereIsOnlyOneElementThenReturnTheElementInsteadOfAValueLi $parser = new StringMergerParser($decoratedParser); $actual = $parser->parse(''); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function provideOneElementValues() + public function provideOneElementValues(): iterable { yield 'one value' => [ new FakeValue(), diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParserTest.php index ec73f2915..b076727fd 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParserTest.php @@ -22,17 +22,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\AbstractChainableParserAwareParser + * @internal */ class AbstractChainableParserAwareParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(ImpartialChainableParserAwareParser::class, AbstractChainableParserAwareParser::class, true)); + self::assertTrue(is_a(ImpartialChainableParserAwareParser::class, AbstractChainableParserAwareParser::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ImpartialChainableParserAwareParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ImpartialChainableParserAwareParser::class))->isCloneable()); } public function testCanBeInstantiatedWithoutAParser(): void @@ -50,8 +51,8 @@ public function testWithersReturnNewAModifiedInstance(): void $parser = new ImpartialChainableParserAwareParser(); $newParser = $parser->withParser(new FakeParser()); - static::assertEquals(new ImpartialChainableParserAwareParser(), $parser); - static::assertEquals(new ImpartialChainableParserAwareParser(new FakeParser()), $newParser); + self::assertEquals(new ImpartialChainableParserAwareParser(), $parser); + self::assertEquals(new ImpartialChainableParserAwareParser(new FakeParser()), $newParser); } public function testThrowsAnExceptionIfNoDecoratedParserIsFound(): void @@ -70,6 +71,6 @@ public function testDoNothingIfTriesToParseATokenAndDecoratedParserIsFound(): vo $token = new Token('', new TokenType(TokenType::DYNAMIC_ARRAY_TYPE)); $parser = new ImpartialChainableParserAwareParser(new FakeParser()); - static::assertNull($parser->parse($token)); + self::assertNull($parser->parse($token)); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParserTest.php index 3f3f18dea..0d8f903de 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/DynamicArrayTokenParserTest.php @@ -29,6 +29,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\DynamicArrayTokenParser + * @internal */ class DynamicArrayTokenParserTest extends TestCase { @@ -36,12 +37,12 @@ class DynamicArrayTokenParserTest extends TestCase public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(DynamicArrayTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(DynamicArrayTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(DynamicArrayTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(DynamicArrayTokenParser::class))->isCloneable()); } public function testCanParseDynamicArrayTokens(): void @@ -50,8 +51,8 @@ public function testCanParseDynamicArrayTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new DynamicArrayTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfNoDecoratedParserIsFound(): void @@ -91,7 +92,7 @@ public function testReturnsADynamicArrayIfCanParseToken(): void $parser = new DynamicArrayTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); } @@ -111,7 +112,7 @@ public function testParsedDynamicArrayQuantifierCanBeAValue(): void $parser = new DynamicArrayTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParserTest.php index be6938908..2927eb354 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/EscapedValueTokenParserTest.php @@ -22,17 +22,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\EscapedValueTokenParser + * @internal */ class EscapedValueTokenParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(EscapedValueTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(EscapedValueTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(EscapedValueTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(EscapedValueTokenParser::class))->isCloneable()); } /** @@ -43,7 +44,7 @@ public function testCanParseEscapedTokens(Token $token, bool $expected): void $parser = new EscapedValueTokenParser(); $actual = $parser->canParse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfAMalformedTokenIsGiven(): void @@ -66,7 +67,7 @@ public function testReturnsEscapedValue(): void $parser = new EscapedValueTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testTheEscapedValueIsDetokenizedBeforeBeingReturned(): void @@ -77,10 +78,10 @@ public function testTheEscapedValueIsDetokenizedBeforeBeingReturned(): void $parser = new EscapedValueTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function provideTokens() + public function provideTokens(): iterable { return [ [ diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParserTest.php index aa07ec2b1..79313c856 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureListReferenceTokenParserTest.php @@ -24,17 +24,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\FixtureListReferenceTokenParser + * @internal */ class FixtureListReferenceTokenParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(FixtureListReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(FixtureListReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FixtureListReferenceTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FixtureListReferenceTokenParser::class))->isCloneable()); } /** @@ -45,7 +46,7 @@ public function testCanParseListReferenceTokens(Token $token, bool $expected): v $parser = new FixtureListReferenceTokenParser(); $actual = $parser->canParse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfInvalidTokenIsGiven(): void @@ -83,10 +84,10 @@ public function testReturnsListOfPossibleValues(): void $parser = new FixtureListReferenceTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function provideTokens() + public function provideTokens(): iterable { return [ [ diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParserTest.php index d78b78f39..bb7794dde 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureMethodReferenceTokenParserTest.php @@ -29,6 +29,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\FixtureMethodReferenceTokenParser + * @internal */ class FixtureMethodReferenceTokenParserTest extends TestCase { @@ -36,12 +37,12 @@ class FixtureMethodReferenceTokenParserTest extends TestCase public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(FixtureMethodReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(FixtureMethodReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FixtureMethodReferenceTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FixtureMethodReferenceTokenParser::class))->isCloneable()); } public function testCanParseMethodReferenceTokens(): void @@ -50,8 +51,8 @@ public function testCanParseMethodReferenceTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new FixtureMethodReferenceTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfNoDecoratedParserIsFound(): void @@ -73,7 +74,6 @@ public function testThrowsAnExceptionIfCouldNotParseToken(): void $this->expectException(ParseException::class); $this->expectExceptionMessage('Could not parse the token "" (type: METHOD_REFERENCE_TYPE).'); - $parser->parse($token); } @@ -92,7 +92,7 @@ public function testReturnsFunctionValue(): void $parser = new FixtureMethodReferenceTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfMethodReferenceIsMalformed(): void @@ -117,18 +117,18 @@ public function testThrowsAnExceptionIfParsingReturnsAnUnexpectedResult(ParserIn $parser = new FixtureMethodReferenceTokenParser($decoratedParser); $parser->parse($token); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (ParseException $exception) { - static::assertEquals( + self::assertEquals( 'Could not parse the token "@user->getName()" (type: METHOD_REFERENCE_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } - public function provideParser() + public function provideParser(): iterable { $decoratedParserProphecy = $this->prophesize(ParserInterface::class); $decoratedParserProphecy->parse('@user')->willReturn('foo'); diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParserTest.php index 5502400ae..4346d5730 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParserTest.php @@ -24,17 +24,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\FixtureRangeReferenceTokenParser + * @internal */ class FixtureRangeReferenceTokenParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(FixtureRangeReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(FixtureRangeReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FixtureRangeReferenceTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FixtureRangeReferenceTokenParser::class))->isCloneable()); } public function testCanParseRangedReferencesTokens(): void @@ -43,8 +44,8 @@ public function testCanParseRangedReferencesTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new FixtureRangeReferenceTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfPassedTokenIsMalformed(): void @@ -55,7 +56,6 @@ public function testThrowsAnExceptionIfPassedTokenIsMalformed(): void $this->expectException(ParseException::class); $this->expectExceptionMessage('Could not parse the token "" (type: RANGE_REFERENCE_TYPE).'); - $parser->parse($token); } @@ -94,7 +94,7 @@ public function testReturnsAChoiceListIfCanParseToken(): void $parser = new FixtureRangeReferenceTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testReturnsAChoiceListWithStepsIfCanParseToken(): void @@ -109,6 +109,6 @@ public function testReturnsAChoiceListWithStepsIfCanParseToken(): void $parser = new FixtureRangeReferenceTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php index 7492ba3b1..08ad13f0e 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\IdentityTokenParser + * @internal */ class IdentityTokenParserTest extends TestCase { @@ -30,12 +31,12 @@ class IdentityTokenParserTest extends TestCase public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(IdentityTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(IdentityTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(IdentityTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(IdentityTokenParser::class))->isCloneable()); } public function testCanParseIdentityTokens(): void @@ -44,8 +45,8 @@ public function testCanParseIdentityTokens(): void $anotherToken = new Token('', new TokenType(TokenType::ESCAPED_VALUE_TYPE)); $parser = new IdentityTokenParser(new FakeChainableTokenParser()); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testReplaceIdentityIntoAFunctionCallBeforeHandingItOverToItsDecorated(): void @@ -55,17 +56,16 @@ public function testReplaceIdentityIntoAFunctionCallBeforeHandingItOverToItsDeco $decoratedParserProphecy = $this->prophesize(ChainableTokenParserInterface::class); $decoratedParserProphecy ->parse( - new Token('', new TokenType(TokenType::FUNCTION_TYPE)) + new Token('', new TokenType(TokenType::FUNCTION_TYPE)), ) - ->willReturn($expected = 'foo') - ; + ->willReturn($expected = 'foo'); /** @var ChainableTokenParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); $parser = new IdentityTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -77,17 +77,16 @@ public function testSupportNewlines(): void $decoratedParserProphecy = $this->prophesize(ChainableTokenParserInterface::class); $decoratedParserProphecy ->parse( - new Token("", new TokenType(TokenType::FUNCTION_TYPE)) + new Token("", new TokenType(TokenType::FUNCTION_TYPE)), ) - ->willReturn($expected = 'foo') - ; + ->willReturn($expected = 'foo'); /** @var ChainableTokenParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); $parser = new IdentityTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParserTest.php index eab512851..c6a641fa2 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/MethodReferenceTokenParserTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\MethodReferenceTokenParser + * @internal */ class MethodReferenceTokenParserTest extends TestCase { @@ -37,12 +38,12 @@ class MethodReferenceTokenParserTest extends TestCase public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(MethodReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(MethodReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(MethodReferenceTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(MethodReferenceTokenParser::class))->isCloneable()); } public function testCanParseMethodTokens(): void @@ -51,8 +52,8 @@ public function testCanParseMethodTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new MethodReferenceTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfNoDecoratedParserIsFound(): void @@ -82,12 +83,10 @@ public function testThrowsAnExceptionIfParsingReferenceGivesAnUnexpectedResult() $token = new Token('@@malformed_user->getUserName(arg1, arg2)', new TokenType(TokenType::METHOD_REFERENCE_TYPE)); $decoratedParserProphecy = $this->prophesize(ParserInterface::class); - $decoratedParserProphecy->parse('@@malformed_user')->willReturn('string value') - ; + $decoratedParserProphecy->parse('@@malformed_user')->willReturn('string value'); $decoratedParserProphecy ->parse('') - ->willReturn($call = new FunctionCallValue('getUserName', ['parsed_arg1', 'parsed_arg2'])) - ; + ->willReturn($call = new FunctionCallValue('getUserName', ['parsed_arg1', 'parsed_arg2'])); /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); @@ -106,12 +105,10 @@ public function testThrowsAnExceptionIfParsingFunctionCallGivesAnUnexpectedResul $decoratedParserProphecy = $this->prophesize(ParserInterface::class); $decoratedParserProphecy ->parse('@user') - ->willReturn($reference = new FixtureReferenceValue('user')) - ; + ->willReturn($reference = new FixtureReferenceValue('user')); $decoratedParserProphecy ->parse('') - ->willReturn('string value') - ; + ->willReturn('string value'); /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); @@ -130,12 +127,10 @@ public function testReturnsAFixtureMethodCallValueIfCanParseToken(): void $decoratedParserProphecy = $this->prophesize(ParserInterface::class); $decoratedParserProphecy ->parse('@user') - ->willReturn($reference = new FixtureReferenceValue('user')) - ; + ->willReturn($reference = new FixtureReferenceValue('user')); $decoratedParserProphecy ->parse('') - ->willReturn($call = new FunctionCallValue('getUserName', ['parsed_arg1', 'parsed_arg2'])) - ; + ->willReturn($call = new FunctionCallValue('getUserName', ['parsed_arg1', 'parsed_arg2'])); /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); @@ -144,7 +139,7 @@ public function testReturnsAFixtureMethodCallValueIfCanParseToken(): void $parser = new MethodReferenceTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParserTest.php index b7b244e7b..b77884704 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/OptionalTokenParserTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\OptionalTokenParser + * @internal */ class OptionalTokenParserTest extends TestCase { @@ -35,12 +36,12 @@ class OptionalTokenParserTest extends TestCase public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(OptionalTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(OptionalTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(OptionalTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(OptionalTokenParser::class))->isCloneable()); } public function testCanParseMethodTokens(): void @@ -49,8 +50,8 @@ public function testCanParseMethodTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new OptionalTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfNoDecoratedParserIsFound(): void @@ -96,8 +97,8 @@ public function testReturnsAnOptionalValueIfCanParseToken(): void $actual0 = $parser->parse($token); $actual1 = $parser->parse($anotherToken); - static::assertEquals($expected0, $actual0); - static::assertEquals($expected1, $actual1); + self::assertEquals($expected0, $actual0); + self::assertEquals($expected1, $actual1); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(5); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParserTest.php index 73e83ebf5..5830fd639 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/ParameterTokenParserTest.php @@ -23,17 +23,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\ParameterTokenParser + * @internal */ class ParameterTokenParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(ParameterTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(ParameterTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ParameterTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ParameterTokenParser::class))->isCloneable()); } public function testCanParseMethodTokens(): void @@ -42,8 +43,8 @@ public function testCanParseMethodTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new ParameterTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnErrorIfPassedParameterIsMalformed(): void @@ -53,14 +54,14 @@ public function testThrowsAnErrorIfPassedParameterIsMalformed(): void $parser = new ParameterTokenParser(); $parser->parse($token); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (ParseException $exception) { - static::assertEquals( + self::assertEquals( 'Could not parse the token "" (type: PARAMETER_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -72,6 +73,6 @@ public function testReturnsAParameterValueIfCanParseToken(): void $parser = new ParameterTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParserTest.php index c838de71c..096312824 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/PropertyReferenceTokenParserTest.php @@ -29,6 +29,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\PropertyReferenceTokenParser + * @internal */ class PropertyReferenceTokenParserTest extends TestCase { @@ -36,12 +37,12 @@ class PropertyReferenceTokenParserTest extends TestCase public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(PropertyReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(PropertyReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(PropertyReferenceTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(PropertyReferenceTokenParser::class))->isCloneable()); } public function testCanParseDynamicArrayTokens(): void @@ -50,8 +51,8 @@ public function testCanParseDynamicArrayTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new PropertyReferenceTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfNoDecoratedParserIsFound(): void @@ -107,7 +108,7 @@ public function testReturnsAPropertyReferenceIfCanParseToken(): void $parser = new PropertyReferenceTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParserTest.php index b7366c2d8..71d59c74e 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/SimpleReferenceTokenParserTest.php @@ -23,17 +23,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\SimpleReferenceTokenParser + * @internal */ class SimpleReferenceTokenParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(SimpleReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(SimpleReferenceTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleReferenceTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleReferenceTokenParser::class))->isCloneable()); } public function testCanParseDynamicArrayTokens(): void @@ -42,8 +43,8 @@ public function testCanParseDynamicArrayTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new SimpleReferenceTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnErrorIfAMalformedTokenIsGiven(): void @@ -53,14 +54,14 @@ public function testThrowsAnErrorIfAMalformedTokenIsGiven(): void $parser = new SimpleReferenceTokenParser(); $parser->parse($token); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (ParseException $exception) { - static::assertEquals( + self::assertEquals( 'Could not parse the token "" (type: SIMPLE_REFERENCE_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } @@ -72,6 +73,6 @@ public function testReturnsAFixtureReferenceValueIfCanParseToken(): void $parser = new SimpleReferenceTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParserTest.php index e1c534fd2..b73df3a74 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringArrayTokenParserTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\StringArrayTokenParser + * @internal */ class StringArrayTokenParserTest extends TestCase { @@ -35,12 +36,12 @@ class StringArrayTokenParserTest extends TestCase public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(StringArrayTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(StringArrayTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StringArrayTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StringArrayTokenParser::class))->isCloneable()); } public function testCanParseDynamicArrayTokens(): void @@ -49,8 +50,8 @@ public function testCanParseDynamicArrayTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new StringArrayTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfNoDecoratedParserIsFound(): void @@ -73,15 +74,15 @@ public function testThrowsAnErrorIfCouldNotParseToken(): void $parser->parse($token); if (PHP_VERSION_ID < 80000) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } } catch (ParseException $exception) { - static::assertEquals( + self::assertEquals( 'Could not parse the token "" (type: STRING_ARRAY_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -100,7 +101,7 @@ public function testParsesEachArrayElementAndReturnsTheConstructedArray(): void $parser = new StringArrayTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); } @@ -119,7 +120,7 @@ public function testIsAbleToParseEmptyArrays(): void $parser = new StringArrayTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testTrimsEachArgumentValueBeforePassingThemToTheDecoratedParser(): void @@ -137,6 +138,6 @@ public function testTrimsEachArgumentValueBeforePassingThemToTheDecoratedParser( $parser = new StringArrayTokenParser($decoratedParser); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParserTest.php index 4a3c4920a..8178438f9 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/StringTokenParserTest.php @@ -21,17 +21,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\StringTokenParser + * @internal */ class StringTokenParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(StringTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(StringTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StringTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StringTokenParser::class))->isCloneable()); } public function testCanParseDynamicArrayTokens(): void @@ -40,8 +41,8 @@ public function testCanParseDynamicArrayTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new StringTokenParser(new ArgumentEscaper()); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testReturnsTheTokenValue(): void @@ -52,6 +53,6 @@ public function testReturnsTheTokenValue(): void $parser = new StringTokenParser(new ArgumentEscaper()); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParserTest.php index 00abd0aef..9994d84aa 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParserTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/VariableTokenParserTest.php @@ -23,17 +23,18 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\VariableTokenParser + * @internal */ class VariableTokenParserTest extends TestCase { public function testIsAChainableTokenParser(): void { - static::assertTrue(is_a(VariableTokenParser::class, ChainableTokenParserInterface::class, true)); + self::assertTrue(is_a(VariableTokenParser::class, ChainableTokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(VariableTokenParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(VariableTokenParser::class))->isCloneable()); } public function testCanParseDynamicArrayTokens(): void @@ -42,8 +43,8 @@ public function testCanParseDynamicArrayTokens(): void $anotherToken = new Token('', new TokenType(TokenType::IDENTITY_TYPE)); $parser = new VariableTokenParser(); - static::assertTrue($parser->canParse($token)); - static::assertFalse($parser->canParse($anotherToken)); + self::assertTrue($parser->canParse($token)); + self::assertFalse($parser->canParse($anotherToken)); } public function testThrowsAnExceptionIfCouldNotParseToken(): void @@ -53,14 +54,14 @@ public function testThrowsAnExceptionIfCouldNotParseToken(): void $parser = new VariableTokenParser(); $parser->parse($token); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (ParseException $exception) { - static::assertEquals( + self::assertEquals( 'Could not parse the token "" (type: VARIABLE_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -72,6 +73,6 @@ public function testReturnsADynamicArrayIfCanParseToken(): void $parser = new VariableTokenParser(); $actual = $parser->parse($token); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistryTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistryTest.php index 71d8d1631..6b1ca3e3a 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistryTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistryTest.php @@ -32,6 +32,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\TokenParserRegistry + * @internal */ class TokenParserRegistryTest extends TestCase { @@ -41,7 +42,7 @@ class TokenParserRegistryTest extends TestCase * @var ReflectionProperty */ private $parsersRefl; - + protected function setUp(): void { $this->parsersRefl = (new ReflectionClass(TokenParserRegistry::class))->getProperty('parsers'); @@ -50,12 +51,12 @@ protected function setUp(): void public function testIsATokenParser(): void { - static::assertTrue(is_a(TokenParserRegistry::class, TokenParserInterface::class, true)); + self::assertTrue(is_a(TokenParserRegistry::class, TokenParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(TokenParserRegistry::class))->isCloneable()); + self::assertFalse((new ReflectionClass(TokenParserRegistry::class))->isCloneable()); } public function testAcceptsOnlyChainableParsers(): void @@ -78,29 +79,29 @@ public function testWithersReturnNewModifiedInstance(): void $tokenParser = new TokenParserRegistry([ $parser1 = new FakeChainableTokenParser(), - $parser2 = new ProphecyChainableTokenParserAware(new FakeChainableTokenParser(), $parserAware) + $parser2 = new ProphecyChainableTokenParserAware(new FakeChainableTokenParser(), $parserAware), ]); $newTokenParser = $tokenParser->withParser($parser); - static::assertInstanceOf(TokenParserRegistry::class, $newTokenParser); + self::assertInstanceOf(TokenParserRegistry::class, $newTokenParser); - static::assertSame( + self::assertSame( [ $parser1, $parser2, ], - $this->parsersRefl->getValue($tokenParser) + $this->parsersRefl->getValue($tokenParser), ); $newTokenParserParsers = $this->parsersRefl->getValue($newTokenParser); - static::assertCount(2, $newTokenParserParsers); - static::assertEquals( + self::assertCount(2, $newTokenParserParsers); + self::assertEquals( [ $parser1, $returnedParser, ], - $newTokenParserParsers + $newTokenParserParsers, ); } @@ -111,18 +112,18 @@ public function testPicksTheFirstSuitableParserToParseTheToken(): void $parser1Prophecy = $this->prophesize(ChainableTokenParserInterface::class); $parser1Prophecy->canParse($token)->willReturn(false); - /* @var ChainableTokenParserInterface $parser1 */ + /** @var ChainableTokenParserInterface $parser1 */ $parser1 = $parser1Prophecy->reveal(); $parser2Prophecy = $this->prophesize(ChainableTokenParserInterface::class); $parser2Prophecy->canParse($token)->willReturn(true); $parser2Prophecy->parse($token)->willReturn($expected); - /* @var ChainableTokenParserInterface $parser2 */ + /** @var ChainableTokenParserInterface $parser2 */ $parser2 = $parser2Prophecy->reveal(); $parser3Prophecy = $this->prophesize(ChainableTokenParserInterface::class); $parser3Prophecy->canParse(Argument::any())->shouldNotBeCalled(); - /* @var ChainableTokenParserInterface $parser3 */ + /** @var ChainableTokenParserInterface $parser3 */ $parser3 = $parser3Prophecy->reveal(); $registry = new TokenParserRegistry([ @@ -132,7 +133,7 @@ public function testPicksTheFirstSuitableParserToParseTheToken(): void ]); $actual = $registry->parse($token); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $parser1Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1); $parser2Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/FixtureBuilder/ExpressionLanguage/TokenTest.php b/tests/FixtureBuilder/ExpressionLanguage/TokenTest.php index ee1701aad..2b26393f2 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/TokenTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/TokenTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Token + * @internal */ class TokenTest extends TestCase { @@ -27,17 +28,17 @@ public function testReadAccessorsReturnPropertiesValues(): void $token = new Token($value, $type); - static::assertEquals($value, $token->getValue()); - static::assertEquals($type->getValue(), $token->getType()); - static::assertEquals('(DYNAMIC_ARRAY_TYPE) bob', $token->__toString()); + self::assertEquals($value, $token->getValue()); + self::assertEquals($type->getValue(), $token->getType()); + self::assertEquals('(DYNAMIC_ARRAY_TYPE) bob', $token->__toString()); } /** - * @depends \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\TokenTypeTest::testIsImmutable + * @depends test\Nelmio\Alice\FixtureBuilder\ExpressionLanguage\TokenTypeTest::testIsImmutable */ public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } public function testWithersReturnNewModifiedInstance(): void @@ -49,11 +50,11 @@ public function testWithersReturnNewModifiedInstance(): void $token = new Token($value, $type); $newToken = $token->withValue($newValue); - static::assertEquals($value, $token->getValue()); - static::assertEquals($type->getValue(), $token->getType()); + self::assertEquals($value, $token->getValue()); + self::assertEquals($type->getValue(), $token->getType()); - static::assertInstanceOf(Token::class, $newToken); - static::assertEquals($newValue, $newToken->getValue()); - static::assertEquals($type->getValue(), $newToken->getType()); + self::assertInstanceOf(Token::class, $newToken); + self::assertEquals($newValue, $newToken->getValue()); + self::assertEquals($type->getValue(), $newToken->getType()); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/TokenTypeTest.php b/tests/FixtureBuilder/ExpressionLanguage/TokenTypeTest.php index b0738450d..83089bfba 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/TokenTypeTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/TokenTypeTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\TokenType + * @internal */ class TokenTypeTest extends TestCase { @@ -35,7 +36,7 @@ protected function setUp(): void public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } /** @@ -48,9 +49,9 @@ public function testStaticValues(): void $reflProp->setAccessible(true); $values = $reflProp->getValue($reflClass); - static::assertCount(count($this->constants), $values); + self::assertCount(count($this->constants), $values); foreach ($this->constants as $constant) { - static::assertTrue($values[$constant]); + self::assertTrue($values[$constant]); } } @@ -60,7 +61,7 @@ public function testStaticValues(): void public function testCanCreateType(string $typeConstant): void { $type = new TokenType($typeConstant); - static::assertEquals($type->getValue(), constant(sprintf('%s::%s', TokenType::class, $typeConstant))); + self::assertEquals($type->getValue(), constant(sprintf('%s::%s', TokenType::class, $typeConstant))); } public function testThrowsAnExceptionIfAnInvalidTypeIsGiven(): void @@ -71,7 +72,7 @@ public function testThrowsAnExceptionIfAnInvalidTypeIsGiven(): void new TokenType('unknown'); } - public function provideAcceptableTypes() + public function provideAcceptableTypes(): iterable { $reflClass = new ReflectionClass(TokenType::class); $constants = $reflClass->getConstants(); diff --git a/tests/FixtureBuilder/SimpleBuilderTest.php b/tests/FixtureBuilder/SimpleBuilderTest.php index 10c4d6735..c7494a33b 100644 --- a/tests/FixtureBuilder/SimpleBuilderTest.php +++ b/tests/FixtureBuilder/SimpleBuilderTest.php @@ -26,6 +26,7 @@ /** * @covers \Nelmio\Alice\FixtureBuilder\SimpleBuilder + * @internal */ class SimpleBuilderTest extends TestCase { @@ -33,12 +34,12 @@ class SimpleBuilderTest extends TestCase public function testIsAFixtureBuilder(): void { - static::assertTrue(is_a(SimpleBuilder::class, FixtureBuilderInterface::class, true)); + self::assertTrue(is_a(SimpleBuilder::class, FixtureBuilderInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleBuilder::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleBuilder::class))->isCloneable()); } public function testBuildSet(): void @@ -64,7 +65,7 @@ public function testBuildSet(): void $builder = new SimpleBuilder($denormalizer); $actual = $builder->build($data, $injectedParameters, $injectedObjects); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $denormalizerProphecy->denormalize(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -86,6 +87,6 @@ public function testBuildSetWithoutInjectingParametersOrObjects(): void $builder = new SimpleBuilder($denormalizer); $actual = $builder->build($data); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/FixtureSetTest.php b/tests/FixtureSetTest.php index 56983069b..3b2c340b8 100644 --- a/tests/FixtureSetTest.php +++ b/tests/FixtureSetTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\FixtureSet + * @internal */ class FixtureSetTest extends TestCase { @@ -32,9 +33,9 @@ public function testReadAccessorsReturnPropertiesValues(): void $set = new FixtureSet($loadedParameters, $injectedParameters, $fixtures, $injectedObjects); - static::assertEquals($loadedParameters, $set->getLoadedParameters()); - static::assertEquals($injectedParameters, $set->getInjectedParameters()); - static::assertEquals($fixtures, $set->getFixtures()); - static::assertEquals($injectedObjects, $set->getObjects()); + self::assertEquals($loadedParameters, $set->getLoadedParameters()); + self::assertEquals($injectedParameters, $set->getInjectedParameters()); + self::assertEquals($fixtures, $set->getFixtures()); + self::assertEquals($injectedObjects, $set->getObjects()); } } diff --git a/tests/Generator/Caller/SimpleCallerTest.php b/tests/Generator/Caller/SimpleCallerTest.php index 1e866e1c8..efba89f79 100644 --- a/tests/Generator/Caller/SimpleCallerTest.php +++ b/tests/Generator/Caller/SimpleCallerTest.php @@ -43,6 +43,7 @@ /** * @covers \Nelmio\Alice\Generator\Caller\SimpleCaller + * @internal */ class SimpleCallerTest extends TestCase { @@ -50,26 +51,26 @@ class SimpleCallerTest extends TestCase public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleCaller::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleCaller::class))->isCloneable()); } public function testIsACaller(): void { - static::assertTrue(is_a(SimpleCaller::class, CallerInterface::class, true)); + self::assertTrue(is_a(SimpleCaller::class, CallerInterface::class, true)); } public function testIsValueResolverAware(): void { - static::assertEquals( + self::assertEquals( ( new SimpleCaller( - new FakeCallProcessor() + new FakeCallProcessor(), ) )->withValueResolver(new FakeValueResolver()), new SimpleCaller( new FakeCallProcessor(), - new FakeValueResolver() - ) + new FakeValueResolver(), + ), ); } @@ -78,7 +79,7 @@ public function testThrowsAnExceptionIfDoesNotHaveAResolver(): void $obj = new FakeObject(); $caller = new SimpleCaller( - new FakeCallProcessor() + new FakeCallProcessor(), ); $this->expectException(ResolverNotFoundException::class); @@ -103,10 +104,10 @@ public function testCallsMethodsOntoTheGivenObject(): void (new MethodCallBag()) ->with($methodCall1 = new SimpleMethodCall('setTitle', ['foo_title'])) ->with($methodCall2 = new SimpleMethodCall('addFoo')) - ->with($methodCall3 = new SimpleMethodCall('addFoo')) - ) - ) - ) + ->with($methodCall3 = new SimpleMethodCall('addFoo')), + ), + ), + ), ); $context = new GenerationContext(); @@ -118,55 +119,52 @@ public function testCallsMethodsOntoTheGivenObject(): void $object, $set, $context, - $methodCall1 + $methodCall1, ) ->willReturn( $set1 = ResolvedFixtureSetFactory::create( new ParameterBag([ 'pass' => 1, ]), - $fixtures - ) - ) - ; + $fixtures, + ), + ); $callProcessorProphecy ->process( $object, $set1, $context, - $methodCall2->withArguments([]) + $methodCall2->withArguments([]), ) ->willReturn( $set2 = ResolvedFixtureSetFactory::create( new ParameterBag([ 'pass' => 2, ]), - $fixtures - ) - ) - ; + $fixtures, + ), + ); $callProcessorProphecy ->process( $object, $set2, $context, - $methodCall3->withArguments([]) + $methodCall3->withArguments([]), ) ->willReturn( $set3 = ResolvedFixtureSetFactory::create( new ParameterBag([ 'pass' => 3, ]), - $fixtures - ) - ) - ; + $fixtures, + ), + ); /** @var CallProcessorInterface $callProcessor */ $callProcessor = $callProcessorProphecy->reveal(); $caller = new SimpleCaller( $callProcessor, - new FakeValueResolver() + new FakeValueResolver(), ); $caller->doCallsOn($object, $set, $context); @@ -189,10 +187,10 @@ public function testResolvesAllPropertyValues(): void (new MethodCallBag()) ->with($methodCall1 = new SimpleMethodCall('setTitle', [$value1 = new DummyValue('val1')])) ->with($methodCall2 = new SimpleMethodCall('setTitle', [$value2 = new DummyValue('val2')])) - ->with($methodCall3 = new SimpleMethodCall('setTitle', ['fake_title'])) - ) - ) - ) + ->with($methodCall3 = new SimpleMethodCall('setTitle', ['fake_title'])), + ), + ), + ), ); $context = new GenerationContext(); @@ -214,7 +212,7 @@ public function testResolvesAllPropertyValues(): void [ '_instances' => [], ], - $context + $context, ) ->willReturn( new ResolvedValueWithFixtureSet( @@ -223,15 +221,14 @@ public function testResolvesAllPropertyValues(): void new ParameterBag([ 'resolution pass' => 1, ]), - $fixtures - ) - ) - ) - ; + $fixtures, + ), + ), + ); $methodCall1AfterResolution = new SimpleMethodCall( 'setTitle', - ['Generated Title 1'] + ['Generated Title 1'], ); $callProcessorProphecy @@ -239,7 +236,7 @@ public function testResolvesAllPropertyValues(): void $object, $setAfterResolution1, $context, - $methodCall1AfterResolution + $methodCall1AfterResolution, ) ->willReturn( $setAfterProcessing1 = ResolvedFixtureSetFactory::create( @@ -249,11 +246,10 @@ public function testResolvesAllPropertyValues(): void ]), $fixtures, new ObjectBag($objectsAfterProcessing1 = [ - 'dummy' => new SimpleObject('dummy', $dummy = new stdClass()) - ]) - ) - ) - ; + 'dummy' => new SimpleObject('dummy', $dummy = new stdClass()), + ]), + ), + ); $resolverProphecy ->resolve( @@ -265,7 +261,7 @@ public function testResolvesAllPropertyValues(): void 'dummy' => $dummy, ], ], - $context + $context, ) ->willReturn( new ResolvedValueWithFixtureSet( @@ -276,15 +272,14 @@ public function testResolvesAllPropertyValues(): void 'processing pass' => 1, ]), $fixtures, - new ObjectBag($objectsAfterProcessing1) - ) - ) - ) - ; + new ObjectBag($objectsAfterProcessing1), + ), + ), + ); $methodCall2AfterResolution = new SimpleMethodCall( 'setTitle', - ['Generated Title 2'] + ['Generated Title 2'], ); $callProcessorProphecy @@ -292,7 +287,7 @@ public function testResolvesAllPropertyValues(): void $object, $setAfterResolution2, $context, - $methodCall2AfterResolution + $methodCall2AfterResolution, ) ->willReturn( $setAfterProcessing2 = ResolvedFixtureSetFactory::create( @@ -301,16 +296,15 @@ public function testResolvesAllPropertyValues(): void 'processing pass' => 2, ]), $fixtures, - new ObjectBag($objectsAfterProcessing1) - ) - ) - ; + new ObjectBag($objectsAfterProcessing1), + ), + ); $callProcessorProphecy ->process( $object, $setAfterProcessing2, $context, - $methodCall3 + $methodCall3, ) ->willReturn( $setAfterProcessing3 = ResolvedFixtureSetFactory::create( @@ -319,17 +313,16 @@ public function testResolvesAllPropertyValues(): void 'processing pass' => 2, ]), $fixtures, - new ObjectBag($objectsAfterProcessing1) - ) - ) - ; + new ObjectBag($objectsAfterProcessing1), + ), + ); $expected = $setAfterProcessing3; $caller = new SimpleCaller($callProcessor, $resolver); $actual = $caller->doCallsOn($object, $originalSet, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $resolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2); $callProcessorProphecy->process(Argument::cetera())->shouldHaveBeenCalledTimes(3); @@ -349,17 +342,16 @@ public function testThrowsAGenerationThrowableIfResolutionFails(): void null, new PropertyBag(), (new MethodCallBag()) - ->with(new SimpleMethodCall('setTitle', [new FakeValue()])) - ) - ) - ) + ->with(new SimpleMethodCall('setTitle', [new FakeValue()])), + ), + ), + ), ); $resolverProphecy = $this->prophesize(ValueResolverInterface::class); $resolverProphecy ->resolve(Argument::cetera()) - ->willThrow(RootResolutionException::class) - ; + ->willThrow(RootResolutionException::class); /** @var ValueResolverInterface $resolver */ $resolver = $resolverProphecy->reveal(); @@ -368,7 +360,7 @@ public function testThrowsAGenerationThrowableIfResolutionFails(): void try { $caller->doCallsOn($object, $set, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (GenerationThrowable $throwable) { // Expected result } diff --git a/tests/Generator/DoublePassGeneratorTest.php b/tests/Generator/DoublePassGeneratorTest.php index 1388d1fc5..6f9a8e3ad 100644 --- a/tests/Generator/DoublePassGeneratorTest.php +++ b/tests/Generator/DoublePassGeneratorTest.php @@ -31,6 +31,7 @@ /** * @covers \Nelmio\Alice\Generator\DoublePassGenerator + * @internal */ class DoublePassGeneratorTest extends TestCase { @@ -38,12 +39,12 @@ class DoublePassGeneratorTest extends TestCase public function testIsAGenerator(): void { - static::assertTrue(is_a(DoublePassGenerator::class, GeneratorInterface::class, true)); + self::assertTrue(is_a(DoublePassGenerator::class, GeneratorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(DoublePassGenerator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(DoublePassGenerator::class))->isCloneable()); } public function testGenerateObjects(): void @@ -76,10 +77,9 @@ public function testGenerateObjects(): void ->willReturn($objectsAfterFirstPass = $objects->with( new SimpleObject( 'foo', - StdClassFactory::create(['pass' => 'first']) - ) - )) - ; + StdClassFactory::create(['pass' => 'first']), + ), + )); $contextAfterFirstPass = clone $context; $contextAfterFirstPass->setToSecondPass(); $objectGeneratorProphecy @@ -88,17 +88,16 @@ public function testGenerateObjects(): void new ResolvedFixtureSet( $resolvedSet->getParameters(), $resolvedSet->getFixtures(), - $objectsAfterFirstPass + $objectsAfterFirstPass, ), - $contextAfterFirstPass + $contextAfterFirstPass, ) ->willReturn($objectsAfterFirstPass = $objects->with( new SimpleObject( 'foo', - StdClassFactory::create(['pass' => 'second']) - ) - )) - ; + StdClassFactory::create(['pass' => 'second']), + ), + )); /** @var ObjectGeneratorInterface $objectGenerator */ $objectGenerator = $objectGeneratorProphecy->reveal(); @@ -107,15 +106,15 @@ public function testGenerateObjects(): void $objects->with( new SimpleObject( 'foo', - StdClassFactory::create(['pass' => 'second']) - ) - ) + StdClassFactory::create(['pass' => 'second']), + ), + ), ); $generator = new DoublePassGenerator($resolver, $objectGenerator); $actual = $generator->generate($set); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $resolverProphecy->resolve(Argument::any())->shouldHaveBeenCalledTimes(1); $objectGeneratorProphecy->generate(Argument::cetera())->shouldHaveBeenCalledTimes(2); diff --git a/tests/Generator/GenerationContextTest.php b/tests/Generator/GenerationContextTest.php index 54a0c79dc..0647edc5c 100644 --- a/tests/Generator/GenerationContextTest.php +++ b/tests/Generator/GenerationContextTest.php @@ -20,39 +20,40 @@ /** * @covers \Nelmio\Alice\Generator\GenerationContext + * @internal */ class GenerationContextTest extends TestCase { public function testAccessors(): void { $context = new GenerationContext(); - static::assertTrue($context->isFirstPass()); - static::assertFalse($context->needsCompleteGeneration()); + self::assertTrue($context->isFirstPass()); + self::assertFalse($context->needsCompleteGeneration()); $context->setToSecondPass(); - static::assertFalse($context->isFirstPass()); - static::assertFalse($context->needsCompleteGeneration()); - static::assertFalse($context->needsCallResult()); + self::assertFalse($context->isFirstPass()); + self::assertFalse($context->needsCompleteGeneration()); + self::assertFalse($context->needsCallResult()); $context->markAsNeedsCompleteGeneration(); - static::assertFalse($context->isFirstPass()); - static::assertTrue($context->needsCompleteGeneration()); - static::assertFalse($context->needsCallResult()); + self::assertFalse($context->isFirstPass()); + self::assertTrue($context->needsCompleteGeneration()); + self::assertFalse($context->needsCallResult()); $context->unmarkAsNeedsCompleteGeneration(); - static::assertFalse($context->isFirstPass()); - static::assertFalse($context->needsCompleteGeneration()); - static::assertFalse($context->needsCallResult()); + self::assertFalse($context->isFirstPass()); + self::assertFalse($context->needsCompleteGeneration()); + self::assertFalse($context->needsCallResult()); $context->markRetrieveCallResult(); - static::assertFalse($context->isFirstPass()); - static::assertFalse($context->needsCompleteGeneration()); - static::assertTrue($context->needsCallResult()); + self::assertFalse($context->isFirstPass()); + self::assertFalse($context->needsCompleteGeneration()); + self::assertTrue($context->needsCallResult()); $context->unmarkRetrieveCallResult(); - static::assertFalse($context->isFirstPass()); - static::assertFalse($context->needsCompleteGeneration()); - static::assertFalse($context->needsCallResult()); + self::assertFalse($context->isFirstPass()); + self::assertFalse($context->needsCompleteGeneration()); + self::assertFalse($context->needsCallResult()); } public function testThrowsAnExceptionWhenACircularReferenceIsDetected(): void @@ -63,11 +64,11 @@ public function testThrowsAnExceptionWhenACircularReferenceIsDetected(): void try { $context->markIsResolvingFixture('foo'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (CircularReferenceException $exception) { - static::assertEquals( + self::assertEquals( 'Circular reference detected for the parameter "foo" while resolving ["bar", "foo"].', - $exception->getMessage() + $exception->getMessage(), ); } } @@ -78,7 +79,7 @@ public function testCanSetAnRetrieveAValueFromTheCache(): void $context->cacheValue('foo', $foo = new stdClass()); - static::assertSame($foo, $context->getCachedValue('foo')); + self::assertSame($foo, $context->getCachedValue('foo')); } public function testCannotRetrieveAnInexistingValueFromCache(): void @@ -87,14 +88,14 @@ public function testCannotRetrieveAnInexistingValueFromCache(): void try { $context->getCachedValue('foo'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (CachedValueNotFound $exception) { - static::assertEquals( + self::assertEquals( 'No value with the key "foo" was found in the cache.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } } diff --git a/tests/Generator/Hydrator/Property/SymfonyPropertyAccessorHydratorTest.php b/tests/Generator/Hydrator/Property/SymfonyPropertyAccessorHydratorTest.php index 6151f6ad7..f31218383 100644 --- a/tests/Generator/Hydrator/Property/SymfonyPropertyAccessorHydratorTest.php +++ b/tests/Generator/Hydrator/Property/SymfonyPropertyAccessorHydratorTest.php @@ -37,6 +37,7 @@ /** * @covers \Nelmio\Alice\Generator\Hydrator\Property\SymfonyPropertyAccessorHydrator + * @internal */ class SymfonyPropertyAccessorHydratorTest extends TestCase { @@ -60,12 +61,12 @@ protected function setUp(): void public function testIsAnHydrator(): void { - static::assertTrue(is_a(SymfonyPropertyAccessorHydrator::class, PropertyHydratorInterface::class, true)); + self::assertTrue(is_a(SymfonyPropertyAccessorHydrator::class, PropertyHydratorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SymfonyPropertyAccessorHydrator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SymfonyPropertyAccessorHydrator::class))->isCloneable()); } public function testReturnsHydratedObject(): void @@ -82,7 +83,7 @@ public function testReturnsHydratedObject(): void $hydrator = new SymfonyPropertyAccessorHydrator($accessor); $result = $hydrator->hydrate($object, $property, new GenerationContext()); - static::assertEquals($object, $result); + self::assertEquals($object, $result); $accessorProphecy->setValue(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -102,14 +103,14 @@ public function testThrowsAnHydrationExceptionIfAnAccessExceptionIsThrown(): voi $hydrator = new SymfonyPropertyAccessorHydrator($accessor); $hydrator->hydrate($object, $property, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InaccessiblePropertyException $exception) { - static::assertEquals( + self::assertEquals( 'Could not access to the property "username" of the object "dummy" (class: Nelmio\Alice\Entity\Hydrator\Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -120,14 +121,14 @@ public function testThrowsNoPropertyExceptionIfPropertyCouldNotBeFound(): void $property = new Property('foo', 'bar'); $this->hydrator->hydrate($object, $property, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (NoSuchPropertyException $exception) { - static::assertEquals( + self::assertEquals( 'Could not hydrate the property "foo" of the object "dummy" (class: Nelmio\Alice\Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -139,14 +140,14 @@ public function testThrowsInvalidArgumentExceptionIfInvalidTypeIsGiven(): void $this->hydrator->hydrate($object, $property, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Invalid value given for the property "immutableDateTime" of the object "dummy" (class: Nelmio\Alice\Entity\DummyWithDate).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -157,7 +158,7 @@ public function testReturnsHydratedObjectWithEnum(): void $result = $this->hydrator->hydrate($object, $property, new GenerationContext()); - static::assertEquals(DummyEnum::Case1, $result->getInstance()->getDummyEnum()); + self::assertEquals(DummyEnum::Case1, $result->getInstance()->getDummyEnum()); } public function testThrowsInvalidArgumentExceptionIfEnumCaseIsNotFound(): void @@ -168,14 +169,14 @@ public function testThrowsInvalidArgumentExceptionIfEnumCaseIsNotFound(): void $this->hydrator->hydrate($object, $property, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Invalid value given for the property "dummyEnum" of the object "dummy" (class: Nelmio\Alice\Entity\DummyWithEnum).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -188,22 +189,21 @@ public function testCatchesAnySymfonyPropertyAccessorToThrowAnHydratorException( $accessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $accessorProphecy ->setValue(Argument::cetera()) - ->willThrow(GenericPropertyAccessException::class) - ; + ->willThrow(GenericPropertyAccessException::class); /** @var PropertyAccessorInterface $accessor */ $accessor = $accessorProphecy->reveal(); $hydrator = new SymfonyPropertyAccessorHydrator($accessor); $hydrator->hydrate($object, $property, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (HydrationException $exception) { - static::assertEquals( + self::assertEquals( 'Could not hydrate the property "foo" of the object "dummy" (class: Nelmio\Alice\Entity\DummyWithDate).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -219,10 +219,10 @@ public function testObjectHydrationAgainstMutlipleValues(Property $property): vo $expected = $property->getValue(); $actual = $this->propertyAccessor->getValue($hydratedObject->getInstance(), $property->getName()); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } - public function provideProperties() + public function provideProperties(): iterable { return [ // Accessor methods diff --git a/tests/Generator/Instantiator/Chainable/AbstractChainableInstantiatorTest.php b/tests/Generator/Instantiator/Chainable/AbstractChainableInstantiatorTest.php index 53cdfd6a1..c2efbe556 100644 --- a/tests/Generator/Instantiator/Chainable/AbstractChainableInstantiatorTest.php +++ b/tests/Generator/Instantiator/Chainable/AbstractChainableInstantiatorTest.php @@ -33,6 +33,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\Chainable\AbstractChainableInstantiator + * @internal */ class AbstractChainableInstantiatorTest extends TestCase { @@ -42,7 +43,7 @@ class AbstractChainableInstantiatorTest extends TestCase * @var AbstractChainableInstantiator */ private $instantiator; - + protected function setUp(): void { $this->instantiator = new DummyChainableInstantiator(); @@ -50,12 +51,12 @@ protected function setUp(): void public function testIsAChainableInstantiator(): void { - static::assertTrue(is_a(AbstractChainableInstantiator::class, ChainableInstantiatorInterface::class, true)); + self::assertTrue(is_a(AbstractChainableInstantiator::class, ChainableInstantiatorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(AbstractChainableInstantiator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(AbstractChainableInstantiator::class))->isCloneable()); } public function testThrowsExceptionIfCannotCreateInstance(): void @@ -72,14 +73,14 @@ public function testThrowsExceptionIfCannotCreateInstance(): void $instantiator = new ProphecyChainableInstantiator($decoratedInstantiator); $instantiator->instantiate($fixture, $set, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InstantiationException $exception) { - static::assertEquals( + self::assertEquals( 'Could not instantiate fixture "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -107,7 +108,7 @@ public function testReturnsNewSetWithInstantiatedObject(): void $set = new ResolvedFixtureSet( $parameters = new ParameterBag(['foo' => 'bar']), $fixtures = (new FixtureBag())->with(new DummyFixture('another_dummy')), - $objects = new ObjectBag(['ping' => new Dummy()]) + $objects = new ObjectBag(['ping' => new Dummy()]), ); $instantiatedObject = new stdClass(); @@ -121,13 +122,13 @@ public function testReturnsNewSetWithInstantiatedObject(): void $expected = new ResolvedFixtureSet( $parameters, $fixtures, - $objects->with(new SimpleObject('dummy', $instantiatedObject)) + $objects->with(new SimpleObject('dummy', $instantiatedObject)), ); $instantiator = new ProphecyChainableInstantiator($decoratedInstantiator); $actual = $instantiator->instantiate($fixture, $set, new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedInstantiatorProphecy->createInstance(Argument::any())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiatorTest.php b/tests/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiatorTest.php index 4ae03a0ea..dae334a26 100644 --- a/tests/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiatorTest.php +++ b/tests/Generator/Instantiator/Chainable/NoCallerMethodCallInstantiatorTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\Chainable\NoCallerMethodCallInstantiator + * @internal */ class NoCallerMethodCallInstantiatorTest extends TestCase { @@ -37,7 +38,7 @@ class NoCallerMethodCallInstantiatorTest extends TestCase * @var NoCallerMethodCallInstantiator */ private $instantiator; - + protected function setUp(): void { $this->instantiator = new NoCallerMethodCallInstantiator(); @@ -45,26 +46,26 @@ protected function setUp(): void public function testIsAChainableInstantiator(): void { - static::assertTrue(is_a(NoCallerMethodCallInstantiator::class, ChainableInstantiatorInterface::class, true)); + self::assertTrue(is_a(NoCallerMethodCallInstantiator::class, ChainableInstantiatorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(NoCallerMethodCallInstantiator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(NoCallerMethodCallInstantiator::class))->isCloneable()); } public function testCannotInstantiateFixtureWithDefaultConstructor(): void { $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()); - static::assertFalse($this->instantiator->canInstantiate($fixture)); + self::assertFalse($this->instantiator->canInstantiate($fixture)); } public function testCannotInstantiateFixtureWithNoMethodCallConstructor(): void { $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create(new NoMethodCall())); - static::assertFalse($this->instantiator->canInstantiate($fixture)); + self::assertFalse($this->instantiator->canInstantiate($fixture)); } public function testCannotInstantiateFixtureWithIfConstructorIsAFactory(): void @@ -72,10 +73,10 @@ public function testCannotInstantiateFixtureWithIfConstructorIsAFactory(): void $fixture = new SimpleFixture( 'dummy', 'Dummy', - SpecificationBagFactory::create(new MethodCallWithReference(new DummyReference(), 'fake')) + SpecificationBagFactory::create(new MethodCallWithReference(new DummyReference(), 'fake')), ); - static::assertFalse($this->instantiator->canInstantiate($fixture)); + self::assertFalse($this->instantiator->canInstantiate($fixture)); } public function testCanInstantiateFixtureWithIfConstructorIsAMalformedFactory(): void @@ -83,10 +84,10 @@ public function testCanInstantiateFixtureWithIfConstructorIsAMalformedFactory(): $fixture = new SimpleFixture( 'dummy', 'Dummy', - SpecificationBagFactory::create(new SimpleMethodCall('fake')) + SpecificationBagFactory::create(new SimpleMethodCall('fake')), ); - static::assertTrue($this->instantiator->canInstantiate($fixture)); + self::assertTrue($this->instantiator->canInstantiate($fixture)); } public function testInstantiatesObjectWithArguments(): void @@ -95,15 +96,15 @@ public function testInstantiatesObjectWithArguments(): void 'dummy', DummyWithRequiredParameterInConstructor::class, SpecificationBagFactory::create( - new SimpleMethodCall('__construct', [10]) - ) + new SimpleMethodCall('__construct', [10]), + ), ); $set = $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext()); $expected = new DummyWithRequiredParameterInConstructor(10); $actual = $set->getObjects()->get($fixture)->getInstance(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** @@ -117,15 +118,15 @@ public function testIgnoresConstructorMethodSpecifiedByTheFixtureIfIsSomethingEl 'dummy', DummyWithRequiredParameterInConstructor::class, SpecificationBagFactory::create( - new SimpleMethodCall('fake', [10]) - ) + new SimpleMethodCall('fake', [10]), + ), ); $set = $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext()); $expected = new DummyWithRequiredParameterInConstructor(10); $actual = $set->getObjects()->get($fixture)->getInstance(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfCouldNotInstantiateObject(): void @@ -134,8 +135,8 @@ public function testThrowsAnExceptionIfCouldNotInstantiateObject(): void 'dummy', AbstractDummyWithRequiredParameterInConstructor::class, SpecificationBagFactory::create( - new SimpleMethodCall('fake', [10]) - ) + new SimpleMethodCall('fake', [10]), + ), ); $this->expectException(InstantiationException::class); diff --git a/tests/Generator/Instantiator/Chainable/NoMethodCallInstantiatorTest.php b/tests/Generator/Instantiator/Chainable/NoMethodCallInstantiatorTest.php index 9cd159630..d9ae2a5ea 100644 --- a/tests/Generator/Instantiator/Chainable/NoMethodCallInstantiatorTest.php +++ b/tests/Generator/Instantiator/Chainable/NoMethodCallInstantiatorTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\Chainable\NoMethodCallInstantiator + * @internal */ class NoMethodCallInstantiatorTest extends TestCase { @@ -45,26 +46,26 @@ protected function setUp(): void public function testIsAChainableInstantiator(): void { - static::assertTrue(is_a(NoMethodCallInstantiator::class, ChainableInstantiatorInterface::class, true)); + self::assertTrue(is_a(NoMethodCallInstantiator::class, ChainableInstantiatorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(NoMethodCallInstantiator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(NoMethodCallInstantiator::class))->isCloneable()); } public function testCanInstantiateFixtureWithNoMethodCallConstructor(): void { $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create(new NoMethodCall())); - static::assertTrue($this->instantiator->canInstantiate($fixture)); + self::assertTrue($this->instantiator->canInstantiate($fixture)); } public function testCannotInstantiateFixtureWithDefaultConstructor(): void { $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()); - static::assertFalse($this->instantiator->canInstantiate($fixture)); + self::assertFalse($this->instantiator->canInstantiate($fixture)); } public function testInstantiatesWithReflectionAndNoArguments(): void @@ -72,27 +73,27 @@ public function testInstantiatesWithReflectionAndNoArguments(): void $fixture = new SimpleFixture( 'dummy', DummyWithRequiredParameterInConstructor::class, - SpecificationBagFactory::create() + SpecificationBagFactory::create(), ); $set = $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext()); $instance = $set->getObjects()->get($fixture)->getInstance(); - static::assertInstanceOf(DummyWithRequiredParameterInConstructor::class, $instance); + self::assertInstanceOf(DummyWithRequiredParameterInConstructor::class, $instance); try { (new ReflectionObject($instance))->getProperty('requiredParam'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (ReflectionException $exception) { if (PHP_VERSION_ID < 80000) { - static::assertEquals( + self::assertEquals( 'Property requiredParam does not exist', - $exception->getMessage() + $exception->getMessage(), ); } else { - static::assertEquals( + self::assertEquals( 'Property Nelmio\Alice\Entity\Instantiator\DummyWithRequiredParameterInConstructor::$requiredParam' - . ' does not exist', - $exception->getMessage() + .' does not exist', + $exception->getMessage(), ); } } @@ -104,8 +105,8 @@ public function testThrowsAnExceptionIfCouldNotInstantiateObject(): void 'dummy', AbstractDummyWithRequiredParameterInConstructor::class, SpecificationBagFactory::create( - new SimpleMethodCall('fake', [10]) - ) + new SimpleMethodCall('fake', [10]), + ), ); $this->expectException(InstantiationException::class); diff --git a/tests/Generator/Instantiator/Chainable/NullConstructorInstantiatorTest.php b/tests/Generator/Instantiator/Chainable/NullConstructorInstantiatorTest.php index d65eee328..318db2629 100644 --- a/tests/Generator/Instantiator/Chainable/NullConstructorInstantiatorTest.php +++ b/tests/Generator/Instantiator/Chainable/NullConstructorInstantiatorTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\Chainable\NullConstructorInstantiator + * @internal */ class NullConstructorInstantiatorTest extends TestCase { @@ -37,7 +38,7 @@ class NullConstructorInstantiatorTest extends TestCase * @var NullConstructorInstantiator */ private $instantiator; - + protected function setUp(): void { $this->instantiator = new NullConstructorInstantiator(); @@ -45,19 +46,19 @@ protected function setUp(): void public function testIsAChainableInstantiator(): void { - static::assertTrue(is_a(NullConstructorInstantiator::class, ChainableInstantiatorInterface::class, true)); + self::assertTrue(is_a(NullConstructorInstantiator::class, ChainableInstantiatorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(NullConstructorInstantiator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(NullConstructorInstantiator::class))->isCloneable()); } public function testCanInstantiateFixtureUsingADefaultConstructor(): void { $fixture = new SimpleFixture('dummy', 'Nelmio\Alice\Entity\User', SpecificationBagFactory::create()); - static::assertTrue($this->instantiator->canInstantiate($fixture)); + self::assertTrue($this->instantiator->canInstantiate($fixture)); } public function testIfCannotGetConstructorReflectionTriesToInstantiateObjectWithoutArguments(): void @@ -68,7 +69,7 @@ public function testIfCannotGetConstructorReflectionTriesToInstantiateObjectWith $expected = new DummyWithDefaultConstructor(); $actual = $set->getObjects()->get($fixture)->getInstance(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfInstantiatingObjectWithoutArgumentsFails(): void @@ -87,14 +88,14 @@ public function testThrowsAnExceptionIfReflectionFailsWithAnotherErrorThanMethod $fixture = new SimpleFixture('dummy', 'Unknown', SpecificationBagFactory::create()); $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InstantiationException $exception) { - static::assertEquals( + self::assertEquals( 'Could not get the necessary data on the constructor to instantiate "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } diff --git a/tests/Generator/Instantiator/Chainable/StaticFactoryInstantiatorTest.php b/tests/Generator/Instantiator/Chainable/StaticFactoryInstantiatorTest.php index d71b3f160..258aebe2e 100644 --- a/tests/Generator/Instantiator/Chainable/StaticFactoryInstantiatorTest.php +++ b/tests/Generator/Instantiator/Chainable/StaticFactoryInstantiatorTest.php @@ -33,6 +33,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\Chainable\StaticFactoryInstantiator + * @internal */ class StaticFactoryInstantiatorTest extends TestCase { @@ -40,7 +41,7 @@ class StaticFactoryInstantiatorTest extends TestCase * @var StaticFactoryInstantiator */ private $instantiator; - + protected function setUp(): void { $this->instantiator = new StaticFactoryInstantiator(); @@ -48,26 +49,26 @@ protected function setUp(): void public function testIsAChainableInstantiator(): void { - static::assertTrue(is_a(StaticFactoryInstantiator::class, ChainableInstantiatorInterface::class, true)); + self::assertTrue(is_a(StaticFactoryInstantiator::class, ChainableInstantiatorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StaticFactoryInstantiator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StaticFactoryInstantiator::class))->isCloneable()); } public function testCannotInstantiateFixtureWithDefaultConstructor(): void { $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()); - static::assertFalse($this->instantiator->canInstantiate($fixture)); + self::assertFalse($this->instantiator->canInstantiate($fixture)); } public function testCannotInstantiateFixtureWithNoMethodCallConstructor(): void { $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create(new NoMethodCall())); - static::assertFalse($this->instantiator->canInstantiate($fixture)); + self::assertFalse($this->instantiator->canInstantiate($fixture)); } public function testCannotInstantiateFixtureWithIfConstructorIsANonStaticFactory(): void @@ -75,10 +76,10 @@ public function testCannotInstantiateFixtureWithIfConstructorIsANonStaticFactory $fixture = new SimpleFixture( 'dummy', 'Dummy', - SpecificationBagFactory::create(new MethodCallWithReference(new DummyReference(), 'fake')) + SpecificationBagFactory::create(new MethodCallWithReference(new DummyReference(), 'fake')), ); - static::assertFalse($this->instantiator->canInstantiate($fixture)); + self::assertFalse($this->instantiator->canInstantiate($fixture)); } public function testCanInstantiateFixtureWithIfConstructorIsAStaticFactory(): void @@ -86,10 +87,10 @@ public function testCanInstantiateFixtureWithIfConstructorIsAStaticFactory(): vo $fixture = new SimpleFixture( 'dummy', 'Dummy', - SpecificationBagFactory::create(new MethodCallWithReference(new StaticReference('static_reference'), 'fake')) + SpecificationBagFactory::create(new MethodCallWithReference(new StaticReference('static_reference'), 'fake')), ); - static::assertTrue($this->instantiator->canInstantiate($fixture)); + self::assertTrue($this->instantiator->canInstantiate($fixture)); } public function testInstantiatesObjectWithFactory(): void @@ -100,16 +101,16 @@ public function testInstantiatesObjectWithFactory(): void SpecificationBagFactory::create( new MethodCallWithReference( new StaticReference(DummyWithNamedConstructor::class), - 'namedConstruct' - ) - ) + 'namedConstruct', + ), + ), ); $set = $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext()); $expected = DummyWithNamedConstructor::namedConstruct(); $actual = $set->getObjects()->get($fixture)->getInstance(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testInstantiatesObjectWithFactoryAndArguments(): void @@ -121,16 +122,16 @@ public function testInstantiatesObjectWithFactoryAndArguments(): void new MethodCallWithReference( new StaticReference(DummyWithNamedConstructorAndOptionalParameters::class), 'namedConstruct', - [10] - ) - ) + [10], + ), + ), ); $set = $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext()); $expected = DummyWithNamedConstructorAndOptionalParameters::namedConstruct(10); $actual = $set->getObjects()->get($fixture)->getInstance(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testInstantiatesObjectWithFactoryAndNamedArguments(): void @@ -142,16 +143,16 @@ public function testInstantiatesObjectWithFactoryAndNamedArguments(): void new MethodCallWithReference( new StaticReference(DummyWithNamedConstructorAndOptionalParameters::class), 'namedConstruct', - ['param' => 10] - ) - ) + ['param' => 10], + ), + ), ); $set = $this->instantiator->instantiate($fixture, ResolvedFixtureSetFactory::create(), new GenerationContext()); $expected = DummyWithNamedConstructorAndOptionalParameters::namedConstruct(10); $actual = $set->getObjects()->get($fixture)->getInstance(); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfCouldNotInstantiateObject(): void @@ -162,9 +163,9 @@ public function testThrowsAnExceptionIfCouldNotInstantiateObject(): void SpecificationBagFactory::create( new MethodCallWithReference( new StaticReference(DummyWithExplicitDefaultConstructorThrowingException::class), - 'namedConstruct' - ) - ) + 'namedConstruct', + ), + ), ); $this->expectException(InstantiationException::class); @@ -181,9 +182,9 @@ public function testThrowsAnExceptionIfCouldNotFindFactoryMethod(): void SpecificationBagFactory::create( new MethodCallWithReference( new StaticReference(DummyWithExplicitDefaultConstructorThrowingException::class), - 'unknownMethod' - ) - ) + 'unknownMethod', + ), + ), ); $this->expectException(InstantiationException::class); @@ -200,9 +201,9 @@ public function testThrowsAnExceptionIfCouldNotFindFactoryClass(): void SpecificationBagFactory::create( new MethodCallWithReference( new StaticReference('Unknown'), - 'namedConstruct' - ) - ) + 'namedConstruct', + ), + ), ); $this->expectException(InstantiationException::class); @@ -220,9 +221,9 @@ public function testThrowsAnExceptionIfCouldNotCallOnTheFactory(): void new MethodCallWithReference( new StaticReference(AbstractDummyWithRequiredParameterInConstructor::class), 'namedConstruct', - [10] - ) - ) + [10], + ), + ), ); $this->expectException(InstantiationException::class); @@ -240,9 +241,9 @@ public function testThrowsAnExceptionIfFixtureClassDoesNotMatchObjectClass(): vo new MethodCallWithReference( new StaticReference(DummyWithNamedConstructorAndOptionalParameters::class), 'namedConstruct', - [10] - ) - ) + [10], + ), + ), ); $this->expectException(InstantiationException::class); @@ -259,9 +260,9 @@ public function testThrowsAnExceptionIfFactoryDoesNotReturnAnInstance(): void SpecificationBagFactory::create( new MethodCallWithReference( new StaticReference(DummyWithFakeNamedConstructor::class), - 'namedConstruct' - ) - ) + 'namedConstruct', + ), + ), ); $this->expectException(InstantiationException::class); diff --git a/tests/Generator/Instantiator/ExistingInstanceInstantiatorTest.php b/tests/Generator/Instantiator/ExistingInstanceInstantiatorTest.php index 356e0e2ae..6291f31ed 100644 --- a/tests/Generator/Instantiator/ExistingInstanceInstantiatorTest.php +++ b/tests/Generator/Instantiator/ExistingInstanceInstantiatorTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\ExistingInstanceInstantiator + * @internal */ class ExistingInstanceInstantiatorTest extends TestCase { @@ -35,17 +36,17 @@ class ExistingInstanceInstantiatorTest extends TestCase public function testIsAnInstantiator(): void { - static::assertTrue(is_a(ExistingInstanceInstantiator::class, InstantiatorInterface::class, true)); + self::assertTrue(is_a(ExistingInstanceInstantiator::class, InstantiatorInterface::class, true)); } public function testIsValueResolverAware(): void { - static::assertTrue(is_a(ExistingInstanceInstantiator::class, ValueResolverAwareInterface::class, true)); + self::assertTrue(is_a(ExistingInstanceInstantiator::class, ValueResolverAwareInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ExistingInstanceInstantiator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ExistingInstanceInstantiator::class))->isCloneable()); } public function testReturnsUnchangedSetIfFixtureHasAlreadyBeenInstantiated(): void @@ -57,15 +58,15 @@ public function testReturnsUnchangedSetIfFixtureHasAlreadyBeenInstantiated(): vo (new ObjectBag())->with( new SimpleObject( 'dummy', - new stdClass() - ) - ) + new stdClass(), + ), + ), ); $instantiator = new ExistingInstanceInstantiator(new FakeInstantiator()); $actual = $instantiator->instantiate($fixture, $set, new GenerationContext()); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testReturnsTheResultOfTheDecoratedInstantiatorIfTheFixtureHasNotBeenInstantiated(): void @@ -83,19 +84,18 @@ public function testReturnsTheResultOfTheDecoratedInstantiatorIfTheFixtureHasNot (new ObjectBag())->with( new SimpleObject( 'dummy', - new stdClass() - ) - ) - ) - ) - ; + new stdClass(), + ), + ), + ), + ); /** @var InstantiatorInterface $decoratedInstantiator */ $decoratedInstantiator = $decoratedInstantiatorProphecy->reveal(); $instantiator = new ExistingInstanceInstantiator($decoratedInstantiator); $actual = $instantiator->instantiate($fixture, $set, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $decoratedInstantiatorProphecy->instantiate(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/Generator/Instantiator/InstantiatorRegistryTest.php b/tests/Generator/Instantiator/InstantiatorRegistryTest.php index 490c1ae2e..f166a28f0 100644 --- a/tests/Generator/Instantiator/InstantiatorRegistryTest.php +++ b/tests/Generator/Instantiator/InstantiatorRegistryTest.php @@ -32,6 +32,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\InstantiatorRegistry + * @internal */ class InstantiatorRegistryTest extends TestCase { @@ -39,7 +40,7 @@ class InstantiatorRegistryTest extends TestCase public function testIsAnInstantiator(): void { - static::assertTrue(is_a(InstantiatorRegistry::class, InstantiatorInterface::class, true)); + self::assertTrue(is_a(InstantiatorRegistry::class, InstantiatorInterface::class, true)); } public function testAcceptChainableInstantiators(): void @@ -56,7 +57,7 @@ public function testThrowExceptionIfInvalidParserIsPassed(): void public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(InstantiatorRegistry::class))->isCloneable()); + self::assertFalse((new ReflectionClass(InstantiatorRegistry::class))->isCloneable()); } public function testPassValueResolverAwarenessPropertyToItsInstantiator(): void @@ -66,21 +67,18 @@ public function testPassValueResolverAwarenessPropertyToItsInstantiator(): void $registry = new InstantiatorRegistry([]); $newRegistry = $registry->withValueResolver($resolver); - static::assertEquals(new InstantiatorRegistry([]), $registry); - static::assertEquals(new InstantiatorRegistry([]), $newRegistry); - + self::assertEquals(new InstantiatorRegistry([]), $registry); + self::assertEquals(new InstantiatorRegistry([]), $newRegistry); $registry = new InstantiatorRegistry([new FakeChainableInstantiator()]); $newRegistry = $registry->withValueResolver($resolver); - static::assertEquals(new InstantiatorRegistry([new FakeChainableInstantiator()]), $registry); - static::assertEquals( + self::assertEquals(new InstantiatorRegistry([new FakeChainableInstantiator()]), $registry); + self::assertEquals( new InstantiatorRegistry([new FakeChainableInstantiator()]), - $newRegistry + $newRegistry, ); - - $nonAwareInstantiator = new FakeChainableInstantiator(); // @phpstan-ignore-next-line $nonAwareInstantiator->foo = 'bar'; @@ -94,10 +92,10 @@ public function testPassValueResolverAwarenessPropertyToItsInstantiator(): void $registry = new InstantiatorRegistry([$nonAwareInstantiator, $instantiator]); $newRegistry = $registry->withValueResolver($resolver); - static::assertEquals(new InstantiatorRegistry([$nonAwareInstantiator, $instantiator]), $registry); - static::assertEquals( + self::assertEquals(new InstantiatorRegistry([$nonAwareInstantiator, $instantiator]), $registry); + self::assertEquals( new InstantiatorRegistry([$nonAwareInstantiator, new FakeChainableInstantiator()]), - $newRegistry + $newRegistry, ); $instantiatorProphecy->withValueResolver(Argument::any())->shouldHaveBeenCalledTimes(1); @@ -113,23 +111,23 @@ public function testIterateOverEveryInstantiatorAndUseTheFirstValidOne(): void null, null, (new ObjectBag()) - ->with(new SimpleObject('dummy', new stdClass())) + ->with(new SimpleObject('dummy', new stdClass())), ); $instantiator1Prophecy = $this->prophesize(ChainableInstantiatorInterface::class); $instantiator1Prophecy->canInstantiate($fixture)->willReturn(false); - /* @var ChainableInstantiatorInterface $instantiator1 */ + /** @var ChainableInstantiatorInterface $instantiator1 */ $instantiator1 = $instantiator1Prophecy->reveal(); $instantiator2Prophecy = $this->prophesize(ChainableInstantiatorInterface::class); $instantiator2Prophecy->canInstantiate($fixture)->willReturn(true); $instantiator2Prophecy->instantiate($fixture, $set, $context)->willReturn($expected); - /* @var ChainableInstantiatorInterface $instantiator2 */ + /** @var ChainableInstantiatorInterface $instantiator2 */ $instantiator2 = $instantiator2Prophecy->reveal(); $instantiator3Prophecy = $this->prophesize(ChainableInstantiatorInterface::class); $instantiator3Prophecy->canInstantiate(Argument::any())->shouldNotBeCalled(); - /* @var ChainableInstantiatorInterface $instantiator3 */ + /** @var ChainableInstantiatorInterface $instantiator3 */ $instantiator3 = $instantiator3Prophecy->reveal(); $registry = new InstantiatorRegistry([ @@ -139,7 +137,7 @@ public function testIterateOverEveryInstantiatorAndUseTheFirstValidOne(): void ]); $actual = $registry->instantiate($fixture, $set, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $instantiator1Prophecy->canInstantiate(Argument::any())->shouldHaveBeenCalledTimes(1); $instantiator2Prophecy->canInstantiate(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Generator/Instantiator/InstantiatorResolverTest.php b/tests/Generator/Instantiator/InstantiatorResolverTest.php index d3acc24df..32b9fcf26 100644 --- a/tests/Generator/Instantiator/InstantiatorResolverTest.php +++ b/tests/Generator/Instantiator/InstantiatorResolverTest.php @@ -38,6 +38,7 @@ /** * @covers \Nelmio\Alice\Generator\Instantiator\InstantiatorResolver + * @internal */ class InstantiatorResolverTest extends TestCase { @@ -45,20 +46,20 @@ class InstantiatorResolverTest extends TestCase public function testIsAnInstantiator(): void { - static::assertTrue(is_a(InstantiatorResolver::class, InstantiatorInterface::class, true)); + self::assertTrue(is_a(InstantiatorResolver::class, InstantiatorInterface::class, true)); } public function testIsResolverAware(): void { - static::assertEquals( + self::assertEquals( new InstantiatorResolver(new FakeInstantiator(), new FakeValueResolver()), - (new InstantiatorResolver(new FakeInstantiator()))->withValueResolver(new FakeValueResolver()) + (new InstantiatorResolver(new FakeInstantiator()))->withValueResolver(new FakeValueResolver()), ); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(InstantiatorResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(InstantiatorResolver::class))->isCloneable()); } public function testResolvesAllArguments(): void @@ -69,8 +70,8 @@ public function testResolvesAllArguments(): void [ $firstArg = new VariableValue('firstArg'), $secondArg = new VariableValue('secondArg'), - ] - ) + ], + ), ); $resolvedSpecs = $specs->withConstructor( new SimpleMethodCall( @@ -78,14 +79,14 @@ public function testResolvesAllArguments(): void [ 'resolvedFirstArg', 'resolvedSecondArg', - ] - ) + ], + ), ); $fixture = new SimpleFixture('dummy', 'stdClass', $specs); $set = ResolvedFixtureSetFactory::create( new ParameterBag([ 'ping' => 'pong', - ]) + ]), ); $context = new GenerationContext(); $context->markIsResolvingFixture('foo'); @@ -93,38 +94,36 @@ public function testResolvesAllArguments(): void $expected = ResolvedFixtureSetFactory::create( null, (new FixtureBag())->with($fixture->withSpecs($resolvedSpecs)), - new ObjectBag(['dummy' => new stdClass()]) + new ObjectBag(['dummy' => new stdClass()]), ); $resolverProphecy = $this->prophesize(ValueResolverInterface::class); $setAfterFirstArgResolution = new ResolvedFixtureSet( $set->getParameters(), (new FixtureBag())->with(new DummyFixture('dummy')), - $set->getObjects() + $set->getObjects(), ); $resolverProphecy ->resolve($firstArg, $fixture, $set, ['ping' => 'pong'], $context) ->willReturn( new ResolvedValueWithFixtureSet( 'resolvedFirstArg', - $setAfterFirstArgResolution - ) - ) - ; + $setAfterFirstArgResolution, + ), + ); $setAfterSecondArgResolution = new ResolvedFixtureSet( $setAfterFirstArgResolution->getParameters(), (new FixtureBag())->with(new DummyFixture('another_dummy')), - $setAfterFirstArgResolution->getObjects() + $setAfterFirstArgResolution->getObjects(), ); $resolverProphecy ->resolve($secondArg, $fixture, $setAfterFirstArgResolution, ['ping' => 'pong', 1 => 'resolvedFirstArg'], $context) ->willReturn( new ResolvedValueWithFixtureSet( 'resolvedSecondArg', - $setAfterSecondArgResolution - ) - ) - ; + $setAfterSecondArgResolution, + ), + ); /** @var ValueResolverInterface $resolver */ $resolver = $resolverProphecy->reveal(); @@ -132,15 +131,14 @@ public function testResolvesAllArguments(): void $decoratedInstantiatorProphecy = $this->prophesize(InstantiatorInterface::class); $decoratedInstantiatorProphecy ->instantiate($fixtureAfterResolution, $setAfterSecondArgResolution, $context) - ->willReturn($expected) - ; + ->willReturn($expected); /** @var InstantiatorInterface $decoratedInstantiator */ $decoratedInstantiator = $decoratedInstantiatorProphecy->reveal(); $instantiator = new InstantiatorResolver($decoratedInstantiator, $resolver); $actual = $instantiator->instantiate($fixture, $set, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $resolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2); $decoratedInstantiatorProphecy->instantiate(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -154,8 +152,8 @@ public function testThrowsAGenerationThrowableIfResolutionFails(): void [ $firstArg = new VariableValue('firstArg'), $secondArg = new VariableValue('secondArg'), - ] - ) + ], + ), ); $fixture = new SimpleFixture('dummy', 'stdClass', $specs); $set = ResolvedFixtureSetFactory::create(); @@ -163,8 +161,7 @@ public function testThrowsAGenerationThrowableIfResolutionFails(): void $resolverProphecy = $this->prophesize(ValueResolverInterface::class); $resolverProphecy ->resolve(Argument::cetera()) - ->willThrow(RootResolutionException::class) - ; + ->willThrow(RootResolutionException::class); /** @var ValueResolverInterface $resolver */ $resolver = $resolverProphecy->reveal(); @@ -172,7 +169,7 @@ public function testThrowsAGenerationThrowableIfResolutionFails(): void try { $instantiator->instantiate($fixture, $set, new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (GenerationThrowable $throwable) { // Expected result. } @@ -189,7 +186,7 @@ public function testDoesNotResolveArgumentsIfNoConstructorGiven(): void $expected = ResolvedFixtureSetFactory::create( null, (new FixtureBag())->with($fixture), - new ObjectBag(['dummy' => new stdClass()]) + new ObjectBag(['dummy' => new stdClass()]), ); $resolverProphecy = $this->prophesize(ValueResolverInterface::class); @@ -205,7 +202,7 @@ public function testDoesNotResolveArgumentsIfNoConstructorGiven(): void $instantiator = new InstantiatorResolver($decoratedInstantiator, $resolver); $actual = $instantiator->instantiate($fixture, $set, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testDoesNotResolveArgumentsIfSpecifiedNoConstructor(): void @@ -219,7 +216,7 @@ public function testDoesNotResolveArgumentsIfSpecifiedNoConstructor(): void $expected = ResolvedFixtureSetFactory::create( null, (new FixtureBag())->with($fixture), - new ObjectBag(['dummy' => new stdClass()]) + new ObjectBag(['dummy' => new stdClass()]), ); $resolverProphecy = $this->prophesize(ValueResolverInterface::class); @@ -235,6 +232,6 @@ public function testDoesNotResolveArgumentsIfSpecifiedNoConstructor(): void $instantiator = new InstantiatorResolver($decoratedInstantiator, $resolver); $actual = $instantiator->instantiate($fixture, $set, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/Generator/NamedArgumentsResolverTest.php b/tests/Generator/NamedArgumentsResolverTest.php index 84c1e1bba..55ad89b82 100644 --- a/tests/Generator/NamedArgumentsResolverTest.php +++ b/tests/Generator/NamedArgumentsResolverTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\Generator\NamedArgumentsResolver + * @internal */ class NamedArgumentsResolverTest extends TestCase { @@ -32,13 +33,13 @@ public function testResolveArguments(string $className, string $methodName, arra { $resolver = new NamedArgumentsResolver(); - static::assertSame( + self::assertSame( $expectedResult, - $resolver->resolveArguments($argument, $className, $methodName) + $resolver->resolveArguments($argument, $className, $methodName), ); } - public function provideResolveArgumentsCases() + public function provideResolveArgumentsCases(): iterable { yield 'constructor: no named arguments' => [ DummyWithMethods::class, @@ -349,31 +350,31 @@ public function testResolveVariadicConstructorParam(): void $resolver = new NamedArgumentsResolver(); $onlyFirstParam = [ - 'foo' + 'foo', ]; $resolvedFirst = $resolver->resolveArguments( $onlyFirstParam, DummyWithVariadicConstructorParamAndParam::class, - '__construct' + '__construct', ); - static::assertEquals($onlyFirstParam, $resolvedFirst); + self::assertEquals($onlyFirstParam, $resolvedFirst); $allParams = [ 'foo', [ 'bar', - 'baz' - ] + 'baz', + ], ]; $resolvedAll = $resolver->resolveArguments( $allParams, DummyWithVariadicConstructorParamAndParam::class, - '__construct' + '__construct', ); - static::assertEquals($allParams, $resolvedAll); + self::assertEquals($allParams, $resolvedAll); } } diff --git a/tests/Generator/ObjectGenerator/CompleteObjectGeneratorTest.php b/tests/Generator/ObjectGenerator/CompleteObjectGeneratorTest.php index 1519ccf31..99048cfd4 100644 --- a/tests/Generator/ObjectGenerator/CompleteObjectGeneratorTest.php +++ b/tests/Generator/ObjectGenerator/CompleteObjectGeneratorTest.php @@ -35,6 +35,7 @@ /** * @covers \Nelmio\Alice\Generator\ObjectGenerator\CompleteObjectGenerator + * @internal */ class CompleteObjectGeneratorTest extends TestCase { @@ -42,12 +43,12 @@ class CompleteObjectGeneratorTest extends TestCase public function testIsAnObjectGenerator(): void { - static::assertTrue(is_a(CompleteObjectGenerator::class, ObjectGeneratorInterface::class, true)); + self::assertTrue(is_a(CompleteObjectGenerator::class, ObjectGeneratorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(CompleteObjectGenerator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(CompleteObjectGenerator::class))->isCloneable()); } public function testReturnsFixtureSetObjectsIfObjectIsAlreadyCompletelyGenerated(): void @@ -56,14 +57,14 @@ public function testReturnsFixtureSetObjectsIfObjectIsAlreadyCompletelyGenerated $set = ResolvedFixtureSetFactory::create( null, (new FixtureBag())->with($fixture), - $expected = new ObjectBag(['dummy' => new stdClass()]) + $expected = new ObjectBag(['dummy' => new stdClass()]), ); $context = new GenerationContext(); $generator = new CompleteObjectGenerator(new FakeObjectGenerator()); $actual = $generator->generate($fixture, $set, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testUsesDecoratedGeneratorToGenerateTheObjectAndReturnsTheResultIfDoesNotRequireACompleteObject(): void @@ -73,12 +74,12 @@ public function testUsesDecoratedGeneratorToGenerateTheObjectAndReturnsTheResult 'Dummy', SpecificationBagFactory::create( null, - (new PropertyBag())->with(new Property('foo', 'bar')) - ) + (new PropertyBag())->with(new Property('foo', 'bar')), + ), ); $set = ResolvedFixtureSetFactory::create( null, - (new FixtureBag())->with($fixture) + (new FixtureBag())->with($fixture), ); $context = new GenerationContext(); @@ -86,16 +87,15 @@ public function testUsesDecoratedGeneratorToGenerateTheObjectAndReturnsTheResult $decoratedGeneratorProphecy ->generate($fixture, $set, $context) ->willReturn( - $expected = (new ObjectBag())->with(new SimpleObject('dummy', new stdClass())) - ) - ; + $expected = (new ObjectBag())->with(new SimpleObject('dummy', new stdClass())), + ); /** @var ObjectGeneratorInterface $decoratedGenerator */ $decoratedGenerator = $decoratedGeneratorProphecy->reveal(); $generator = new CompleteObjectGenerator($decoratedGenerator); $actual = $generator->generate($fixture, $set, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedGeneratorProphecy->generate(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -111,16 +111,16 @@ public function testReturnsCompleteObjectWheneverItIsPossible( ): void { $set = ResolvedFixtureSetFactory::create( null, - (new FixtureBag())->with($fixture) + (new FixtureBag())->with($fixture), ); $generator = new CompleteObjectGenerator($decoratedGenerator); $actual = $generator->generate($fixture, $set, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } - public function provideSets() + public function provideSets(): iterable { yield 'decorated generator generates a complete object => complete object' => (function () { $fixture = new SimpleFixture( @@ -128,40 +128,39 @@ public function provideSets() 'Dummy', SpecificationBagFactory::create( null, - (new PropertyBag())->with(new Property('foo', 'bar')) - ) + (new PropertyBag())->with(new Property('foo', 'bar')), + ), ); $context = new GenerationContext(); $decoratedGeneratorProphecy = $this->prophesize(ObjectGeneratorInterface::class); $decoratedGeneratorProphecy - ->generate(Argument::cetera()) - ->willReturn( - (new ObjectBag())->with( - new CompleteObject( - new SimpleObject('dummy', new stdClass()) - ) - ) - ) - ; + ->generate(Argument::cetera()) + ->willReturn( + (new ObjectBag())->with( + new CompleteObject( + new SimpleObject('dummy', new stdClass()), + ), + ), + ); /** @var ObjectGeneratorInterface $decoratedGenerator */ $decoratedGenerator = $decoratedGeneratorProphecy->reveal(); $expected = (new ObjectBag())->with( new CompleteObject( new CompleteObject( - new SimpleObject('dummy', new stdClass()) - ) - ) + new SimpleObject('dummy', new stdClass()), + ), + ), ); return [ - $fixture, - $context, - $decoratedGenerator, - $expected, - ]; + $fixture, + $context, + $decoratedGenerator, + $expected, + ]; })(); yield 'object has been generated during the second pass => complete object' => (function () { @@ -170,8 +169,8 @@ public function provideSets() 'Dummy', SpecificationBagFactory::create( null, - (new PropertyBag())->with(new Property('foo', 'bar')) - ) + (new PropertyBag())->with(new Property('foo', 'bar')), + ), ); $context = new GenerationContext(); @@ -179,28 +178,27 @@ public function provideSets() $decoratedGeneratorProphecy = $this->prophesize(ObjectGeneratorInterface::class); $decoratedGeneratorProphecy - ->generate(Argument::cetera()) - ->willReturn( - (new ObjectBag())->with( - new SimpleObject('dummy', new stdClass()) - ) - ) - ; + ->generate(Argument::cetera()) + ->willReturn( + (new ObjectBag())->with( + new SimpleObject('dummy', new stdClass()), + ), + ); /** @var ObjectGeneratorInterface $decoratedGenerator */ $decoratedGenerator = $decoratedGeneratorProphecy->reveal(); $expected = (new ObjectBag())->with( new CompleteObject( - new SimpleObject('dummy', new stdClass()) - ) + new SimpleObject('dummy', new stdClass()), + ), ); return [ - $fixture, - $context, - $decoratedGenerator, - $expected, - ]; + $fixture, + $context, + $decoratedGenerator, + $expected, + ]; })(); yield 'object was generated with "complete object" generation context => complete object' => (function () { @@ -209,8 +207,8 @@ public function provideSets() 'Dummy', SpecificationBagFactory::create( null, - (new PropertyBag())->with(new Property('foo', 'bar')) - ) + (new PropertyBag())->with(new Property('foo', 'bar')), + ), ); $context = new GenerationContext(); @@ -218,63 +216,61 @@ public function provideSets() $decoratedGeneratorProphecy = $this->prophesize(ObjectGeneratorInterface::class); $decoratedGeneratorProphecy - ->generate(Argument::cetera()) - ->willReturn( - (new ObjectBag())->with( - new SimpleObject('dummy', new stdClass()) - ) - ) - ; + ->generate(Argument::cetera()) + ->willReturn( + (new ObjectBag())->with( + new SimpleObject('dummy', new stdClass()), + ), + ); /** @var ObjectGeneratorInterface $decoratedGenerator */ $decoratedGenerator = $decoratedGeneratorProphecy->reveal(); $expected = (new ObjectBag())->with( new CompleteObject( - new SimpleObject('dummy', new stdClass()) - ) + new SimpleObject('dummy', new stdClass()), + ), ); return [ - $fixture, - $context, - $decoratedGenerator, - $expected, - ]; + $fixture, + $context, + $decoratedGenerator, + $expected, + ]; })(); yield 'object generated needed only instantiation => complete object' => (function () { $fixture = new SimpleFixture( 'dummy', 'Dummy', - SpecificationBagFactory::create() + SpecificationBagFactory::create(), ); $context = new GenerationContext(); $decoratedGeneratorProphecy = $this->prophesize(ObjectGeneratorInterface::class); $decoratedGeneratorProphecy - ->generate(Argument::cetera()) - ->willReturn( - (new ObjectBag())->with( - new SimpleObject('dummy', new stdClass()) - ) - ) - ; + ->generate(Argument::cetera()) + ->willReturn( + (new ObjectBag())->with( + new SimpleObject('dummy', new stdClass()), + ), + ); /** @var ObjectGeneratorInterface $decoratedGenerator */ $decoratedGenerator = $decoratedGeneratorProphecy->reveal(); $expected = (new ObjectBag())->with( new CompleteObject( - new SimpleObject('dummy', new stdClass()) - ) + new SimpleObject('dummy', new stdClass()), + ), ); return [ - $fixture, - $context, - $decoratedGenerator, - $expected, - ]; + $fixture, + $context, + $decoratedGenerator, + $expected, + ]; })(); yield 'object generated during first pass => unchanged' => (function () { @@ -283,30 +279,29 @@ public function provideSets() 'Dummy', SpecificationBagFactory::create( null, - (new PropertyBag())->with(new Property('foo', 'bar')) - ) + (new PropertyBag())->with(new Property('foo', 'bar')), + ), ); $context = new GenerationContext(); $decoratedGeneratorProphecy = $this->prophesize(ObjectGeneratorInterface::class); $decoratedGeneratorProphecy - ->generate(Argument::cetera()) - ->willReturn( - $expected = (new ObjectBag())->with( - new SimpleObject('dummy', new stdClass()) - ) - ) - ; + ->generate(Argument::cetera()) + ->willReturn( + $expected = (new ObjectBag())->with( + new SimpleObject('dummy', new stdClass()), + ), + ); /** @var ObjectGeneratorInterface $decoratedGenerator */ $decoratedGenerator = $decoratedGeneratorProphecy->reveal(); return [ - $fixture, - $context, - $decoratedGenerator, - $expected, - ]; + $fixture, + $context, + $decoratedGenerator, + $expected, + ]; })(); } } diff --git a/tests/Generator/ObjectGenerator/SimpleObjectGeneratorTest.php b/tests/Generator/ObjectGenerator/SimpleObjectGeneratorTest.php index 9ee113a90..382b228dc 100644 --- a/tests/Generator/ObjectGenerator/SimpleObjectGeneratorTest.php +++ b/tests/Generator/ObjectGenerator/SimpleObjectGeneratorTest.php @@ -32,6 +32,7 @@ /** * @covers \Nelmio\Alice\Generator\ObjectGenerator\SimpleObjectGenerator + * @internal */ class SimpleObjectGeneratorTest extends TestCase { @@ -39,12 +40,12 @@ class SimpleObjectGeneratorTest extends TestCase public function testIsAnObjectGenerator(): void { - static::assertTrue(is_a(SimpleObjectGenerator::class, ObjectGeneratorInterface::class, true)); + self::assertTrue(is_a(SimpleObjectGenerator::class, ObjectGeneratorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleObjectGenerator::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleObjectGenerator::class))->isCloneable()); } /** @@ -52,7 +53,7 @@ public function testIsNotClonable(): void */ public function testGenerate(): void { - static::markTestIncomplete('TODO'); + self::markTestIncomplete('TODO'); $fixture = new SimpleFixture('dummy', stdClass::class, SpecificationBagFactory::create()); $set = ResolvedFixtureSetFactory::create(); $context = new GenerationContext(); @@ -67,10 +68,9 @@ public function testGenerate(): void $setWithInstantiatedObject = ResolvedFixtureSetFactory::create( null, null, - (new ObjectBag())->with($instantiatedObject) - ) - ) - ; + (new ObjectBag())->with($instantiatedObject), + ), + ); /** @var InstantiatorInterface $instantiator */ $instantiator = $instantiatorProphecy->reveal(); @@ -86,10 +86,9 @@ public function testGenerate(): void $setWithHydratedObject = ResolvedFixtureSetFactory::create( null, null, - (new ObjectBag())->with($hydratedObject) - ) - ) - ; + (new ObjectBag())->with($hydratedObject), + ), + ); /** @var HydratorInterface $hydrator */ $hydrator = $hydratorProphecy->reveal(); @@ -105,17 +104,16 @@ public function testGenerate(): void $setWithObjectAfterCalls = ResolvedFixtureSetFactory::create( null, null, - (new ObjectBag())->with($objectAfterCalls) - ) - ) - ; + (new ObjectBag())->with($objectAfterCalls), + ), + ); /** @var CallerInterface $caller */ $caller = $callerProphecy->reveal(); $generator = new SimpleObjectGenerator(new FakeValueResolver(), $instantiator, $hydrator, $caller); $objects = $generator->generate($fixture, $set, $context); - static::assertEquals($setWithObjectAfterCalls->getObjects(), $objects); + self::assertEquals($setWithObjectAfterCalls->getObjects(), $objects); $instantiatorProphecy->instantiate(Argument::cetera())->shouldHaveBeenCalledTimes(1); $hydratorProphecy->hydrate(Argument::cetera())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Generator/ResolvedFixtureSetTest.php b/tests/Generator/ResolvedFixtureSetTest.php index e0d6ca8c9..f2e045625 100644 --- a/tests/Generator/ResolvedFixtureSetTest.php +++ b/tests/Generator/ResolvedFixtureSetTest.php @@ -21,6 +21,7 @@ /** * @covers \Nelmio\Alice\Generator\ResolvedFixtureSet + * @internal */ class ResolvedFixtureSetTest extends TestCase { @@ -32,9 +33,9 @@ public function testReadAccessorsReturnPropertiesValues(): void $set = new ResolvedFixtureSet($parameters, $fixtures, $objects); - static::assertEquals($parameters, $set->getParameters()); - static::assertEquals($fixtures, $set->getFixtures()); - static::assertEquals($objects, $set->getObjects()); + self::assertEquals($parameters, $set->getParameters()); + self::assertEquals($fixtures, $set->getFixtures()); + self::assertEquals($objects, $set->getObjects()); } public function testWithersReturnANewModifiedInstance(): void @@ -48,37 +49,37 @@ public function testWithersReturnANewModifiedInstance(): void $newParameters = new ParameterBag(['foo' => 'bar']); $newSet = $set->withParameters($newParameters); - static::assertEquals( + self::assertEquals( new ResolvedFixtureSet($parameters, $fixtures, $objects), - $set + $set, ); - static::assertEquals( + self::assertEquals( new ResolvedFixtureSet($newParameters, $fixtures, $objects), - $newSet + $newSet, ); $newFixtures = new FixtureBag(); $newSet = $set->withFixtures($newFixtures); - static::assertEquals( + self::assertEquals( new ResolvedFixtureSet($parameters, $fixtures, $objects), - $set + $set, ); - static::assertEquals( + self::assertEquals( new ResolvedFixtureSet($parameters, $newFixtures, $objects), - $newSet + $newSet, ); $newObjects = new ObjectBag(['foo' => new stdClass()]); $newSet = $set->withObjects($newObjects); - static::assertEquals( + self::assertEquals( new ResolvedFixtureSet($parameters, $fixtures, $objects), - $set + $set, ); - static::assertEquals( + self::assertEquals( new ResolvedFixtureSet($parameters, $fixtures, $newObjects), - $newSet + $newSet, ); } } diff --git a/tests/Generator/ResolvedValueWithFixtureSetTest.php b/tests/Generator/ResolvedValueWithFixtureSetTest.php index 4397b0aac..7ce21adc1 100644 --- a/tests/Generator/ResolvedValueWithFixtureSetTest.php +++ b/tests/Generator/ResolvedValueWithFixtureSetTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Generator\ResolvedValueWithFixtureSet + * @internal */ class ResolvedValueWithFixtureSetTest extends TestCase { @@ -28,7 +29,7 @@ public function testReadAccessorsReturnPropertiesValues(): void $resolvedValueWithSet = new ResolvedValueWithFixtureSet($value, $set); - static::assertEquals($value, $resolvedValueWithSet->getValue()); - static::assertEquals($set, $resolvedValueWithSet->getSet()); + self::assertEquals($value, $resolvedValueWithSet->getValue()); + self::assertEquals($set, $resolvedValueWithSet->getSet()); } } diff --git a/tests/Generator/Resolver/Fixture/TemplateFixtureBagResolverTest.php b/tests/Generator/Resolver/Fixture/TemplateFixtureBagResolverTest.php index 850326df7..0aaf330ba 100644 --- a/tests/Generator/Resolver/Fixture/TemplateFixtureBagResolverTest.php +++ b/tests/Generator/Resolver/Fixture/TemplateFixtureBagResolverTest.php @@ -34,6 +34,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Fixture\TemplateFixtureBagResolver * @covers \Nelmio\Alice\Generator\Resolver\Fixture\TemplateFixtureResolver + * @internal */ class TemplateFixtureBagResolverTest extends TestCase { @@ -46,7 +47,7 @@ class TemplateFixtureBagResolverTest extends TestCase * @var ReflectionProperty */ private $propRefl; - + protected function setUp(): void { $this->propRefl = (new ReflectionClass(TemplatingFixture::class))->getProperty('fixture'); @@ -57,7 +58,7 @@ protected function setUp(): void public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(TemplateFixtureBagResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(TemplateFixtureBagResolver::class))->isCloneable()); } public function testResolvesTemplatesFixturesAndReturnsResultingFixtureBag(): void @@ -67,19 +68,19 @@ public function testResolvesTemplatesFixturesAndReturnsResultingFixtureBag(): vo $group1 = new SimpleFixture( 'group1', 'Nelmio\Entity\Group', - SpecificationBagFactory::create() - ) + SpecificationBagFactory::create(), + ), ) ->with( $group2 = new SimpleFixtureWithFlags( new SimpleFixture( 'group2', 'Nelmio\Entity\Group', - SpecificationBagFactory::create() + SpecificationBagFactory::create(), ), (new FlagBag('group2')) - ->withFlag(new ElementFlag('dummy_flag')) - ) + ->withFlag(new ElementFlag('dummy_flag')), + ), ) ->with( $user1 = new TemplatingFixture( @@ -90,15 +91,15 @@ public function testResolvesTemplatesFixturesAndReturnsResultingFixtureBag(): vo SpecificationBagFactory::create( null, (new PropertyBag()) - ->with(new Property('p1', 'v11')) - ) + ->with(new Property('p1', 'v11')), + ), ), (new FlagBag('user1')) ->withFlag(new ExtendFlag(new FixtureReference('user3'))) ->withFlag(new ExtendFlag(new FixtureReference('user2'))) - ->withFlag(new ElementFlag('dummy_flag')) - ) - ) + ->withFlag(new ElementFlag('dummy_flag')), + ), + ), ) ->with( $user2 = new TemplatingFixture( @@ -110,13 +111,13 @@ public function testResolvesTemplatesFixturesAndReturnsResultingFixtureBag(): vo null, (new PropertyBag()) ->with(new Property('p1', 'v21')) - ->with(new Property('p2', 'v22')) - ) + ->with(new Property('p2', 'v22')), + ), ), (new FlagBag('user2')) - ->withFlag(new TemplateFlag()) - ) - ) + ->withFlag(new TemplateFlag()), + ), + ), ) ->with( $user3 = new TemplatingFixture( @@ -129,14 +130,14 @@ public function testResolvesTemplatesFixturesAndReturnsResultingFixtureBag(): vo (new PropertyBag()) ->with(new Property('p1', 'v31')) ->with(new Property('p2', 'v32')) - ->with(new Property('p3', 'v33')) - ) + ->with(new Property('p3', 'v33')), + ), ), (new FlagBag('user3')) ->withFlag(new ExtendFlag(new FixtureReference('user4'))) - ->withFlag(new TemplateFlag()) - ) - ) + ->withFlag(new TemplateFlag()), + ), + ), ) ->with( $user4 = new TemplatingFixture( @@ -150,26 +151,25 @@ public function testResolvesTemplatesFixturesAndReturnsResultingFixtureBag(): vo ->with(new Property('p1', 'v41')) ->with(new Property('p2', 'v42')) ->with(new Property('p3', 'v43')) - ->with(new Property('p4', 'v44')) - ) + ->with(new Property('p4', 'v44')), + ), ), (new FlagBag('user4')) - ->withFlag(new TemplateFlag()) - ) - ) + ->withFlag(new TemplateFlag()), + ), + ), ) ->with( $user5 = new SimpleFixtureWithFlags(// has a template flag but is not a templating fixture! new SimpleFixture( 'user5', 'Nelmio\Alice\Entity\User', - SpecificationBagFactory::create() + SpecificationBagFactory::create(), ), (new FlagBag('user5')) - ->withFlag(new TemplateFlag()) - ) - ) - ; + ->withFlag(new TemplateFlag()), + ), + ); $expected = (new FixtureBag()) ->with($group1) ->with($group2) @@ -185,18 +185,17 @@ public function testResolvesTemplatesFixturesAndReturnsResultingFixtureBag(): vo ->with(new Property('p1', 'v11')) ->with(new Property('p2', 'v22')) ->with(new Property('p3', 'v33')) - ->with(new Property('p4', 'v44')) - ) + ->with(new Property('p4', 'v44')), + ), ), - $this->getDecoratedFixturesFlag($user1) - ) - ) + $this->getDecoratedFixturesFlag($user1), + ), + ), ) - ->with($user5) - ; + ->with($user5); $actual = $this->resolver->resolve($unresolvedFixtures); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testTheResolutionIsInvarientToTheOrderInWhichFixturesAreGiven(): void @@ -214,13 +213,13 @@ public function testTheResolutionIsInvarientToTheOrderInWhichFixturesAreGiven(): ->with(new Property('p1', 'v41')) ->with(new Property('p2', 'v42')) ->with(new Property('p3', 'v43')) - ->with(new Property('p4', 'v44')) - ) + ->with(new Property('p4', 'v44')), + ), ), (new FlagBag('user4')) - ->withFlag(new TemplateFlag()) - ) - ) + ->withFlag(new TemplateFlag()), + ), + ), ) ->with( $user3 = new TemplatingFixture( @@ -233,14 +232,14 @@ public function testTheResolutionIsInvarientToTheOrderInWhichFixturesAreGiven(): (new PropertyBag()) ->with(new Property('p1', 'v31')) ->with(new Property('p2', 'v32')) - ->with(new Property('p3', 'v33')) - ) + ->with(new Property('p3', 'v33')), + ), ), (new FlagBag('user3')) ->withFlag(new ExtendFlag(new FixtureReference('user4'))) - ->withFlag(new TemplateFlag()) - ) - ) + ->withFlag(new TemplateFlag()), + ), + ), ) ->with( $user2 = new TemplatingFixture( @@ -252,13 +251,13 @@ public function testTheResolutionIsInvarientToTheOrderInWhichFixturesAreGiven(): null, (new PropertyBag()) ->with(new Property('p1', 'v21')) - ->with(new Property('p2', 'v22')) - ) + ->with(new Property('p2', 'v22')), + ), ), (new FlagBag('user2')) - ->withFlag(new TemplateFlag()) - ) - ) + ->withFlag(new TemplateFlag()), + ), + ), ) ->with( $user1 = new TemplatingFixture( @@ -269,17 +268,16 @@ public function testTheResolutionIsInvarientToTheOrderInWhichFixturesAreGiven(): SpecificationBagFactory::create( null, (new PropertyBag()) - ->with(new Property('p1', 'v11')) - ) + ->with(new Property('p1', 'v11')), + ), ), (new FlagBag('user1')) ->withFlag(new ExtendFlag(new FixtureReference('user3'))) ->withFlag(new ExtendFlag(new FixtureReference('user2'))) - ->withFlag(new ElementFlag('dummy_flag')) - ) - ) - ) - ; + ->withFlag(new ElementFlag('dummy_flag')), + ), + ), + ); $expected = (new FixtureBag()) ->with( new TemplatingFixture( @@ -293,17 +291,16 @@ public function testTheResolutionIsInvarientToTheOrderInWhichFixturesAreGiven(): ->with(new Property('p1', 'v11')) ->with(new Property('p2', 'v22')) ->with(new Property('p3', 'v33')) - ->with(new Property('p4', 'v44')) - ) + ->with(new Property('p4', 'v44')), + ), ), - $this->getDecoratedFixturesFlag($user1) - ) - ) - ) - ; + $this->getDecoratedFixturesFlag($user1), + ), + ), + ); $actual = $this->resolver->resolve($unresolvedFixtures); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfFixtureExtendsANonExistingFixture(): void @@ -315,18 +312,17 @@ public function testThrowsAnExceptionIfFixtureExtendsANonExistingFixture(): void new SimpleFixture( 'user0', 'Nelmio\Alice\Entity\User', - SpecificationBagFactory::create() + SpecificationBagFactory::create(), ), (new FlagBag('user0')) ->withFlag( new ExtendFlag( - new FixtureReference('user_base') - ) - ) - ) - ) - ) - ; + new FixtureReference('user_base'), + ), + ), + ), + ), + ); $this->expectException(FixtureNotFoundException::class); $this->expectExceptionMessage('Could not find the fixture "user_base".'); @@ -343,25 +339,24 @@ public function testThrowsAnExceptionIfAFixtureExtendANonTemplateFixture(): void new SimpleFixture( 'user0', 'Nelmio\Alice\Entity\User', - SpecificationBagFactory::create() + SpecificationBagFactory::create(), ), (new FlagBag('user0')) ->withFlag( new ExtendFlag( - new FixtureReference('user_base') - ) - ) - ) - ) + new FixtureReference('user_base'), + ), + ), + ), + ), ) ->with( new SimpleFixture( 'user_base', 'Nelmio\Alice\Entity\User', - SpecificationBagFactory::create() - ) - ) - ; + SpecificationBagFactory::create(), + ), + ); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Fixture "user0" extends "user_base" but "user_base" is not a template.'); diff --git a/tests/Generator/Resolver/Fixture/TemplateFixtureResolverTest.php b/tests/Generator/Resolver/Fixture/TemplateFixtureResolverTest.php index 05f523c97..d21559780 100644 --- a/tests/Generator/Resolver/Fixture/TemplateFixtureResolverTest.php +++ b/tests/Generator/Resolver/Fixture/TemplateFixtureResolverTest.php @@ -22,11 +22,12 @@ * More tests in: * * @see \Nelmio\Alice\Generator\Resolver\Fixture\TemplateFixtureBagResolverTest + * @internal */ class TemplateFixtureResolverTest extends TestCase { public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(TemplateFixtureResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(TemplateFixtureResolver::class))->isCloneable()); } } diff --git a/tests/Generator/Resolver/Fixture/TemplatingFixtureBagTest.php b/tests/Generator/Resolver/Fixture/TemplatingFixtureBagTest.php index 22d840014..7fb9fbb27 100644 --- a/tests/Generator/Resolver/Fixture/TemplatingFixtureBagTest.php +++ b/tests/Generator/Resolver/Fixture/TemplatingFixtureBagTest.php @@ -13,7 +13,6 @@ namespace Nelmio\Alice\Generator\Resolver\Fixture; -use function Nelmio\Alice\deep_clone; use Nelmio\Alice\Definition\FakeMethodCall; use Nelmio\Alice\Definition\Fixture\DummyFixture; use Nelmio\Alice\Definition\Fixture\MutableFixture; @@ -26,9 +25,11 @@ use Nelmio\Alice\FixtureBag; use Nelmio\Alice\Throwable\Exception\FixtureNotFoundException; use PHPUnit\Framework\TestCase; +use function Nelmio\Alice\deep_clone; /** * @covers \Nelmio\Alice\Generator\Resolver\Fixture\TemplatingFixtureBag + * @internal */ class TemplatingFixtureBagTest extends TestCase { @@ -41,50 +42,49 @@ public function testReadAccessorsReturnPropertiesValues(): void $template = new TemplatingFixture( new SimpleFixtureWithFlags( new DummyFixture($templateId), - (new FlagBag('user_base'))->withFlag(new TemplateFlag()) - ) + (new FlagBag('user_base'))->withFlag(new TemplateFlag()), + ), ); - + $bag = (new TemplatingFixtureBag()) ->with($fixture) - ->with($template) - ; + ->with($template); - static::assertTrue($bag->has($fixtureId)); - static::assertFalse($bag->hasTemplate($fixtureId)); - static::assertEquals($fixture, $bag->get($fixtureId)); + self::assertTrue($bag->has($fixtureId)); + self::assertFalse($bag->hasTemplate($fixtureId)); + self::assertEquals($fixture, $bag->get($fixtureId)); - static::assertTrue($bag->has($templateId)); - static::assertTrue($bag->hasTemplate($templateId)); - static::assertEquals($template, $bag->get($templateId)); + self::assertTrue($bag->has($templateId)); + self::assertTrue($bag->hasTemplate($templateId)); + self::assertEquals($template, $bag->get($templateId)); - static::assertFalse($bag->has('foo')); + self::assertFalse($bag->has('foo')); try { $bag->get('foo'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (FixtureNotFoundException $exception) { - static::assertEquals( + self::assertEquals( 'Could not find the fixture "foo".', - $exception->getMessage() + $exception->getMessage(), ); } try { $bag->getTemplate($fixtureId); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (FixtureNotFoundException $exception) { // expected result } - static::assertEquals( + self::assertEquals( (new FixtureBag())->with($fixture), - $bag->getFixtures() + $bag->getFixtures(), ); } /** - * @depends \Nelmio\Alice\FixtureBagTest::testIsImmutable + * @depends test\Nelmio\Alice\FixtureBagTest::testIsImmutable */ public function testIsImmutable(): void { @@ -100,7 +100,7 @@ public function testIsImmutable(): void // @phpstan-ignore-next-line $bag->getFixtures()->get('user0')->setSpecs(SpecificationBagFactory::create(new NoMethodCall())); - static::assertEquals($originalFixture, $bag->getFixtures()->get('user0')); + self::assertEquals($originalFixture, $bag->getFixtures()->get('user0')); } public function testAddTemplateFixtureToTemplates(): void @@ -109,19 +109,18 @@ public function testAddTemplateFixtureToTemplates(): void $template = new TemplatingFixture( new SimpleFixtureWithFlags( new DummyFixture('user_base'), - (new FlagBag('user_base'))->withFlag(new TemplateFlag()) - ) + (new FlagBag('user_base'))->withFlag(new TemplateFlag()), + ), ); $bag = (new TemplatingFixtureBag()) ->with($fixture) - ->with($template) - ; + ->with($template); - static::assertEquals( + self::assertEquals( (new FixtureBag()) ->with($fixture), - $bag->getFixtures() + $bag->getFixtures(), ); } } diff --git a/tests/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolverTest.php b/tests/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolverTest.php index d9a484ec4..929666775 100644 --- a/tests/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolverTest.php +++ b/tests/Generator/Resolver/FixtureSet/RemoveConflictingObjectsResolverTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\FixtureSet\RemoveConflictingObjectsResolver + * @internal */ class RemoveConflictingObjectsResolverTest extends TestCase { @@ -35,12 +36,12 @@ class RemoveConflictingObjectsResolverTest extends TestCase public function testIsAFixtureResolver(): void { - static::assertTrue(is_a(RemoveConflictingObjectsResolver::class, FixtureSetResolverInterface::class, true)); + self::assertTrue(is_a(RemoveConflictingObjectsResolver::class, FixtureSetResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(RemoveConflictingObjectsResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(RemoveConflictingObjectsResolver::class))->isCloneable()); } public function testRemovesConflictingObjectsByIteratingFixturesIfThereIsLessFixturesThanInjectedObjects(): void @@ -56,10 +57,9 @@ public function testRemovesConflictingObjectsByIteratingFixturesIfThereIsLessFix $fixtures = (new FixtureBag())->with(new DummyFixture('dummy')), $objects = (new ObjectBag()) ->with(new SimpleObject('dummy', new stdClass())) - ->with(new SimpleObject('another_injected_object', new stdClass())) - ) - ) - ; + ->with(new SimpleObject('another_injected_object', new stdClass())), + ), + ); /** @var FixtureSetResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); @@ -67,12 +67,12 @@ public function testRemovesConflictingObjectsByIteratingFixturesIfThereIsLessFix $parameters, $fixtures, $objects = (new ObjectBag()) - ->with(new SimpleObject('another_injected_object', new stdClass())) + ->with(new SimpleObject('another_injected_object', new stdClass())), ); $resolver = new RemoveConflictingObjectsResolver($decoratedResolver); $actual = $resolver->resolve($set); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/Generator/Resolver/FixtureSet/SimpleFixtureSetResolverTest.php b/tests/Generator/Resolver/FixtureSet/SimpleFixtureSetResolverTest.php index 2e260b5a2..48f3fb1cb 100644 --- a/tests/Generator/Resolver/FixtureSet/SimpleFixtureSetResolverTest.php +++ b/tests/Generator/Resolver/FixtureSet/SimpleFixtureSetResolverTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\FixtureSet\SimpleFixtureSetResolver + * @internal */ class SimpleFixtureSetResolverTest extends TestCase { @@ -37,12 +38,12 @@ class SimpleFixtureSetResolverTest extends TestCase public function testIsAFixtureResolver(): void { - static::assertTrue(is_a(SimpleFixtureSetResolver::class, FixtureSetResolverInterface::class, true)); + self::assertTrue(is_a(SimpleFixtureSetResolver::class, FixtureSetResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleFixtureSetResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleFixtureSetResolver::class))->isCloneable()); } public function testReturnsResolvedParametersAndFixtures(): void @@ -51,16 +52,15 @@ public function testReturnsResolvedParametersAndFixtures(): void $injectedParameters = new ParameterBag(['injected' => true]), $loadedParameters = new ParameterBag(['loaded' => true]), $fixtures = (new FixtureBag())->with(new DummyFixture('dummy')), - $objects = (new ObjectBag())->with(new SimpleObject('injected_object', new stdClass())) + $objects = (new ObjectBag())->with(new SimpleObject('injected_object', new stdClass())), ); $parameterResolverProphecy = $this->prophesize(ParameterBagResolverInterface::class); $parameterResolverProphecy ->resolve($injectedParameters, $loadedParameters) ->willReturn( - $resolvedParameters = (new ParameterBag(['resolved' => true])) - ) - ; + $resolvedParameters = (new ParameterBag(['resolved' => true])), + ); /** @var ParameterBagResolverInterface $parameterResolver */ $parameterResolver = $parameterResolverProphecy->reveal(); @@ -68,9 +68,8 @@ public function testReturnsResolvedParametersAndFixtures(): void $fixtureResolverProphecy ->resolve($fixtures) ->willReturn( - $resolvedFixtures = (new FixtureBag())->with(new DummyFixture('another_dummy')) - ) - ; + $resolvedFixtures = (new FixtureBag())->with(new DummyFixture('another_dummy')), + ); /** @var FixtureBagResolverInterface $fixtureResolver */ $fixtureResolver = $fixtureResolverProphecy->reveal(); @@ -79,6 +78,6 @@ public function testReturnsResolvedParametersAndFixtures(): void $resolver = new SimpleFixtureSetResolver($parameterResolver, $fixtureResolver); $actual = $resolver->resolve($set); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/Generator/Resolver/Parameter/Chainable/ArrayParameterResolverTest.php b/tests/Generator/Resolver/Parameter/Chainable/ArrayParameterResolverTest.php index 062ae982a..f7d11434f 100644 --- a/tests/Generator/Resolver/Parameter/Chainable/ArrayParameterResolverTest.php +++ b/tests/Generator/Resolver/Parameter/Chainable/ArrayParameterResolverTest.php @@ -29,6 +29,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Parameter\Chainable\ArrayParameterResolver + * @internal */ class ArrayParameterResolverTest extends TestCase { @@ -36,17 +37,17 @@ class ArrayParameterResolverTest extends TestCase public function testIsAChainableParameterResolver(): void { - static::assertTrue(is_a(ArrayParameterResolver::class, ChainableParameterResolverInterface::class, true)); + self::assertTrue(is_a(ArrayParameterResolver::class, ChainableParameterResolverInterface::class, true)); } public function testIsAParameterResolverAwareResolver(): void { - static::assertTrue(is_a(ArrayParameterResolver::class, ParameterResolverAwareInterface::class, true)); + self::assertTrue(is_a(ArrayParameterResolver::class, ParameterResolverAwareInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ArrayParameterResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ArrayParameterResolver::class))->isCloneable()); } public function testCanBeInstantiatedWithoutAResolver(): void @@ -67,8 +68,8 @@ public function testWithersReturnANewModifiedInstance(): void $resolver = new ArrayParameterResolver(); $newResolver = $resolver->withResolver(new FakeParameterResolver()); - static::assertEquals(new ArrayParameterResolver(), $resolver); - static::assertEquals(new ArrayParameterResolver(new FakeParameterResolver()), $newResolver); + self::assertEquals(new ArrayParameterResolver(), $resolver); + self::assertEquals(new ArrayParameterResolver(new FakeParameterResolver()), $newResolver); } public function testCanOnlyResolveArrayValues(): void @@ -76,16 +77,16 @@ public function testCanOnlyResolveArrayValues(): void $resolver = new ArrayParameterResolver(); $parameter = new Parameter('foo', null); - static::assertTrue($resolver->canResolve($parameter->withValue([]))); + self::assertTrue($resolver->canResolve($parameter->withValue([]))); - static::assertFalse($resolver->canResolve($parameter->withValue(null))); - static::assertFalse($resolver->canResolve($parameter->withValue(10))); - static::assertFalse($resolver->canResolve($parameter->withValue(.75))); - static::assertFalse($resolver->canResolve($parameter->withValue('string'))); - static::assertFalse($resolver->canResolve($parameter->withValue(new stdClass()))); - static::assertFalse($resolver->canResolve($parameter->withValue( + self::assertFalse($resolver->canResolve($parameter->withValue(null))); + self::assertFalse($resolver->canResolve($parameter->withValue(10))); + self::assertFalse($resolver->canResolve($parameter->withValue(.75))); + self::assertFalse($resolver->canResolve($parameter->withValue('string'))); + self::assertFalse($resolver->canResolve($parameter->withValue(new stdClass()))); + self::assertFalse($resolver->canResolve($parameter->withValue( static function (): void { - } + }, ))); } @@ -106,7 +107,7 @@ public function testIteratesOverEachElementAndUsesTheDecoratedResolverToResolveE [ 'foo', 'bar', - ] + ], ); $unresolvedParameters = new ParameterBag(['name' => 'unresolvedParams']); @@ -120,37 +121,35 @@ public function testIteratesOverEachElementAndUsesTheDecoratedResolverToResolveE new Parameter('0', 'foo'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( new ParameterBag([ 'name' => 'resolvedParams', '0' => 'val1', - ]) - ) - ; + ]), + ); $context->add('array_param'); $injectedResolverProphecy ->resolve( new Parameter('1', 'bar'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( new ParameterBag([ 'name' => 'resolvedParams', '1' => 'val2', - ]) - ) - ; - /* @var ParameterResolverInterface $injectedResolver */ + ]), + ); + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new ArrayParameterResolver())->withResolver($injectedResolver); $result = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::assertEquals( + self::assertEquals( new ParameterBag([ 'name' => 'resolvedParams', 'array_param' => [ @@ -158,7 +157,7 @@ public function testIteratesOverEachElementAndUsesTheDecoratedResolverToResolveE '1' => 'val2', ], ]), - $result + $result, ); $injectedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2); } @@ -182,30 +181,29 @@ public function testIfResolutionResultsInMultipleParametersBeingResolvedThenThey new ParameterBag([ '0' => 'val1', 'other_param' => 'yo', - ]) - ) - ; - /* @var ParameterResolverInterface $injectedResolver */ + ]), + ); + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new ArrayParameterResolver())->withResolver($injectedResolver); $result = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::assertEquals( + self::assertEquals( new ParameterBag([ 'array_param' => [ '0' => 'val1', ], 'other_param' => 'yo', ]), - $result + $result, ); } /** * @dataProvider provideContexts */ - public function testTheContextPassedToTheInjectedResolverIsAlwaysValid(ResolvingContext $context = null, ResolvingContext $expected): void + public function testTheContextPassedToTheInjectedResolverIsAlwaysValid(?ResolvingContext $context = null, ResolvingContext $expected): void { $array = [ $val1 = 'foo', @@ -223,36 +221,34 @@ public function testTheContextPassedToTheInjectedResolverIsAlwaysValid(Resolving new Parameter('0', $val1), $unresolvedParameters, $resolvedParameters, - $expected + $expected, ) ->willReturn( new ParameterBag([ 'name' => 'resolvedParams', '0' => 'val1', - ]) - ) - ; + ]), + ); $injectedResolverProphecy ->resolve( new Parameter('1', $val2), $unresolvedParameters, $resolvedParameters, - $expected + $expected, ) ->willReturn( new ParameterBag([ 'name' => 'resolvedParams', '1' => 'val2', - ]) - ) - ; - /* @var ParameterResolverInterface $injectedResolver */ + ]), + ); + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new ArrayParameterResolver())->withResolver($injectedResolver); $result = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::assertEquals( + self::assertEquals( new ParameterBag([ 'name' => 'resolvedParams', 'array_param' => [ @@ -260,11 +256,11 @@ public function testTheContextPassedToTheInjectedResolverIsAlwaysValid(Resolving '1' => 'val2', ], ]), - $result + $result, ); } - public function provideContexts() + public function provideContexts(): iterable { return [ 'no context' => [ @@ -292,7 +288,7 @@ public function provideContexts() $context->add('array_param'); return $context; - })() + })(), ], ]; } diff --git a/tests/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolverTest.php b/tests/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolverTest.php index 3de3f5504..9fdfabd79 100644 --- a/tests/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolverTest.php +++ b/tests/Generator/Resolver/Parameter/Chainable/RecursiveParameterResolverTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Parameter\Chainable\RecursiveParameterResolver + * @internal */ class RecursiveParameterResolverTest extends TestCase { @@ -35,28 +36,28 @@ class RecursiveParameterResolverTest extends TestCase public function testIsAChainableParameterResolver(): void { - static::assertTrue(is_a(RecursiveParameterResolver::class, ChainableParameterResolverInterface::class, true)); + self::assertTrue(is_a(RecursiveParameterResolver::class, ChainableParameterResolverInterface::class, true)); } public function testIsAParameterResolverAwareResolver(): void { - static::assertTrue(is_a(RecursiveParameterResolver::class, ParameterResolverAwareInterface::class, true)); + self::assertTrue(is_a(RecursiveParameterResolver::class, ParameterResolverAwareInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(RecursiveParameterResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(RecursiveParameterResolver::class))->isCloneable()); } public function testThrowsExceptionIfInvalidRecursionLimitGiven(): void { try { new RecursiveParameterResolver(new FakeChainableParameterResolver(), 1); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'Expected limit for recursive calls to be of at least 2. Got "1" instead.', - $exception->getMessage() + $exception->getMessage(), ); } } @@ -66,13 +67,13 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new RecursiveParameterResolver(new DummyChainableParameterResolverAwareResolver()); $newResolver = $resolver->withResolver(new FakeParameterResolver()); - static::assertEquals( + self::assertEquals( new RecursiveParameterResolver(new DummyChainableParameterResolverAwareResolver()), - $resolver + $resolver, ); - static::assertEquals( + self::assertEquals( new RecursiveParameterResolver(new DummyChainableParameterResolverAwareResolver(new FakeParameterResolver())), - $newResolver + $newResolver, ); } @@ -84,13 +85,13 @@ public function testUseDecoratedResolverToKnowWhichParameterItCanResolve(): void $decoratedResolverProphecy = $this->prophesize(ChainableParameterResolverInterface::class); $decoratedResolverProphecy->canResolve($parameter1)->willReturn(false); $decoratedResolverProphecy->canResolve($parameter2)->willReturn(true); - /* @var ChainableParameterResolverInterface $decoratedResolver */ + /** @var ChainableParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RecursiveParameterResolver($decoratedResolver); - static::assertFalse($resolver->canResolve($parameter1)); - static::assertTrue($resolver->canResolve($parameter2)); + self::assertFalse($resolver->canResolve($parameter1)); + self::assertTrue($resolver->canResolve($parameter2)); $decoratedResolverProphecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(2); } @@ -112,26 +113,24 @@ public function testResolveWithNoChange(): void $parameter, $unresolvedParameters, $resolvedParameters, - $context + $context, ) - ->willReturn($expected) - ; + ->willReturn($expected); $decoratedResolverProphecy ->resolve( new Parameter('foo', 'bar'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) - ->willReturn($expected) - ; - /* @var ChainableParameterResolverInterface $decoratedResolver */ + ->willReturn($expected); + /** @var ChainableParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RecursiveParameterResolver($decoratedResolver); $actual = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2); } @@ -148,56 +147,53 @@ public function testIfMultipleParametersAreResolvedInTheProcessThenTheyWillBeInc $parameter, $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( new ParameterBag([ 'foo' => 'first result', 'another_param1' => 'val1', - ]) - ) - ; + ]), + ); $decoratedResolverProphecy ->resolve( new Parameter('foo', 'first result'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( new ParameterBag([ 'foo' => 'second result', 'another_param2' => 'val2', // 'another_param1' has already been resolved so is not return in the result set! - ]) - ) - ; + ]), + ); $decoratedResolverProphecy ->resolve( new Parameter('foo', 'second result'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( new ParameterBag([ 'foo' => 'second result', // same as previous - ]) - ) - ; - /* @var ChainableParameterResolverInterface $decoratedResolver */ + ]), + ); + /** @var ChainableParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RecursiveParameterResolver($decoratedResolver); $actual = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::assertEquals( + self::assertEquals( new ParameterBag([ 'foo' => 'second result', 'another_param1' => 'val1', 'another_param2' => 'val2', ]), - $actual + $actual, ); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(3); } @@ -205,16 +201,15 @@ public function testIfMultipleParametersAreResolvedInTheProcessThenTheyWillBeInc /** * @dataProvider provideContexts */ - public function testTheSameContextIsPassedBetweenEachResolution(ResolvingContext $context = null): void + public function testTheSameContextIsPassedBetweenEachResolution(?ResolvingContext $context = null): void { $parameter = new Parameter('foo', null); $decoratedResolverProphecy = $this->prophesize(ChainableParameterResolverInterface::class); $decoratedResolverProphecy ->resolve(Argument::any(), Argument::any(), Argument::any(), $context) - ->willReturn(new ParameterBag(['foo' => null])) - ; - /* @var ChainableParameterResolverInterface $decoratedResolver */ + ->willReturn(new ParameterBag(['foo' => null])); + /** @var ChainableParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RecursiveParameterResolver($decoratedResolver); @@ -237,52 +232,48 @@ public function testResolveWithChange(): void $parameter, $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( - new ParameterBag(['foo' => 'result1']) - ) - ; + new ParameterBag(['foo' => 'result1']), + ); $decoratedResolverProphecy ->resolve( new Parameter('foo', 'result1'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( - new ParameterBag(['foo' => 'result2']) - ) - ; + new ParameterBag(['foo' => 'result2']), + ); $decoratedResolverProphecy ->resolve( new Parameter('foo', 'result2'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( - new ParameterBag(['foo' => 'result3']) - ) - ; + new ParameterBag(['foo' => 'result3']), + ); $decoratedResolverProphecy ->resolve( new Parameter('foo', 'result3'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( - $expected = new ParameterBag(['foo' => 'result3']) - ) - ; - /* @var ChainableParameterResolverInterface $decoratedResolver */ + $expected = new ParameterBag(['foo' => 'result3']), + ); + /** @var ChainableParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RecursiveParameterResolver($decoratedResolver); $actual = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(4); } @@ -297,25 +288,24 @@ public function testThrowsAnExceptionWhenRecursionLimitIsReached(): void $decoratedResolverProphecy ->resolve(Argument::cetera()) ->will( - function ($args) { + static function ($args) { $hash = spl_object_hash($args[0]); return new ParameterBag(['foo' => uniqid($hash)]); - } - ) - ; - /* @var ChainableParameterResolverInterface $decoratedResolver */ + }, + ); + /** @var ChainableParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RecursiveParameterResolver($decoratedResolver); try { $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (RecursionLimitReachedException $exception) { - static::assertEquals( + self::assertEquals( 'Recursion limit (5 tries) reached while resolving the parameter "foo"', - $exception->getMessage() + $exception->getMessage(), ); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(5); } @@ -324,17 +314,17 @@ function ($args) { try { $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (RecursionLimitReachedException $exception) { - static::assertEquals( + self::assertEquals( 'Recursion limit (10 tries) reached while resolving the parameter "foo"', - $exception->getMessage() + $exception->getMessage(), ); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(15); } } - public function provideContexts() + public function provideContexts(): iterable { return [ 'no context' => [ diff --git a/tests/Generator/Resolver/Parameter/Chainable/StringParameterResolverTest.php b/tests/Generator/Resolver/Parameter/Chainable/StringParameterResolverTest.php index c54c62d69..3d6d8e80c 100644 --- a/tests/Generator/Resolver/Parameter/Chainable/StringParameterResolverTest.php +++ b/tests/Generator/Resolver/Parameter/Chainable/StringParameterResolverTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Parameter\Chainable\StringParameterResolver + * @internal */ class StringParameterResolverTest extends TestCase { @@ -37,12 +38,12 @@ class StringParameterResolverTest extends TestCase public function testIsAChainableParameterResolver(): void { - static::assertTrue(is_a(StringParameterResolver::class, ChainableParameterResolverInterface::class, true)); + self::assertTrue(is_a(StringParameterResolver::class, ChainableParameterResolverInterface::class, true)); } public function testIsAParameterResolverAwareResolver(): void { - static::assertTrue(is_a(StringParameterResolver::class, ParameterResolverAwareInterface::class, true)); + self::assertTrue(is_a(StringParameterResolver::class, ParameterResolverAwareInterface::class, true)); } public function testCanBeInstantiatedWithoutAResolver(): void @@ -57,7 +58,7 @@ public function testCanBeInstantiatedWithAResolver(): void public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StringParameterResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StringParameterResolver::class))->isCloneable()); } public function testWithersReturnNewModifiedInstance(): void @@ -65,8 +66,8 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new StringParameterResolver(); $newResolver = $resolver->withResolver(new FakeParameterResolver()); - static::assertEquals(new StringParameterResolver(), $resolver); - static::assertEquals(new StringParameterResolver(new FakeParameterResolver()), $newResolver); + self::assertEquals(new StringParameterResolver(), $resolver); + self::assertEquals(new StringParameterResolver(new FakeParameterResolver()), $newResolver); } public function testCanOnlyResolveStringValues(): void @@ -74,16 +75,16 @@ public function testCanOnlyResolveStringValues(): void $resolver = new StringParameterResolver(); $parameter = new Parameter('foo', null); - static::assertTrue($resolver->canResolve($parameter->withValue('string'))); + self::assertTrue($resolver->canResolve($parameter->withValue('string'))); - static::assertFalse($resolver->canResolve($parameter->withValue(null))); - static::assertFalse($resolver->canResolve($parameter->withValue(10))); - static::assertFalse($resolver->canResolve($parameter->withValue(.75))); - static::assertFalse($resolver->canResolve($parameter->withValue([]))); - static::assertFalse($resolver->canResolve($parameter->withValue(new stdClass()))); - static::assertFalse($resolver->canResolve($parameter->withValue( + self::assertFalse($resolver->canResolve($parameter->withValue(null))); + self::assertFalse($resolver->canResolve($parameter->withValue(10))); + self::assertFalse($resolver->canResolve($parameter->withValue(.75))); + self::assertFalse($resolver->canResolve($parameter->withValue([]))); + self::assertFalse($resolver->canResolve($parameter->withValue(new stdClass()))); + self::assertFalse($resolver->canResolve($parameter->withValue( static function (): void { - } + }, ))); } @@ -95,22 +96,22 @@ public function testCanResolveStaticStringsWithoutDecoratedResolver(): void $resolver = new StringParameterResolver(); $result = $resolver->resolve($parameter, new ParameterBag(), new ParameterBag()); - static::assertEquals( + self::assertEquals( $expected, - $result + $result, ); $injectedResolverProphecy = $this->prophesize(ParameterResolverInterface::class); $injectedResolverProphecy->resolve(Argument::cetera())->shouldNotBeCalled(); - /* @var ParameterResolverInterface $injectedResolver */ + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new StringParameterResolver())->withResolver($injectedResolver); $result = $resolver->resolve($parameter, new ParameterBag(), new ParameterBag()); - static::assertEquals( + self::assertEquals( $expected, - $result + $result, ); } @@ -127,22 +128,22 @@ public function testWhenResolvingDynamicStringLookForResolvedParametersFirst(): $resolver = new StringParameterResolver(); $result = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters); - static::assertEquals( + self::assertEquals( $expected, - $result + $result, ); $injectedResolverProphecy = $this->prophesize(ParameterResolverInterface::class); $injectedResolverProphecy->resolve(Argument::cetera())->shouldNotBeCalled(); - /* @var ParameterResolverInterface $injectedResolver */ + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new StringParameterResolver())->withResolver($injectedResolver); $result = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters); - static::assertEquals( + self::assertEquals( $expected, - $result + $result, ); } @@ -156,28 +157,28 @@ public function testChecksIfParameterIsReferencedBeforeTryingToResolveIt(): void try { $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters); - static::fail('Expected exception to be thrown'); + self::fail('Expected exception to be thrown'); } catch (ParameterNotFoundException $exception) { - static::assertEquals( + self::assertEquals( 'Could not find the parameter "bar" when resolving "foo".', - $exception->getMessage() + $exception->getMessage(), ); } $injectedResolverProphecy = $this->prophesize(ParameterResolverInterface::class); $injectedResolverProphecy->resolve(Argument::cetera())->shouldNotBeCalled(); - /* @var ParameterResolverInterface $injectedResolver */ + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new StringParameterResolver())->withResolver($injectedResolver); try { $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters); - static::fail('Expected exception to be thrown'); + self::fail('Expected exception to be thrown'); } catch (ParameterNotFoundException $exception) { - static::assertEquals( + self::assertEquals( 'Could not find the parameter "bar" when resolving "foo".', - $exception->getMessage() + $exception->getMessage(), ); } } @@ -208,24 +209,23 @@ public function testInjectedResolverToResolveDynamicParameter(): void $context->add('bar'); return $context; - })() + })(), ) ->willReturn( new ParameterBag([ 'random' => 'param', 'bar' => 'Mad Hatter', - ]) - ) - ; - /* @var ParameterResolverInterface $injectedResolver */ + ]), + ); + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new StringParameterResolver())->withResolver($injectedResolver); $result = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters); - static::assertEquals( + self::assertEquals( $expected, - $result + $result, ); $injectedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -250,23 +250,22 @@ public function testReuseContextIfOneIsFoundWhenResolvingDynamicParameter(): voi new Parameter('bar', 'unresolved(bar)'), $unresolvedParameters, $resolvedParameters, - $context + $context, ) ->willReturn( new ParameterBag([ 'bar' => 'Mad Hatter', - ]) - ) - ; - /* @var ParameterResolverInterface $injectedResolver */ + ]), + ); + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = (new StringParameterResolver())->withResolver($injectedResolver); $result = $resolver->resolve($parameter, $unresolvedParameters, $resolvedParameters, $context); - static::assertEquals( + self::assertEquals( $expected, - $result + $result, ); $injectedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/Generator/Resolver/Parameter/ParameterResolverRegistryTest.php b/tests/Generator/Resolver/Parameter/ParameterResolverRegistryTest.php index 1074b11d8..974599831 100644 --- a/tests/Generator/Resolver/Parameter/ParameterResolverRegistryTest.php +++ b/tests/Generator/Resolver/Parameter/ParameterResolverRegistryTest.php @@ -29,6 +29,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Parameter\ParameterResolverRegistry + * @internal */ class ParameterResolverRegistryTest extends TestCase { @@ -36,14 +37,14 @@ class ParameterResolverRegistryTest extends TestCase public function testIsAParameterResolver(): void { - static::assertTrue(is_a(ParameterResolverRegistry::class, ParameterResolverInterface::class, true)); + self::assertTrue(is_a(ParameterResolverRegistry::class, ParameterResolverInterface::class, true)); } public function testAcceptsChainableParameterResolvers(): void { $resolverProphecy = $this->prophesize(ChainableParameterResolverInterface::class); $resolverProphecy->canResolve(Argument::any())->shouldNotBeCalled(); - /* @var ChainableParameterResolverInterface $resolver */ + /** @var ChainableParameterResolverInterface $resolver */ $resolver = $resolverProphecy->reveal(); new ParameterResolverRegistry([$resolver]); @@ -59,12 +60,12 @@ public function testInjectsItselfToParameterResolverAwareResolvers(): void $registry = new ParameterResolverRegistry([$oneResolver, $secondResolver]); - static::assertSame($registry, $propRefl->getValue($registry)[1]->resolver); + self::assertSame($registry, $propRefl->getValue($registry)[1]->resolver); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ParameterResolverRegistry::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ParameterResolverRegistry::class))->isCloneable()); } public function testThrowsAnExceptionIfInvalidResolverIsPassed(): void @@ -82,18 +83,18 @@ public function testIteratesOverEveryResolverAndUsesTheFirstValidOne(): void $resolver1Prophecy = $this->prophesize(ChainableParameterResolverInterface::class); $resolver1Prophecy->canResolve($parameter)->willReturn(false); - /* @var ChainableParameterResolverInterface $resolver1 */ + /** @var ChainableParameterResolverInterface $resolver1 */ $resolver1 = $resolver1Prophecy->reveal(); $resolver2Prophecy = $this->prophesize(ChainableParameterResolverInterface::class); $resolver2Prophecy->canResolve($parameter)->willReturn(true); $resolver2Prophecy->resolve(Argument::cetera())->willReturn($expected); - /* @var ChainableParameterResolverInterface $resolver2 */ + /** @var ChainableParameterResolverInterface $resolver2 */ $resolver2 = $resolver2Prophecy->reveal(); $resolver3Prophecy = $this->prophesize(ChainableParameterResolverInterface::class); $resolver3Prophecy->canResolve(Argument::any())->shouldNotBeCalled(); - /* @var ChainableParameterResolverInterface $resolver */ + /** @var ChainableParameterResolverInterface $resolver */ $resolver = $resolver3Prophecy->reveal(); $registry = new ParameterResolverRegistry([ @@ -103,7 +104,7 @@ public function testIteratesOverEveryResolverAndUsesTheFirstValidOne(): void ]); $actual = $registry->resolve($parameter, new ParameterBag(), new ParameterBag()); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $resolver1Prophecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); $resolver2Prophecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolverTest.php b/tests/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolverTest.php index d7deb0a6f..4af52b463 100644 --- a/tests/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolverTest.php +++ b/tests/Generator/Resolver/Parameter/RemoveConflictingParametersParameterBagResolverTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Parameter\RemoveConflictingParametersParameterBagResolver + * @internal */ class RemoveConflictingParametersParameterBagResolverTest extends TestCase { @@ -29,16 +30,16 @@ class RemoveConflictingParametersParameterBagResolverTest extends TestCase public function testIsAParameterBagResolver(): void { - static::assertTrue(is_a( + self::assertTrue(is_a( RemoveConflictingParametersParameterBagResolver::class, ParameterBagResolverInterface::class, - true + true, )); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(RemoveConflictingParametersParameterBagResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(RemoveConflictingParametersParameterBagResolver::class))->isCloneable()); } public function testRemovesAllConflictingKeysFromInjectedParametersBagBeforeResolvingIt(): void @@ -52,27 +53,26 @@ public function testRemovesAllConflictingKeysFromInjectedParametersBagBeforeReso 'foz' => 'baz', ]); - $decoratedResolverProphecy = $this->prophesize(ParameterBagResolverInterface::class); $decoratedResolverProphecy ->resolve( $unresolvedParameters, - new ParameterBag(['foz' => 'baz']) + new ParameterBag(['foz' => 'baz']), ) ->willReturn( $expected = new ParameterBag([ 'foo' => '(resolved) bar', 'ping' => '(resolved) pong', 'foz' => 'baz', - ]) + ]), ); - /* @var ParameterBagResolverInterface $decoratedResolver */ + /** @var ParameterBagResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RemoveConflictingParametersParameterBagResolver($decoratedResolver); $actual = $resolver->resolve($unresolvedParameters, $injectedParameters); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -85,27 +85,26 @@ public function testCanHandleTheCaseWhereNoParameterIsInjected(): void ]); $injectedParameters = null; - $decoratedResolverProphecy = $this->prophesize(ParameterBagResolverInterface::class); $decoratedResolverProphecy ->resolve( $unresolvedParameters, - new ParameterBag() + new ParameterBag(), ) ->willReturn( $expected = new ParameterBag([ 'foo' => '(resolved) bar', 'ping' => '(resolved) pong', 'foz' => 'baz', - ]) + ]), ); - /* @var ParameterBagResolverInterface $decoratedResolver */ + /** @var ParameterBagResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new RemoveConflictingParametersParameterBagResolver($decoratedResolver); $actual = $resolver->resolve($unresolvedParameters, $injectedParameters); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/Generator/Resolver/Parameter/SimpleParameterBagResolverTest.php b/tests/Generator/Resolver/Parameter/SimpleParameterBagResolverTest.php index 1b4148c29..10801a6dc 100644 --- a/tests/Generator/Resolver/Parameter/SimpleParameterBagResolverTest.php +++ b/tests/Generator/Resolver/Parameter/SimpleParameterBagResolverTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Parameter\SimpleParameterBagResolver + * @internal */ class SimpleParameterBagResolverTest extends TestCase { @@ -32,12 +33,12 @@ class SimpleParameterBagResolverTest extends TestCase public function testIsAParameterBagResolver(): void { - static::assertTrue(is_a(SimpleParameterBagResolver::class, ParameterBagResolverInterface::class, true)); + self::assertTrue(is_a(SimpleParameterBagResolver::class, ParameterBagResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleParameterBagResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleParameterBagResolver::class))->isCloneable()); } public function testDecoratesResolverToResolveParameterBag(): void @@ -53,43 +54,41 @@ public function testDecoratesResolverToResolveParameterBag(): void new Parameter('foo', '(unresolved) bar'), $unresolvedParameters, new ParameterBag(), - new ResolvingContext('foo') + new ResolvingContext('foo'), ) ->willReturn( $firstResolveResult = new ParameterBag([ 'foo' => 'bar', 'other_param' => 'yo', - ]) - ) - ; + ]), + ); $injectedResolverProphecy ->resolve( new Parameter('ping', '(unresolved) pong'), $unresolvedParameters, $firstResolveResult, - new ResolvingContext('ping') + new ResolvingContext('ping'), ) ->willReturn( new ParameterBag([ 'foo' => 'bar', 'other_param' => 'yo', 'ping' => 'pong', - ]) - ) - ; - /* @var ParameterResolverInterface $injectedResolver */ + ]), + ); + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = new SimpleParameterBagResolver($injectedResolver); $result = $resolver->resolve($unresolvedParameters); - static::assertEquals( + self::assertEquals( new ParameterBag([ 'foo' => 'bar', 'other_param' => 'yo', 'ping' => 'pong', ]), - $result + $result, ); $injectedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2); } @@ -107,13 +106,13 @@ public function testDoesNotResolveAlreadyResolvedParameters(): void $injectedResolverProphecy = $this->prophesize(ParameterResolverInterface::class); $injectedResolverProphecy->resolve(Argument::cetera())->shouldNotBeCalled(); - /* @var ParameterResolverInterface $injectedResolver */ + /** @var ParameterResolverInterface $injectedResolver */ $injectedResolver = $injectedResolverProphecy->reveal(); $resolver = new SimpleParameterBagResolver($injectedResolver); $result = $resolver->resolve($unresolvedParameters, $resolvedParameters); - static::assertEquals($resolvedParameters, $result); + self::assertEquals($resolvedParameters, $result); } public function testResolvesBagWithInjectedParameters(): void @@ -132,15 +131,14 @@ public function testResolvesBagWithInjectedParameters(): void new Parameter('foo', '(unresolved) bar'), $unresolvedParameters, $injectedParameters, - new ResolvingContext('foo') + new ResolvingContext('foo'), ) ->willReturn( new ParameterBag([ 'other_param' => 'yo', 'foo' => 'bar', - ]) - ) - ; + ]), + ); $decoratedResolverProphecy ->resolve( new Parameter('ping', '(unresolved) pong'), @@ -149,29 +147,28 @@ public function testResolvesBagWithInjectedParameters(): void 'other_param' => 'yo', 'foo' => 'bar', ]), - new ResolvingContext('ping') + new ResolvingContext('ping'), ) ->willReturn( new ParameterBag([ 'other_param' => 'yo', 'foo' => 'bar', 'ping' => 'pong', - ]) - ) - ; - /* @var ParameterResolverInterface $decoratedResolver */ + ]), + ); + /** @var ParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new SimpleParameterBagResolver($decoratedResolver); $result = $resolver->resolve($unresolvedParameters, $injectedParameters); - static::assertEquals( + self::assertEquals( new ParameterBag([ 'other_param' => 'yo', 'foo' => 'bar', 'ping' => 'pong', ]), - $result + $result, ); } } diff --git a/tests/Generator/Resolver/Parameter/StaticParameterResolverTest.php b/tests/Generator/Resolver/Parameter/StaticParameterResolverTest.php index 01090017b..bbf278a52 100644 --- a/tests/Generator/Resolver/Parameter/StaticParameterResolverTest.php +++ b/tests/Generator/Resolver/Parameter/StaticParameterResolverTest.php @@ -23,17 +23,18 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Parameter\Chainable\StaticParameterResolver + * @internal */ class StaticParameterResolverTest extends TestCase { public function testIsAChainableParameterResolver(): void { - static::assertTrue(is_a(StaticParameterResolver::class, ChainableParameterResolverInterface::class, true)); + self::assertTrue(is_a(StaticParameterResolver::class, ChainableParameterResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StaticParameterResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StaticParameterResolver::class))->isCloneable()); } public function testCanOnlyResolveSimpleValues(): void @@ -41,16 +42,16 @@ public function testCanOnlyResolveSimpleValues(): void $resolver = new StaticParameterResolver(); $parameter = new Parameter('foo', null); - static::assertTrue($resolver->canResolve($parameter->withValue(null))); - static::assertTrue($resolver->canResolve($parameter->withValue(10))); - static::assertTrue($resolver->canResolve($parameter->withValue(.75))); - static::assertTrue($resolver->canResolve($parameter->withValue(new stdClass()))); - static::assertTrue($resolver->canResolve($parameter->withValue( + self::assertTrue($resolver->canResolve($parameter->withValue(null))); + self::assertTrue($resolver->canResolve($parameter->withValue(10))); + self::assertTrue($resolver->canResolve($parameter->withValue(.75))); + self::assertTrue($resolver->canResolve($parameter->withValue(new stdClass()))); + self::assertTrue($resolver->canResolve($parameter->withValue( static function (): void { - } + }, ))); - static::assertFalse($resolver->canResolve($parameter->withValue('string'))); + self::assertFalse($resolver->canResolve($parameter->withValue('string'))); } public function testReturnsResolvedParameter(): void @@ -60,11 +61,11 @@ public function testReturnsResolvedParameter(): void $result = $resolver->resolve($parameter, new ParameterBag(), new ParameterBag()); - static::assertEquals( + self::assertEquals( new ParameterBag([ 'foo' => null, ]), - $result + $result, ); } } diff --git a/tests/Generator/Resolver/ParameterResolverIntegrationTest.php b/tests/Generator/Resolver/ParameterResolverIntegrationTest.php index 9435d268b..5c91e68a0 100644 --- a/tests/Generator/Resolver/ParameterResolverIntegrationTest.php +++ b/tests/Generator/Resolver/ParameterResolverIntegrationTest.php @@ -24,11 +24,12 @@ * @group integration * * @coversNothing + * @internal */ class ParameterResolverIntegrationTest extends TestCase { protected ParameterBagResolverInterface $resolver; - + protected function setUp(): void { $this->resolver = (new NativeLoader())->getParameterResolver(); @@ -44,13 +45,13 @@ public function testResolveParameters( ): void { $actual = $this->resolver->resolve($unresolvedParameters, $injectedParameters); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** * @dataProvider provideCircularReferences */ - public function testThrowExceptionIfCircularReferenceDetected(ParameterBag $unresolvedParameters, ParameterBag $injectedParameters = null): void + public function testThrowExceptionIfCircularReferenceDetected(ParameterBag $unresolvedParameters, ?ParameterBag $injectedParameters = null): void { $this->expectException(CircularReferenceException::class); $this->expectExceptionMessageMatches('/^Circular reference detected for the parameter "[^\"]+" while resolving \[.+]\.$/'); @@ -65,11 +66,11 @@ public function testThrowExceptionWhenResolvingNonExistentParameter(): void $this->resolver->resolve( new ParameterBag([ 'param1' => '<{inexisting_param}>', - ]) + ]), ); } - public function provideCircularReferences() + public function provideCircularReferences(): iterable { $return = []; @@ -102,7 +103,7 @@ public function provideCircularReferences() return $return; } - public function provideParameters() + public function provideParameters(): iterable { $return = []; @@ -126,7 +127,7 @@ public function provideParameters() $return['static values'] = [ $staticValues, null, - $staticValues + $staticValues, ]; $return['simple dynamic parameter'] = [ @@ -138,7 +139,7 @@ public function provideParameters() new ParameterBag([ 'param1' => 'hello', 'param2' => 'hello', - ]) + ]), ]; $return['simple inversed dynamic parameter'] = [ @@ -150,21 +151,21 @@ public function provideParameters() new ParameterBag([ 'param1' => 'hello', 'param2' => 'hello', - ]) + ]), ]; $return['composite parameter'] = [ new ParameterBag([ 'param1' => '<{param2}> <{param3}>', 'param2' => 'NaN', - 'param3' => 'Bat' + 'param3' => 'Bat', ]), null, new ParameterBag([ 'param1' => 'NaN Bat', 'param2' => 'NaN', - 'param3' => 'Bat' - ]) + 'param3' => 'Bat', + ]), ]; $return['composite stringified reference'] = [ @@ -180,7 +181,7 @@ public function provideParameters() 'param2' => true, 'param3' => false, 'param4' => -.89, - ]) + ]), ]; $return['composite stringified reference'] = [ @@ -196,7 +197,7 @@ public function provideParameters() 'param2' => false, 'param3' => false, 'param4' => -.89, - ]) + ]), ]; $return['nested parameters'] = [ @@ -210,7 +211,7 @@ public function provideParameters() 'param1' => 'foo', 'param2' => 3, 'param3' => 'foo', - ]) + ]), ]; $return['deep nested parameters'] = [ @@ -218,15 +219,15 @@ public function provideParameters() 'param1' => '<{param<{param<{param3}>}>}>', 'param3' => 2, 'param2' => 4, - 'param4' => 'foo' + 'param4' => 'foo', ]), null, new ParameterBag([ 'param1' => 'foo', 'param3' => 2, 'param2' => 4, - 'param4' => 'foo' - ]) + 'param4' => 'foo', + ]), ]; $return['deep nested parameters'] = [ @@ -234,15 +235,15 @@ public function provideParameters() 'param1' => 'hey <{param<{param<{param3}>}>}> <{param4}> world', 'param3' => 2, 'param2' => 4, - 'param4' => 'foo' + 'param4' => 'foo', ]), null, new ParameterBag([ 'param1' => 'hey foo foo world', 'param3' => 2, 'param2' => 4, - 'param4' => 'foo' - ]) + 'param4' => 'foo', + ]), ]; return $return; diff --git a/tests/Generator/Resolver/ResolvingContextTest.php b/tests/Generator/Resolver/ResolvingContextTest.php index 8e36750e4..32b34fc50 100644 --- a/tests/Generator/Resolver/ResolvingContextTest.php +++ b/tests/Generator/Resolver/ResolvingContextTest.php @@ -18,36 +18,37 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\ResolvingContext + * @internal */ class ResolvingContextTest extends TestCase { public function testReadAccessorsReturnPropertiesValues(): void { $context = new ResolvingContext(); - static::assertFalse($context->has('foo')); + self::assertFalse($context->has('foo')); $context = new ResolvingContext('foo'); - static::assertTrue($context->has('foo')); + self::assertTrue($context->has('foo')); } public function testMutator(): void { $context = new ResolvingContext(); - static::assertFalse($context->has('foo')); + self::assertFalse($context->has('foo')); $context->add('foo'); - static::assertTrue($context->has('foo')); + self::assertTrue($context->has('foo')); } public function testStaticFactoryMethodReturnsExistingInstance(): void { $context = ResolvingContext::createFrom(null, 'foo'); - static::assertTrue($context->has('foo')); + self::assertTrue($context->has('foo')); $newContext = ResolvingContext::createFrom($context, 'ping'); - static::assertSame($context, $newContext); - static::assertTrue($context->has('foo')); - static::assertTrue($context->has('ping')); + self::assertSame($context, $newContext); + self::assertTrue($context->has('foo')); + self::assertTrue($context->has('ping')); } public function testFactoryMethodCannotTriggerACircularReference(): void @@ -65,7 +66,7 @@ public function testFactoryMethodCannotTriggerACircularReference(): void try { $context->checkForCircularReference('foo'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (CircularReferenceException $exception) { // Expected result } @@ -83,11 +84,11 @@ public function testThrowsAnExceptionWhenACircularReferenceIsDetected(): void try { $context->checkForCircularReference('foo'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (CircularReferenceException $exception) { - static::assertEquals( + self::assertEquals( 'Circular reference detected for the parameter "foo" while resolving ["bar", "foo"].', - $exception->getMessage() + $exception->getMessage(), ); } @@ -98,11 +99,11 @@ public function testThrowsAnExceptionWhenACircularReferenceIsDetected(): void try { $context->checkForCircularReference('foo'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (CircularReferenceException $exception) { - static::assertEquals( + self::assertEquals( 'Circular reference detected for the parameter "foo" while resolving ["foo"].', - $exception->getMessage() + $exception->getMessage(), ); } } diff --git a/tests/Generator/Resolver/SimpleResolverTest.php b/tests/Generator/Resolver/SimpleResolverTest.php index 6d3356f38..b272c9e3a 100644 --- a/tests/Generator/Resolver/SimpleResolverTest.php +++ b/tests/Generator/Resolver/SimpleResolverTest.php @@ -28,6 +28,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\FixtureSet\SimpleFixtureSetResolver + * @internal */ class SimpleResolverTest extends TestCase { @@ -35,7 +36,7 @@ class SimpleResolverTest extends TestCase public function testIsAResolver(): void { - static::assertTrue(is_a(SimpleFixtureSetResolver::class, FixtureSetResolverInterface::class, true)); + self::assertTrue(is_a(SimpleFixtureSetResolver::class, FixtureSetResolverInterface::class, true)); } public function testCanResolveAFixtureSet(): void @@ -79,7 +80,7 @@ public function testCanResolveAFixtureSet(): void $resolver = new SimpleFixtureSetResolver($parametersResolver, $fixtureResolver); $actual = $resolver->resolve($set); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $parametersResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); $fixtureResolverProphecy->resolve(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Generator/Resolver/UniqueValuesPoolTest.php b/tests/Generator/Resolver/UniqueValuesPoolTest.php index d01e88974..b9f80e68f 100644 --- a/tests/Generator/Resolver/UniqueValuesPoolTest.php +++ b/tests/Generator/Resolver/UniqueValuesPoolTest.php @@ -20,21 +20,22 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\UniqueValuesPool + * @internal */ class UniqueValuesPoolTest extends TestCase { public function testDoesNotHaveValueIfValueIsNotCached(): void { $pool = new UniqueValuesPool(); - static::assertFalse($pool->has(new UniqueValue('', ''))); + self::assertFalse($pool->has(new UniqueValue('', ''))); } /** - * @depends \Nelmio\Alice\Definition\Value\UniqueValueTest::testIsImmutable + * @depends test\Nelmio\Alice\Definition\Value\UniqueValueTest::testIsImmutable */ public function testIsImmutable(): void { - static::assertTrue(true, 'Nothing to do.'); + self::assertTrue(true, 'Nothing to do.'); } /** @@ -42,13 +43,13 @@ public function testIsImmutable(): void */ public function testHasObjectValue(UniqueValuesPool $pool, UniqueValue $value, bool $expected): void { - static::assertEquals($expected, $pool->has($value)); + self::assertEquals($expected, $pool->has($value)); $pool->add($value); - static::assertTrue($pool->has($value)); + self::assertTrue($pool->has($value)); } - public function provideHasValueSet() + public function provideHasValueSet(): iterable { $baseValue = new UniqueValue('foo', 'temporary value'); @@ -83,7 +84,6 @@ public function provideHasValueSet() false, ]; - // Full checks for a scalar value yield '[`true`] empty' => [ new UniqueValuesPool(), @@ -127,7 +127,6 @@ public function provideHasValueSet() false, ]; - // Check objects yield 'with two equivalent objects' => [ $this->createPoolWithValue(new stdClass()), @@ -146,15 +145,15 @@ public function provideHasValueSet() StdClassFactory::create([ 'relatedDummy' => StdClassFactory::create([ 'foo' => 'bar', - ]) - ]) + ]), + ]), ), $baseValue->withValue( StdClassFactory::create([ 'relatedDummy' => StdClassFactory::create([ 'foo' => 'bar', - ]) - ]) + ]), + ]), ), true, ]; @@ -164,20 +163,19 @@ public function provideHasValueSet() StdClassFactory::create([ 'relatedDummy' => StdClassFactory::create([ 'foo' => 'bar', - ]) - ]) + ]), + ]), ), $baseValue->withValue( StdClassFactory::create([ 'relatedDummy' => StdClassFactory::create([ 'foo' => new stdClass(), - ]) - ]) + ]), + ]), ), false, ]; - // Checks arrays yield 'two identical arrays' => [ $this->createPoolWithValue([]), diff --git a/tests/Generator/Resolver/Value/Chainable/DynamicArrayValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/DynamicArrayValueResolverTest.php index 504ed7086..f0edccfc5 100644 --- a/tests/Generator/Resolver/Value/Chainable/DynamicArrayValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/DynamicArrayValueResolverTest.php @@ -33,6 +33,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\DynamicArrayValueResolver + * @internal */ class DynamicArrayValueResolverTest extends TestCase { @@ -42,7 +43,7 @@ class DynamicArrayValueResolverTest extends TestCase * @var ReflectionProperty */ private $resolverRefl; - + protected function setUp(): void { $reflClass = new ReflectionClass(DynamicArrayValueResolver::class); @@ -53,12 +54,12 @@ protected function setUp(): void public function testIsAChainableResolver(): void { - static::assertTrue(is_a(DynamicArrayValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(DynamicArrayValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(DynamicArrayValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(DynamicArrayValueResolver::class))->isCloneable()); } public function testWithersReturnNewModifiedInstance(): void @@ -66,16 +67,16 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new DynamicArrayValueResolver(); $newResolver = $resolver->withValueResolver(new FakeValueResolver()); - static::assertEquals(new DynamicArrayValueResolver(), $resolver); - static::assertEquals(new DynamicArrayValueResolver(new FakeValueResolver()), $newResolver); + self::assertEquals(new DynamicArrayValueResolver(), $resolver); + self::assertEquals(new DynamicArrayValueResolver(new FakeValueResolver()), $newResolver); } public function testCanResolveDynamicArrayValues(): void { $resolver = new DynamicArrayValueResolver(); - static::assertTrue($resolver->canResolve(new DynamicArrayValue(1, ''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new DynamicArrayValue(1, ''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoResolver(): void @@ -103,9 +104,8 @@ public function testIfQuantifierIsAValueThenItWillBeResolvedAsWell(): void $decoratedResolverProphecy ->resolve($quantifier, $fixture, $set, $scope, $context) ->willReturn( - new ResolvedValueWithFixtureSet(10, ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']))) - ) - ; + new ResolvedValueWithFixtureSet(10, ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']))), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); @@ -127,9 +127,8 @@ public function testThrowsExceptionIfAnInvalidQuantifierIsGiven(): void $decoratedResolverProphecy ->resolve($quantifier, $fixture, $set, $scope, $context) ->willReturn( - new ResolvedValueWithFixtureSet(-1, ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']))) - ) - ; + new ResolvedValueWithFixtureSet(-1, ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']))), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); @@ -155,17 +154,16 @@ public function testDoesNotResolveElementIfIsNotAValue(): void $decoratedResolverProphecy ->resolve($quantifier, $fixture, $set, $scope, $context) ->willReturn( - new ResolvedValueWithFixtureSet(2, $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']))) - ) - ; + new ResolvedValueWithFixtureSet(2, $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']))), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new DynamicArrayValueResolver($decoratedResolver); $result = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertSame(['static val', 'static val'], $result->getValue()); - static::assertEquals($newSet, $result->getSet()); + self::assertSame(['static val', 'static val'], $result->getValue()); + self::assertEquals($newSet, $result->getSet()); } public function testResolvesElementAsManyTimeAsNecessaryIfItIsAValue(): void @@ -184,23 +182,21 @@ public function testResolvesElementAsManyTimeAsNecessaryIfItIsAValue(): void $decoratedResolverProphecy ->resolve($element, $fixture, $set, $scope, $context) ->willReturn( - new ResolvedValueWithFixtureSet(10, $setAfterFirstResolution) - ) - ; + new ResolvedValueWithFixtureSet(10, $setAfterFirstResolution), + ); $setAfterSecondResolution = ResolvedFixtureSetFactory::create(new ParameterBag(['iteration' => 1])); $decoratedResolverProphecy ->resolve($element, $fixture, $setAfterFirstResolution, $scope, $context) ->willReturn( - new ResolvedValueWithFixtureSet(100, $setAfterSecondResolution) - ) - ; + new ResolvedValueWithFixtureSet(100, $setAfterSecondResolution), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new DynamicArrayValueResolver($decoratedResolver); $result = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertSame([10, 100], $result->getValue()); - static::assertEquals($setAfterSecondResolution, $result->getSet()); + self::assertSame([10, 100], $result->getValue()); + self::assertEquals($setAfterSecondResolution, $result->getSet()); } } diff --git a/tests/Generator/Resolver/Value/Chainable/EvaluatedValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/EvaluatedValueResolverTest.php index 5be538714..ea26865e0 100644 --- a/tests/Generator/Resolver/Value/Chainable/EvaluatedValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/EvaluatedValueResolverTest.php @@ -27,25 +27,26 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\EvaluatedValueResolver + * @internal */ class EvaluatedValueResolverTest extends TestCase { public function testIsAChainableResolver(): void { - static::assertTrue(is_a(EvaluatedValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(EvaluatedValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(EvaluatedValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(EvaluatedValueResolver::class))->isCloneable()); } public function testCanResolveFixtureReferenceValues(): void { $resolver = new EvaluatedValueResolver(); - static::assertTrue($resolver->canResolve(new EvaluatedValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new EvaluatedValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testEvaluateTheGivenExpression(): void @@ -56,13 +57,13 @@ public function testEvaluateTheGivenExpression(): void $expected = new ResolvedValueWithFixtureSet( 'Hello world!', - $set + $set, ); $resolver = new EvaluatedValueResolver(); $actual = $resolver->resolve($value, $fixture, $set, [], new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfInvalidExpression(): void @@ -75,22 +76,22 @@ public function testThrowsAnExceptionIfInvalidExpression(): void $resolver = new EvaluatedValueResolver(); $resolver->resolve($value, $fixture, $set, [], new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (UnresolvableValueException $exception) { - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); if (PHP_VERSION_ID < 80000) { - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression ""unclosed string": syntax error, unexpected end of file,' - . ' expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN)', - $exception->getMessage() + .' expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN)', + $exception->getMessage(), ); } else { - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression ""unclosed string": syntax error, unexpected end of file,' - . ' expecting variable or "${" or "{$"', - $exception->getMessage() + .' expecting variable or "${" or "{$"', + $exception->getMessage(), ); } } @@ -121,13 +122,13 @@ public function testTheEvaluatedExpressionCanContainScopeFunctions(): void $expected = new ResolvedValueWithFixtureSet( 'bar', - $set + $set, ); $resolver = new EvaluatedValueResolver(); $actual = $resolver->resolve($value, $fixture, $set, $scope, new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** @@ -148,30 +149,30 @@ public function testVariablesInference(): void 'expression' => '["foo" => $foo, "expression" => $_expression, "scope" => $_scope]', 'scope' => $scope, ], - $set + $set, ); $resolver = new EvaluatedValueResolver(); $actual = $resolver->resolve($value, $fixture, $set, $scope, new GenerationContext()); - static::assertEquals($expected, $actual); - static::assertSame(['foo' => 'bar'], $scope); + self::assertEquals($expected, $actual); + self::assertSame(['foo' => 'bar'], $scope); $value = new EvaluatedValue('$scope'); try { $resolver->resolve($value, $fixture, $set, $scope, new GenerationContext()); - static::fail('Expected an exception to be thrown.'); + self::fail('Expected an exception to be thrown.'); } catch (UnresolvableValueException $exception) { if (PHP_VERSION_ID < 80000) { - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression "$scope": Undefined variable: scope', - $exception->getMessage() + $exception->getMessage(), ); } else { - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression "$scope": Undefined variable $scope', - $exception->getMessage() + $exception->getMessage(), ); } } @@ -195,29 +196,29 @@ public function testVariablesInferenceWithCurrent(): void 'current' => '1', ], ], - $set + $set, ); $resolver = new EvaluatedValueResolver(); $actual = $resolver->resolve($value, $fixture, $set, $scope, new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $value = new EvaluatedValue('$scope'); try { $resolver->resolve($value, $fixture, $set, $scope, new GenerationContext()); - static::fail('Expected an exception to be thrown.'); + self::fail('Expected an exception to be thrown.'); } catch (UnresolvableValueException $exception) { if (PHP_VERSION_ID < 80000) { - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression "$scope": Undefined variable: scope', - $exception->getMessage() + $exception->getMessage(), ); } else { - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression "$scope": Undefined variable $scope', - $exception->getMessage() + $exception->getMessage(), ); } } diff --git a/tests/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolverValueTest.php b/tests/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolverValueTest.php index fd34a69fa..8e30cfdb8 100644 --- a/tests/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolverValueTest.php +++ b/tests/Generator/Resolver/Value/Chainable/FakerFunctionCallValueResolverValueTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\FakerFunctionCallValueResolver + * @internal */ class FakerFunctionCallValueResolverValueTest extends TestCase { @@ -37,20 +38,20 @@ class FakerFunctionCallValueResolverValueTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(FakerFunctionCallValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(FakerFunctionCallValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FakerFunctionCallValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FakerFunctionCallValueResolver::class))->isCloneable()); } public function testCanResolvePropertyReferenceValues(): void { $resolver = new FakerFunctionCallValueResolver(FakerGeneratorFactory::create()); - static::assertTrue($resolver->canResolve(new ResolvedFunctionCallValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new ResolvedFunctionCallValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testReturnsSetWithResolvedValue(): void @@ -72,7 +73,7 @@ public function testReturnsSetWithResolvedValue(): void $resolver = new FakerFunctionCallValueResolver($fakerGenerator); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testCallAProviderFunction(): void @@ -84,8 +85,8 @@ public function testCallAProviderFunction(): void $resolver = new FakerFunctionCallValueResolver(FakerGeneratorFactory::create()); $result = $resolver->resolve($value, $fixture, $set, [], new GenerationContext()); - static::assertEquals(9, strlen($result->getValue())); - static::assertEquals('Hello ', substr($result->getValue(), 0, 6)); + self::assertEquals(9, mb_strlen($result->getValue())); + self::assertEquals('Hello ', mb_substr($result->getValue(), 0, 6)); } public function testThrowsAnExceptionIfTriesToCallAnUndefinedProviderFunction(): void diff --git a/tests/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolverTest.php b/tests/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolverTest.php index b9dc9adcd..411828eab 100644 --- a/tests/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/FixtureMethodCallReferenceResolverTest.php @@ -40,6 +40,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\FixtureMethodCallReferenceResolver + * @internal */ class FixtureMethodCallReferenceResolverTest extends TestCase { @@ -47,12 +48,12 @@ class FixtureMethodCallReferenceResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(FixtureMethodCallReferenceResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(FixtureMethodCallReferenceResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FixtureMethodCallReferenceResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FixtureMethodCallReferenceResolver::class))->isCloneable()); } public function testWithersReturnNewModifiedInstance(): void @@ -60,16 +61,16 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new FixtureMethodCallReferenceResolver(); $newResolver = $resolver->withValueResolver(new FakeValueResolver()); - static::assertEquals(new FixtureMethodCallReferenceResolver(), $resolver); - static::assertEquals(new FixtureMethodCallReferenceResolver(new FakeValueResolver()), $newResolver); + self::assertEquals(new FixtureMethodCallReferenceResolver(), $resolver); + self::assertEquals(new FixtureMethodCallReferenceResolver(new FakeValueResolver()), $newResolver); } public function testCanResolveMethodCallReferenceValues(): void { $resolver = new FixtureMethodCallReferenceResolver(); - static::assertTrue($resolver->canResolve(new FixtureMethodCallValue(new FakeValue(), new FunctionCallValue('method')))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new FixtureMethodCallValue(new FakeValue(), new FunctionCallValue('method')))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoResolver(): void @@ -89,7 +90,7 @@ public function testReturnsSetWithResolvedValue(): void $reference = new FakeValue(), new FunctionCallValue('getFoo', [ $arg1 = new FakeValue(), - ]) + ]), ); $fixture = new FakeFixture(); $set = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar'])); @@ -104,8 +105,7 @@ public function testReturnsSetWithResolvedValue(): void $dummyProphecy = $this->prophesize(DummyWithGetter::class); $dummyProphecy->getFoo('resolved_argument') ->shouldBeCalled() - ->willReturn('resolved_value') - ; + ->willReturn('resolved_value'); /** @var DummyWithGetter $dummy */ $dummy = $dummyProphecy->reveal(); @@ -116,16 +116,14 @@ public function testReturnsSetWithResolvedValue(): void ->willReturn( new ResolvedValueWithFixtureSet( 'resolved_argument', - $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])) - ) - ) - ; + $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])), + ), + ); $valueResolverProphecy ->resolve($reference, $fixture, $newSet, $scope, $valueResolverContext) ->willReturn( - new ResolvedValueWithFixtureSet($dummy, $newSet) - ) - ; + new ResolvedValueWithFixtureSet($dummy, $newSet), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -134,7 +132,7 @@ public function testReturnsSetWithResolvedValue(): void $resolver = new FixtureMethodCallReferenceResolver($valueResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $valueResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2); $dummyProphecy->getFoo(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -145,16 +143,16 @@ public function testThrowsAResolverExceptionOnError(): void try { $value = new FixtureMethodCallValue( $reference = new MutableValue(new DummyWithGetter()), - new FunctionCallValue('getFoo') + new FunctionCallValue('getFoo'), ); $set = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar'])); $error = new Error(); $dummyProphecy = $this->prophesize(DummyWithGetter::class); $dummyProphecy->getFoo()->will( - function () use ($error): void { + static function () use ($error): void { throw $error; - } + }, ); $valueResolverProphecy = $this->prophesize(ValueResolverInterface::class); @@ -163,24 +161,23 @@ function () use ($error): void { ->willReturn( new ResolvedValueWithFixtureSet( $instance = $dummyProphecy->reveal(), - $newSet = ResolvedFixtureSetFactory::create(new ParameterBag()) - ) - ) - ; + $newSet = ResolvedFixtureSetFactory::create(new ParameterBag()), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); $resolver = new FixtureMethodCallReferenceResolver($valueResolver); $resolver->resolve($value, new FakeFixture(), $set, [], new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (UnresolvableValueException $exception) { - static::assertEquals( + self::assertEquals( 'Could not resolve value "mutable->getFoo()".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertSame($error, $exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertSame($error, $exception->getPrevious()); } } @@ -190,7 +187,7 @@ public function testThrowsAnExceptionIfResolvedReferenceHasNoSuchMethod(): void $instance = new DummyWithGetter(); $value = new FixtureMethodCallValue( new MutableValue($instance), - new FunctionCallValue('getNonExistent') + new FunctionCallValue('getNonExistent'), ); $set = ResolvedFixtureSetFactory::create(); @@ -199,9 +196,8 @@ public function testThrowsAnExceptionIfResolvedReferenceHasNoSuchMethod(): void $valueResolverProphecy ->resolve(Argument::cetera()) ->willReturn( - new ResolvedValueWithFixtureSet(new stdClass(), $set) - ) - ; + new ResolvedValueWithFixtureSet(new stdClass(), $set), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -211,17 +207,17 @@ public function testThrowsAnExceptionIfResolvedReferenceHasNoSuchMethod(): void new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), $set, [], - new GenerationContext() + new GenerationContext(), ); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (NoSuchMethodException $exception) { - static::assertEquals( + self::assertEquals( 'Could not find the method "getNonExistent" of the object "dummy" (class: Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } } diff --git a/tests/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolverTest.php b/tests/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolverTest.php index be8674bbc..598c96480 100644 --- a/tests/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/FixturePropertyReferenceResolverTest.php @@ -44,6 +44,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\FixturePropertyReferenceResolver + * @internal */ class FixturePropertyReferenceResolverTest extends TestCase { @@ -51,12 +52,12 @@ class FixturePropertyReferenceResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(FixturePropertyReferenceResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(FixturePropertyReferenceResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FixturePropertyReferenceResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FixturePropertyReferenceResolver::class))->isCloneable()); } public function testWithersReturnNewModifiedInstance(): void @@ -64,16 +65,16 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new FixturePropertyReferenceResolver(new FakePropertyAccessor()); $newResolver = $resolver->withValueResolver(new FakeValueResolver()); - static::assertEquals(new FixturePropertyReferenceResolver(new FakePropertyAccessor()), $resolver); - static::assertEquals(new FixturePropertyReferenceResolver(new FakePropertyAccessor(), new FakeValueResolver()), $newResolver); + self::assertEquals(new FixturePropertyReferenceResolver(new FakePropertyAccessor()), $resolver); + self::assertEquals(new FixturePropertyReferenceResolver(new FakePropertyAccessor(), new FakeValueResolver()), $newResolver); } public function testCanResolvePropertyReferenceValues(): void { $resolver = new FixturePropertyReferenceResolver(new FakePropertyAccessor()); - static::assertTrue($resolver->canResolve(new FixturePropertyValue(new FakeValue(), ''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new FixturePropertyValue(new FakeValue(), ''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoResolver(): void @@ -91,7 +92,7 @@ public function testReturnsSetWithResolvedValue(): void { $value = new FixturePropertyValue( $reference = new FakeValue(), - $property = 'prop' + $property = 'prop', ); $fixture = new FakeFixture(); $set = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar'])); @@ -109,10 +110,9 @@ public function testReturnsSetWithResolvedValue(): void ->willReturn( new ResolvedValueWithFixtureSet( $instance = new stdClass(), - $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])) - ) - ) - ; + $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -126,7 +126,7 @@ public function testReturnsSetWithResolvedValue(): void $resolver = new FixturePropertyReferenceResolver($propertyAccessor, $valueResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $valueResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); $propertyAccessorProphecy->getValue(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -137,7 +137,7 @@ public function testCatchesAccessorExceptionsToThrowResolverException(): void try { $value = new FixturePropertyValue( $reference = new DummyValue('dummy'), - $property = 'prop' + $property = 'prop', ); $set = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar'])); @@ -147,10 +147,9 @@ public function testCatchesAccessorExceptionsToThrowResolverException(): void ->willReturn( new ResolvedValueWithFixtureSet( $instance = new stdClass(), - $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])) - ) - ) - ; + $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -162,14 +161,14 @@ public function testCatchesAccessorExceptionsToThrowResolverException(): void $resolver = new FixturePropertyReferenceResolver($propertyAccessor, $valueResolver); $resolver->resolve($value, new FakeFixture(), $set, [], new GenerationContext()); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (UnresolvableValueException $exception) { - static::assertEquals( + self::assertEquals( 'Could not resolve value "dummy->prop".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -177,7 +176,7 @@ public function testResolutionWithSymfonyPropertyAccessor(): void { $value = new FixturePropertyValue( $reference = new FakeValue(), - $property = 'publicProperty' + $property = 'publicProperty', ); $instance = new Dummy(); @@ -189,9 +188,8 @@ public function testResolutionWithSymfonyPropertyAccessor(): void $valueResolverProphecy ->resolve(Argument::cetera()) ->willReturn( - new ResolvedValueWithFixtureSet($instance, $set) - ) - ; + new ResolvedValueWithFixtureSet($instance, $set), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -200,14 +198,14 @@ public function testResolutionWithSymfonyPropertyAccessor(): void $resolver = new FixturePropertyReferenceResolver(PropertyAccess::createPropertyAccessor(), $valueResolver); $actual = $resolver->resolve($value, new FakeFixture(), $set, [], new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfReferenceResolvedIsNotAnObject(): void { $value = new FixturePropertyValue( $reference = new DummyValue('dummy'), - $property = 'publicProperty' + $property = 'publicProperty', ); $instance = new Dummy(); @@ -219,15 +217,14 @@ public function testThrowsAnExceptionIfReferenceResolvedIsNotAnObject(): void $valueResolverProphecy ->resolve(Argument::cetera()) ->willReturn( - new ResolvedValueWithFixtureSet('string value', $set) - ) - ; + new ResolvedValueWithFixtureSet('string value', $set), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); $resolver = new FixturePropertyReferenceResolver(PropertyAccess::createPropertyAccessor(), $valueResolver); - if ((new ReflectionMethod(PropertyAccessorInterface::class, 'getValue'))->getParameters()[0]->getType() !== null) { + if (null !== (new ReflectionMethod(PropertyAccessorInterface::class, 'getValue'))->getParameters()[0]->getType()) { // Since symfony/property-access 6.0 $this->expectException(TypeError::class); $this->expectExceptionMessageMatches(sprintf('/^%s/', preg_quote('Symfony\Component\PropertyAccess\PropertyAccessor::getValue(): Argument #1 ($objectOrArray) must be of type object|array, string given', '/'))); @@ -244,7 +241,7 @@ public function testThrowsAnExceptionIfResolvedReferenceHasNoSuchProperty(): voi try { $value = new FixturePropertyValue( $reference = new FakeValue(), - $property = 'prop' + $property = 'prop', ); $instance = new stdClass(); @@ -256,9 +253,8 @@ public function testThrowsAnExceptionIfResolvedReferenceHasNoSuchProperty(): voi $valueResolverProphecy ->resolve(Argument::cetera()) ->willReturn( - new ResolvedValueWithFixtureSet(new stdClass(), $set) - ) - ; + new ResolvedValueWithFixtureSet(new stdClass(), $set), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -268,17 +264,17 @@ public function testThrowsAnExceptionIfResolvedReferenceHasNoSuchProperty(): voi new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), $set, [], - new GenerationContext() + new GenerationContext(), ); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (NoSuchPropertyException $exception) { - static::assertEquals( + self::assertEquals( 'Could not find the property "prop" of the object "dummy" (class: Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } } diff --git a/tests/Generator/Resolver/Value/Chainable/FixtureReferenceResolverTest.php b/tests/Generator/Resolver/Value/Chainable/FixtureReferenceResolverTest.php index e217887b1..5e6c74592 100644 --- a/tests/Generator/Resolver/Value/Chainable/FixtureReferenceResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/FixtureReferenceResolverTest.php @@ -40,6 +40,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\FixtureReferenceResolver + * @internal */ class FixtureReferenceResolverTest extends TestCase { @@ -47,12 +48,12 @@ class FixtureReferenceResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(FixtureReferenceResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(FixtureReferenceResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FixtureReferenceResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FixtureReferenceResolver::class))->isCloneable()); } public function testIsGeneratorAware(): void @@ -62,16 +63,16 @@ public function testIsGeneratorAware(): void $resolver = new FixtureReferenceResolver(); $newResolver = $resolver->withObjectGenerator($generator); - static::assertEquals(new FixtureReferenceResolver(), $resolver); - static::assertEquals(new FixtureReferenceResolver($generator), $newResolver); + self::assertEquals(new FixtureReferenceResolver(), $resolver); + self::assertEquals(new FixtureReferenceResolver($generator), $newResolver); } public function testCanResolveFixtureReferenceValues(): void { $resolver = new FixtureReferenceResolver(); - static::assertTrue($resolver->canResolve(new FixtureReferenceValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new FixtureReferenceValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoGenerator(): void @@ -86,7 +87,7 @@ public function testCannotResolveValueIfHasNoGenerator(): void new FakeFixture(), ResolvedFixtureSetFactory::create(), [], - new GenerationContext() + new GenerationContext(), ); } @@ -102,7 +103,7 @@ public function testCannotResolveReferenceIsTheReferenceIsAValue(): void new FakeFixture(), ResolvedFixtureSetFactory::create(), [], - new GenerationContext() + new GenerationContext(), ); } @@ -113,7 +114,7 @@ public function testIfTheReferenceRefersToACompletelyGeneratedFixtureThenReturns $set = ResolvedFixtureSetFactory::create( null, null, - new ObjectBag(['dummy' => $expectedInstance = new stdClass()]) + new ObjectBag(['dummy' => $expectedInstance = new stdClass()]), ); $scope = []; $context = new GenerationContext(); @@ -123,7 +124,7 @@ public function testIfTheReferenceRefersToACompletelyGeneratedFixtureThenReturns $resolver = new FixtureReferenceResolver(new FakeObjectGenerator()); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testIfTheReferenceRefersToAnInstantiatedFixtureAndRequiresToBeCompleteThenGenerateIt(): void @@ -133,14 +134,14 @@ public function testIfTheReferenceRefersToAnInstantiatedFixtureAndRequiresToBeCo $set = ResolvedFixtureSetFactory::create( null, $fixtures = (new FixtureBag())->with( - $referredFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()) + $referredFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), ), (new ObjectBag())->with( new SimpleObject( 'dummy', - $expectedInstance = new stdClass() - ) - ) + $expectedInstance = new stdClass(), + ), + ), ); $scope = []; $context = new GenerationContext(); @@ -157,10 +158,9 @@ public function testIfTheReferenceRefersToAnInstantiatedFixtureAndRequiresToBeCo $objects = new ObjectBag([ 'dummy' => $expectedInstance = StdClassFactory::create([ 'complete' => true, - ]) - ]) - ) - ; + ]), + ]), + ); /** @var ObjectGeneratorInterface $generator */ $generator = $generatorProphecy->reveal(); @@ -169,15 +169,15 @@ public function testIfTheReferenceRefersToAnInstantiatedFixtureAndRequiresToBeCo ResolvedFixtureSetFactory::create( null, $fixtures, - $objects - ) + $objects, + ), ); $resolver = new FixtureReferenceResolver($generator); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); - static::assertEquals($context, $generatorContext); + self::assertEquals($expected, $actual); + self::assertEquals($context, $generatorContext); $generatorProphecy->generate(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -189,9 +189,9 @@ public function testIfTheReferenceRefersToANonInstantiatedFixtureThenGenerateItB $set = ResolvedFixtureSetFactory::create( null, $fixtures = (new FixtureBag())->with( - $referredFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()) + $referredFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), ), - null + null, ); $scope = []; $context = new GenerationContext(); @@ -204,9 +204,8 @@ public function testIfTheReferenceRefersToANonInstantiatedFixtureThenGenerateItB $generatorProphecy ->generate($referredFixture, $set, $generatorContext) ->willReturn( - $objects = new ObjectBag(['dummy' => $expectedInstance = new stdClass()]) - ) - ; + $objects = new ObjectBag(['dummy' => $expectedInstance = new stdClass()]), + ); /** @var ObjectGeneratorInterface $generator */ $generator = $generatorProphecy->reveal(); @@ -215,8 +214,8 @@ public function testIfTheReferenceRefersToANonInstantiatedFixtureThenGenerateItB ResolvedFixtureSetFactory::create( null, $fixtures, - $objects - ) + $objects, + ), ); $resolver = new FixtureReferenceResolver($generator); @@ -224,8 +223,8 @@ public function testIfTheReferenceRefersToANonInstantiatedFixtureThenGenerateItB $generatorContext->unmarkAsNeedsCompleteGeneration(); - static::assertEquals($expected, $actual); - static::assertEquals($generatorContext, $context); + self::assertEquals($expected, $actual); + self::assertEquals($generatorContext, $context); $generatorProphecy->generate(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolverTest.php b/tests/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolverTest.php index 875ad2838..991632634 100644 --- a/tests/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/FixtureWildcardReferenceResolverTest.php @@ -38,6 +38,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\FixtureWildcardReferenceResolver + * @internal */ class FixtureWildcardReferenceResolverTest extends TestCase { @@ -45,12 +46,12 @@ class FixtureWildcardReferenceResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(FixtureWildcardReferenceResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(FixtureWildcardReferenceResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FixtureWildcardReferenceResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FixtureWildcardReferenceResolver::class))->isCloneable()); } public function testWithersReturnNewModifiedInstance(): void @@ -58,16 +59,16 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new FixtureWildcardReferenceResolver(); $newResolver = $resolver->withValueResolver(new FakeValueResolver()); - static::assertEquals(new FixtureWildcardReferenceResolver(), $resolver); - static::assertEquals(new FixtureWildcardReferenceResolver(new FakeValueResolver()), $newResolver); + self::assertEquals(new FixtureWildcardReferenceResolver(), $resolver); + self::assertEquals(new FixtureWildcardReferenceResolver(new FakeValueResolver()), $newResolver); } public function testCanResolveFixtureMatchReferenceValues(): void { $resolver = new FixtureWildcardReferenceResolver(); - static::assertTrue($resolver->canResolve(new FixtureMatchReferenceValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new FixtureMatchReferenceValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoResolver(): void @@ -86,7 +87,7 @@ public function testReturnsARandomMatchingFixture(): void $set = ResolvedFixtureSetFactory::create( $parameters = new ParameterBag(['foo' => 'bar']), $fixtures = (new FixtureBag()) - ->with($fixture = new DummyFixture('dummy')) + ->with($fixture = new DummyFixture('dummy')), ); $scope = ['val' => 'scopie']; $context = new GenerationContext(); @@ -100,18 +101,17 @@ public function testReturnsARandomMatchingFixture(): void 'dummy', $newSet = ResolvedFixtureSetFactory::create( $parameters = new ParameterBag(['ping' => 'pong']), - $fixtures = (new FixtureBag())->with($fixture) - ) - ) - ) - ; + $fixtures = (new FixtureBag())->with($fixture), + ), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); $resolver = new FixtureWildcardReferenceResolver($valueResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $valueResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -123,7 +123,7 @@ public function testTheMatchingFixtureCanBeFromLoadedFixtures(): void $set = ResolvedFixtureSetFactory::create( null, (new FixtureBag()) - ->with(new DummyFixture('dummy')) + ->with(new DummyFixture('dummy')), ); $scope = ['foo' => 'bar']; $context = new GenerationContext(); @@ -137,18 +137,17 @@ public function testTheMatchingFixtureCanBeFromLoadedFixtures(): void 'dummy', $newSet = ResolvedFixtureSetFactory::create( new ParameterBag(['ping' => 'pong']), - (new FixtureBag())->with($fixture) - ) - ) - ) - ; + (new FixtureBag())->with($fixture), + ), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); $resolver = new FixtureWildcardReferenceResolver($valueResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testTheMatchingFixtureCanBeFromObjects(): void @@ -159,7 +158,7 @@ public function testTheMatchingFixtureCanBeFromObjects(): void null, null, (new ObjectBag()) - ->with(new SimpleObject('dummy', new stdClass())) + ->with(new SimpleObject('dummy', new stdClass())), ); $scope = []; $context = new GenerationContext(); @@ -172,18 +171,17 @@ public function testTheMatchingFixtureCanBeFromObjects(): void 'dummy', $newSet = ResolvedFixtureSetFactory::create( new ParameterBag(['ping' => 'pong']), - (new FixtureBag())->with($fixture) - ) - ) - ) - ; + (new FixtureBag())->with($fixture), + ), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); $resolver = new FixtureWildcardReferenceResolver($valueResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testThrowsAnExceptionIfNotMathcingIdFound(): void diff --git a/tests/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolverTest.php b/tests/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolverTest.php index 837add5f2..d35c39abb 100644 --- a/tests/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/FunctionCallArgumentResolverTest.php @@ -32,6 +32,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\FunctionCallArgumentResolver + * @internal */ class FunctionCallArgumentResolverTest extends TestCase { @@ -39,20 +40,20 @@ class FunctionCallArgumentResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(FunctionCallArgumentResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(FunctionCallArgumentResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(FunctionCallArgumentResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(FunctionCallArgumentResolver::class))->isCloneable()); } public function testCanResolvePropertyReferenceValues(): void { $resolver = new FunctionCallArgumentResolver(new FakeValueResolver()); - static::assertTrue($resolver->canResolve(new FunctionCallValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new FunctionCallValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testIsResolverAware(): void @@ -75,14 +76,14 @@ public function testIsResolverAware(): void $resolver = new FunctionCallArgumentResolver($decoratedResolverConstructor()); $newResolver = $resolver->withValueResolver($argumentResolverConstructor()); - static::assertNotSame($resolver, $newResolver); - static::assertEquals( + self::assertNotSame($resolver, $newResolver); + self::assertEquals( new FunctionCallArgumentResolver($decoratedResolverConstructor()), - $resolver + $resolver, ); - static::assertEquals( + self::assertEquals( new FunctionCallArgumentResolver($decoratedResolverConstructor(), $argumentResolverConstructor()), - $newResolver + $newResolver, ); } @@ -98,15 +99,15 @@ public function testThrowsAnExceptionIfDoesNotHaveAnArgumentResolver(): void try { $resolver->resolve($value, $fixture, $set, $scope, $context); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (ResolverNotFoundException $exception) { - static::assertEquals( + self::assertEquals( 'Expected method "Nelmio\Alice\Generator\Resolver\Value\Chainable\FunctionCallArgumentResolver::resolve"' .' to be called only if it has a resolver.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } @@ -118,7 +119,7 @@ public function testResolvesAllArgumentsValuesBeforePassingThemToTheDecoratedRes 'scalar', new FakeValue(), 'another scalar', - ] + ], ); $fixture = new FakeFixture(); $set = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar'])); @@ -132,10 +133,9 @@ public function testResolvesAllArgumentsValuesBeforePassingThemToTheDecoratedRes ->willReturn( new ResolvedValueWithFixtureSet( $instance = new stdClass(), - $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])) - ) - ) - ; + $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong'])), + ), + ); /** @var ValueResolverInterface $argumentResolver */ $argumentResolver = $argumentResolverProphecy->reveal(); @@ -148,26 +148,25 @@ public function testResolvesAllArgumentsValuesBeforePassingThemToTheDecoratedRes 'scalar', $instance, 'another scalar', - ] + ], ), $fixture, $newSet, $scope, - $context + $context, ) ->willReturn( $expected = new ResolvedValueWithFixtureSet( 'end', - ResolvedFixtureSetFactory::create(new ParameterBag(['gnip' => 'gnop'])) - ) - ) - ; + ResolvedFixtureSetFactory::create(new ParameterBag(['gnip' => 'gnop'])), + ), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new FunctionCallArgumentResolver($decoratedResolver, $argumentResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } } diff --git a/tests/Generator/Resolver/Value/Chainable/ListValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/ListValueResolverTest.php index d2579097d..debb97199 100644 --- a/tests/Generator/Resolver/Value/Chainable/ListValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/ListValueResolverTest.php @@ -31,6 +31,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\ListValueResolver + * @internal */ class ListValueResolverTest extends TestCase { @@ -38,12 +39,12 @@ class ListValueResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(ListValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(ListValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ListValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ListValueResolver::class))->isCloneable()); } public function testWithersReturnNewModifiedInstance(): void @@ -51,16 +52,16 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new ListValueResolver(); $newResolver = $resolver->withValueResolver(new FakeValueResolver()); - static::assertEquals(new ListValueResolver(), $resolver); - static::assertEquals(new ListValueResolver(new FakeValueResolver()), $newResolver); + self::assertEquals(new ListValueResolver(), $resolver); + self::assertEquals(new ListValueResolver(new FakeValueResolver()), $newResolver); } public function testCanResolveOptionalValues(): void { $resolver = new ListValueResolver(); - static::assertTrue($resolver->canResolve(new ListValue([]))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new ListValue([]))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoResolver(): void @@ -82,7 +83,7 @@ public function testImplodesTheGivenArrayOfValues(): void $resolver = new ListValueResolver(new FakeValueResolver()); $actual = $resolver->resolve($value, new FakeFixture(), ResolvedFixtureSetFactory::create(), [], new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testResolvesAllTheValuesInArrayBeforeImplodingIt(): void @@ -100,19 +101,17 @@ public function testResolvesAllTheValuesInArrayBeforeImplodingIt(): void ->willReturn( new ResolvedValueWithFixtureSet( 'b', - $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'baz'])) - ) - ) - ; + $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'baz'])), + ), + ); $valueResolverProphecy ->resolve(new FakeValue(), $fixture, $newSet, $scope, $context) ->willReturn( new ResolvedValueWithFixtureSet( 'd', - $newSet2 = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'zab'])) - ) - ) - ; + $newSet2 = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'zab'])), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -121,7 +120,7 @@ public function testResolvesAllTheValuesInArrayBeforeImplodingIt(): void $resolver = new ListValueResolver($valueResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $valueResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2); } diff --git a/tests/Generator/Resolver/Value/Chainable/OptionalValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/OptionalValueResolverTest.php index b1273e6d7..ae4d4869f 100644 --- a/tests/Generator/Resolver/Value/Chainable/OptionalValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/OptionalValueResolverTest.php @@ -14,7 +14,6 @@ namespace Nelmio\Alice\Generator\Resolver\Value\Chainable; use Faker\Generator; -use function in_array; use Nelmio\Alice\Definition\Fixture\FakeFixture; use Nelmio\Alice\Definition\Value\FakeValue; use Nelmio\Alice\Definition\Value\FixturePropertyValue; @@ -27,9 +26,11 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use ReflectionClass; +use function in_array; /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\OptionalValueResolver + * @internal */ class OptionalValueResolverTest extends TestCase { @@ -37,12 +38,12 @@ class OptionalValueResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(OptionalValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(OptionalValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(OptionalValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(OptionalValueResolver::class))->isCloneable()); } public function testWithersReturnNewModifiedInstance(): void @@ -50,16 +51,16 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new OptionalValueResolver(); $newResolver = $resolver->withValueResolver(new FakeValueResolver()); - static::assertEquals(new OptionalValueResolver(), $resolver); - static::assertEquals(new OptionalValueResolver(new FakeValueResolver()), $newResolver); + self::assertEquals(new OptionalValueResolver(), $resolver); + self::assertEquals(new OptionalValueResolver(new FakeValueResolver()), $newResolver); } public function testCanResolveOptionalValues(): void { $resolver = new OptionalValueResolver(); - static::assertTrue($resolver->canResolve(new OptionalValue('', ''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new OptionalValue('', ''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoResolver(): void @@ -89,7 +90,7 @@ public function testCanHandleExtremaQuantifiersCorrectly( $resolvedValue = $resolver->resolve($value, new FakeFixture(), ResolvedFixtureSetFactory::create(), [], new GenerationContext()); - static::assertSame($expectedValue, $resolvedValue->getValue()); + self::assertSame($expectedValue, $resolvedValue->getValue()); } public function testCanHandleExtremaQuantifiersCorrectlyWithoutGenerator(): void @@ -100,7 +101,7 @@ public function testCanHandleExtremaQuantifiersCorrectlyWithoutGenerator(): void $resolvedValue = $resolver->resolve($value, new FakeFixture(), ResolvedFixtureSetFactory::create(), [], new GenerationContext()); - static::assertTrue(in_array($resolvedValue->getValue(), ['first_0', 'second_0'], true)); + self::assertTrue(in_array($resolvedValue->getValue(), ['first_0', 'second_0'], true)); } public static function optionalValueProvider(): iterable diff --git a/tests/Generator/Resolver/Value/Chainable/ParameterValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/ParameterValueResolverTest.php index c2a0e4aaa..687dbc077 100644 --- a/tests/Generator/Resolver/Value/Chainable/ParameterValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/ParameterValueResolverTest.php @@ -27,32 +27,33 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\ParameterValueResolver + * @internal */ class ParameterValueResolverTest extends TestCase { public function testIsAChainableResolver(): void { - static::assertTrue(is_a(ParameterValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(ParameterValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ParameterValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ParameterValueResolver::class))->isCloneable()); } public function testCanResolveVariableValues(): void { $resolver = new ParameterValueResolver(); - static::assertTrue($resolver->canResolve(new ParameterValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new ParameterValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testReturnsParameterFromTheFixtureSet(): void { $value = new ParameterValue('foo'); $set = ResolvedFixtureSetFactory::create( - new ParameterBag(['foo' => 'bar']) + new ParameterBag(['foo' => 'bar']), ); $expected = new ResolvedValueWithFixtureSet('bar', $set); @@ -60,7 +61,7 @@ public function testReturnsParameterFromTheFixtureSet(): void $resolver = new ParameterValueResolver(); $actual = $resolver->resolve($value, new FakeFixture(), $set, [], new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfTheVariableCannotBeFoundInTheScope(): void diff --git a/tests/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolverTest.php index 8521594bf..ab7ef2091 100644 --- a/tests/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolverTest.php @@ -30,6 +30,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\PhpFunctionCallValueResolver + * @internal */ class PhpFunctionCallValueResolverTest extends TestCase { @@ -37,20 +38,20 @@ class PhpFunctionCallValueResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(PhpFunctionCallValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(PhpFunctionCallValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(PhpFunctionCallValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(PhpFunctionCallValueResolver::class))->isCloneable()); } public function testCanResolvePropertyReferenceValues(): void { $resolver = new PhpFunctionCallValueResolver([], new FakeValueResolver()); - static::assertTrue($resolver->canResolve(new ResolvedFunctionCallValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new ResolvedFunctionCallValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testReturnsSetWithEvaluatedValueIfFunctionIsAPhpNativeFunction(): void @@ -67,7 +68,7 @@ public function testReturnsSetWithEvaluatedValueIfFunctionIsAPhpNativeFunction() $resolver = new PhpFunctionCallValueResolver([], new FakeValueResolver()); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testReturnsResultOfTheDecoratedResolverIfFunctionIsNotAPhpNativeFunction(): void @@ -86,22 +87,21 @@ public function testReturnsResultOfTheDecoratedResolverIfFunctionIsNotAPhpNative $fixture, $set, $scope, - $context + $context, ) ->willReturn( $expected = new ResolvedValueWithFixtureSet( 'bar', - ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar', 'ping' => 'pong'])) - ) - ) - ; + ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar', 'ping' => 'pong'])), + ), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new PhpFunctionCallValueResolver([], $decoratedResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -122,22 +122,21 @@ public function testReturnsResultOfTheDecoratedResolverIfFunctionIsBlacklisted() $fixture, $set, $scope, - $context + $context, ) ->willReturn( $expected = new ResolvedValueWithFixtureSet( 'bar', - ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar', 'ping' => 'pong'])) - ) - ) - ; + ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar', 'ping' => 'pong'])), + ), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new PhpFunctionCallValueResolver(['strtolower'], $decoratedResolver); $actual = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolverTest.php b/tests/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolverTest.php index d8ad757f3..ce762ec4f 100644 --- a/tests/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/SelfFixtureReferenceResolverTest.php @@ -36,6 +36,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\SelfFixtureReferenceResolver + * @internal */ class SelfFixtureReferenceResolverTest extends TestCase { @@ -43,22 +44,22 @@ class SelfFixtureReferenceResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(SelfFixtureReferenceResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(SelfFixtureReferenceResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsObjectGeneratorAware(): void { - static::assertTrue(is_a(SelfFixtureReferenceResolver::class, ObjectGeneratorAwareInterface::class, true)); + self::assertTrue(is_a(SelfFixtureReferenceResolver::class, ObjectGeneratorAwareInterface::class, true)); } public function testIsValueResolverAware(): void { - static::assertTrue(is_a(SelfFixtureReferenceResolver::class, ValueResolverAwareInterface::class, true)); + self::assertTrue(is_a(SelfFixtureReferenceResolver::class, ValueResolverAwareInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SelfFixtureReferenceResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SelfFixtureReferenceResolver::class))->isCloneable()); } public function testCanResolveTheValueResolvableByItsDecoratedResolver(): void @@ -72,7 +73,7 @@ public function testCanResolveTheValueResolvableByItsDecoratedResolver(): void $resolver = new SelfFixtureReferenceResolver($decoratedResolver); - static::assertTrue($resolver->canResolve($value)); + self::assertTrue($resolver->canResolve($value)); $decoratedResolverProphecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -84,24 +85,22 @@ public function testPassesTheObjectGeneratorAwarenessPropertyToItsDecoratedResol $resolver = new SelfFixtureReferenceResolver(new FakeChainableValueResolver()); $newResolver = $resolver->withObjectGenerator($generator); - static::assertEquals($newResolver, $resolver); - static::assertNotSame($newResolver, $resolver); - + self::assertEquals($newResolver, $resolver); + self::assertNotSame($newResolver, $resolver); $decoratedResolverProphecy = $this->prophesize(ChainableValueResolverInterface::class); $decoratedResolverProphecy->willImplement(ObjectGeneratorAwareInterface::class); $decoratedResolverProphecy ->withObjectGenerator($generator) - ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()) - ; + ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()); /** @var ChainableValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new SelfFixtureReferenceResolver($decoratedResolver); $newResolver = $resolver->withObjectGenerator($generator); - static::assertEquals(new SelfFixtureReferenceResolver($decoratedResolver), $resolver); - static::assertEquals(new SelfFixtureReferenceResolver($newDecoratedResolver), $newResolver); + self::assertEquals(new SelfFixtureReferenceResolver($decoratedResolver), $resolver); + self::assertEquals(new SelfFixtureReferenceResolver($newDecoratedResolver), $newResolver); $decoratedResolverProphecy->withObjectGenerator(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -113,24 +112,22 @@ public function testPassesTheValeResolverAwarenessPropertyToItsDecoratedResolver $resolver = new SelfFixtureReferenceResolver(new FakeChainableValueResolver()); $newResolver = $resolver->withValueResolver($valueResolver); - static::assertEquals($newResolver, $resolver); - static::assertNotSame($newResolver, $resolver); - + self::assertEquals($newResolver, $resolver); + self::assertNotSame($newResolver, $resolver); $decoratedResolverProphecy = $this->prophesize(ChainableValueResolverInterface::class); $decoratedResolverProphecy->willImplement(ValueResolverAwareInterface::class); $decoratedResolverProphecy ->withValueResolver($valueResolver) - ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()) - ; + ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()); /** @var ChainableValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new SelfFixtureReferenceResolver($decoratedResolver); $newResolver = $resolver->withValueResolver($valueResolver); - static::assertEquals(new SelfFixtureReferenceResolver($decoratedResolver), $resolver); - static::assertEquals(new SelfFixtureReferenceResolver($newDecoratedResolver), $newResolver); + self::assertEquals(new SelfFixtureReferenceResolver($decoratedResolver), $resolver); + self::assertEquals(new SelfFixtureReferenceResolver($newDecoratedResolver), $newResolver); $decoratedResolverProphecy->withValueResolver(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -146,7 +143,7 @@ public function testCanResolveValuesOfItsDecoratedResolver(): void $resolver = new SelfFixtureReferenceResolver($decoratedResolver); - static::assertTrue($resolver->canResolve($value)); + self::assertTrue($resolver->canResolve($value)); $decoratedResolverProphecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -164,12 +161,12 @@ public function testReturnsTheFixtureBeingResolvedAsTheResolvedValueIfTheReferen null, (new FixtureBag()) ->with( - $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()) + $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), ) ->with( - $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()) + $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()), ), - (new ObjectBag(['dummy' => $expectedObject])) + new ObjectBag(['dummy' => $expectedObject]), ); $scope = ['injected' => true]; $context = new GenerationContext(); @@ -179,7 +176,7 @@ public function testReturnsTheFixtureBeingResolvedAsTheResolvedValueIfTheReferen $actual = $resolver->resolve($value, $dummyFixture, $set, $scope, $context); $expected = new ResolvedValueWithFixtureSet($expectedObject, $set); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $valueProphecy->getValue()->shouldHaveBeenCalledTimes(1); } @@ -198,12 +195,12 @@ public function testReturnsResultOfTheDecoratedResolverIfReferenceDoesNotMatchSe null, $fixtureBag = (new FixtureBag()) ->with( - $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()) + $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), ) ->with( - $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()) + $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()), ), - (new ObjectBag(['dummy' => $expectedObject])) + new ObjectBag(['dummy' => $expectedObject]), ); $scope = ['injected' => true]; $context = new GenerationContext(); @@ -215,17 +212,16 @@ public function testReturnsResultOfTheDecoratedResolverIfReferenceDoesNotMatchSe ->willReturn( $expected = new ResolvedValueWithFixtureSet( $resolvedFixture = new SimpleFixture('resolved_fixture', 'Dummy', SpecificationBagFactory::create()), - ResolvedFixtureSetFactory::create(null, $fixtureBag->with($resolvedFixture)) - ) - ) - ; + ResolvedFixtureSetFactory::create(null, $fixtureBag->with($resolvedFixture)), + ), + ); /** @var ChainableValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new SelfFixtureReferenceResolver($decoratedResolver); $actual = $resolver->resolve($value, $dummyFixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $valueProphecy->getValue()->shouldHaveBeenCalledTimes(1); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Generator/Resolver/Value/Chainable/UniqueValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/UniqueValueResolverTest.php index 7b67d1d46..962c9926e 100644 --- a/tests/Generator/Resolver/Value/Chainable/UniqueValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/UniqueValueResolverTest.php @@ -35,6 +35,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\UniqueValueResolver + * @internal */ class UniqueValueResolverTest extends TestCase { @@ -49,7 +50,7 @@ class UniqueValueResolverTest extends TestCase * @var ReflectionProperty */ private $poolRefl; - + protected function setUp(): void { $reflClass = new ReflectionClass(UniqueValueResolver::class); @@ -63,12 +64,12 @@ protected function setUp(): void public function testIsAChainableResolver(): void { - static::assertTrue(is_a(UniqueValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(UniqueValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(UniqueValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(UniqueValueResolver::class))->isCloneable()); } public function testThrowsExceptionIfInvalidLimitGiven(): void @@ -84,13 +85,13 @@ public function testWithersReturnNewModifiedInstance(): void $resolver = new UniqueValueResolver(new UniqueValuesPool()); $newResolver = $resolver->withValueResolver(new FakeValueResolver()); - static::assertEquals( + self::assertEquals( new UniqueValueResolver(new UniqueValuesPool()), - $resolver + $resolver, ); - static::assertEquals( + self::assertEquals( new UniqueValueResolver(new UniqueValuesPool(), new FakeValueResolver()), - $newResolver + $newResolver, ); } @@ -98,8 +99,8 @@ public function testCanResolveDynamicArrayValues(): void { $resolver = new UniqueValueResolver(new UniqueValuesPool()); - static::assertTrue($resolver->canResolve(new UniqueValue('', ''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new UniqueValue('', ''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testCannotResolveValueIfHasNoResolver(): void @@ -135,8 +136,8 @@ public function testReturnsResultIfResultDoesNotAlreadyExists(): void $resolver = new UniqueValueResolver(new UniqueValuesPool(), new FakeValueResolver()); $result = $resolver->resolve($value, $fixture, $set, [], new GenerationContext()); - static::assertEquals(10, $result->getValue()); - static::assertEquals($set, $result->getSet()); + self::assertEquals(10, $result->getValue()); + self::assertEquals($set, $result->getSet()); } public function testResolvesValueFirstIfNecessary(): void @@ -155,18 +156,17 @@ public function testResolvesValueFirstIfNecessary(): void ->willReturn( new ResolvedValueWithFixtureSet( 10, - $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar'])) - ) - ) - ; + $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar'])), + ), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new UniqueValueResolver(new UniqueValuesPool(), $decoratedResolver); $result = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals(10, $result->getValue()); - static::assertEquals($newSet, $result->getSet()); + self::assertEquals(10, $result->getValue()); + self::assertEquals($newSet, $result->getSet()); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -195,37 +195,33 @@ public function testResolvesValueAsMuchAsNecessaryIfValueIsNotUnique(): void ->willReturn( new ResolvedValueWithFixtureSet( 10, - $setAfterResolution0 - ) - ) - ; + $setAfterResolution0, + ), + ); $decoratedResolverProphecy ->resolve($realValue, $fixture, $setAfterResolution0, $scope, $context) ->willReturn( new ResolvedValueWithFixtureSet( 11, - $setAfterResolution1 - ) - ) - ; + $setAfterResolution1, + ), + ); $decoratedResolverProphecy ->resolve($realValue, $fixture, $setAfterResolution1, $scope, $context) ->willReturn( new ResolvedValueWithFixtureSet( 12, - $setAfterResolution2 - ) - ) - ; + $setAfterResolution2, + ), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); - $resolver = new UniqueValueResolver($pool, $decoratedResolver); $result = $resolver->resolve($value, $fixture, $set, $scope, $context); - static::assertEquals(12, $result->getValue()); - static::assertEquals($setAfterResolution2, $result->getSet()); + self::assertEquals(12, $result->getValue()); + self::assertEquals($setAfterResolution2, $result->getSet()); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(3); } @@ -249,18 +245,16 @@ public function testThrowsIfLimitForGenerationOfUniqueValuesIsReached(): void $decoratedResolverProphecy ->resolve($realValue, $fixture, $set, $scope, $context) ->willReturn( - new ResolvedValueWithFixtureSet(10, $set) - ) - ; + new ResolvedValueWithFixtureSet(10, $set), + ); /** @var ValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); - $resolver = new UniqueValueResolver($pool, $decoratedResolver); try { $resolver->resolve($value, $fixture, $set, $scope, $context); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (UniqueValueGenerationLimitReachedException $exception) { $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(150); } diff --git a/tests/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolverTest.php b/tests/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolverTest.php index 2b135cdd4..40cffd428 100644 --- a/tests/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/UnresolvedFixtureReferenceIdResolverTest.php @@ -42,6 +42,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\UnresolvedFixtureReferenceIdResolver + * @internal */ class UnresolvedFixtureReferenceIdResolverTest extends TestCase { @@ -49,22 +50,22 @@ class UnresolvedFixtureReferenceIdResolverTest extends TestCase public function testIsAChainableResolver(): void { - static::assertTrue(is_a(UnresolvedFixtureReferenceIdResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(UnresolvedFixtureReferenceIdResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsObjectGeneratorAware(): void { - static::assertTrue(is_a(UnresolvedFixtureReferenceIdResolver::class, ObjectGeneratorAwareInterface::class, true)); + self::assertTrue(is_a(UnresolvedFixtureReferenceIdResolver::class, ObjectGeneratorAwareInterface::class, true)); } public function testIsValueResolverAware(): void { - static::assertTrue(is_a(UnresolvedFixtureReferenceIdResolver::class, ValueResolverAwareInterface::class, true)); + self::assertTrue(is_a(UnresolvedFixtureReferenceIdResolver::class, ValueResolverAwareInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(UnresolvedFixtureReferenceIdResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(UnresolvedFixtureReferenceIdResolver::class))->isCloneable()); } public function testCanResolveTheValueResolvableByItsDecoratedResolver(): void @@ -78,7 +79,7 @@ public function testCanResolveTheValueResolvableByItsDecoratedResolver(): void $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver); - static::assertTrue($resolver->canResolve($value)); + self::assertTrue($resolver->canResolve($value)); $decoratedResolverProphecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -101,43 +102,39 @@ public function testPassesTheObjectGeneratorAwarenessPropertyToItsDecoratedResol $resolver = new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver()); $newResolver = $resolver->withObjectGenerator($generator); - static::assertEquals($newResolver, $resolver); - static::assertNotSame($newResolver, $resolver); - + self::assertEquals($newResolver, $resolver); + self::assertNotSame($newResolver, $resolver); $resolver = new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver(), new FakeValueResolver()); $newResolver = $resolver->withObjectGenerator($generator); - static::assertEquals($newResolver, $resolver); - static::assertNotSame($newResolver, $resolver); - + self::assertEquals($newResolver, $resolver); + self::assertNotSame($newResolver, $resolver); $decoratedResolverProphecy = $this->prophesize(ChainableValueResolverInterface::class); $decoratedResolverProphecy->willImplement(ObjectGeneratorAwareInterface::class); $decoratedResolverProphecy ->withObjectGenerator($generator) - ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()) - ; + ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()); /** @var ChainableValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver); $newResolver = $resolver->withObjectGenerator($generator); - static::assertEquals(new UnresolvedFixtureReferenceIdResolver($decoratedResolver), $resolver); - static::assertEquals(new UnresolvedFixtureReferenceIdResolver($newDecoratedResolver), $newResolver); - + self::assertEquals(new UnresolvedFixtureReferenceIdResolver($decoratedResolver), $resolver); + self::assertEquals(new UnresolvedFixtureReferenceIdResolver($newDecoratedResolver), $newResolver); $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver, new FakeValueResolver()); $newResolver = $resolver->withObjectGenerator($generator); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver($decoratedResolver, new FakeValueResolver()), - $resolver + $resolver, ); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver($newDecoratedResolver, new FakeValueResolver()), - $newResolver + $newResolver, ); $decoratedResolverProphecy->withObjectGenerator(Argument::any())->shouldHaveBeenCalledTimes(2); @@ -153,55 +150,51 @@ public function testPassesTheValeResolverAwarenessPropertyToItsDecoratedResolver $resolver = new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver()); $newResolver = $resolver->withValueResolver($valueResolver); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver()), - $resolver + $resolver, ); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver(), $valueResolver), - $newResolver + $newResolver, ); - $resolver = new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver(), $injectedValueResolver); $newResolver = $resolver->withValueResolver($valueResolver); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver(), $injectedValueResolver), - $resolver + $resolver, ); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver(), $valueResolver), - $newResolver + $newResolver, ); - $decoratedResolverProphecy = $this->prophesize(ChainableValueResolverInterface::class); $decoratedResolverProphecy->willImplement(ValueResolverAwareInterface::class); $decoratedResolverProphecy ->withValueResolver($valueResolver) - ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()) - ; + ->willReturn($newDecoratedResolver = new FakeChainableValueResolver()); /** @var ChainableValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver); $newResolver = $resolver->withValueResolver($valueResolver); - static::assertEquals(new UnresolvedFixtureReferenceIdResolver($decoratedResolver), $resolver); - static::assertEquals(new UnresolvedFixtureReferenceIdResolver($newDecoratedResolver, $valueResolver), $newResolver); - + self::assertEquals(new UnresolvedFixtureReferenceIdResolver($decoratedResolver), $resolver); + self::assertEquals(new UnresolvedFixtureReferenceIdResolver($newDecoratedResolver, $valueResolver), $newResolver); $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver, $injectedValueResolver); $newResolver = $resolver->withValueResolver($valueResolver); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver($decoratedResolver, $injectedValueResolver), - $resolver + $resolver, ); - static::assertEquals( + self::assertEquals( new UnresolvedFixtureReferenceIdResolver($newDecoratedResolver, $valueResolver), - $newResolver + $newResolver, ); $decoratedResolverProphecy->withValueResolver(Argument::any())->shouldHaveBeenCalledTimes(2); @@ -218,7 +211,7 @@ public function testCanResolveValuesOfItsDecoratedResolver(): void $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver); - static::assertTrue($resolver->canResolve($value)); + self::assertTrue($resolver->canResolve($value)); $decoratedResolverProphecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); } @@ -232,12 +225,12 @@ public function testReturnsResultOfTheDecoratedResolverIfReferenceIdIsAString(): null, $fixtureBag = (new FixtureBag()) ->with( - $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()) + $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), ) ->with( - $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()) + $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()), ), - (new ObjectBag(['dummy' => $expectedObject])) + new ObjectBag(['dummy' => $expectedObject]), ); $scope = ['injected' => true]; $context = new GenerationContext(); @@ -249,17 +242,16 @@ public function testReturnsResultOfTheDecoratedResolverIfReferenceIdIsAString(): ->willReturn( $expected = new ResolvedValueWithFixtureSet( $resolvedFixture = new SimpleFixture('resolved_fixture', 'Dummy', SpecificationBagFactory::create()), - ResolvedFixtureSetFactory::create(null, $fixtureBag->with($resolvedFixture)) - ) - ) - ; + ResolvedFixtureSetFactory::create(null, $fixtureBag->with($resolvedFixture)), + ), + ); /** @var ChainableValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver, new FakeValueResolver()); $actual = $resolver->resolve($value, $dummyFixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -276,12 +268,12 @@ public function testResolvesReferenceBeforeHandingOverTheResolutionToTheDecorate null, $fixtureBag = (new FixtureBag()) ->with( - $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()) + $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), ) ->with( - $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()) + $anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create()), ), - $objectBag = (new ObjectBag(['dummy' => $expectedObject])) + $objectBag = (new ObjectBag(['dummy' => $expectedObject])), ); $scope = ['injected' => true]; $context = new GenerationContext(); @@ -296,11 +288,10 @@ public function testResolvesReferenceBeforeHandingOverTheResolutionToTheDecorate $newSet = ResolvedFixtureSetFactory::create( null, $fixtureBag->with(new SimpleFixture('value_resolver_fixture', 'Dummy', SpecificationBagFactory::create())), - $newObjectBag = $objectBag->with(new SimpleObject('value_resolver_fixture', new stdClass())) - ) - ) - ) - ; + $newObjectBag = $objectBag->with(new SimpleObject('value_resolver_fixture', new stdClass())), + ), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); @@ -310,17 +301,16 @@ public function testResolvesReferenceBeforeHandingOverTheResolutionToTheDecorate ->willReturn( $expected = new ResolvedValueWithFixtureSet( $expectedObject, - ResolvedFixtureSetFactory::create(null, $fixtureBag, $newObjectBag->with(new SimpleObject('alice', $expectedObject))) - ) - ) - ; + ResolvedFixtureSetFactory::create(null, $fixtureBag, $newObjectBag->with(new SimpleObject('alice', $expectedObject))), + ), + ); /** @var ChainableValueResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver, $valueResolver); $actual = $resolver->resolve($value, $dummyFixture, $set, $scope, $context); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $valueResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -343,10 +333,9 @@ public function testThrowsAnExceptionIfResolvedIdIsInvalid(): void ->willReturn( new ResolvedValueWithFixtureSet( 200, // returns a new value instead of a string - ResolvedFixtureSetFactory::create() - ) - ) - ; + ResolvedFixtureSetFactory::create(), + ), + ); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); diff --git a/tests/Generator/Resolver/Value/Chainable/VariableValueResolverTest.php b/tests/Generator/Resolver/Value/Chainable/VariableValueResolverTest.php index 413187a6c..757f5d7fa 100644 --- a/tests/Generator/Resolver/Value/Chainable/VariableValueResolverTest.php +++ b/tests/Generator/Resolver/Value/Chainable/VariableValueResolverTest.php @@ -27,32 +27,33 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\Chainable\VariableValueResolver + * @internal */ class VariableValueResolverTest extends TestCase { public function testIsAChainableResolver(): void { - static::assertTrue(is_a(VariableValueResolver::class, ChainableValueResolverInterface::class, true)); + self::assertTrue(is_a(VariableValueResolver::class, ChainableValueResolverInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(VariableValueResolver::class))->isCloneable()); + self::assertFalse((new ReflectionClass(VariableValueResolver::class))->isCloneable()); } public function testCanResolveVariableValues(): void { $resolver = new VariableValueResolver(); - static::assertTrue($resolver->canResolve(new VariableValue(''))); - static::assertFalse($resolver->canResolve(new FakeValue())); + self::assertTrue($resolver->canResolve(new VariableValue(''))); + self::assertFalse($resolver->canResolve(new FakeValue())); } public function testGetsTheVariableFromTheScope(): void { $value = new VariableValue('ping'); $set = ResolvedFixtureSetFactory::create( - new ParameterBag(['foo' => 'bar']) + new ParameterBag(['foo' => 'bar']), ); $scope = ['ping' => 'pong']; @@ -61,7 +62,7 @@ public function testGetsTheVariableFromTheScope(): void $resolver = new VariableValueResolver(); $actual = $resolver->resolve($value, new FakeFixture(), $set, $scope, new GenerationContext()); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfTheVariableCannotBeFoundInTheScope(): void diff --git a/tests/Generator/Resolver/Value/ValueResolverRegistryTest.php b/tests/Generator/Resolver/Value/ValueResolverRegistryTest.php index 71eb01481..0d09fcd42 100644 --- a/tests/Generator/Resolver/Value/ValueResolverRegistryTest.php +++ b/tests/Generator/Resolver/Value/ValueResolverRegistryTest.php @@ -33,6 +33,7 @@ /** * @covers \Nelmio\Alice\Generator\Resolver\Value\ValueResolverRegistry + * @internal */ class ValueResolverRegistryTest extends TestCase { @@ -40,7 +41,7 @@ class ValueResolverRegistryTest extends TestCase public function testIsAValueResolver(): void { - static::assertTrue(is_a(ValueResolverRegistry::class, ValueResolverInterface::class, true)); + self::assertTrue(is_a(ValueResolverRegistry::class, ValueResolverInterface::class, true)); } public function testAcceptChainableInstantiators(): void @@ -57,7 +58,7 @@ public function testThrowExceptionIfInvalidParserIsPassed(): void public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ValueResolverRegistry::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ValueResolverRegistry::class))->isCloneable()); } public function testPicksTheFirstSuitableResolverToResolveTheGivenValue(): void @@ -70,23 +71,23 @@ public function testPicksTheFirstSuitableResolverToResolveTheGivenValue(): void $context->markIsResolvingFixture('foo'); $expected = new ResolvedValueWithFixtureSet( 10, - ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with(new SimpleObject('dummy', new stdClass()))) + ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with(new SimpleObject('dummy', new stdClass()))), ); $instantiator1Prophecy = $this->prophesize(ChainableValueResolverInterface::class); $instantiator1Prophecy->canResolve($value)->willReturn(false); - /* @var ChainableValueResolverInterface $instantiator1 */ + /** @var ChainableValueResolverInterface $instantiator1 */ $instantiator1 = $instantiator1Prophecy->reveal(); $instantiator2Prophecy = $this->prophesize(ChainableValueResolverInterface::class); $instantiator2Prophecy->canResolve($value)->willReturn(true); $instantiator2Prophecy->resolve($value, $fixture, $set, $scope, $context)->willReturn($expected); - /* @var ChainableValueResolverInterface $instantiator2 */ + /** @var ChainableValueResolverInterface $instantiator2 */ $instantiator2 = $instantiator2Prophecy->reveal(); $instantiator3Prophecy = $this->prophesize(ChainableValueResolverInterface::class); $instantiator3Prophecy->canResolve(Argument::any())->shouldNotBeCalled(); - /* @var ChainableValueResolverInterface $instantiator3 */ + /** @var ChainableValueResolverInterface $instantiator3 */ $instantiator3 = $instantiator3Prophecy->reveal(); $registry = new ValueResolverRegistry([ @@ -96,7 +97,7 @@ public function testPicksTheFirstSuitableResolverToResolveTheGivenValue(): void ]); $actual = $registry->resolve($value, $fixture, $set, $scope, $context); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $instantiator1Prophecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); $instantiator2Prophecy->canResolve(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/IsAServiceTraitTest.php b/tests/IsAServiceTraitTest.php index f2309a389..458ad5515 100644 --- a/tests/IsAServiceTraitTest.php +++ b/tests/IsAServiceTraitTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\IsAServiceTrait + * @internal */ class IsAServiceTraitTest extends TestCase { @@ -26,28 +27,28 @@ public function testThrowsAnExceptionWhenTryingToCloneInstance(): void { try { clone new NotClonableDummy(); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (Throwable $exception) { - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); if (PHP_VERSION_ID < 80000) { - static::assertEquals( + self::assertEquals( 'Call to private Nelmio\Alice\NotClonableDummy::__clone() from context ' - . '\'Nelmio\Alice\IsAServiceTraitTest\'', - $exception->getMessage() + .'\'Nelmio\Alice\IsAServiceTraitTest\'', + $exception->getMessage(), ); } else { - static::assertEquals( + self::assertEquals( 'Call to private Nelmio\Alice\NotClonableDummy::__clone() from scope ' - . 'Nelmio\Alice\IsAServiceTraitTest', - $exception->getMessage() + .'Nelmio\Alice\IsAServiceTraitTest', + $exception->getMessage(), ); } } $dummyRefl = new ReflectionClass(NotClonableDummy::class); - static::assertFalse($dummyRefl->isCloneable()); + self::assertFalse($dummyRefl->isCloneable()); } } diff --git a/tests/Loader/LoaderIntegrationTest.php b/tests/Loader/LoaderIntegrationTest.php index 1def8c23a..d5619426c 100644 --- a/tests/Loader/LoaderIntegrationTest.php +++ b/tests/Loader/LoaderIntegrationTest.php @@ -45,11 +45,12 @@ * @group integration * * @coversNothing + * @internal */ class LoaderIntegrationTest extends TestCase { - const PARSER_FILES_DIR = __DIR__.'/../../fixtures/Parser/files'; - const FIXTURES_FILES_DIR = __DIR__.'/../../fixtures/Integration'; + public const PARSER_FILES_DIR = __DIR__.'/../../fixtures/Parser/files'; + public const FIXTURES_FILES_DIR = __DIR__.'/../../fixtures/Integration'; /** * @var FilesLoaderInterface|FileLoaderInterface|DataLoaderInterface @@ -71,11 +72,11 @@ public function testLoadFile(): void { $objects = $this->loader->loadFile(self::FIXTURES_FILES_DIR.'/dummy.yml')->getObjects(); - static::assertEquals( + self::assertEquals( [ 'dummy' => new stdClass(), ], - $objects + $objects, ); } @@ -86,12 +87,12 @@ public function testLoadFiles(): void self::FIXTURES_FILES_DIR.'/another_dummy.yml', ])->getObjects(); - static::assertEquals( + self::assertEquals( [ 'dummy' => new stdClass(), 'another_dummy' => new stdClass(), ], - $objects + $objects, ); } @@ -101,12 +102,12 @@ public function testLoadJsonFile(): void self::FIXTURES_FILES_DIR.'/dummy.json', ])->getObjects(); - static::assertEquals( + self::assertEquals( [ 'dummy1' => new stdClass(), 'dummy2' => new stdClass(), ], - $objects + $objects, ); } @@ -116,38 +117,38 @@ public function testLoadRecursiveFiles(): void self::FIXTURES_FILES_DIR.'/recursive_0/dummy.yml', ])->getObjects(); - static::assertEquals( + self::assertEquals( [ 'dummy' => new stdClass(), 'another_dummy' => new stdClass(), ], - $objects + $objects, ); $objects = $this->loader->loadFiles([ self::FIXTURES_FILES_DIR.'/recursive_1/dummy.yml', ])->getObjects(); - static::assertEquals( + self::assertEquals( [ 'dummy' => new stdClass(), 'another_dummy' => new stdClass(), 'yet_another_dummy' => new stdClass(), ], - $objects + $objects, ); $objects = $this->loader->loadFiles([ self::FIXTURES_FILES_DIR.'/recursive_1/another_dummy.yml', ])->getObjects(); - static::assertEquals( + self::assertEquals( [ 'dummy' => new stdClass(), 'another_dummy' => new stdClass(), 'yet_another_dummy' => new stdClass(), ], - $objects + $objects, ); } @@ -179,9 +180,9 @@ public function testLoadEmptyData(): void { $set = $this->loader->loadData([]); - static::assertEquals( + self::assertEquals( new ObjectSet(new ParameterBag(), new ObjectBag()), - $set + $set, ); } @@ -190,21 +191,21 @@ public function testLoadEmptyData(): void * * @param object|string $expected */ - public function testObjectInstantiation(array $data, $expected, string $instanceof = null): void + public function testObjectInstantiation(array $data, $expected, ?string $instanceof = null): void { try { $objects = $this->loader->loadData($data)->getObjects(); if (is_string($expected)) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } } catch (Throwable $throwable) { if (is_string($expected)) { - static::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); + self::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); - static::assertInstanceOf($instanceof, $throwable); + self::assertInstanceOf($instanceof, $throwable); - static::assertSame($expected, $throwable->getMessage()); + self::assertSame($expected, $throwable->getMessage()); return; } @@ -212,8 +213,8 @@ public function testObjectInstantiation(array $data, $expected, string $instance throw $throwable; } - static::assertCount(1, $objects); - static::assertEquals($expected, $objects['dummy']); + self::assertCount(1, $objects); + self::assertEquals($expected, $objects['dummy']); } /** @@ -225,21 +226,21 @@ public function testObjectInstantiation(array $data, $expected, string $instance * * @param object|string $expected */ - public function testObjectInstantiationWithLegacyConstruct(array $data, $expected, string $instanceof = null): void + public function testObjectInstantiationWithLegacyConstruct(array $data, $expected, ?string $instanceof = null): void { try { $objects = $this->loader->loadData($data)->getObjects(); if (is_string($expected)) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } } catch (Throwable $throwable) { if (is_string($expected)) { - static::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); + self::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); - static::assertInstanceOf($instanceof, $throwable); + self::assertInstanceOf($instanceof, $throwable); - static::assertSame($expected, $throwable->getMessage()); + self::assertSame($expected, $throwable->getMessage()); return; } @@ -247,8 +248,8 @@ public function testObjectInstantiationWithLegacyConstruct(array $data, $expecte throw $throwable; } - static::assertCount(1, $objects); - static::assertEquals($expected, $objects['dummy']); + self::assertCount(1, $objects); + self::assertEquals($expected, $objects['dummy']); } /** @@ -256,21 +257,21 @@ public function testObjectInstantiationWithLegacyConstruct(array $data, $expecte * * @param array|string $expected */ - public function testObjectInstantiationWithFactory(array $data, $expected, string $instanceof = null): void + public function testObjectInstantiationWithFactory(array $data, $expected, ?string $instanceof = null): void { try { $objects = $this->loader->loadData($data)->getObjects(); if (is_string($expected)) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } } catch (Throwable $throwable) { if (is_string($expected)) { - static::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); + self::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); - static::assertInstanceOf($instanceof, $throwable); + self::assertInstanceOf($instanceof, $throwable); - static::assertSame($expected, $throwable->getMessage()); + self::assertSame($expected, $throwable->getMessage()); return; } @@ -278,8 +279,8 @@ public function testObjectInstantiationWithFactory(array $data, $expected, strin throw $throwable; } - static::assertCount(1, $objects); - static::assertEquals($expected, $objects['dummy']); + self::assertCount(1, $objects); + self::assertEquals($expected, $objects['dummy']); } public function testCannotUseBothConstructAndFactoryAtTheSameTime(): void @@ -303,13 +304,14 @@ public function testCannotUseBothConstructAndFactoryAtTheSameTime(): void * @group legacy * * @expectedDeprecation Using factories with the fixture keyword "__construct" has been deprecated since 3.0.0 and will no longer be supported in Alice 4.0.0. Use "__factory" instead. + * @param mixed $expected */ public function testUsingConstructorAsAFactoryIsDeprecated(array $data, $expected): void { $objects = $this->loader->loadData($data)->getObjects(); - static::assertCount(1, $objects); - static::assertEquals($expected, $objects['dummy']); + self::assertCount(1, $objects); + self::assertEquals($expected, $objects['dummy']); } /** @@ -317,21 +319,21 @@ public function testUsingConstructorAsAFactoryIsDeprecated(array $data, $expecte * * @param array|string $expected */ - public function testObjectHydration(array $data, $expected, string $instanceof = null): void + public function testObjectHydration(array $data, $expected, ?string $instanceof = null): void { try { $objects = $this->loader->loadData($data)->getObjects(); if (!is_array($expected)) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } } catch (Throwable $throwable) { if (is_string($expected)) { - static::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); + self::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); - static::assertInstanceOf($instanceof, $throwable); + self::assertInstanceOf($instanceof, $throwable); - static::assertSame($expected, $throwable->getMessage()); + self::assertSame($expected, $throwable->getMessage()); return; } @@ -339,8 +341,8 @@ public function testObjectHydration(array $data, $expected, string $instanceof = throw $throwable; } - static::assertCount(count($expected), $objects); - static::assertEquals($expected, $objects); + self::assertCount(count($expected), $objects); + self::assertEquals($expected, $objects); } /** @@ -348,21 +350,21 @@ public function testObjectHydration(array $data, $expected, string $instanceof = * * @param string|array $expected */ - public function testFixtureGeneration(array $data, $expected, string $instanceof = null): void + public function testFixtureGeneration(array $data, $expected, ?string $instanceof = null): void { try { $set = $this->loader->loadData($data); if (!is_array($expected)) { - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } } catch (Throwable $exception) { if (is_string($expected)) { - static::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); + self::assertNotNull($instanceof, 'Expected to know the type of the throwable expected.'); - static::assertInstanceOf($instanceof, $exception); + self::assertInstanceOf($instanceof, $exception); - static::assertSame($expected, $exception->getMessage()); + self::assertSame($expected, $exception->getMessage()); return; } @@ -372,13 +374,13 @@ public function testFixtureGeneration(array $data, $expected, string $instanceof $expectedParameters = $expected['parameters']; $actualParameters = $set->getParameters(); - static::assertCount(count($expectedParameters), $actualParameters); - static::assertEquals($expectedParameters, $actualParameters); + self::assertCount(count($expectedParameters), $actualParameters); + self::assertEquals($expectedParameters, $actualParameters); $expectedObjects = $expected['objects']; $actualObjects = $set->getObjects(); - static::assertCount(count($expectedObjects), $actualObjects); - static::assertEquals($expectedObjects, $actualObjects); + self::assertCount(count($expectedObjects), $actualObjects); + self::assertEquals($expectedObjects, $actualObjects); } public function testWithReflection(): void @@ -398,8 +400,8 @@ public function testWithReflection(): void $set = $loader->loadData($data); $actual = $set->getObjects(); - static::assertCount(count($expected), $actual); - static::assertEquals($expected, $actual); + self::assertCount(count($expected), $actual); + self::assertEquals($expected, $actual); } public function testLoadASetOfDataWithInjectedObjects(): void @@ -414,20 +416,20 @@ public function testLoadASetOfDataWithInjectedObjects(): void ], [], [ - 'injected_dummy' => StdClassFactory::create(['injected' => true]) - ] + 'injected_dummy' => StdClassFactory::create(['injected' => true]), + ], ); $objects = $set->getObjects(); - static::assertCount(0, $set->getParameters()); - static::assertCount(2, $objects); + self::assertCount(0, $set->getParameters()); + self::assertCount(2, $objects); - static::assertEquals( + self::assertEquals( [ 'injected_dummy' => $injectedDummy = StdClassFactory::create(['injected' => true]), 'dummy' => StdClassFactory::create(['relatedDummy' => $injectedDummy]), ], - $objects + $objects, ); } @@ -458,21 +460,21 @@ public function testIfAFixtureAndAnInjectedObjectHaveTheSameIdThenTheInjectedObj [], [ 'another_dummy' => StdClassFactory::create(['injected' => true]), - ] + ], ); $objects = $set->getObjects(); - static::assertCount(0, $set->getParameters()); - static::assertCount(2, $objects); + self::assertCount(0, $set->getParameters()); + self::assertCount(2, $objects); - static::assertEquals( + self::assertEquals( [ 'dummy' => new FixtureEntity\ImmutableStd([ 'relatedDummy' => StdClassFactory::create(['injected' => false]), ]), 'another_dummy' => StdClassFactory::create(['injected' => false]), ], - $objects + $objects, ); } @@ -497,15 +499,15 @@ public function testLoadOptionalValues(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(4, $objects); + self::assertCount(4, $objects); - static::assertContains($objects['user0']->username, ['something', null]); - static::assertContains($objects['user1']->username, ['something', 'nothing']); - static::assertEquals('nothing', $objects['user2']->username); - static::assertEquals('something', $objects['user3']->username); + self::assertContains($objects['user0']->username, ['something', null]); + self::assertContains($objects['user1']->username, ['something', 'nothing']); + self::assertEquals('nothing', $objects['user2']->username); + self::assertEquals('something', $objects['user3']->username); } public function testLoadTwoSuccessiveFakerFunctions(): void @@ -520,14 +522,14 @@ public function testLoadTwoSuccessiveFakerFunctions(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(1, $objects); + self::assertCount(1, $objects); $user = $objects['user']; - static::assertInstanceOf(stdClass::class, $user); - static::assertMatchesRegularExpression('/^[\w\']+ [\w\']+$/i', $user->username); + self::assertInstanceOf(stdClass::class, $user); + self::assertMatchesRegularExpression('/^[\w\']+ [\w\']+$/i', $user->username); } public function testLoadFakerFunctionWithData(): void @@ -542,14 +544,14 @@ public function testLoadFakerFunctionWithData(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(1, $objects); + self::assertCount(1, $objects); $user = $objects['user']; - static::assertInstanceOf(stdClass::class, $user); - static::assertSame(10, $user->age); + self::assertInstanceOf(stdClass::class, $user); + self::assertSame(10, $user->age); } public function testLoadLocalizedFakerFunctionWithData(): void @@ -564,14 +566,14 @@ public function testLoadLocalizedFakerFunctionWithData(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(1, $objects); + self::assertCount(1, $objects); $user = $objects['user']; - static::assertInstanceOf(stdClass::class, $user); - static::assertMatchesRegularExpression('/^\d{3} \d{3} \d{3}$/', $user->siren); + self::assertInstanceOf(stdClass::class, $user); + self::assertMatchesRegularExpression('/^\d{3} \d{3} \d{3}$/', $user->siren); } public function testLoadFakerFunctionWithPhpArguments(): void @@ -586,19 +588,19 @@ public function testLoadFakerFunctionWithPhpArguments(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(1, $objects); + self::assertCount(1, $objects); $user = $objects['user']; - static::assertInstanceOf(stdClass::class, $user); + self::assertInstanceOf(stdClass::class, $user); $updatedAt = $user->updatedAt; - static::assertInstanceOf(DateTimeInterface::class, $updatedAt); + self::assertInstanceOf(DateTimeInterface::class, $updatedAt); /** @var DateTimeInterface $updatedAt */ - static::assertGreaterThanOrEqual(strtotime('yesterday'), $updatedAt->getTimestamp()); - static::assertLessThanOrEqual(strtotime('tomorrow'), $updatedAt->getTimestamp()); + self::assertGreaterThanOrEqual(strtotime('yesterday'), $updatedAt->getTimestamp()); + self::assertLessThanOrEqual(strtotime('tomorrow'), $updatedAt->getTimestamp()); } public function testLoadSelfReferencedFixture(): void @@ -613,15 +615,15 @@ public function testLoadSelfReferencedFixture(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(1, $objects); + self::assertCount(1, $objects); $expectedDummy = new stdClass(); $expectedDummy->relatedDummy = $expectedDummy; - static::assertEquals($expectedDummy, $objects['dummy']); + self::assertEquals($expectedDummy, $objects['dummy']); } public function testLoadAutomaticallyEscapedReference(): void @@ -636,16 +638,16 @@ public function testLoadAutomaticallyEscapedReference(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(1, $objects); + self::assertCount(1, $objects); $expectedDummy = StdClassFactory::create([ 'email' => 'email@example.com', ]); - static::assertEquals($expectedDummy, $objects['dummy']); + self::assertEquals($expectedDummy, $objects['dummy']); } public function testLoadSelfReferencedFixtures(): void @@ -660,10 +662,10 @@ public function testLoadSelfReferencedFixtures(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(2, $objects); + self::assertCount(2, $objects); } public function testLoadRangeWithStepFixtures(): void @@ -678,15 +680,15 @@ public function testLoadRangeWithStepFixtures(): void $set = $this->loader->loadData($data); - static::assertCount(0, $set->getParameters()); + self::assertCount(0, $set->getParameters()); $objects = $set->getObjects(); - static::assertCount(2, $objects); + self::assertCount(2, $objects); - static::assertArrayHasKey('dummy1', $objects); - static::assertArrayNotHasKey('dummy2', $objects); - static::assertArrayHasKey('dummy3', $objects); - static::assertArrayNotHasKey('dummy4', $objects); + self::assertArrayHasKey('dummy1', $objects); + self::assertArrayNotHasKey('dummy2', $objects); + self::assertArrayHasKey('dummy3', $objects); + self::assertArrayNotHasKey('dummy4', $objects); } public function testLoadReferenceRange(): void @@ -706,11 +708,11 @@ public function testLoadReferenceRange(): void UserDetail::class => [ 'userdetail_{@user*}' => [ 'email' => '', - 'user' => '', + 'user' => '', ], 'userdetail_single_{@user1}' => [ 'email' => '', - 'user' => '<($current)>', + 'user' => '<($current)>', ], ], ]; @@ -718,19 +720,19 @@ public function testLoadReferenceRange(): void $set = $this->loader->loadData($data); $objects = $set->getObjects(); - static::assertCount(5, $objects); + self::assertCount(5, $objects); - static::assertArrayHasKey('userdetail_user0', $objects); - static::assertArrayHasKey('userdetail_user1', $objects); - static::assertArrayHasKey('userdetail_single_user1', $objects); + self::assertArrayHasKey('userdetail_user0', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_single_user1', $objects); - static::assertInstanceOf(User::class, $objects['userdetail_user0']->getUser()); - static::assertInstanceOf(User::class, $objects['userdetail_user1']->getUser()); - static::assertInstanceOf(User::class, $objects['userdetail_single_user1']->getUser()); + self::assertInstanceOf(User::class, $objects['userdetail_user0']->getUser()); + self::assertInstanceOf(User::class, $objects['userdetail_user1']->getUser()); + self::assertInstanceOf(User::class, $objects['userdetail_single_user1']->getUser()); - static::assertSame($objects['user0'], $objects['userdetail_user0']->getUser()); - static::assertSame($objects['user1'], $objects['userdetail_user1']->getUser()); - static::assertSame($objects['user1'], $objects['userdetail_single_user1']->getUser()); + self::assertSame($objects['user0'], $objects['userdetail_user0']->getUser()); + self::assertSame($objects['user1'], $objects['userdetail_user1']->getUser()); + self::assertSame($objects['user1'], $objects['userdetail_single_user1']->getUser()); } public function testLoadReferenceRangeWithDotInName(): void @@ -745,7 +747,7 @@ public function testLoadReferenceRangeWithDotInName(): void UserDetail::class => [ 'foo.user_detail.{@foo.user.*}' => [ 'email' => '', - 'user' => '', + 'user' => '', ], ], ]; @@ -753,19 +755,19 @@ public function testLoadReferenceRangeWithDotInName(): void $set = $this->loader->loadData($data); $objects = $set->getObjects(); - static::assertCount(6, $objects); + self::assertCount(6, $objects); - static::assertArrayHasKey('foo.user.1', $objects); - static::assertArrayHasKey('foo.user.2', $objects); - static::assertArrayHasKey('foo.user.3', $objects); + self::assertArrayHasKey('foo.user.1', $objects); + self::assertArrayHasKey('foo.user.2', $objects); + self::assertArrayHasKey('foo.user.3', $objects); - static::assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.1']->getUser()); - static::assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.2']->getUser()); - static::assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.3']->getUser()); + self::assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.1']->getUser()); + self::assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.2']->getUser()); + self::assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.3']->getUser()); - static::assertSame($objects['foo.user.1'], $objects['foo.user_detail.foo.user.1']->getUser()); - static::assertSame($objects['foo.user.2'], $objects['foo.user_detail.foo.user.2']->getUser()); - static::assertSame($objects['foo.user.3'], $objects['foo.user_detail.foo.user.3']->getUser()); + self::assertSame($objects['foo.user.1'], $objects['foo.user_detail.foo.user.1']->getUser()); + self::assertSame($objects['foo.user.2'], $objects['foo.user_detail.foo.user.2']->getUser()); + self::assertSame($objects['foo.user.3'], $objects['foo.user_detail.foo.user.3']->getUser()); } public function testLoadReferenceRangeOutOfOrder(): void @@ -774,7 +776,7 @@ public function testLoadReferenceRangeOutOfOrder(): void UserDetail::class => [ 'userdetail_{@user*}' => [ 'email' => '', - 'user' => '', + 'user' => '', ], ], User::class => [ @@ -793,16 +795,16 @@ public function testLoadReferenceRangeOutOfOrder(): void $set = $this->loader->loadData($data); $objects = $set->getObjects(); - static::assertCount(4, $objects); + self::assertCount(4, $objects); - static::assertArrayHasKey('userdetail_user0', $objects); - static::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_user0', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); - static::assertInstanceOf(User::class, $objects['userdetail_user0']->getUser()); - static::assertInstanceOf(User::class, $objects['userdetail_user1']->getUser()); + self::assertInstanceOf(User::class, $objects['userdetail_user0']->getUser()); + self::assertInstanceOf(User::class, $objects['userdetail_user1']->getUser()); - static::assertSame($objects['user0'], $objects['userdetail_user0']->getUser()); - static::assertSame($objects['user1'], $objects['userdetail_user1']->getUser()); + self::assertSame($objects['user0'], $objects['userdetail_user0']->getUser()); + self::assertSame($objects['user1'], $objects['userdetail_user1']->getUser()); } public function testTemplatesAreKeptBetweenFiles(): void @@ -813,11 +815,11 @@ public function testTemplatesAreKeptBetweenFiles(): void 'dummy' => StdClassFactory::create([ 'foo' => 'bar', ]), - ]) + ]), ); $actual = $this->loader->loadFile(self::FIXTURES_FILES_DIR.'/template_in_another_file/dummy.yml'); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testLoadDuplicatedDummyKeysWithIncludeFiles(): void @@ -826,14 +828,14 @@ public function testLoadDuplicatedDummyKeysWithIncludeFiles(): void new ParameterBag(), new ObjectBag([ 'dummy' => StdClassFactory::create([ - 'var' => 'bar' + 'var' => 'bar', ]), - ]) + ]), ); $actual = $this->loader->loadFile(self::FIXTURES_FILES_DIR.'/duplicates/dummies.yml'); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testLoadDuplicatedDummyKeysWithLists(): void @@ -856,12 +858,12 @@ public function testLoadDuplicatedDummyKeysWithLists(): void 'var' => 'foo', 'val' => 'val', ]), - ]) + ]), ); $actual = $this->loader->loadFile(self::FIXTURES_FILES_DIR.'/duplicates/dummy_list.yml'); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testTemplatesAreBuildBeforeUsage(): void @@ -870,8 +872,8 @@ public function testTemplatesAreBuildBeforeUsage(): void new ParameterBag(), new ObjectBag([ 'dummy' => new DummyWithConstructorAndCallable(null), - 'foo-0' => new FixtureEntity\DummyWithConstructorParam(null) - ]) + 'foo-0' => new FixtureEntity\DummyWithConstructorParam(null), + ]), ); $actual = $this->loader->loadData([ @@ -879,22 +881,22 @@ public function testTemplatesAreBuildBeforeUsage(): void 'dummy_template (template)' => [ '__calls' => [ [ - 'reset' => [] - ] - ] + 'reset' => [], + ], + ], ], 'dummy (extends dummy_template)' => [ - '__construct' => ['foo'] - ] + '__construct' => ['foo'], + ], ], FixtureEntity\DummyWithConstructorParam::class => [ 'foo-0' => [ - '__construct' => ['@dummy->foo'] + '__construct' => ['@dummy->foo'], ], ], ]); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testTemplateCanExtendOtherTemplateObjectsCombinedWithRange(): void @@ -923,11 +925,11 @@ public function testTemplateCanExtendOtherTemplateObjectsCombinedWithRange(): vo 'base' => 'true', 'foo' => 'baz', ]), - ]) + ]), ); $actual = $this->loader->loadData($data); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testEmptyInheritance(): void @@ -946,11 +948,11 @@ public function testEmptyInheritance(): void 'dummy' => StdClassFactory::create([ 'foo' => 'bar', ]), - ]) + ]), ); $actual = $this->loader->loadData($data); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testMultipleInheritanceInTemplates(): void @@ -983,11 +985,11 @@ public function testMultipleInheritanceInTemplates(): void 'favoriteNumber' => 2, 'friends' => 'plenty', ]), - ]) + ]), ); $actual = $this->loader->loadData($data); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testMultipleInheritanceInInstance(): void @@ -1014,11 +1016,11 @@ public function testMultipleInheritanceInInstance(): void 'dummy' => StdClassFactory::create([ 'number' => 3, ]), - ]) + ]), ); $actual = $this->loader->loadData($data); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testUniqueValueGeneration(): void @@ -1033,18 +1035,18 @@ public function testUniqueValueGeneration(): void $result = $this->loader->loadData($data); - static::assertCount(0, $result->getParameters()); - static::assertCount(10, $result->getObjects()); + self::assertCount(0, $result->getParameters()); + self::assertCount(10, $result->getObjects()); $objects = $result->getObjects(); $value = []; foreach ($objects as $object) { - static::assertGreaterThanOrEqual(1, $object->number); - static::assertLessThanOrEqual(10, $object->number); + self::assertGreaterThanOrEqual(1, $object->number); + self::assertLessThanOrEqual(10, $object->number); $value[$object->number] = true; } - static::assertCount(10, $value); + self::assertCount(10, $value); } public function testUniqueValueGenerationFailure(): void @@ -1060,18 +1062,18 @@ public function testUniqueValueGenerationFailure(): void try { $this->loader->loadData($data); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (GenerationThrowable $exception) { $previous = $exception->getPrevious(); - static::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); + self::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); $previous = $previous->getPrevious(); - static::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous); - static::assertMatchesRegularExpression( + self::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous); + self::assertMatchesRegularExpression( '/^Could not generate a unique value after 150 attempts for ".*"\.$/', - $previous->getMessage() + $previous->getMessage(), ); } } @@ -1090,18 +1092,18 @@ public function testUniqueValueGenerationInAFunctionCall(): void $result = $this->loader->loadData($data); - static::assertCount(0, $result->getParameters()); - static::assertCount(10, $result->getObjects()); + self::assertCount(0, $result->getParameters()); + self::assertCount(10, $result->getObjects()); $objects = $result->getObjects(); $value = []; foreach ($objects as $object) { - static::assertGreaterThanOrEqual(1, $object->requiredParam); - static::assertLessThanOrEqual(10, $object->requiredParam); + self::assertGreaterThanOrEqual(1, $object->requiredParam); + self::assertLessThanOrEqual(10, $object->requiredParam); $value[$object->requiredParam] = true; } - static::assertCount(10, $value); + self::assertCount(10, $value); try { $this->loader->loadData([ @@ -1113,15 +1115,15 @@ public function testUniqueValueGenerationInAFunctionCall(): void ], ], ]); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (GenerationThrowable $throwable) { - static::assertInstanceOf(DebugUnexpectedValueException::class, $throwable); + self::assertInstanceOf(DebugUnexpectedValueException::class, $throwable); $previous = $throwable->getPrevious(); - static::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); + self::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); - static::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous->getPrevious()); + self::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous->getPrevious()); } } @@ -1165,7 +1167,6 @@ public function testUniqueValueGenerationWithDynamicArray(): void }; $assertEachValuesInRelatedDummiesAreUnique($result); - // Do another check with range/list where a temporary fixture is being used for the unique key $data = [ stdClass::class => [ @@ -1181,7 +1182,6 @@ public function testUniqueValueGenerationWithDynamicArray(): void $assertEachValuesInRelatedDummiesAreUnique($result); - try { $this->loader->loadData([ stdClass::class => [ @@ -1193,15 +1193,15 @@ public function testUniqueValueGenerationWithDynamicArray(): void ], ], ]); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (GenerationThrowable $throwable) { - static::assertInstanceOf(DebugUnexpectedValueException::class, $throwable); + self::assertInstanceOf(DebugUnexpectedValueException::class, $throwable); $previous = $throwable->getPrevious(); - static::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); + self::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); - static::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous->getPrevious()); + self::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous->getPrevious()); } } @@ -1248,15 +1248,15 @@ public function testUniqueOnArray(): void ], ], ]); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (GenerationThrowable $throwable) { - static::assertInstanceOf(DebugUnexpectedValueException::class, $throwable); + self::assertInstanceOf(DebugUnexpectedValueException::class, $throwable); $previous = $throwable->getPrevious(); - static::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); + self::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); - static::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous->getPrevious()); + self::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous->getPrevious()); } } @@ -1280,8 +1280,8 @@ public function testUniqueValuesAreUniqueAcrossAClass(): void $result = $this->loader->loadData($data); - static::assertCount(0, $result->getParameters()); - static::assertCount(20, $result->getObjects()); + self::assertCount(0, $result->getParameters()); + self::assertCount(20, $result->getObjects()); $objects = $result->getObjects(); $value = [ @@ -1289,13 +1289,13 @@ public function testUniqueValuesAreUniqueAcrossAClass(): void FixtureEntity\DummyWithPublicProperty::class => [], ]; foreach ($objects as $object) { - static::assertGreaterThanOrEqual(1, $object->val); - static::assertLessThanOrEqual(10, $object->val); - $value[get_class($object)][$object->val] = true; + self::assertGreaterThanOrEqual(1, $object->val); + self::assertLessThanOrEqual(10, $object->val); + $value[$object::class][$object->val] = true; } - static::assertCount(10, $value[stdClass::class]); - static::assertCount(10, $value[FixtureEntity\DummyWithPublicProperty::class]); + self::assertCount(10, $value[stdClass::class]); + self::assertCount(10, $value[FixtureEntity\DummyWithPublicProperty::class]); } /** @@ -1319,13 +1319,13 @@ public function testUniqueCircularReferencesThrowNoFatal(): void try { $this->loader->loadData($data); } catch (DebugUnexpectedValueException $exception) { - static::assertNotNull($previous = $exception->getPrevious()); + self::assertNotNull($previous = $exception->getPrevious()); - static::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); + self::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); - static::assertNotNull($previous = $previous->getPrevious()); + self::assertNotNull($previous = $previous->getPrevious()); - static::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous); + self::assertInstanceOf(UniqueValueGenerationLimitReachedException::class, $previous); } } @@ -1371,17 +1371,17 @@ public function testThrowsAnExceptionIfUsingCurrentOutOfACollection(): void try { $this->loader->loadData($data); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (DebugUnexpectedValueException $exception) { - static::assertSame( + self::assertSame( 'An error occurred while generating the fixture "dummy" (stdClass): No value for ' .'\'\' found for the fixture "dummy".', - $exception->getMessage() + $exception->getMessage(), ); $previous = $exception->getPrevious(); - static::assertInstanceOf(NoValueForCurrentException::class, $previous); + self::assertInstanceOf(NoValueForCurrentException::class, $previous); } } @@ -1410,8 +1410,8 @@ public function testInjectedParametersAndObjectsAreOverriddenByLocalParameters() [ 'dummy' => StdClassFactory::create([ 'injected' => true, - ]) - ] + ]), + ], ); $expected = new ObjectSet( @@ -1424,10 +1424,10 @@ public function testInjectedParametersAndObjectsAreOverriddenByLocalParameters() 'injected' => false, ]), 'another_dummy' => new FixtureEntity\DummyWithConstructorParam($dummy), - ]) + ]), ); - static::assertEquals($expected, $set); + self::assertEquals($expected, $set); } public function testParametersShouldBeResolvedOnlyOnce(): void @@ -1443,15 +1443,15 @@ public function testParametersShouldBeResolvedOnlyOnce(): void 'bar' => '<{unique_id}>', ], ], - ] + ], ); $uniqueId = $set->getParameters()['unique_id']; $dummy = $set->getObjects()['dummy']; - static::assertEquals($uniqueId, $dummy->foo); - static::assertEquals($uniqueId, $dummy->bar); + self::assertEquals($uniqueId, $dummy->foo); + self::assertEquals($uniqueId, $dummy->bar); } public function testLoadParsesReferencesInQuotes(): void @@ -1463,14 +1463,14 @@ public function testLoadParsesReferencesInQuotes(): void 'name' => 'foo', ], 'dummy2' => [ - 'dummy' => '\'@dummy1\'' + 'dummy' => '\'@dummy1\'', ], ], ]); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (DebugUnexpectedValueException $exception) { - static::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $exception->getPrevious()); + self::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $exception->getPrevious()); } } @@ -1490,7 +1490,7 @@ public function testGenerationCache(): void 'related' => '@another*', ], ], - ] + ], ); // This loading will also the caching part of the FixtureWildcardReferenceResolver. The @@ -1505,7 +1505,7 @@ public function testGenerationCache(): void 'related' => '@another*', ], ], - ] + ], ); } @@ -1523,14 +1523,14 @@ public function testInstancesAreNotInjectedInTheScopeDuringInstantiation(): void ], ]); } catch (DebugUnexpectedValueException $exception) { - static::assertSame( + self::assertSame( 'An error occurred while generating the fixture "another_dummy" (stdClass): Could not resolve value during the generation process.', - $exception->getMessage() + $exception->getMessage(), ); $previous = $exception->getPrevious(); - static::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); + self::assertInstanceOf(UnresolvableValueDuringGenerationException::class, $previous); } } @@ -1544,15 +1544,15 @@ public function testFunctionCallArgumentResolverWithObjectsKeepsSameInstances(): ], 'dummy2' => [ 'foo' => 'baz', - ] - ] + ], + ], ]); - static::assertCount(2, $set->getObjects()); + self::assertCount(2, $set->getObjects()); ['dummy1' => $dummy1, 'dummy2' => $dummy2] = $set->getObjects(); - static::assertNotSame($dummy1, $dummy2); - static::assertSame($dummy2, $dummy1->sibling); + self::assertNotSame($dummy1, $dummy2); + self::assertSame($dummy2, $dummy1->sibling); } public function testNewlinesInIdentity(): void @@ -1567,15 +1567,15 @@ public function testNewlinesInIdentity(): void $expected->newlinesKeptNoNewlineAtEnd = new DateTime('2022-01-05'); $expected->newlinesKeptAllNewlinesFromEnd = new DateTime('2022-01-06'); - static::assertEquals( + self::assertEquals( [ 'dummy' => $expected, ], - $objects + $objects, ); } - public function provideFixturesToInstantiate() + public function provideFixturesToInstantiate(): iterable { yield 'with default constructor – use default constructor' => [ [ @@ -1609,7 +1609,7 @@ public function provideFixturesToInstantiate() FixtureEntity\Instantiator\DummyWithOptionalParameterInConstructor::class => [ 'dummy' => [ '__construct' => [ - 100 + 100, ], ], ], @@ -1757,7 +1757,6 @@ public function provideFixturesToInstantiate() ], ], (new ReflectionClass(FixtureEntity\Instantiator\DummyWithPrivateConstructor::class))->newInstanceWithoutConstructor(), - ]; yield 'with protected constructor – use reflection' => [ @@ -1769,7 +1768,6 @@ public function provideFixturesToInstantiate() ], ], (new ReflectionClass(FixtureEntity\Instantiator\DummyWithProtectedConstructor::class))->newInstanceWithoutConstructor(), - ]; yield 'with private named constructor – use reflection' => [ @@ -1830,7 +1828,7 @@ public function provideFixturesToInstantiate() 'bar2' => 'value 4', 'bar1' => 'value 3', ], - ] + ], ], ], ], @@ -1839,7 +1837,7 @@ public function provideFixturesToInstantiate() ]; } - public function provideLegacyFixturesToInstantiate() + public function provideLegacyFixturesToInstantiate(): iterable { yield 'with named constructor - use factory function' => [ [ @@ -1970,7 +1968,7 @@ public function provideLegacyFixturesToInstantiate() ]; } - public function provideFixturesToInstantiateWithFactory() + public function provideFixturesToInstantiateWithFactory(): iterable { yield 'regular factory' => [ [ @@ -2101,7 +2099,7 @@ public function provideFixturesToInstantiateWithFactory() ]; } - public function provideFixtureToInstantiateWithDeprecatedConstructor() + public function provideFixtureToInstantiateWithDeprecatedConstructor(): iterable { yield 'with named constructor - use factory function' => [ [ @@ -2190,7 +2188,7 @@ public function provideFixtureToInstantiateWithDeprecatedConstructor() ]; } - public function provideFixturesToHydrate() + public function provideFixturesToHydrate(): iterable { yield 'public camelCase property' => [ [ @@ -2205,7 +2203,7 @@ public function provideFixturesToHydrate() $dummy->publicProperty = 'bob'; return $dummy; - })(new FixtureEntity\Hydrator\CamelCaseDummy()) + })(new FixtureEntity\Hydrator\CamelCaseDummy()), ], ]; @@ -2222,7 +2220,7 @@ public function provideFixturesToHydrate() $dummy->public_property = 'bob'; return $dummy; - })(new FixtureEntity\Hydrator\SnakeCaseDummy()) + })(new FixtureEntity\Hydrator\SnakeCaseDummy()), ], ]; @@ -2239,7 +2237,7 @@ public function provideFixturesToHydrate() $dummy->PublicProperty = 'bob'; return $dummy; - })(new FixtureEntity\Hydrator\PascalCaseDummy()) + })(new FixtureEntity\Hydrator\PascalCaseDummy()), ], ]; @@ -2256,7 +2254,7 @@ public function provideFixturesToHydrate() $dummy->setSetterProperty('bob'); return $dummy; - })(new FixtureEntity\Hydrator\CamelCaseDummy()) + })(new FixtureEntity\Hydrator\CamelCaseDummy()), ], ]; @@ -2285,7 +2283,7 @@ public function provideFixturesToHydrate() $dummy->setMagicProperty('bob'); return $dummy; - })(new FixtureEntity\Hydrator\MagicCallDummy()) + })(new FixtureEntity\Hydrator\MagicCallDummy()), ], ]; @@ -2302,7 +2300,7 @@ public function provideFixturesToHydrate() $dummy->setMagicProperty('bob'); return $dummy; - })(new FixtureEntity\Hydrator\MagicCallDummy()) + })(new FixtureEntity\Hydrator\MagicCallDummy()), ], ]; @@ -2319,12 +2317,12 @@ public function provideFixturesToHydrate() $dummy->setMagicProperty('bob'); return $dummy; - })(new FixtureEntity\Hydrator\MagicCallDummy()) + })(new FixtureEntity\Hydrator\MagicCallDummy()), ], ]; } - public function provideFixturesToGenerate() + public function provideFixturesToGenerate(): iterable { yield '[construct] with reference to object with throwable setter and caller' => [ [ @@ -2333,16 +2331,16 @@ public function provideFixturesToGenerate() 'hydrate' => true, '__calls' => [ ['call' => [true]], - ] - ] + ], + ], ], FixtureEntity\DummyWithConstructorParam::class => [ 'dummy' => [ '__construct' => [ - '@another_dummy' - ] - ] - ] + '@another_dummy', + ], + ], + ], ], [ 'parameters' => [], @@ -2354,8 +2352,8 @@ public function provideFixturesToGenerate() return $anotherDummy1; })(new FixtureEntity\OnceTimerDummy()), 'dummy' => $dummy1 = new FixtureEntity\DummyWithConstructorParam($yetAnotherDummy1), - ] - ] + ], + ], ]; yield 'empty instance' => [ @@ -2399,7 +2397,7 @@ public function provideFixturesToGenerate() 'objects' => [ 'dummy' => StdClassFactory::create([ 'foo' => 'bar', - ]) + ]), ], ], ]; @@ -2652,7 +2650,7 @@ public function provideFixturesToGenerate() 'dummy' => $dummy = (new FixtureEntity\ValueResolver\DummyWithGetter())->setName('foo'), 'another_dummy' => (new FixtureEntity\ValueResolver\DummyWithGetter())->setName('__get__foo'), ], - ] + ], ]; yield 'inverted property reference value with a getter' => [ @@ -2672,7 +2670,7 @@ public function provideFixturesToGenerate() 'dummy' => $dummy = (new FixtureEntity\ValueResolver\DummyWithGetter())->setName('__get__foo'), 'another_dummy' => (new FixtureEntity\ValueResolver\DummyWithGetter())->setName('foo'), ], - ] + ], ]; yield 'array value' => [ @@ -2693,7 +2691,7 @@ public function provideFixturesToGenerate() 'foo' => 'bar', ]), 'another_dummy' => StdClassFactory::create([ - 'dummies' => [$dummy, $dummy, $dummy] + 'dummies' => [$dummy, $dummy, $dummy], ]), ], ], @@ -2765,7 +2763,7 @@ public function provideFixturesToGenerate() 'foo' => 'bar', ]), 'another_dummy' => StdClassFactory::create([ - 'dummies' => [$dummy, $dummy, $dummy] + 'dummies' => [$dummy, $dummy, $dummy], ]), ], ], @@ -2789,7 +2787,7 @@ public function provideFixturesToGenerate() 'foo' => 'bar', ]), 'another_dummy' => StdClassFactory::create([ - 'dummies' => [$dummy, $dummy, $dummy] + 'dummies' => [$dummy, $dummy, $dummy], ]), ], ], @@ -2813,7 +2811,7 @@ public function provideFixturesToGenerate() 'foo' => 'bar', ]), 'another_dummy' => StdClassFactory::create([ - 'dummies' => [$dummy, $dummy, $dummy] + 'dummies' => [$dummy, $dummy, $dummy], ]), ], ], @@ -2846,7 +2844,7 @@ public function provideFixturesToGenerate() 'dummies' => [ $dummy1, $dummy2, - ] + ], ]), ], ], @@ -3178,7 +3176,7 @@ public function provideFixturesToGenerate() 'foo' => 'bar', ], 'another_dummy' => [ - 'foo' => '<(@dummy->foo)>' + 'foo' => '<(@dummy->foo)>', ], ], ], @@ -3199,10 +3197,10 @@ public function provideFixturesToGenerate() [ stdClass::class => [ 'dummy' => [ - 'foo' => 'bar' + 'foo' => 'bar', ], 'another_dummy' => [ - 'relatedDummy' => '<(@dummy)>' + 'relatedDummy' => '<(@dummy)>', ], ], ], @@ -3223,7 +3221,7 @@ public function provideFixturesToGenerate() [ stdClass::class => [ 'dummy_{1..2}' => [ - 'foo' => '<($current)>' + 'foo' => '<($current)>', ], ], ], @@ -3303,7 +3301,7 @@ public function provideFixturesToGenerate() 'email' => 'dummy2@mail.com', ], 'detailedDummy_{@dummy_*} (extends detailedDummy)' => [ - 'dummy' => '' + 'dummy' => '', ], ], ], @@ -3318,11 +3316,11 @@ public function provideFixturesToGenerate() ]), 'detailedDummy_dummy_1' => StdClassFactory::create([ 'field' => 'value', - 'dummy' => $dummy1 + 'dummy' => $dummy1, ]), 'detailedDummy_dummy_2' => StdClassFactory::create([ 'field' => 'value', - 'dummy' => $dummy2 + 'dummy' => $dummy2, ]), ], ], @@ -3420,7 +3418,7 @@ public function provideFixturesToGenerate() '\\', '\\@foo', '\\foo', - ] + ], ]), ], ], @@ -3620,7 +3618,7 @@ public function provideFixturesToGenerate() 'pong', 'pong', 'pong', - 'pong' + 'pong', ), ], ], @@ -3641,7 +3639,7 @@ public function provideFixturesToGenerate() 'parameters' => [], 'objects' => [ 'dummy' => new FixtureEntity\DummyWithVariadicConstructorParam( - 'bar' + 'bar', ), ], ], @@ -3659,7 +3657,7 @@ public function provideFixturesToGenerate() 'parameters' => [], 'objects' => [ 'dummy' => StdClassFactory::create([ - 'foo' => ['bar', 'bar', 'bar', 'bar', 'bar'] + 'foo' => ['bar', 'bar', 'bar', 'bar', 'bar'], ]), ], ], @@ -3703,7 +3701,7 @@ public function provideFixturesToGenerate() 'foo' => 'bar', ], 'another_dummy' => [ - 'foo' => '@dummy->foo' + 'foo' => '@dummy->foo', ], ], ], @@ -3728,9 +3726,9 @@ public function provideFixturesToGenerate() ['setTitle' => ['Fake Title']], ['addFoo' => []], ['addFoo' => []], - ] - ] - ] + ], + ], + ], ], [ 'parameters' => [], @@ -3747,9 +3745,9 @@ public function provideFixturesToGenerate() '__calls' => [ ['setTitle' => ['Fake Title ']], ['addFoo' => []], - ] - ] - ] + ], + ], + ], ], [ 'parameters' => [], @@ -3768,9 +3766,9 @@ public function provideFixturesToGenerate() '__calls' => [ ['setTitle' => ['Dummy 2']], ['setRelatedDummy' => ['@dummy_1']], - ] - ] - ] + ], + ], + ], ], [ 'parameters' => [], @@ -3785,7 +3783,7 @@ public function provideFixturesToGenerate() [ FixtureEntity\ValueResolver\DummyWithGetter::class => [ 'dummy' => [ - 'name' => 'foobar' + 'name' => 'foobar', ], ], stdClass::class => [ @@ -3811,7 +3809,7 @@ public function provideFixturesToGenerate() [ FixtureEntity\ValueResolver\DummyWithGetter::class => [ 'dummy' => [ - 'name' => 'foobar' + 'name' => 'foobar', ], ], FixtureEntity\ValueResolver\DummyWithMethodArgument::class => [ @@ -3844,9 +3842,9 @@ public function provideFixturesToGenerate() '__construct' => false, '__calls' => [ [FixtureEntity\Caller\StaticService::class.'::setTitle' => ['@self', 'Foo']], - ] - ] - ] + ], + ], + ], ], [ 'parameters' => [], @@ -3863,9 +3861,9 @@ public function provideFixturesToGenerate() '__construct' => false, '__calls' => [ [FixtureEntity\Caller\StaticService::class.'::setTitle (0%?)' => ['@self', 'Foo']], - ] - ] - ] + ], + ], + ], ], [ 'parameters' => [], @@ -3882,9 +3880,9 @@ public function provideFixturesToGenerate() '__construct' => false, '__calls' => [ [FixtureEntity\Caller\DummyWithStaticFunction::class.'::setTitle' => ['@self', 'Foo']], - ] - ] - ] + ], + ], + ], ], [ 'parameters' => [], @@ -3920,9 +3918,7 @@ public function provideFixturesToGenerate() [ stdClass::class => [ 'dummy' => [ - 'foo' => (static function () { - return StdClassFactory::create(['ping' => 'pong']); - })(), + 'foo' => (static fn () => StdClassFactory::create(['ping' => 'pong']))(), ], ], ], @@ -3962,7 +3958,7 @@ public function provideFixturesToGenerate() '__calls' => [ [ 'withVal (configurator)' => [ - 'foo' + 'foo', ], ], ], @@ -4008,7 +4004,7 @@ public function provideFixturesToGenerate() return $address; })(), - 'person' => FixtureEntity\InitializationOrder\Person::createWithAddress($address) + 'person' => FixtureEntity\InitializationOrder\Person::createWithAddress($address), ], ], ]; @@ -4024,22 +4020,22 @@ public function provideFixturesToGenerate() 'hydrate' => true, '__calls' => [ ['call' => [true]], - ] + ], ], 'anotherDummy' => [ 'relatedDummy' => '@yetAnotherDummy', 'hydrate' => true, '__calls' => [ ['call' => [true]], - ] + ], ], 'yetAnotherDummy' => [ 'hydrate' => true, '__calls' => [ ['call' => [true]], - ] - ] - ] + ], + ], + ], ], [ 'parameters' => [], @@ -4064,8 +4060,8 @@ public function provideFixturesToGenerate() return $dummy; })(new FixtureEntity\OnceTimerDummy(), $anotherDummy), - ] - ] + ], + ], ]; })(); @@ -4101,9 +4097,9 @@ public function provideFixturesToGenerate() // https://github.com/nelmio/alice/issues/894 yield 'complex circular reference case' => (static function () { - for ($i = 1; $i < 13; $i++) { + for ($i = 1; $i < 13; ++$i) { $var = 's'.$i; - $$var = new stdClass(); + ${$var} = new stdClass(); } $s1->related = [$s3, $s1]; diff --git a/tests/Loader/NativeLoaderTest.php b/tests/Loader/NativeLoaderTest.php index 084f02b93..731b9ba93 100644 --- a/tests/Loader/NativeLoaderTest.php +++ b/tests/Loader/NativeLoaderTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Loader\NativeLoader + * @internal */ class NativeLoaderTest extends TestCase { @@ -49,6 +50,6 @@ public function testAlwaysReturnsTheSameService(): void $fileLoader1 = $loader->getFileLoader(); $fileLoader2 = $loader->getFileLoader(); - static::assertSame($fileLoader1, $fileLoader2); + self::assertSame($fileLoader1, $fileLoader2); } } diff --git a/tests/Loader/SimpleDataLoaderTest.php b/tests/Loader/SimpleDataLoaderTest.php index 18d3ca74b..e9e6261a9 100644 --- a/tests/Loader/SimpleDataLoaderTest.php +++ b/tests/Loader/SimpleDataLoaderTest.php @@ -26,6 +26,7 @@ /** * @covers \Nelmio\Alice\Loader\SimpleDataLoader + * @internal */ class SimpleDataLoaderTest extends TestCase { @@ -33,12 +34,12 @@ class SimpleDataLoaderTest extends TestCase public function testIsADataLoader(): void { - static::assertTrue(is_a(SimpleDataLoader::class, DataLoaderInterface::class, true)); + self::assertTrue(is_a(SimpleDataLoader::class, DataLoaderInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleDataLoader::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleDataLoader::class))->isCloneable()); } public function testLoadAFileAndReturnsAnObjectSet(): void @@ -67,7 +68,7 @@ public function testLoadAFileAndReturnsAnObjectSet(): void $loader = new SimpleDataLoader($fixtureBuilder, $generator); $result = $loader->loadData($data, $parameters, $objects); - static::assertSame($objectSet, $result); + self::assertSame($objectSet, $result); $fixtureBuilderProphecy->build(Argument::cetera())->shouldHaveBeenCalledTimes(1); $generatorProphecy->generate(Argument::cetera())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Loader/SimpleFileLoaderTest.php b/tests/Loader/SimpleFileLoaderTest.php index f3b2f3532..899062321 100644 --- a/tests/Loader/SimpleFileLoaderTest.php +++ b/tests/Loader/SimpleFileLoaderTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\Loader\SimpleFileLoader + * @internal */ class SimpleFileLoaderTest extends TestCase { @@ -32,12 +33,12 @@ class SimpleFileLoaderTest extends TestCase public function testIsALoader(): void { - static::assertTrue(is_a(SimpleFileLoader::class, FileLoaderInterface::class, true)); + self::assertTrue(is_a(SimpleFileLoader::class, FileLoaderInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleFileLoader::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleFileLoader::class))->isCloneable()); } public function testLoadAFileAndReturnsAnObjectSet(): void @@ -69,7 +70,7 @@ public function testLoadAFileAndReturnsAnObjectSet(): void $loader = new SimpleFileLoader($parser, $dataLoader); $result = $loader->loadFile($file, $parameters, $objects); - static::assertSame($objectSet, $result); + self::assertSame($objectSet, $result); $parserProphecy->parse(Argument::cetera())->shouldHaveBeenCalledTimes(1); $dataLoaderProphecy->loadData(Argument::cetera())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Loader/SimpleFilesLoaderTest.php b/tests/Loader/SimpleFilesLoaderTest.php index cb63fea34..cccd6fb76 100644 --- a/tests/Loader/SimpleFilesLoaderTest.php +++ b/tests/Loader/SimpleFilesLoaderTest.php @@ -27,6 +27,7 @@ /** * @covers \Nelmio\Alice\Loader\SimpleFilesLoader + * @internal */ class SimpleFilesLoaderTest extends TestCase { @@ -34,12 +35,12 @@ class SimpleFilesLoaderTest extends TestCase public function testIsALoader(): void { - static::assertTrue(is_a(SimpleFilesLoader::class, FilesLoaderInterface::class, true)); + self::assertTrue(is_a(SimpleFilesLoader::class, FilesLoaderInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(SimpleFilesLoader::class))->isCloneable()); + self::assertFalse((new ReflectionClass(SimpleFilesLoader::class))->isCloneable()); } public function testLoadFilesAndReturnsAnObjectSet(): void @@ -104,7 +105,7 @@ public function testLoadFilesAndReturnsAnObjectSet(): void $loader = new SimpleFilesLoader($parser, $dataLoader); $result = $loader->loadFiles($files, $parameters, $objects); - static::assertSame($objectSet, $result); + self::assertSame($objectSet, $result); $parserProphecy->parse(Argument::cetera())->shouldHaveBeenCalledTimes(3); $dataLoaderProphecy->loadData(Argument::cetera())->shouldHaveBeenCalledTimes(1); @@ -142,14 +143,14 @@ public function testLoadFilesWithDifferentOrder(): void $loader = new SimpleFilesLoader($parser, new IsolatedLoader()); $objects = $loader->loadFiles([$file2, $file1], [], [])->getObjects(); - static::assertArrayHasKey('user1', $objects); - static::assertArrayHasKey('userdetail_user1', $objects); - static::assertArrayHasKey('userdetail_single_user1', $objects); + self::assertArrayHasKey('user1', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_single_user1', $objects); $objects = $loader->loadFiles([$file1, $file2], [], [])->getObjects(); - static::assertArrayHasKey('user1', $objects); - static::assertArrayHasKey('userdetail_user1', $objects); - static::assertArrayHasKey('userdetail_single_user1', $objects); + self::assertArrayHasKey('user1', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_single_user1', $objects); } public function testLoadFixturesWithDifferentOrder(): void @@ -197,13 +198,13 @@ public function testLoadFixturesWithDifferentOrder(): void $loader = new SimpleFilesLoader($parser, new IsolatedLoader()); $objects = $loader->loadFiles([$file1], [], [])->getObjects(); - static::assertArrayHasKey('user1', $objects); - static::assertArrayHasKey('userdetail_user1', $objects); - static::assertArrayHasKey('userdetail_single_user1', $objects); + self::assertArrayHasKey('user1', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_single_user1', $objects); $objects = $loader->loadFiles([$file2], [], [])->getObjects(); - static::assertArrayHasKey('user1', $objects); - static::assertArrayHasKey('userdetail_user1', $objects); - static::assertArrayHasKey('userdetail_single_user1', $objects); + self::assertArrayHasKey('user1', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_single_user1', $objects); } } diff --git a/tests/ObjectBagTest.php b/tests/ObjectBagTest.php index 6f0a7671a..04d1126fb 100644 --- a/tests/ObjectBagTest.php +++ b/tests/ObjectBagTest.php @@ -27,6 +27,7 @@ /** * @covers \Nelmio\Alice\ObjectBag + * @internal */ class ObjectBagTest extends TestCase { @@ -36,7 +37,7 @@ class ObjectBagTest extends TestCase * @var ReflectionProperty */ private $propRefl; - + protected function setUp(): void { $this->propRefl = (new ReflectionClass(ObjectBag::class))->getProperty('objects'); @@ -58,7 +59,7 @@ public function testBagsCanBeInstantiatedWithRegularObjects(): void 'user1' => new CompleteObject(new SimpleObject('user1', $u1)), 'user2' => new CompleteObject(new SimpleObject('user2', $u2)), ], - $bag + $bag, ); } @@ -79,7 +80,7 @@ public function testBagsCanBeInstantiatedWithObjects(): void 'user1' => new CompleteObject(new SimpleObject('user1', $u1)), 'user2' => new CompleteObject(new SimpleObject('user2', $u2)), ], - $bag + $bag, ); } @@ -98,7 +99,7 @@ public function testBagsCanBeInstantiatedWithoutAnyObject(): void $bag = new ObjectBag(); $this->assertSameObjects( [], - $bag + $bag, ); } @@ -113,19 +114,19 @@ public function testReadAccessorsReturnPropertiesValues(): void $group1Fixture = $this->createFixture('group1', stdClass::class); $inexistingReference = $this->createFixture('unknown', 'Dummy'); - static::assertTrue($bag->has($user1Fixture)); - static::assertEquals( + self::assertTrue($bag->has($user1Fixture)); + self::assertEquals( new CompleteObject(new SimpleObject('user1', new stdClass())), - $bag->get($user1Fixture) + $bag->get($user1Fixture), ); - static::assertTrue($bag->has($group1Fixture)); - static::assertEquals( + self::assertTrue($bag->has($group1Fixture)); + self::assertEquals( new CompleteObject(new SimpleObject('group1', new stdClass())), - $bag->get($group1Fixture) + $bag->get($group1Fixture), ); - static::assertFalse($bag->has($inexistingReference)); + self::assertFalse($bag->has($inexistingReference)); } public function testThrowsExceptionWhenTryingToGetInexistingObject(): void @@ -147,16 +148,16 @@ public function testNamedConstructorReturnNewModifiedInstanceWhenAddingAnObject( $newBag = $bag->with(new CompleteObject(new SimpleObject('bar', $std))); - static::assertEquals( + self::assertEquals( new ObjectBag(['foo' => new stdClass()]), - $bag + $bag, ); - static::assertEquals( + self::assertEquals( new ObjectBag([ 'foo' => new stdClass(), 'bar' => new CompleteObject(new SimpleObject('bar', $std)), ]), - $newBag + $newBag, ); } @@ -170,18 +171,18 @@ public function testAddingAnObjectCanOverrideTheExistingOne(): void $newBag = $bag->with(new CompleteObject(new SimpleObject('foo', $std))); - static::assertEquals( + self::assertEquals( new ObjectBag([ 'foo' => new CompleteObject( new SimpleObject( 'foo', StdClassFactory::create([ 'ping' => 'pong', - ]) - ) + ]), + ), ), ]), - $newBag + $newBag, ); } @@ -190,16 +191,16 @@ public function testNamedConstructorReturnNewModifiedInstanceWhenRemovingAnObjec $bag = new ObjectBag(['foo' => new stdClass()]); $newBag = $bag->without( - new SimpleObject('foo', new stdClass()) + new SimpleObject('foo', new stdClass()), ); - static::assertEquals( + self::assertEquals( new ObjectBag(['foo' => new stdClass()]), - $bag + $bag, ); - static::assertEquals( + self::assertEquals( new ObjectBag([]), - $newBag + $newBag, ); } @@ -208,12 +209,12 @@ public function testCanRemoveAnNonExistentObject(): void $bag = new ObjectBag([]); $newBag = $bag->without( - new SimpleObject('foo', new stdClass()) + new SimpleObject('foo', new stdClass()), ); - static::assertEquals( + self::assertEquals( new ObjectBag([]), - $newBag + $newBag, ); } @@ -239,20 +240,20 @@ public function testImmutableMerge(): void $bag2 = (new ObjectBag())->with($object3)->with($object4); $bag = $bag1->mergeWith($bag2); - static::assertInstanceOf(ObjectBag::class, $bag); + self::assertInstanceOf(ObjectBag::class, $bag); $this->assertSameObjects( [ 'foo' => $object1, 'bar' => $object2, ], - $bag1 + $bag1, ); $this->assertSameObjects( [ 'bar' => $object3, 'baz' => $object4, ], - $bag2 + $bag2, ); $this->assertSameObjects( [ @@ -260,7 +261,7 @@ public function testImmutableMerge(): void 'bar' => $object3, 'baz' => $object4, ], - $bag + $bag, ); } @@ -275,12 +276,12 @@ public function testIsTraversable(): void $traversed[$reference] = $object; } - static::assertSame( + self::assertSame( [ 'foo' => $object1, 'bar' => $object2, ], - $traversed + $traversed, ); } @@ -290,47 +291,47 @@ public function testToArray(): void $object2 = new CompleteObject(new SimpleObject('bar', new stdClass())); $bag = (new ObjectBag())->with($object1)->with($object2); - static::assertEquals( + self::assertEquals( [ 'foo' => new stdClass(), 'bar' => new stdClass(), ], - $bag->toArray() + $bag->toArray(), ); - static::assertCount(count($bag), $bag->toArray()); + self::assertCount(count($bag), $bag->toArray()); } public function testCountable(): void { - static::assertTrue(is_a(ObjectBag::class, Countable::class, true)); + self::assertTrue(is_a(ObjectBag::class, Countable::class, true)); $bag = new ObjectBag(); - static::assertEquals(0, $bag->count()); + self::assertEquals(0, $bag->count()); $bag = new ObjectBag([ 'foo' => new stdClass(), 'bar' => new stdClass(), ]); - static::assertEquals(2, $bag->count()); + self::assertEquals(2, $bag->count()); $object1 = new CompleteObject(new SimpleObject('foo', new stdClass())); $object2 = new CompleteObject(new SimpleObject('bar', new stdClass())); $bag = (new ObjectBag())->with($object1)->with($object2); - static::assertEquals(2, $bag->count()); + self::assertEquals(2, $bag->count()); $object3 = new CompleteObject(new SimpleObject('foz', new stdClass())); $object4 = new CompleteObject(new SimpleObject('baz', new stdClass())); $anotherBag = (new ObjectBag())->with($object3)->with($object4); $bag = $bag->mergeWith($anotherBag); - static::assertEquals(4, $bag->count()); + self::assertEquals(4, $bag->count()); } private function assertSameObjects(array $expected, ObjectBag $actual): void { $actualObjects = $this->propRefl->getValue($actual); - static::assertEquals($expected, $actualObjects); - static::assertCount(count($expected), $actualObjects); + self::assertEquals($expected, $actualObjects); + self::assertCount(count($expected), $actualObjects); } private function createFixture(string $reference, string $className): FixtureInterface diff --git a/tests/ObjectSetTest.php b/tests/ObjectSetTest.php index 27d7a8beb..b3d4e4476 100644 --- a/tests/ObjectSetTest.php +++ b/tests/ObjectSetTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\ObjectSet + * @internal */ class ObjectSetTest extends TestCase { @@ -32,18 +33,18 @@ public function testReadAccessorsReturnPropertiesValues(): void $set = new ObjectSet($parameters, $objects); - static::assertSame( + self::assertSame( [ 'foo' => 'bar', ], - $set->getParameters() + $set->getParameters(), ); - static::assertEquals( + self::assertEquals( [ - 'dummy' => $std + 'dummy' => $std, ], - $set->getObjects() + $set->getObjects(), ); - static::assertCount(1, $set->getObjects()); + self::assertCount(1, $set->getObjects()); } } diff --git a/tests/ParameterBagTest.php b/tests/ParameterBagTest.php index 7517bf5c7..d2e5f1395 100644 --- a/tests/ParameterBagTest.php +++ b/tests/ParameterBagTest.php @@ -20,6 +20,7 @@ /** * @covers \Nelmio\Alice\ParameterBag + * @internal */ class ParameterBagTest extends TestCase { @@ -32,14 +33,14 @@ public function testReadAccessorsReturnPropertiesValues(): void $bag = new ParameterBag($parameters); - static::assertTrue($bag->has('foo')); - static::assertTrue($bag->has('ping')); + self::assertTrue($bag->has('foo')); + self::assertTrue($bag->has('ping')); - static::assertFalse($bag->has('bar')); - static::assertFalse($bag->has('pong')); + self::assertFalse($bag->has('bar')); + self::assertFalse($bag->has('pong')); - static::assertEquals('bar', $bag->get('foo')); - static::assertEquals('pong', $bag->get('ping')); + self::assertEquals('bar', $bag->get('foo')); + self::assertEquals('pong', $bag->get('ping')); $this->assertBagSize(2, $bag); } @@ -65,39 +66,38 @@ public function testIsImmutable(): void // Mutate retrieved object $bag->get('foo')->foo = 'baz'; - static::assertEquals( + self::assertEquals( new ParameterBag([ 'foo' => new stdClass(), ]), - $bag + $bag, ); } /** - * @depends \Nelmio\Alice\ParameterTest::testIsImmutable + * @depends test\Nelmio\Alice\ParameterTest::testIsImmutable */ public function testWithersReturnNewModifiedObject(): void { $bag = new ParameterBag(['foo' => 'bar']); $newBag = $bag->with(new Parameter('ping', 'pong')); - static::assertEquals(new ParameterBag(['foo' => 'bar']), $bag); - static::assertEquals(new ParameterBag(['foo' => 'bar', 'ping' => 'pong']), $newBag); + self::assertEquals(new ParameterBag(['foo' => 'bar']), $bag); + self::assertEquals(new ParameterBag(['foo' => 'bar', 'ping' => 'pong']), $newBag); } public function testIfTwoParametersWithTheSameKeyAreAddedThenTheNewerOneWillBeDiscarded(): void { $bag = (new ParameterBag([ - 'foo' => 'bar', - 'ping' => 'pong', - ])) + 'foo' => 'bar', + 'ping' => 'pong', + ])) ->with(new Parameter('ping', 'boo')) - ->with(new Parameter('he', 'ho')) - ; + ->with(new Parameter('he', 'ho')); - static::assertEquals('bar', $bag->get('foo')); - static::assertEquals('pong', $bag->get('ping')); - static::assertEquals('ho', $bag->get('he')); + self::assertEquals('bar', $bag->get('foo')); + self::assertEquals('pong', $bag->get('ping')); + self::assertEquals('ho', $bag->get('he')); $this->assertBagSize(3, $bag); } @@ -116,26 +116,25 @@ public function testIsTraversable(): void $traversed[$key] = $param; } - static::assertSame($params, $traversed); + self::assertSame($params, $traversed); } public function testIsCountable(): void { $bag = new ParameterBag(); - static::assertCount(0, $bag); + self::assertCount(0, $bag); $bag = $bag ->with(new Parameter('foo', 'bar')) - ->with(new Parameter('ping', 'pong')) - ; - static::assertCount(2, $bag); + ->with(new Parameter('ping', 'pong')); + self::assertCount(2, $bag); } public function testCanRemoveElements(): void { $bag = (new ParameterBag(['foo' => 'bar']))->without('foo')->without('foo'); - static::assertEquals(new ParameterBag(), $bag); + self::assertEquals(new ParameterBag(), $bag); } private function assertBagSize(int $size, ParameterBag $bag): void @@ -144,26 +143,26 @@ private function assertBagSize(int $size, ParameterBag $bag): void $paramReflection = $reflectionObject->getProperty('parameters'); $paramReflection->setAccessible(true); - static::assertCount($size, $paramReflection->getValue($bag)); + self::assertCount($size, $paramReflection->getValue($bag)); } public function testToArray(): void { $bag = new ParameterBag(); - static::assertEquals([], $bag->toArray()); + self::assertEquals([], $bag->toArray()); $bag = new ParameterBag([ 'foo' => 'bar', 'baz' => $std = new stdClass(), ]); - static::assertEquals( + self::assertEquals( [ 'foo' => 'bar', 'baz' => $std, ], - $bag->toArray() + $bag->toArray(), ); } } diff --git a/tests/ParameterTest.php b/tests/ParameterTest.php index 6f903169c..460ef0819 100644 --- a/tests/ParameterTest.php +++ b/tests/ParameterTest.php @@ -18,18 +18,20 @@ /** * @covers \Nelmio\Alice\Parameter + * @internal */ class ParameterTest extends TestCase { /** * @dataProvider provideValues + * @param mixed $value */ public function testAccessors($value): void { $parameter = new Parameter('foo', $value); - static::assertEquals('foo', $parameter->getKey()); - static::assertEquals($value, $parameter->getValue()); + self::assertEquals('foo', $parameter->getKey()); + self::assertEquals($value, $parameter->getValue()); } public function testIsImmutable(): void @@ -42,7 +44,7 @@ public function testIsImmutable(): void // Mutate retrieved object $parameter->getValue()[0]->foo = 'baz'; - static::assertEquals(new Parameter('foo', [new stdClass()]), $parameter); + self::assertEquals(new Parameter('foo', [new stdClass()]), $parameter); } public function testWithersReturnNewModifiedInstance(): void @@ -50,12 +52,12 @@ public function testWithersReturnNewModifiedInstance(): void $parameter = new Parameter('foo', 'bar'); $newParam = $parameter->withValue('rab'); - static::assertNotSame($newParam, $parameter); - static::assertEquals('bar', $parameter->getValue()); - static::assertEquals('rab', $newParam->getValue()); + self::assertNotSame($newParam, $parameter); + self::assertEquals('bar', $parameter->getValue()); + self::assertEquals('rab', $newParam->getValue()); } - public function provideValues() + public function provideValues(): iterable { return [ 'boolean' => [true], diff --git a/tests/Parser/Chainable/JsonParserTest.php b/tests/Parser/Chainable/JsonParserTest.php index b96c0a323..a37687cb0 100644 --- a/tests/Parser/Chainable/JsonParserTest.php +++ b/tests/Parser/Chainable/JsonParserTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\Parser\Chainable\PhpParser + * @internal */ class JsonParserTest extends TestCase { @@ -33,21 +34,21 @@ class JsonParserTest extends TestCase * @var JsonParser */ private $parser; - + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); self::$dir = __DIR__.'/../../../fixtures/Parser/files/json'; } - + public static function tearDownAfterClass(): void { self::$dir = null; parent::tearDownAfterClass(); } - + protected function setUp(): void { $this->parser = new JsonParser(); @@ -55,12 +56,12 @@ protected function setUp(): void public function testIsAChainableParser(): void { - static::assertTrue(is_a(JsonParser::class, ChainableParserInterface::class, true)); + self::assertTrue(is_a(JsonParser::class, ChainableParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(JsonParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(JsonParser::class))->isCloneable()); } /** @@ -69,9 +70,9 @@ public function testIsNotClonable(): void public function testCanParseJsonFiles(string $file, array $expectedParsers): void { $actual = $this->parser->canParse($file); - $expected = (in_array(get_class($this->parser), $expectedParsers, true)); + $expected = in_array(get_class($this->parser), $expectedParsers, true); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** @@ -81,7 +82,7 @@ public function testCanNotParsePhpFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } /** @@ -91,7 +92,7 @@ public function testCannotParseYamlFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } /** @@ -101,7 +102,7 @@ public function testCannotParseUnsupportedFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } public function testThrowsAnExceptionIfFileDoesNotExist(): void @@ -116,7 +117,7 @@ public function testReturnsParsedFileContent(): void { $actual = $this->parser->parse(self::$dir.'/basic.json'); - static::assertSame( + self::assertSame( [ 'Nelmio\Alice\support\models\User' => [ 'user0' => [ @@ -124,7 +125,7 @@ public function testReturnsParsedFileContent(): void ], ], ], - $actual + $actual, ); } @@ -132,14 +133,14 @@ public function testParsingEmptyFileResultsInEmptySet(): void { $actual = $this->parser->parse(self::$dir.'/empty.json'); - static::assertSame([], $actual); + self::assertSame([], $actual); } public function testParseReturnsNamedParameters(): void { $actual = $this->parser->parse(self::$dir.'/named_parameters.json'); - static::assertSame( + self::assertSame( [ 'Nelmio\Alice\DummyWithMethods' => [ 'dummy_with_methods' => [ @@ -158,7 +159,7 @@ public function testParseReturnsNamedParameters(): void ], ], ], - $actual + $actual, ); } diff --git a/tests/Parser/Chainable/PhpParserTest.php b/tests/Parser/Chainable/PhpParserTest.php index 4432fd436..330d0559f 100644 --- a/tests/Parser/Chainable/PhpParserTest.php +++ b/tests/Parser/Chainable/PhpParserTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\Parser\Chainable\PhpParser + * @internal */ class PhpParserTest extends TestCase { @@ -33,21 +34,21 @@ class PhpParserTest extends TestCase * @var PhpParser */ private $parser; - + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); self::$dir = __DIR__.'/../../../fixtures/Parser/files/php'; } - + public static function tearDownAfterClass(): void { self::$dir = null; parent::tearDownAfterClass(); } - + protected function setUp(): void { $this->parser = new PhpParser(); @@ -55,12 +56,12 @@ protected function setUp(): void public function testIsAChainableParser(): void { - static::assertTrue(is_a(PhpParser::class, ChainableParserInterface::class, true)); + self::assertTrue(is_a(PhpParser::class, ChainableParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(PhpParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(PhpParser::class))->isCloneable()); } /** @@ -69,9 +70,9 @@ public function testIsNotClonable(): void public function testCanParsePhpFiles(string $file, array $expectedParsers): void { $actual = $this->parser->canParse($file); - $expected = (in_array(get_class($this->parser), $expectedParsers, true)); + $expected = in_array(get_class($this->parser), $expectedParsers, true); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** @@ -81,7 +82,7 @@ public function testCannotParseYamlFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } /** @@ -91,7 +92,7 @@ public function testCannotParseJsonFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } /** @@ -101,7 +102,7 @@ public function testCannotParseUnsupportedFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } public function testThrowsAnExceptionIfFileDoesNotExist(): void @@ -116,7 +117,7 @@ public function testReturnsParsedFileContent(): void { $actual = $this->parser->parse(self::$dir.'/basic.php'); - static::assertSame( + self::assertSame( [ 'Nelmio\Alice\support\models\User' => [ 'user0' => [ @@ -124,7 +125,7 @@ public function testReturnsParsedFileContent(): void ], ], ], - $actual + $actual, ); } @@ -132,14 +133,14 @@ public function testParsingEmptyFileResultsInEmptySet(): void { $actual = $this->parser->parse(self::$dir.'/empty.php'); - static::assertSame([], $actual); + self::assertSame([], $actual); } public function testParseReturnsNamedParameters(): void { $actual = $this->parser->parse(self::$dir.'/named_parameters.php'); - static::assertSame( + self::assertSame( [ 'Nelmio\Alice\DummyWithMethods' => [ 'dummy_with_methods' => [ @@ -158,7 +159,7 @@ public function testParseReturnsNamedParameters(): void ], ], ], - $actual + $actual, ); } diff --git a/tests/Parser/Chainable/YamlParserTest.php b/tests/Parser/Chainable/YamlParserTest.php index b0609dff5..1b174096b 100644 --- a/tests/Parser/Chainable/YamlParserTest.php +++ b/tests/Parser/Chainable/YamlParserTest.php @@ -29,11 +29,12 @@ /** * @covers \Nelmio\Alice\Parser\Chainable\YamlParser + * @internal */ class YamlParserTest extends TestCase { - use ProphecyTrait; use FileListProviderTrait; + use ProphecyTrait; private static $dir; @@ -41,26 +42,26 @@ class YamlParserTest extends TestCase * @var YamlParser */ private $parser; - + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); self::$dir = __DIR__.'/../../../fixtures/Parser/files/yaml'; } - + public static function tearDownAfterClass(): void { self::$dir = null; parent::tearDownAfterClass(); } - + protected function setUp(): void { $symfonyYamlParserProphecy = $this->prophesize(SymfonyYamlParser::class); $symfonyYamlParserProphecy->parse(Argument::cetera())->shouldNotBeCalled(); - /* @var SymfonyYamlParser $symfonyYamlParser */ + /** @var SymfonyYamlParser $symfonyYamlParser */ $symfonyYamlParser = $symfonyYamlParserProphecy->reveal(); $this->parser = new YamlParser($symfonyYamlParser); @@ -68,12 +69,12 @@ protected function setUp(): void public function testIsAChainableParser(): void { - static::assertTrue(is_a(YamlParser::class, ChainableParserInterface::class, true)); + self::assertTrue(is_a(YamlParser::class, ChainableParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(YamlParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(YamlParser::class))->isCloneable()); } /** @@ -83,7 +84,7 @@ public function testCannotParsePhpFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } /** @@ -92,9 +93,9 @@ public function testCannotParsePhpFiles(string $file): void public function testCanParseYamlFiles(string $file, array $expectedParsers): void { $actual = $this->parser->canParse($file); - $expected = (in_array(get_class($this->parser), $expectedParsers, true)); + $expected = in_array(get_class($this->parser), $expectedParsers, true); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } /** @@ -104,7 +105,7 @@ public function testCannotParseJsonFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } /** @@ -114,7 +115,7 @@ public function testCannotParseUnsupportedFiles(string $file): void { $actual = $this->parser->canParse($file); - static::assertFalse($actual); + self::assertFalse($actual); } public function testThrowExceptionIfFileDoesNotExist(): void @@ -129,20 +130,20 @@ public function testUseSymfonyParserToParseFile(): void { $file = self::$dir.'/basic.yml'; $fileContent = <<<'EOF' -# -# This file is part of the Alice package. -# -# (c) Nelmio -# -# For the full copyright and license information, please view the LICENSE -# file that was distributed with this source code. -# + # + # This file is part of the Alice package. + # + # (c) Nelmio + # + # For the full copyright and license information, please view the LICENSE + # file that was distributed with this source code. + # -Nelmio\Alice\Model\User: - user0: - fullname: John Doe + Nelmio\Alice\Model\User: + user0: + fullname: John Doe -EOF; + EOF; $expected = [new stdClass()]; @@ -153,13 +154,13 @@ public function testUseSymfonyParserToParseFile(): void $symfonyYamlParserProphecy->parse($fileContent)->willReturn($expected); } - /* @var SymfonyYamlParser $symfonyYamlParser */ + /** @var SymfonyYamlParser $symfonyYamlParser */ $symfonyYamlParser = $symfonyYamlParserProphecy->reveal(); $parser = new YamlParser($symfonyYamlParser); $actual = $parser->parse($file); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $symfonyYamlParserProphecy->parse(Argument::cetera())->shouldBeCalledTimes(1); } @@ -171,7 +172,7 @@ public function testReturnsParsedFileContent(): void $parser = new YamlParser($symfonyParser); $actual = $parser->parse(self::$dir.'/basic.yml'); - static::assertSame( + self::assertSame( [ 'Nelmio\Alice\Model\User' => [ 'user0' => [ @@ -179,14 +180,14 @@ public function testReturnsParsedFileContent(): void ], ], ], - $actual + $actual, ); } public function testParseReturnsInterpretedConstants(): void { if (!defined('Symfony\\Component\\Yaml\\Yaml::PARSE_CONSTANT')) { - static::markTestSkipped('This test needs symfony/yaml v3.2 or higher.'); + self::markTestSkipped('This test needs symfony/yaml v3.2 or higher.'); } $symfonyParser = new SymfonyYamlParser(); @@ -194,7 +195,7 @@ public function testParseReturnsInterpretedConstants(): void $parser = new YamlParser($symfonyParser); $actual = $parser->parse(self::$dir.'/constants.yml'); - static::assertSame( + self::assertSame( [ 'Nelmio\Alice\Model\User' => [ 'user0' => [ @@ -202,7 +203,7 @@ public function testParseReturnsInterpretedConstants(): void ], ], ], - $actual + $actual, ); } @@ -213,7 +214,7 @@ public function testParsingEmptyFileResultsInEmptySet(): void $parser = new YamlParser($symfonyParser); $actual = $parser->parse(self::$dir.'/empty.yml'); - static::assertSame([], $actual); + self::assertSame([], $actual); } public function testParseReturnsNamedParameters(): void @@ -223,7 +224,7 @@ public function testParseReturnsNamedParameters(): void $parser = new YamlParser($symfonyParser); $actual = $parser->parse(self::$dir.'/named_parameters.yml'); - static::assertSame( + self::assertSame( [ 'Nelmio\Alice\DummyWithMethods' => [ 'dummy_with_methods' => [ @@ -242,7 +243,7 @@ public function testParseReturnsNamedParameters(): void ], ], ], - $actual + $actual, ); } @@ -253,17 +254,17 @@ public function testThrowsAnExceptionIfFileNotParsable(): void $symfonyYamlParserProphecy = $this->prophesize(SymfonyYamlParser::class); $symfonyYamlParserProphecy->parse(Argument::cetera())->willThrow(SymfonyParseException::class); - /* @var SymfonyYamlParser $symfonyYamlParser */ + /** @var SymfonyYamlParser $symfonyYamlParser */ $symfonyYamlParser = $symfonyYamlParserProphecy->reveal(); $parser = new YamlParser($symfonyYamlParser); $parser->parse($file); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (UnparsableFileException $exception) { - static::assertMatchesRegularExpression('/^The file ".+\/basic\.yml" does not contain valid YAML\.$/', $exception->getMessage()); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertMatchesRegularExpression('/^The file ".+\/basic\.yml" does not contain valid YAML\.$/', $exception->getMessage()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -274,17 +275,17 @@ public function testThrowsAnExceptionOnUnexpectedParseException(): void $symfonyYamlParserProphecy = $this->prophesize(SymfonyYamlParser::class); $symfonyYamlParserProphecy->parse(Argument::cetera())->willThrow(Exception::class); - /* @var SymfonyYamlParser $symfonyYamlParser */ + /** @var SymfonyYamlParser $symfonyYamlParser */ $symfonyYamlParser = $symfonyYamlParserProphecy->reveal(); $parser = new YamlParser($symfonyYamlParser); $parser->parse($file); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (UnparsableFileException $exception) { - static::assertMatchesRegularExpression('/^Could not parse the file ".+\/basic\.yml"\.$/', $exception->getMessage()); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertMatchesRegularExpression('/^Could not parse the file ".+\/basic\.yml"\.$/', $exception->getMessage()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } } diff --git a/tests/Parser/FilesReference.php b/tests/Parser/FilesReference.php index 536478df9..b557dab4d 100644 --- a/tests/Parser/FilesReference.php +++ b/tests/Parser/FilesReference.php @@ -140,7 +140,7 @@ public function __construct() 'unsupported' => [ 'XML file' => ['dummy.xml'], 'CSV file' => ['dummy.csv'], - ] + ], ]; } diff --git a/tests/Parser/IncludeProcessor/DefaultIncludeProcessorTest.php b/tests/Parser/IncludeProcessor/DefaultIncludeProcessorTest.php index 091504ea4..1ac1e5495 100644 --- a/tests/Parser/IncludeProcessor/DefaultIncludeProcessorTest.php +++ b/tests/Parser/IncludeProcessor/DefaultIncludeProcessorTest.php @@ -26,13 +26,14 @@ /** * @covers \Nelmio\Alice\Parser\IncludeProcessor\DefaultIncludeProcessor + * @internal */ class DefaultIncludeProcessorTest extends TestCase { use ProphecyTrait; private static $dir; - + protected function setUp(): void { self::$dir = __DIR__.'/../../../fixtures/Parser/files/cache'; @@ -40,24 +41,24 @@ protected function setUp(): void public function testIsAnIncludeProcessor(): void { - static::assertTrue(is_a(DefaultIncludeProcessor::class, IncludeProcessorInterface::class, true)); + self::assertTrue(is_a(DefaultIncludeProcessor::class, IncludeProcessorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(DefaultIncludeProcessor::class))->isCloneable()); + self::assertFalse((new ReflectionClass(DefaultIncludeProcessor::class))->isCloneable()); } public function testThrowsAnExceptionIfNoIncludeStatementFound(): void { $parserProphecy = $this->prophesize(ParserInterface::class); $parserProphecy->parse(Argument::any())->shouldNotBeCalled(); - /* @var ParserInterface $parser */ + /** @var ParserInterface $parser */ $parser = $parserProphecy->reveal(); $fileLocatorProphecy = $this->prophesize(FileLocatorInterface::class); $fileLocatorProphecy->locate('dummy.php')->willReturn('dummy.php'); - /* @var FileLocatorInterface $fileLocator */ + /** @var FileLocatorInterface $fileLocator */ $fileLocator = $fileLocatorProphecy->reveal(); $processor = new DefaultIncludeProcessor($fileLocator); @@ -85,19 +86,19 @@ public function testIncludeStatementCanBeNull(): void $parserProphecy = $this->prophesize(ParserInterface::class); $parserProphecy->parse(Argument::any())->shouldNotBeCalled(); - /* @var ParserInterface $parser */ + /** @var ParserInterface $parser */ $parser = $parserProphecy->reveal(); $fileLocatorProphecy = $this->prophesize(FileLocatorInterface::class); $fileLocatorProphecy->locate($mainFile)->willReturn('main.yml'); - /* @var FileLocatorInterface $fileLocator */ + /** @var FileLocatorInterface $fileLocator */ $fileLocator = $fileLocatorProphecy->reveal(); $processor = new DefaultIncludeProcessor($fileLocator); $actual = $processor->process($parser, $mainFile, $parsedMainFileContent); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testIfNotNullIncludeStatementMustBeAnArray(): void @@ -112,7 +113,7 @@ public function testIfNotNullIncludeStatementMustBeAnArray(): void $parserProphecy = $this->prophesize(ParserInterface::class); $parserProphecy->parse(Argument::any())->shouldNotBeCalled(); - /* @var ParserInterface $parser */ + /** @var ParserInterface $parser */ $parser = $parserProphecy->reveal(); $processor = new DefaultIncludeProcessor(new DefaultFileLocator()); @@ -137,7 +138,7 @@ public function testIncludedFilesMustBeStrings(): void $parserProphecy = $this->prophesize(ParserInterface::class); $parserProphecy->parse(Argument::any())->shouldNotBeCalled(); - /* @var ParserInterface $parser */ + /** @var ParserInterface $parser */ $parser = $parserProphecy->reveal(); $processor = new DefaultIncludeProcessor(new DefaultFileLocator()); @@ -162,7 +163,7 @@ public function testIncludedFilesMustBeNonEmptyStrings(): void $parserProphecy = $this->prophesize(ParserInterface::class); $parserProphecy->parse(Argument::any())->shouldNotBeCalled(); - /* @var ParserInterface $parser */ + /** @var ParserInterface $parser */ $parser = $parserProphecy->reveal(); $processor = new DefaultIncludeProcessor(new DefaultFileLocator()); @@ -217,7 +218,7 @@ public function testProcessesIncludeFiles(): void $parserProphecy->parse(Argument::containingString('file1.yml'))->willReturn($parsedFile1Content); $parserProphecy->parse(Argument::containingString('file2.yml'))->willReturn($parsedFile2Content); $parserProphecy->parse(Argument::containingString('file3.yml'))->willReturn($parsedFile3Content); - /* @var ParserInterface $parser */ + /** @var ParserInterface $parser */ $parser = $parserProphecy->reveal(); $fileLocatorProphecy = $this->prophesize(FileLocatorInterface::class); @@ -226,13 +227,13 @@ public function testProcessesIncludeFiles(): void $fileLocatorProphecy->locate($file1Path, Argument::cetera())->willReturn('file1.yml'); $fileLocatorProphecy->locate($file2Path, Argument::cetera())->willReturn('file2.yml'); $fileLocatorProphecy->locate($file3Path, Argument::cetera())->willReturn('file3.yml'); - /* @var FileLocatorInterface $fileLocator */ + /** @var FileLocatorInterface $fileLocator */ $fileLocator = $fileLocatorProphecy->reveal(); $processor = new DefaultIncludeProcessor($fileLocator); $actual = $processor->process($parser, $mainFile, $parsedMainFileContent); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/Parser/IncludeProcessor/IncludeDataMergerTest.php b/tests/Parser/IncludeProcessor/IncludeDataMergerTest.php index fb2134474..b3a57dfc3 100644 --- a/tests/Parser/IncludeProcessor/IncludeDataMergerTest.php +++ b/tests/Parser/IncludeProcessor/IncludeDataMergerTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Parser\IncludeProcessor\IncludeDataMerger + * @internal */ class IncludeDataMergerTest extends TestCase { @@ -24,7 +25,7 @@ class IncludeDataMergerTest extends TestCase * @var IncludeDataMerger */ private $merger; - + protected function setUp(): void { $this->merger = new IncludeDataMerger(); @@ -43,8 +44,7 @@ public function testMergesNonArrayData(): void ]; $actual = $this->merger->mergeInclude($data, $include); - static::assertSame($expected, $actual); - + self::assertSame($expected, $actual); $data = [ 'parameters' => [ @@ -61,8 +61,7 @@ public function testMergesNonArrayData(): void ]; $actual = $this->merger->mergeInclude($data, $include); - static::assertSame($expected, $actual); - + self::assertSame($expected, $actual); $data = [ 'parameters' => 'foo', @@ -75,7 +74,7 @@ public function testMergesNonArrayData(): void ]; $actual = $this->merger->mergeInclude($data, $include); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testMergesParametersAndReturnTheResult(): void @@ -101,7 +100,7 @@ public function testMergesParametersAndReturnTheResult(): void ]; $actual = $this->merger->mergeInclude($data, $include); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testCanMergeClassNames(): void @@ -157,7 +156,7 @@ public function testCanMergeClassNames(): void ]; $actual = $this->merger->mergeInclude($data, $include); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testCanMergeCompleteDataSet(): void @@ -226,6 +225,6 @@ public function testCanMergeCompleteDataSet(): void ]; $actual = $this->merger->mergeInclude($data, $include); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/Parser/ParserRegistryTest.php b/tests/Parser/ParserRegistryTest.php index bf86be51b..e55fadcdb 100644 --- a/tests/Parser/ParserRegistryTest.php +++ b/tests/Parser/ParserRegistryTest.php @@ -24,6 +24,7 @@ /** * @covers \Nelmio\Alice\Parser\ParserRegistry + * @internal */ class ParserRegistryTest extends TestCase { @@ -31,14 +32,14 @@ class ParserRegistryTest extends TestCase public function testIsAParser(): void { - static::assertTrue(is_a(ParserRegistry::class, ParserInterface::class, true)); + self::assertTrue(is_a(ParserRegistry::class, ParserInterface::class, true)); } public function testAcceptChainableParsers(): void { $parserProphecy = $this->prophesize(ChainableParserInterface::class); $parserProphecy->canParse(Argument::any())->shouldNotBeCalled(); - /* @var ChainableParserInterface $parser */ + /** @var ChainableParserInterface $parser */ $parser = $parserProphecy->reveal(); new ParserRegistry([$parser]); @@ -53,7 +54,7 @@ public function testThrowsAnExceptionIfInvalidParserIsPassed(): void public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ParserRegistry::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ParserRegistry::class))->isCloneable()); } public function testIteratesOverEveryParsersAndUseTheFirstValidOne(): void @@ -63,18 +64,18 @@ public function testIteratesOverEveryParsersAndUseTheFirstValidOne(): void $parser1Prophecy = $this->prophesize(ChainableParserInterface::class); $parser1Prophecy->canParse($file)->willReturn(false); - /* @var ChainableParserInterface $parser1 */ + /** @var ChainableParserInterface $parser1 */ $parser1 = $parser1Prophecy->reveal(); $parser2Prophecy = $this->prophesize(ChainableParserInterface::class); $parser2Prophecy->canParse($file)->willReturn(true); $parser2Prophecy->parse($file)->willReturn($expected); - /* @var ChainableParserInterface $parser2 */ + /** @var ChainableParserInterface $parser2 */ $parser2 = $parser2Prophecy->reveal(); $parser3Prophecy = $this->prophesize(ChainableParserInterface::class); $parser3Prophecy->canParse(Argument::any())->shouldNotBeCalled(); - /* @var ChainableParserInterface $parser3 */ + /** @var ChainableParserInterface $parser3 */ $parser3 = $parser3Prophecy->reveal(); $registry = new ParserRegistry([ @@ -84,7 +85,7 @@ public function testIteratesOverEveryParsersAndUseTheFirstValidOne(): void ]); $actual = $registry->parse($file); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $parser1Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1); $parser2Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1); diff --git a/tests/Parser/RuntimeCacheParserTest.php b/tests/Parser/RuntimeCacheParserTest.php index 10f87f7ed..9dcd72bf1 100644 --- a/tests/Parser/RuntimeCacheParserTest.php +++ b/tests/Parser/RuntimeCacheParserTest.php @@ -27,13 +27,14 @@ /** * @covers \Nelmio\Alice\Parser\RuntimeCacheParser + * @internal */ class RuntimeCacheParserTest extends TestCase { use ProphecyTrait; private static $dir; - + protected function setUp(): void { self::$dir = __DIR__.'/../../fixtures/Parser/files/cache'; @@ -41,12 +42,12 @@ protected function setUp(): void public function testIsAParser(): void { - static::assertTrue(is_a(RuntimeCacheParser::class, ParserInterface::class, true)); + self::assertTrue(is_a(RuntimeCacheParser::class, ParserInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(RuntimeCacheParser::class))->isCloneable()); + self::assertFalse((new ReflectionClass(RuntimeCacheParser::class))->isCloneable()); } public function testCanParseFile(): void @@ -61,7 +62,7 @@ public function testCanParseFile(): void $decoratedParserProphecy = $this->prophesize(ParserInterface::class); $decoratedParserProphecy->parse('/path/to/foo.php')->willReturn($expected); - /* @var ParserInterface $decoratedParser */ + /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); $includeProcessor = new FakeIncludeProcessor(); @@ -69,12 +70,12 @@ public function testCanParseFile(): void $parser = new RuntimeCacheParser($decoratedParser, $fileLocator, $includeProcessor); $actual = $parser->parse($file); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); // As the parser cache the results, parsing each file does not re-trigger a parse call $actual = $parser->parse($file); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testParsesTheResultAndCacheIt(): void @@ -98,9 +99,8 @@ public function testParsesTheResultAndCacheIt(): void 'parameters' => [ 'foo', ], - ] - ) - ; + ], + ); $decoratedParserProphecy ->parse('/path/to/bar.php') ->willReturn( @@ -108,10 +108,9 @@ public function testParsesTheResultAndCacheIt(): void 'parameters' => [ 'bar', ], - ] - ) - ; - /* @var ParserInterface $decoratedParser */ + ], + ); + /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); $includeProcessor = new FakeIncludeProcessor(); @@ -121,9 +120,9 @@ public function testParsesTheResultAndCacheIt(): void $actual2 = $parser->parse($file2); $actual3 = $parser->parse($file3); - static::assertSame($file1Result, $actual1); - static::assertSame($file1Result, $actual2); - static::assertSame($file3Result, $actual3); + self::assertSame($file1Result, $actual1); + self::assertSame($file1Result, $actual2); + self::assertSame($file3Result, $actual3); $fileLocatorProphecy->locate(Argument::any())->shouldHaveBeenCalledTimes(3); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2); @@ -141,14 +140,14 @@ public function testThrowsAnExceptionIfFileCouldNotBeFound(): void try { $parser->parse('/nowhere'); - static::fail('Expected exception to be thrown.'); + self::fail('Expected exception to be thrown.'); } catch (InvalidArgumentException $exception) { - static::assertEquals( + self::assertEquals( 'The file "/nowhere" could not be found.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNotNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNotNull($exception->getPrevious()); } } @@ -213,18 +212,17 @@ public function testProcessesIncludesAndCacheTheResultOfEachIncludedFile(): void $decoratedParserProphecy->parse('/path/to/file1.yml')->willReturn($parsedFile1Content); $decoratedParserProphecy->parse('/path/to/file2.yml')->willReturn($parsedFile2Content); $decoratedParserProphecy->parse('/path/to/file3.yml')->willReturn($parsedFile3Content); - /* @var ParserInterface $decoratedParser */ + /** @var ParserInterface $decoratedParser */ $decoratedParser = $decoratedParserProphecy->reveal(); $parser = new RuntimeCacheParser($decoratedParser, $fileLocator, new DefaultIncludeProcessor($fileLocator)); $actual = $parser->parse($mainFile); - static::assertSame($expected, $actual); + self::assertSame($expected, $actual); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(4); $fileLocatorProphecy->locate(Argument::any())->shouldHaveBeenCalledTimes(4 + 2); // nbr of files + includes - // As the parser cache the results, parsing each file does not re-trigger a parse call $fileLocatorProphecy->locate('file1.yml')->willReturn('/path/to/file1.yml'); $fileLocatorProphecy->locate('file2.yml')->willReturn('/path/to/file2.yml'); @@ -235,10 +233,10 @@ public function testProcessesIncludesAndCacheTheResultOfEachIncludedFile(): void $actualFile2 = $parser->parse('file2.yml'); $actualFile3 = $parser->parse('file3.yml'); - static::assertSame($expected, $actual); - static::assertSame($parsedFile1Content, $actualFile1); - static::assertSame($expectedFile2, $actualFile2); - static::assertSame($parsedFile3Content, $actualFile3); + self::assertSame($expected, $actual); + self::assertSame($parsedFile1Content, $actualFile1); + self::assertSame($expectedFile2, $actualFile2); + self::assertSame($parsedFile3Content, $actualFile3); $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(4); $fileLocatorProphecy->locate(Argument::any())->shouldHaveBeenCalledTimes(4 + 4 + 2); diff --git a/tests/PropertyAccess/ReflectionPropertyAccessorTest.php b/tests/PropertyAccess/ReflectionPropertyAccessorTest.php index dc0080c17..5e428fc41 100644 --- a/tests/PropertyAccess/ReflectionPropertyAccessorTest.php +++ b/tests/PropertyAccess/ReflectionPropertyAccessorTest.php @@ -25,6 +25,7 @@ /** * @covers \Nelmio\Alice\PropertyAccess\ReflectionPropertyAccessor + * @internal */ class ReflectionPropertyAccessorTest extends TestCase { @@ -32,12 +33,12 @@ class ReflectionPropertyAccessorTest extends TestCase public function testIsAPropertyAccessor(): void { - static::assertTrue(is_a(ReflectionPropertyAccessor::class, PropertyAccessorInterface::class, true)); + self::assertTrue(is_a(ReflectionPropertyAccessor::class, PropertyAccessorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(ReflectionPropertyAccessor::class))->isCloneable()); + self::assertFalse((new ReflectionClass(ReflectionPropertyAccessor::class))->isCloneable()); } public function testSetValueOnNoSuchPropertyException(): void @@ -49,15 +50,14 @@ public function testSetValueOnNoSuchPropertyException(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->setValue($object, $property, $value) - ->willThrow(NoSuchPropertyException::class) - ; + ->willThrow(NoSuchPropertyException::class); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); $accessor->setValue($object, $property, $value); - static::assertSame($value, $object->test_get_val()); + self::assertSame($value, $object->test_get_val()); } public function testSetParentValueOnNoSuchPropertyException(): void @@ -71,15 +71,14 @@ public function testSetParentValueOnNoSuchPropertyException(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->setValue($object, $property, $value) - ->willThrow(NoSuchPropertyException::class) - ; + ->willThrow(NoSuchPropertyException::class); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); $accessor->setValue($object, $property, $value); - static::assertSame($value, $object->test_get_val()); + self::assertSame($value, $object->test_get_val()); } public function testThrowsAnOriginalExceptionIfSetValueForANonExistentProperty(): void @@ -91,8 +90,7 @@ public function testThrowsAnOriginalExceptionIfSetValueForANonExistentProperty() $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->setValue($object, $property, $value) - ->willThrow(new NoSuchPropertyException("Cannot set property \"$property\".")) - ; + ->willThrow(new NoSuchPropertyException("Cannot set property \"{$property}\".")); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); @@ -114,8 +112,7 @@ public function testThrowsAnOriginalExceptionIfSetValueForANonExistentPropertyOn $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->setValue($object, $property, $value) - ->willThrow(new NoSuchPropertyException("Cannot set property \"$property\".")) - ; + ->willThrow(new NoSuchPropertyException("Cannot set property \"{$property}\".")); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); @@ -137,8 +134,7 @@ public function testThrowsAnOriginalExceptionIfSetValueForANonExistentPropertyIs $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->setValue($object, $property, $value) - ->willThrow(new NoSuchPropertyException("Cannot set property \"$property\".")) - ; + ->willThrow(new NoSuchPropertyException("Cannot set property \"{$property}\".")); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); @@ -164,18 +160,17 @@ public function testSetValueWithTheDecoratedAccessorWhenPossible(): void $decoratedAccessorProphecy ->setValue($object, $property, $value) ->will( - function ($args): void { + static function ($args): void { $args[0]->{$args[1]} = $args[2]; - } - ) - ; + }, + ); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); $accessor->setValue($object, $property, $value); - static::assertEquals($expected, $object); + self::assertEquals($expected, $object); $decoratedAccessorProphecy->setValue(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -189,8 +184,7 @@ public function testGetPrivateValueOnNoSuchPropertyException(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->getValue($object, $property) - ->willThrow(NoSuchPropertyException::class) - ; + ->willThrow(NoSuchPropertyException::class); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); @@ -198,7 +192,7 @@ public function testGetPrivateValueOnNoSuchPropertyException(): void $accessor = new ReflectionPropertyAccessor($decoratedAccessor); $actual = $accessor->getValue($object, $property); - static::assertEquals($value, $actual); + self::assertEquals($value, $actual); } public function testThrowsAnOriginalExceptionIfPropertyDoesNotExist(): void @@ -209,8 +203,7 @@ public function testThrowsAnOriginalExceptionIfPropertyDoesNotExist(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->getValue($object, $property) - ->willThrow(new NoSuchPropertyException("Cannot read property \"$property\".")) - ; + ->willThrow(new NoSuchPropertyException("Cannot read property \"{$property}\".")); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); @@ -231,8 +224,7 @@ public function testThrowsAnOriginalExceptionIfPropertyDoesNotExistOnNonObject() $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->getValue($object, $property) - ->willThrow(new NoSuchPropertyException("Cannot read property \"$property\".")) - ; + ->willThrow(new NoSuchPropertyException("Cannot read property \"{$property}\".")); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); @@ -253,8 +245,7 @@ public function testThrowsAnOriginalExceptionIfPropertyIsStatic(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->getValue($object, $property) - ->willThrow(new NoSuchPropertyException("Cannot read property \"$property\".")) - ; + ->willThrow(new NoSuchPropertyException("Cannot read property \"{$property}\".")); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); @@ -276,15 +267,14 @@ public function testGetValueWithTheDecoratedAccessorWhenPossible(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->getValue($object, $property) - ->willReturn($value) - ; + ->willReturn($value); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); $actual = $accessor->getValue($object, $property); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedAccessorProphecy->getValue(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -297,25 +287,23 @@ public function testExistingClassPropertiesAreAlwaysWritable(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->isWritable($object, Argument::any()) - ->willReturn(false) - ; + ->willReturn(false); $decoratedAccessorProphecy ->isWritable($objectWithInheritance, Argument::any()) - ->willReturn(false) - ; + ->willReturn(false); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); - static::assertTrue($accessor->isWritable($object, 'val'), 'writable if the property exists'); - static::assertFalse($accessor->isWritable($object, 'foo'), 'non writable if the property does not exist'); - static::assertFalse($accessor->isWritable($object, 'staticVal'), 'non writable if the property is static'); + self::assertTrue($accessor->isWritable($object, 'val'), 'writable if the property exists'); + self::assertFalse($accessor->isWritable($object, 'foo'), 'non writable if the property does not exist'); + self::assertFalse($accessor->isWritable($object, 'staticVal'), 'non writable if the property is static'); - static::assertTrue($accessor->isWritable($objectWithInheritance, 'val'), 'writable if the property exists'); - static::assertTrue($accessor->isWritable($objectWithInheritance, 'val2'), 'writable if the property exists'); - static::assertFalse($accessor->isWritable($objectWithInheritance, 'foo'), 'non writable if the property does not exist'); - static::assertFalse($accessor->isWritable($objectWithInheritance, 'staticVal'), 'non writable if the property is static'); + self::assertTrue($accessor->isWritable($objectWithInheritance, 'val'), 'writable if the property exists'); + self::assertTrue($accessor->isWritable($objectWithInheritance, 'val2'), 'writable if the property exists'); + self::assertFalse($accessor->isWritable($objectWithInheritance, 'foo'), 'non writable if the property does not exist'); + self::assertFalse($accessor->isWritable($objectWithInheritance, 'staticVal'), 'non writable if the property is static'); } public function testUsesDecoratedAccessorToDetermineIfPropertyIsWritable(): void @@ -326,15 +314,14 @@ public function testUsesDecoratedAccessorToDetermineIfPropertyIsWritable(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->isWritable($object, $property) - ->willReturn($expected = true) - ; + ->willReturn($expected = true); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); $actual = $accessor->isWritable($object, $property); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedAccessorProphecy->isWritable(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -347,25 +334,23 @@ public function testPrivateClassPropertiesAreReadableOnlyIfTheyExists(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->isReadable($object, Argument::any()) - ->willReturn(false) - ; + ->willReturn(false); $decoratedAccessorProphecy ->isReadable($objectWithInheritance, Argument::any()) - ->willReturn(false) - ; + ->willReturn(false); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); - static::assertTrue($accessor->isReadable($object, 'val'), 'readable if the property exists'); - static::assertFalse($accessor->isReadable($object, 'foo'), 'non readable if the property does not exist'); - static::assertFalse($accessor->isReadable($object, 'staticVal'), 'non readable if the property is static'); + self::assertTrue($accessor->isReadable($object, 'val'), 'readable if the property exists'); + self::assertFalse($accessor->isReadable($object, 'foo'), 'non readable if the property does not exist'); + self::assertFalse($accessor->isReadable($object, 'staticVal'), 'non readable if the property is static'); - static::assertTrue($accessor->isReadable($objectWithInheritance, 'val'), 'readable if the property exists'); - static::assertTrue($accessor->isReadable($objectWithInheritance, 'val2'), 'readable if the property exists'); - static::assertFalse($accessor->isReadable($objectWithInheritance, 'foo'), 'non readable if the property does not exist'); - static::assertFalse($accessor->isReadable($objectWithInheritance, 'staticVal'), 'non readable if the property is static'); + self::assertTrue($accessor->isReadable($objectWithInheritance, 'val'), 'readable if the property exists'); + self::assertTrue($accessor->isReadable($objectWithInheritance, 'val2'), 'readable if the property exists'); + self::assertFalse($accessor->isReadable($objectWithInheritance, 'foo'), 'non readable if the property does not exist'); + self::assertFalse($accessor->isReadable($objectWithInheritance, 'staticVal'), 'non readable if the property is static'); } public function testUsesDecoratedAccessorToDetermineIfPropertyIsReadable(): void @@ -376,15 +361,14 @@ public function testUsesDecoratedAccessorToDetermineIfPropertyIsReadable(): void $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->isReadable($object, $property) - ->willReturn($expected = true) - ; + ->willReturn($expected = true); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new ReflectionPropertyAccessor($decoratedAccessor); $actual = $accessor->isReadable($object, $property); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedAccessorProphecy->isReadable(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/PropertyAccess/StdPropertyAccessorTest.php b/tests/PropertyAccess/StdPropertyAccessorTest.php index d0ddf9125..e138acf81 100644 --- a/tests/PropertyAccess/StdPropertyAccessorTest.php +++ b/tests/PropertyAccess/StdPropertyAccessorTest.php @@ -26,6 +26,7 @@ /** * @covers \Nelmio\Alice\PropertyAccess\StdPropertyAccessor + * @internal */ class StdPropertyAccessorTest extends TestCase { @@ -33,12 +34,12 @@ class StdPropertyAccessorTest extends TestCase public function testIsAPropertyAccessor(): void { - static::assertTrue(is_a(StdPropertyAccessor::class, PropertyAccessorInterface::class, true)); + self::assertTrue(is_a(StdPropertyAccessor::class, PropertyAccessorInterface::class, true)); } public function testIsNotClonable(): void { - static::assertFalse((new ReflectionClass(StdPropertyAccessor::class))->isCloneable()); + self::assertFalse((new ReflectionClass(StdPropertyAccessor::class))->isCloneable()); } public function testSetValueOfAStdClass(): void @@ -52,7 +53,7 @@ public function testSetValueOfAStdClass(): void $accessor = new StdPropertyAccessor(new FakePropertyAccessor()); $accessor->setValue($object, $property, $value); - static::assertEquals($expected, $object); + self::assertEquals($expected, $object); } public function testSetValueWithTheDecoratedAccessorWhenTheObjectIsNotAnInstanceOfStdClass(): void @@ -68,18 +69,17 @@ public function testSetValueWithTheDecoratedAccessorWhenTheObjectIsNotAnInstance $decoratedAccessorProphecy ->setValue($object, $property, $value) ->will( - function ($args): void { + static function ($args): void { $args[0]->{$args[1]} = $args[2]; - } - ) - ; + }, + ); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new StdPropertyAccessor($decoratedAccessor); $accessor->setValue($object, $property, $value); - static::assertEquals($expected, $object); + self::assertEquals($expected, $object); $decoratedAccessorProphecy->setValue(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -91,7 +91,7 @@ public function testGetValueOfAStdClass(): void $accessor = new StdPropertyAccessor(new FakePropertyAccessor()); $actual = $accessor->getValue($object, $property); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } public function testThrowsAnExceptionIfPropertyNotFoundOnStdClass(): void @@ -110,24 +110,21 @@ public function testGetValueWithTheDecoratedAccessorWhenTheObjectIsNotAnInstance { $object = new DummyWithPublicProperty(); $property = 'val'; - $object->$property = $expected = 'bar'; + $object->{$property} = $expected = 'bar'; $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->getValue($object, $property) ->will( - function ($args) { - return $args[0]->{$args[1]}; - } - ) - ; + static fn ($args) => $args[0]->{$args[1]}, + ); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new StdPropertyAccessor($decoratedAccessor); $actual = $accessor->getValue($object, $property); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedAccessorProphecy->getValue(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -137,7 +134,7 @@ public function testStdClassPropertiesAreAlwaysWriteable(): void $object = new stdClass(); $accessor = new StdPropertyAccessor(new FakePropertyAccessor()); - static::assertTrue($accessor->isWritable($object, 'foo')); + self::assertTrue($accessor->isWritable($object, 'foo')); } public function testUsesDecoratedAccessorToDertermineIfPropertyIsWritableIfObjectIsNotAnStdClassInstance(): void @@ -148,15 +145,14 @@ public function testUsesDecoratedAccessorToDertermineIfPropertyIsWritableIfObjec $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->isWritable($object, $property) - ->willReturn($expected = true) - ; + ->willReturn($expected = true); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new StdPropertyAccessor($decoratedAccessor); $actual = $accessor->isWritable($object, $property); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedAccessorProphecy->isWritable(Argument::cetera())->shouldHaveBeenCalledTimes(1); } @@ -166,8 +162,8 @@ public function testStdClassPropertiesAreReadableOnlyIfTheyExists(): void $object = StdClassFactory::create(['foo' => 'bar']); $accessor = new StdPropertyAccessor(new FakePropertyAccessor()); - static::assertTrue($accessor->isReadable($object, 'foo')); - static::assertFalse($accessor->isReadable($object, 'foz')); + self::assertTrue($accessor->isReadable($object, 'foo')); + self::assertFalse($accessor->isReadable($object, 'foz')); } public function testUsesDecoratedAccessorToDertermineIfPropertyIsReadbleIfObjectIsNotAnStdClassInstance(): void @@ -178,15 +174,14 @@ public function testUsesDecoratedAccessorToDertermineIfPropertyIsReadbleIfObject $decoratedAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); $decoratedAccessorProphecy ->isReadable($object, $property) - ->willReturn($expected = true) - ; + ->willReturn($expected = true); /** @var PropertyAccessorInterface $decoratedAccessor */ $decoratedAccessor = $decoratedAccessorProphecy->reveal(); $accessor = new StdPropertyAccessor($decoratedAccessor); $actual = $accessor->isReadable($object, $property); - static::assertEquals($expected, $actual); + self::assertEquals($expected, $actual); $decoratedAccessorProphecy->isReadable(Argument::cetera())->shouldHaveBeenCalledTimes(1); } diff --git a/tests/Throwable/BuildThrowableTest.php b/tests/Throwable/BuildThrowableTest.php index ea152de2f..bbd8f6395 100644 --- a/tests/Throwable/BuildThrowableTest.php +++ b/tests/Throwable/BuildThrowableTest.php @@ -18,11 +18,12 @@ /** * @coversNothing + * @internal */ class BuildThrowableTest extends TestCase { public function testIsABuildThrowable(): void { - static::assertTrue(is_a(RootBuildException::class, LoadingThrowable::class, true)); + self::assertTrue(is_a(RootBuildException::class, LoadingThrowable::class, true)); } } diff --git a/tests/Throwable/DenormalizationThrowableTest.php b/tests/Throwable/DenormalizationThrowableTest.php index 1d14c8b47..2a79631eb 100644 --- a/tests/Throwable/DenormalizationThrowableTest.php +++ b/tests/Throwable/DenormalizationThrowableTest.php @@ -18,11 +18,12 @@ /** * @coversNothing + * @internal */ class DenormalizationThrowableTest extends TestCase { public function testIsABuildThrowable(): void { - static::assertTrue(is_a(RootDenormalizationException::class, BuildThrowable::class, true)); + self::assertTrue(is_a(RootDenormalizationException::class, BuildThrowable::class, true)); } } diff --git a/tests/Throwable/Error/TypeErrorFactoryTest.php b/tests/Throwable/Error/TypeErrorFactoryTest.php index fa631ea16..fb4ae6f40 100644 --- a/tests/Throwable/Error/TypeErrorFactoryTest.php +++ b/tests/Throwable/Error/TypeErrorFactoryTest.php @@ -21,6 +21,7 @@ /** * @covers \Nelmio\Alice\Throwable\Error\TypeErrorFactory + * @internal */ class TypeErrorFactoryTest extends TestCase { @@ -28,272 +29,263 @@ public function testCreateForDynamicArrayQuantifier(): void { $error = TypeErrorFactory::createForDynamicArrayQuantifier(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' .'"stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForDynamicArrayQuantifier(10); - static::assertEquals( + self::assertEquals( 'Expected quantifier to be either an integer or a "'.ValueInterface::class.'". Got ' .'"integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForDynamicArrayElement(): void { $error = TypeErrorFactory::createForDynamicArrayElement(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' .'"stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForDynamicArrayElement(10); - static::assertEquals( + self::assertEquals( 'Expected element to be either string, an array or a "'.ValueInterface::class.'". Got ' .'"integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForOptionalValueQuantifier(): void { $error = TypeErrorFactory::createForOptionalValueQuantifier(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected quantifier to be either a scalar value or an instance of "'.ValueInterface::class.'". ' .'Got "stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForOptionalValueQuantifier(10); - static::assertEquals( + self::assertEquals( 'Expected quantifier to be either a scalar value or an instance of "'.ValueInterface::class.'". ' .'Got "integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForOptionalValueFirstMember(): void { $error = TypeErrorFactory::createForOptionalValueFirstMember(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected first member to be either a string or an instance of "'.ValueInterface::class.'". ' .'Got "stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForOptionalValueFirstMember(10); - static::assertEquals( + self::assertEquals( 'Expected first member to be either a string or an instance of "'.ValueInterface::class.'". ' .'Got "integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForOptionalValueSecondMember(): void { $error = TypeErrorFactory::createForOptionalValueSecondMember(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected second member to be either null, a string or an instance of "'.ValueInterface::class.'". ' .'Got "stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForOptionalValueSecondMember(10); - static::assertEquals( + self::assertEquals( 'Expected second member to be either null, a string or an instance of "'.ValueInterface::class.'". ' .'Got "integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidParameterKey(): void { $error = TypeErrorFactory::createForInvalidParameterKey(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected parameter key to be either a string or an instance of "'.ValueInterface::class.'". ' .'Got "stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForInvalidParameterKey(10); - static::assertEquals( + self::assertEquals( 'Expected parameter key to be either a string or an instance of "'.ValueInterface::class.'". ' .'Got "integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidDenormalizerType(): void { $error = TypeErrorFactory::createForInvalidDenormalizerType(2, new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected denormalizer 2 to be a "'.ChainableFixtureDenormalizerInterface::class.'". Got ' .'"stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForInvalidDenormalizerType(2, 10); - static::assertEquals( + self::assertEquals( 'Expected denormalizer 2 to be a "'.ChainableFixtureDenormalizerInterface::class.'". Got ' .'"integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidSpecificationBagMethodCall(): void { $error = TypeErrorFactory::createForInvalidSpecificationBagMethodCall(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected method call value to be an array. Got "object" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidSpecificationBagMethodCallName(): void { $error = TypeErrorFactory::createForInvalidSpecificationBagMethodCallName(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected method name. Got "object" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidFixtureBagParameters(): void { $error = TypeErrorFactory::createForInvalidFixtureBagParameters(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected parameters to be an array. Got "stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForInvalidFixtureBagParameters(10); - static::assertEquals( + self::assertEquals( 'Expected parameters to be an array. Got "integer" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidIncludeStatementInData(): void { $error = TypeErrorFactory::createForInvalidIncludeStatementInData(new stdClass(), 'foo.yml'); - static::assertEquals( + self::assertEquals( 'Expected include statement to be either null or an array of files to include. Got "object" ' .'instead in file "foo.yml".', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidIncludedFilesInData(): void { $error = TypeErrorFactory::createForInvalidIncludedFilesInData(new stdClass(), 'foo.yml'); - static::assertEquals( + self::assertEquals( 'Expected elements of include statement to be file names. Got "object" instead in file "foo.yml".', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidFixtureFileReturnedData(): void { $error = TypeErrorFactory::createForInvalidFixtureFileReturnedData('foo.yml'); - static::assertEquals( + self::assertEquals( 'The file "foo.yml" must return a PHP array.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } public function testCreateForInvalidChainableParameterResolver(): void { $error = TypeErrorFactory::createForInvalidChainableParameterResolver(new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected resolvers to be "'.ParameterResolverInterface::class.'" objects. Got "stdClass" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); - + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); $error = TypeErrorFactory::createForInvalidChainableParameterResolver(10); - static::assertEquals( + self::assertEquals( 'Expected resolvers to be "'.ParameterResolverInterface::class.'" objects. Got "10" instead.', - $error->getMessage() + $error->getMessage(), ); - static::assertEquals(0, $error->getCode()); - static::assertNull($error->getPrevious()); + self::assertEquals(0, $error->getCode()); + self::assertNull($error->getPrevious()); } } diff --git a/tests/Throwable/Exception/BadMethodCallExceptionFactoryTest.php b/tests/Throwable/Exception/BadMethodCallExceptionFactoryTest.php index 09b0f889c..750ff3ecc 100644 --- a/tests/Throwable/Exception/BadMethodCallExceptionFactoryTest.php +++ b/tests/Throwable/Exception/BadMethodCallExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\BadMethodCallExceptionFactory + * @internal */ class BadMethodCallExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateForUnknownMethod(): void { $exception = BadMethodCallExceptionFactory::createForUnknownMethod('foo'); - static::assertEquals( + self::assertEquals( 'Unknown method "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/FileLocator/FileNotFoundExceptionTest.php b/tests/Throwable/Exception/FileLocator/FileNotFoundExceptionTest.php index a9fb53d9a..3e4af34d6 100644 --- a/tests/Throwable/Exception/FileLocator/FileNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/FileLocator/FileNotFoundExceptionTest.php @@ -18,41 +18,42 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FileLocator\FileNotFoundException + * @internal */ class FileNotFoundExceptionTest extends TestCase { public function testIsAnUnexpectedValueException(): void { - static::assertTrue(is_a(FileNotFoundException::class, UnexpectedValueException::class, true)); + self::assertTrue(is_a(FileNotFoundException::class, UnexpectedValueException::class, true)); } public function testIsExtensible(): void { $exception = new ChildFileNotFoundException(); - static::assertInstanceOf(ChildFileNotFoundException::class, $exception); + self::assertInstanceOf(ChildFileNotFoundException::class, $exception); } public function testCreateForEmptyFile(): void { $exception = FileNotFoundException::createForEmptyFile(); - static::assertEquals( + self::assertEquals( 'An empty file name is not valid to be located.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForNonExistentFile(): void { $exception = FileNotFoundException::createForNonExistentFile('foo.yml'); - static::assertEquals( + self::assertEquals( 'The file "foo.yml" does not exist.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactoryTest.php b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactoryTest.php index ebb3f54d9..c2f9f1fe3 100644 --- a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactoryTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactoryTest.php @@ -18,29 +18,30 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\DenormalizerExceptionFactory + * @internal */ class DenormalizerExceptionFactoryTest extends TestCase { public function testCreateForUndenormalizableConstructor(): void { $exception = DenormalizerExceptionFactory::createForUndenormalizableConstructor(); - static::assertEquals( + self::assertEquals( 'Could not denormalize the given constructor.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForUndenormalizableFactory(): void { $exception = DenormalizerExceptionFactory::createForUndenormalizableFactory(); - static::assertEquals( + self::assertEquals( 'Could not denormalize the given factory.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForUnparsableValue(): void @@ -49,47 +50,47 @@ public function testCreateForUnparsableValue(): void $previous = new Error(); $exception = DenormalizerExceptionFactory::createForUnparsableValue('foo', $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not parse value "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateDenormalizerNotFoundForFixture(): void { $exception = DenormalizerExceptionFactory::createDenormalizerNotFoundForFixture('foo'); - static::assertEquals( + self::assertEquals( 'No suitable fixture denormalizer found to handle the fixture with the reference "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateDenormalizerNotFoundUnexpectedCall(): void { $exception = DenormalizerExceptionFactory::createDenormalizerNotFoundUnexpectedCall('fake'); - static::assertEquals( + self::assertEquals( 'Expected method "fake" to be called only if it has a denormalizer.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidScopeForUniqueValue(): void { $exception = DenormalizerExceptionFactory::createForInvalidScopeForUniqueValue(); - static::assertEquals( + self::assertEquals( 'Cannot bind a unique value scope to a temporary fixture.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php index d603fd04a..ed41be34c 100644 --- a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\DenormalizerNotFoundException + * @internal */ class DenormalizerNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(DenormalizerNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(DenormalizerNotFoundException::class, LogicException::class, true)); } public function testIsNotADenormalizationThrowable(): void { - static::assertFalse(is_a(DenormalizerNotFoundException::class, DenormalizationThrowable::class, true)); + self::assertFalse(is_a(DenormalizerNotFoundException::class, DenormalizationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildDenormalizerNotFoundException(); - static::assertInstanceOf(ChildDenormalizerNotFoundException::class, $exception); + self::assertInstanceOf(ChildDenormalizerNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactoryTest.php b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactoryTest.php index 42f59ede4..3f7f61f98 100644 --- a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactoryTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\FlagParser\FlagParserExceptionFactory + * @internal */ class FlagParserExceptionFactoryTest extends TestCase { @@ -24,23 +25,23 @@ public function testCreateNewException(): void { $exception = FlagParserExceptionFactory::createForNoParserFoundForElement('foo'); - static::assertEquals( + self::assertEquals( 'No suitable flag parser found to handle the element "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateNewExceptionForUnexpectedCall(): void { $exception = FlagParserExceptionFactory::createForExpectedMethodToBeCalledIfHasAParser('foo'); - static::assertEquals( + self::assertEquals( 'Expected method "foo" to be called only if it has a flag parser.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php index fd281c96d..ed7971ae4 100644 --- a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\FlagParser\FlagParserNotFoundException + * @internal */ class FlagParserNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(FlagParserNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(FlagParserNotFoundException::class, LogicException::class, true)); } public function testIsNotADenormalizationThrowable(): void { - static::assertFalse(is_a(FlagParserNotFoundException::class, DenormalizationThrowable::class, true)); + self::assertFalse(is_a(FlagParserNotFoundException::class, DenormalizationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildFlagParserNotFoundException(); - static::assertInstanceOf(ChildFlagParserNotFoundException::class, $exception); + self::assertInstanceOf(ChildFlagParserNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/InvalidScopeExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/InvalidScopeExceptionTest.php index 2140345f6..facc3ebcb 100644 --- a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/InvalidScopeExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/InvalidScopeExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\InvalidScopeException + * @internal */ class InvalidScopeExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(InvalidScopeException::class, RuntimeException::class, true)); + self::assertTrue(is_a(InvalidScopeException::class, RuntimeException::class, true)); } public function testIsADenormalizationThrowable(): void { - static::assertTrue(is_a(InvalidScopeException::class, DenormalizationThrowable::class, true)); + self::assertTrue(is_a(InvalidScopeException::class, DenormalizationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildInvalidScopeException(); - static::assertInstanceOf(ChildInvalidScopeException::class, $exception); + self::assertInstanceOf(ChildInvalidScopeException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php index 6e9d506d7..ddaf753dd 100644 --- a/tests/Throwable/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\UnexpectedValueException + * @internal */ class UnexpectedValueExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(UnexpectedValueException::class, RuntimeException::class, true)); + self::assertTrue(is_a(UnexpectedValueException::class, RuntimeException::class, true)); } public function testIsADenormalizationThrowable(): void { - static::assertTrue(is_a(UnexpectedValueException::class, DenormalizationThrowable::class, true)); + self::assertTrue(is_a(UnexpectedValueException::class, DenormalizationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildUnexpectedValueException(); - static::assertInstanceOf(ChildUnexpectedValueException::class, $exception); + self::assertInstanceOf(ChildUnexpectedValueException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactoryTest.php b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactoryTest.php index 7417f7e3f..608d08fbb 100644 --- a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactoryTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ExpressionLanguageExceptionFactoryTest.php @@ -20,6 +20,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\ExpressionLanguageExceptionFactory + * @internal */ class ExpressionLanguageExceptionFactoryTest extends TestCase { @@ -28,24 +29,24 @@ public function testCreateForNoParserFoundForToken(): void $token = new Token('foo', new TokenType(TokenType::DYNAMIC_ARRAY_TYPE)); $exception = ExpressionLanguageExceptionFactory::createForNoParserFoundForToken($token); - static::assertEquals( + self::assertEquals( 'No suitable token parser found to handle the token "foo" (type: DYNAMIC_ARRAY_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForExpectedMethodCallOnlyIfHasAParser(): void { $exception = ExpressionLanguageExceptionFactory::createForExpectedMethodCallOnlyIfHasAParser('foo'); - static::assertEquals( + self::assertEquals( 'Expected method "foo" to be called only if it has a parser.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForUnparsableToken(): void @@ -53,47 +54,46 @@ public function testCreateForUnparsableToken(): void $token = new Token('foo', new TokenType(TokenType::DYNAMIC_ARRAY_TYPE)); $exception = ExpressionLanguageExceptionFactory::createForUnparsableToken($token); - static::assertEquals( + self::assertEquals( 'Could not parse the token "foo" (type: DYNAMIC_ARRAY_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = ExpressionLanguageExceptionFactory::createForUnparsableToken($token, $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not parse the token "foo" (type: DYNAMIC_ARRAY_TYPE).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForMalformedFunction(): void { $exception = ExpressionLanguageExceptionFactory::createForMalformedFunction('foo'); - static::assertEquals( + self::assertEquals( 'The value "foo" contains an unclosed function.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForCouldNotLexValue(): void { $exception = ExpressionLanguageExceptionFactory::createForCouldNotLexValue('foo'); - static::assertEquals( + self::assertEquals( 'Could not lex the value "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php index 3f4397e4d..3981a937f 100644 --- a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\LexException + * @internal */ class LexExceptionTest extends TestCase { public function testIsAnException(): void { - static::assertTrue(is_a(LexException::class, Exception::class, true)); + self::assertTrue(is_a(LexException::class, Exception::class, true)); } public function testIsAParseThrowable(): void { - static::assertTrue(is_a(LexException::class, ExpressionLanguageParseThrowable::class, true)); + self::assertTrue(is_a(LexException::class, ExpressionLanguageParseThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildLexException(); - static::assertInstanceOf(ChildLexException::class, $exception); + self::assertInstanceOf(ChildLexException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/MalformedFunctionExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/MalformedFunctionExceptionTest.php index f56932bc8..4aad66cfd 100644 --- a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/MalformedFunctionExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/MalformedFunctionExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\MalformedFunctionException + * @internal */ class MalformedFunctionExceptionTest extends TestCase { public function testIsAnInvalidArgumentException(): void { - static::assertTrue(is_a(MalformedFunctionException::class, InvalidArgumentException::class, true)); + self::assertTrue(is_a(MalformedFunctionException::class, InvalidArgumentException::class, true)); } public function testIsNotAParseThrowable(): void { - static::assertFalse(is_a(MalformedFunctionException::class, ExpressionLanguageParseThrowable::class, true)); + self::assertFalse(is_a(MalformedFunctionException::class, ExpressionLanguageParseThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildMalformedFunctionException(); - static::assertInstanceOf(ChildMalformedFunctionException::class, $exception); + self::assertInstanceOf(ChildMalformedFunctionException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php index 4abde4482..ebddcb5fa 100644 --- a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\ParseException + * @internal */ class ParseExceptionTest extends TestCase { public function testIsAnException(): void { - static::assertTrue(is_a(ParseException::class, Exception::class, true)); + self::assertTrue(is_a(ParseException::class, Exception::class, true)); } public function testIsAParseThrowable(): void { - static::assertTrue(is_a(ParseException::class, ExpressionLanguageParseThrowable::class, true)); + self::assertTrue(is_a(ParseException::class, ExpressionLanguageParseThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildParseException(); - static::assertInstanceOf(ChildParseException::class, $exception); + self::assertInstanceOf(ChildParseException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php index 7e03aaaf3..033876a1b 100644 --- a/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\ParserNotFoundException + * @internal */ class ParserNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(ParserNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(ParserNotFoundException::class, LogicException::class, true)); } public function testIsNotAParseThrowable(): void { - static::assertFalse(is_a(ParserNotFoundException::class, ExpressionLanguageParseThrowable::class, true)); + self::assertFalse(is_a(ParserNotFoundException::class, ExpressionLanguageParseThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildParserNotFoundException(); - static::assertInstanceOf(ChildParserNotFoundException::class, $exception); + self::assertInstanceOf(ChildParserNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/FixtureNotFoundExceptionFactoryTest.php b/tests/Throwable/Exception/FixtureNotFoundExceptionFactoryTest.php index 887bb3dbc..9bc15c1dd 100644 --- a/tests/Throwable/Exception/FixtureNotFoundExceptionFactoryTest.php +++ b/tests/Throwable/Exception/FixtureNotFoundExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureNotFoundExceptionFactory + * @internal */ class FixtureNotFoundExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateNewExceptionWithFactory(): void { $exception = FixtureNotFoundExceptionFactory::create('foo'); - static::assertEquals( + self::assertEquals( 'Could not find the fixture "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/FixtureNotFoundExceptionTest.php b/tests/Throwable/Exception/FixtureNotFoundExceptionTest.php index c6f1a9eb2..f35b0cc17 100644 --- a/tests/Throwable/Exception/FixtureNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/FixtureNotFoundExceptionTest.php @@ -18,17 +18,18 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\FixtureNotFoundException + * @internal */ class FixtureNotFoundExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(FixtureNotFoundException::class, RuntimeException::class, true)); + self::assertTrue(is_a(FixtureNotFoundException::class, RuntimeException::class, true)); } public function testIsExtensible(): void { $exception = new ChildFixtureNotFoundException(); - static::assertInstanceOf(ChildFixtureNotFoundException::class, $exception); + self::assertInstanceOf(ChildFixtureNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactoryTest.php index d946c3578..c341694a7 100644 --- a/tests/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Caller/CallProcessorExceptionFactoryTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Caller\CallProcessorExceptionFactory + * @internal */ class CallProcessorExceptionFactoryTest extends TestCase { @@ -25,11 +26,11 @@ public function testCreateForNoProcessorFoundForMethodCall(): void { $exception = CallProcessorExceptionFactory::createForNoProcessorFoundForMethodCall(new DummyMethodCall('dummy')); - static::assertEquals( + self::assertEquals( 'No suitable processor found to handle the method call "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Caller/ProcessorNotFoundExceptionTest.php b/tests/Throwable/Exception/Generator/Caller/ProcessorNotFoundExceptionTest.php index d090f4b4c..8b06b823c 100644 --- a/tests/Throwable/Exception/Generator/Caller/ProcessorNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Caller/ProcessorNotFoundExceptionTest.php @@ -20,22 +20,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Caller\ProcessorNotFoundException + * @internal */ class ProcessorNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(ProcessorNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(ProcessorNotFoundException::class, LogicException::class, true)); } public function testIsNotAnInstantiationThrowable(): void { - static::assertFalse(is_a(ProcessorNotFoundException::class, InstantiationThrowable::class, true)); + self::assertFalse(is_a(ProcessorNotFoundException::class, InstantiationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildInstantiatorNotFoundException(); - static::assertInstanceOf(ChildInstantiatorNotFoundException::class, $exception); + self::assertInstanceOf(ChildInstantiatorNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Context/CachedValueNotFoundTest.php b/tests/Throwable/Exception/Generator/Context/CachedValueNotFoundTest.php index 44963e1df..8234c1b59 100644 --- a/tests/Throwable/Exception/Generator/Context/CachedValueNotFoundTest.php +++ b/tests/Throwable/Exception/Generator/Context/CachedValueNotFoundTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Context\CachedValueNotFound + * @internal */ class CachedValueNotFoundTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreate(): void { $exception = CachedValueNotFound::create('foo'); - static::assertEquals( + self::assertEquals( 'No value with the key "foo" was found in the cache.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactoryTest.php index d12fcf721..6d0d82cca 100644 --- a/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionFactoryTest.php @@ -21,6 +21,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Hydrator\HydrationExceptionFactory + * @internal */ class HydrationExceptionFactoryTest extends TestCase { @@ -33,12 +34,12 @@ public function testCreate(): void $previous = new Error(); $exception = HydrationExceptionFactory::create($object, $property, $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not hydrate the property "foo" of the object "dummy" (class: stdClass).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForInaccessibleProperty(): void @@ -47,24 +48,23 @@ public function testCreateForInaccessibleProperty(): void $property = new Property('foo', 'bar'); $exception = HydrationExceptionFactory::createForInaccessibleProperty($object, $property); - static::assertEquals( + self::assertEquals( 'Could not access to the property "foo" of the object "dummy" (class: stdClass).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = HydrationExceptionFactory::createForInaccessibleProperty($object, $property, $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not access to the property "foo" of the object "dummy" (class: stdClass).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForInvalidProperty(): void @@ -73,24 +73,23 @@ public function testCreateForInvalidProperty(): void $property = new Property('foo', 'bar'); $exception = HydrationExceptionFactory::createForInvalidProperty($object, $property); - static::assertEquals( + self::assertEquals( 'Invalid value given for the property "foo" of the object "dummy" (class: stdClass).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = HydrationExceptionFactory::createForInvalidProperty($object, $property, $code, $previous); - static::assertEquals( + self::assertEquals( 'Invalid value given for the property "foo" of the object "dummy" (class: stdClass).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForCouldNotHydrateObjectWithProperty(): void @@ -99,23 +98,22 @@ public function testCreateForCouldNotHydrateObjectWithProperty(): void $property = new Property('foo', 'bar'); $exception = HydrationExceptionFactory::createForCouldNotHydrateObjectWithProperty($object, $property); - static::assertEquals( + self::assertEquals( 'Could not hydrate the property "foo" of the object "dummy" (class: stdClass).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = HydrationExceptionFactory::createForCouldNotHydrateObjectWithProperty($object, $property, $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not hydrate the property "foo" of the object "dummy" (class: stdClass).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionTest.php b/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionTest.php index eb5fd6cac..4a3ede033 100644 --- a/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Hydrator/HydrationExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Hydrator\HydrationException + * @internal */ class HydrationExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(HydrationException::class, RuntimeException::class, true)); + self::assertTrue(is_a(HydrationException::class, RuntimeException::class, true)); } public function testIsAHydrationThrowable(): void { - static::assertTrue(is_a(HydrationException::class, HydrationThrowable::class, true)); + self::assertTrue(is_a(HydrationException::class, HydrationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildHydrationException(); - static::assertInstanceOf(ChildHydrationException::class, $exception); + self::assertInstanceOf(ChildHydrationException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Hydrator/InaccessiblePropertyExceptionTest.php b/tests/Throwable/Exception/Generator/Hydrator/InaccessiblePropertyExceptionTest.php index fa54fad23..c743c77cd 100644 --- a/tests/Throwable/Exception/Generator/Hydrator/InaccessiblePropertyExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Hydrator/InaccessiblePropertyExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Hydrator\InaccessiblePropertyException + * @internal */ class InaccessiblePropertyExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(InaccessiblePropertyException::class, RuntimeException::class, true)); + self::assertTrue(is_a(InaccessiblePropertyException::class, RuntimeException::class, true)); } public function testIsAHydrationThrowable(): void { - static::assertTrue(is_a(InaccessiblePropertyException::class, HydrationThrowable::class, true)); + self::assertTrue(is_a(InaccessiblePropertyException::class, HydrationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildInaccessiblePropertyException(); - static::assertInstanceOf(ChildInaccessiblePropertyException::class, $exception); + self::assertInstanceOf(ChildInaccessiblePropertyException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php b/tests/Throwable/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php index ddfb05d9d..f82f9953d 100644 --- a/tests/Throwable/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php @@ -22,17 +22,18 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Hydrator\InvalidArgumentException + * @internal */ class InvalidArgumentExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(InvalidArgumentException::class, RuntimeException::class, true)); + self::assertTrue(is_a(InvalidArgumentException::class, RuntimeException::class, true)); } public function testIsAHydrationThrowable(): void { - static::assertTrue(is_a(InvalidArgumentException::class, HydrationThrowable::class, true)); + self::assertTrue(is_a(InvalidArgumentException::class, HydrationThrowable::class, true)); } public function testIsExtensible(): void @@ -41,6 +42,6 @@ public function testIsExtensible(): void $property = new Property('foo', 'bar'); $exception = new ChildInvalidArgumentException(); - static::assertInstanceOf(ChildInvalidArgumentException::class, $exception); + self::assertInstanceOf(ChildInvalidArgumentException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php b/tests/Throwable/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php index f44369e1a..911eb1759 100644 --- a/tests/Throwable/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Hydrator\NoSuchPropertyException + * @internal */ class NoSuchPropertyExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(NoSuchPropertyException::class, RuntimeException::class, true)); + self::assertTrue(is_a(NoSuchPropertyException::class, RuntimeException::class, true)); } public function testIsAHydrationThrowable(): void { - static::assertTrue(is_a(NoSuchPropertyException::class, HydrationThrowable::class, true)); + self::assertTrue(is_a(NoSuchPropertyException::class, HydrationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildNoSuchPropertyException(); - static::assertInstanceOf(ChildNoSuchPropertyException::class, $exception); + self::assertInstanceOf(ChildNoSuchPropertyException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactoryTest.php index 7a96ea097..d0c82e80b 100644 --- a/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionFactoryTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Instantiator\InstantiationExceptionFactory + * @internal */ class InstantiationExceptionFactoryTest extends TestCase { @@ -31,82 +32,82 @@ public function testCreate(): void $previous = new Error(); $exception = InstantiationExceptionFactory::create(new DummyFixture('foo'), $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not instantiate fixture "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForNonPublicConstructor(): void { $exception = InstantiationExceptionFactory::createForNonPublicConstructor( - new SimpleFixture('foo', 'Dummy', SpecificationBagFactory::create()) + new SimpleFixture('foo', 'Dummy', SpecificationBagFactory::create()), ); - static::assertEquals( + self::assertEquals( 'Could not instantiate "foo", the constructor of "Dummy" is not public.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForConstructorIsMissingMandatoryParameters(): void { $exception = InstantiationExceptionFactory::createForConstructorIsMissingMandatoryParameters( - new DummyFixture('foo') + new DummyFixture('foo'), ); - static::assertEquals( + self::assertEquals( 'Could not instantiate "foo", the constructor has mandatory parameters but no parameters have been given.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForCouldNotGetConstructorData(): void { $exception = InstantiationExceptionFactory::createForCouldNotGetConstructorData( - new DummyFixture('foo') + new DummyFixture('foo'), ); - static::assertEquals( + self::assertEquals( 'Could not get the necessary data on the constructor to instantiate "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidInstanceType(): void { $exception = InstantiationExceptionFactory::createForInvalidInstanceType( new SimpleFixture('foo', 'Dummy', SpecificationBagFactory::create()), - new stdClass() + new stdClass(), ); - static::assertEquals( + self::assertEquals( 'Instantiated fixture was expected to be an instance of "Dummy". Got "stdClass" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInstantiatorNotFoundForFixture(): void { $exception = InstantiationExceptionFactory::createForInstantiatorNotFoundForFixture( - new DummyFixture('foo') + new DummyFixture('foo'), ); - static::assertEquals( + self::assertEquals( 'No suitable instantiator found for the fixture "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionTest.php b/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionTest.php index 4ad168565..668ee7f97 100644 --- a/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Instantiator/InstantiationExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Instantiator\InstantiationException + * @internal */ class InstantiationExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(InstantiationException::class, RuntimeException::class, true)); + self::assertTrue(is_a(InstantiationException::class, RuntimeException::class, true)); } public function testIsAnInstantiationThrowable(): void { - static::assertTrue(is_a(InstantiationException::class, InstantiationThrowable::class, true)); + self::assertTrue(is_a(InstantiationException::class, InstantiationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildInstantiationException(); - static::assertInstanceOf(ChildInstantiationException::class, $exception); + self::assertInstanceOf(ChildInstantiationException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php b/tests/Throwable/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php index 9a92fc160..bdb599c8f 100644 --- a/tests/Throwable/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Instantiator\InstantiatorNotFoundException + * @internal */ class InstantiatorNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(InstantiatorNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(InstantiatorNotFoundException::class, LogicException::class, true)); } public function testIsNotAnInstantiationThrowable(): void { - static::assertFalse(is_a(InstantiatorNotFoundException::class, InstantiationThrowable::class, true)); + self::assertFalse(is_a(InstantiatorNotFoundException::class, InstantiationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildInstantiatorNotFoundException(); - static::assertInstanceOf(ChildInstantiatorNotFoundException::class, $exception); + self::assertInstanceOf(ChildInstantiatorNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactoryTest.php index 538306d5e..60e97baea 100644 --- a/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\ObjectGenerator\ObjectGeneratorNotFoundExceptionFactory + * @internal */ class ObjectGeneratorNotFoundExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateNewExceptionWithFactory(): void { $exception = ObjectGeneratorNotFoundExceptionFactory::createUnexpectedCall('dummyMethod'); - static::assertEquals( + self::assertEquals( 'Expected method "dummyMethod" to be called only if it has a generator.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php b/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php index afc31d133..0330c09f9 100644 --- a/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\ObjectGenerator\ObjectGeneratorNotFoundException + * @internal */ class ObjectGeneratorNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(ObjectGeneratorNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(ObjectGeneratorNotFoundException::class, LogicException::class, true)); } public function testIsNotAGenerationThrowable(): void { - static::assertFalse(is_a(ObjectGeneratorNotFoundException::class, GenerationThrowable::class, true)); + self::assertFalse(is_a(ObjectGeneratorNotFoundException::class, GenerationThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildObjectGeneratorNotFoundException(); - static::assertInstanceOf(ChildObjectGeneratorNotFoundException::class, $exception); + self::assertInstanceOf(ChildObjectGeneratorNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactoryTest.php index c43f793c0..e0063409d 100644 --- a/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\CircularReferenceExceptionFactory + * @internal */ class CircularReferenceExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateNewExceptionWithFactory(): void { $exception = CircularReferenceExceptionFactory::createForParameter('foo', ['bar' => 1, 'baz' => 0]); - static::assertEquals( + self::assertEquals( 'Circular reference detected for the parameter "foo" while resolving ["bar", "baz"].', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionTest.php index 305c88a45..67c300e24 100644 --- a/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/CircularReferenceExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\CircularReferenceException + * @internal */ class CircularReferenceExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(CircularReferenceException::class, RuntimeException::class, true)); + self::assertTrue(is_a(CircularReferenceException::class, RuntimeException::class, true)); } public function testIsAResolutionThrowable(): void { - static::assertTrue(is_a(CircularReferenceException::class, ResolutionThrowable::class, true)); + self::assertTrue(is_a(CircularReferenceException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildCircularReferenceException(); - static::assertInstanceOf(ChildCircularReferenceException::class, $exception); + self::assertInstanceOf(ChildCircularReferenceException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactoryTest.php index b25d70cf3..a3a71b29b 100644 --- a/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\FixtureNotFoundExceptionFactory + * @internal */ class FixtureNotFoundExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateNewExceptionWithFactory(): void { $exception = FixtureNotFoundExceptionFactory::create('foo'); - static::assertEquals( + self::assertEquals( 'Could not find the fixture "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionTest.php index b45ecd115..51771ab3e 100644 --- a/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\FixtureNotFoundException + * @internal */ class FixtureNotFoundExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(FixtureNotFoundException::class, RuntimeException::class, true)); + self::assertTrue(is_a(FixtureNotFoundException::class, RuntimeException::class, true)); } public function testIsAResolutionThrowable(): void { - static::assertTrue(is_a(FixtureNotFoundException::class, ResolutionThrowable::class, true)); + self::assertTrue(is_a(FixtureNotFoundException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildFixtureNotFoundException(); - static::assertInstanceOf(ChildFixtureNotFoundException::class, $exception); + self::assertInstanceOf(ChildFixtureNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactoryTest.php index e579357e0..97c12efa5 100644 --- a/tests/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/NoSuchMethodExceptionFactoryTest.php @@ -23,6 +23,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\NoSuchMethodExceptionFactory + * @internal */ class NoSuchMethodExceptionFactoryTest extends TestCase { @@ -31,29 +32,28 @@ public function testCreateForFixture(): void $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()); $methodCall = new FixtureMethodCallValue( new DummyValue('dummy'), - new FunctionCallValue('foo') + new FunctionCallValue('foo'), ); $exception = NoSuchMethodExceptionFactory::createForFixture($fixture, $methodCall); - static::assertEquals( + self::assertEquals( 'Could not find the method "foo" of the object "dummy" (class: Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = NoSuchMethodExceptionFactory::createForFixture($fixture, $methodCall, $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not find the method "foo" of the object "dummy" (class: Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactoryTest.php index 3a2a05471..f7e3f46c2 100644 --- a/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionFactoryTest.php @@ -22,6 +22,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\NoSuchPropertyExceptionFactory + * @internal */ class NoSuchPropertyExceptionFactoryTest extends TestCase { @@ -32,24 +33,23 @@ public function testCreateForFixture(): void $exception = NoSuchPropertyExceptionFactory::createForFixture($fixture, $property); - static::assertEquals( + self::assertEquals( 'Could not find the property "foo" of the object "dummy" (class: Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = NoSuchPropertyExceptionFactory::createForFixture($fixture, $property, $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not find the property "foo" of the object "dummy" (class: Dummy).', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionTest.php index ae676f3fa..461310899 100644 --- a/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/NoSuchPropertyExceptionTest.php @@ -19,27 +19,28 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\NoSuchPropertyException + * @internal */ class NoSuchPropertyExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(NoSuchPropertyException::class, RuntimeException::class, true)); + self::assertTrue(is_a(NoSuchPropertyException::class, RuntimeException::class, true)); } public function testIsAnUnresolvableValueException(): void { - static::assertTrue(is_a(NoSuchPropertyException::class, UnresolvableValueException::class, true)); + self::assertTrue(is_a(NoSuchPropertyException::class, UnresolvableValueException::class, true)); } public function testIsAResolutionThrowable(): void { - static::assertTrue(is_a(NoSuchPropertyException::class, ResolutionThrowable::class, true)); + self::assertTrue(is_a(NoSuchPropertyException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildNoSuchPropertyException(); - static::assertInstanceOf(ChildNoSuchPropertyException::class, $exception); + self::assertInstanceOf(ChildNoSuchPropertyException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactoryTest.php index 8bc514397..c933a7e41 100644 --- a/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\RecursionLimitReachedExceptionFactory + * @internal */ class RecursionLimitReachedExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateNewExceptionWithFactory(): void { $exception = RecursionLimitReachedExceptionFactory::create(10, 'foo'); - static::assertEquals( + self::assertEquals( 'Recursion limit (10 tries) reached while resolving the parameter "foo"', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php index cc83c26ba..b6ea6f186 100644 --- a/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\RecursionLimitReachedException + * @internal */ class RecursionLimitReachedExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(RecursionLimitReachedException::class, RuntimeException::class, true)); + self::assertTrue(is_a(RecursionLimitReachedException::class, RuntimeException::class, true)); } public function testIsAResolutionThrowable(): void { - static::assertTrue(is_a(RecursionLimitReachedException::class, ResolutionThrowable::class, true)); + self::assertTrue(is_a(RecursionLimitReachedException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildRecursionLimitReachedException(); - static::assertInstanceOf(ChildRecursionLimitReachedException::class, $exception); + self::assertInstanceOf(ChildRecursionLimitReachedException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactoryTest.php index 9ca1d071f..15115250b 100644 --- a/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionFactoryTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\ResolverNotFoundExceptionFactory + * @internal */ class ResolverNotFoundExceptionFactoryTest extends TestCase { @@ -25,35 +26,35 @@ public function testCreateNewExceptionWithFactoryForParameter(): void { $exception = ResolverNotFoundExceptionFactory::createForParameter('foo'); - static::assertEquals( + self::assertEquals( 'No resolver found to resolve parameter "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateNewExceptionWithFactoryForValue(): void { $exception = ResolverNotFoundExceptionFactory::createForValue(new DummyValue('dummy')); - static::assertEquals( + self::assertEquals( 'No resolver found to resolve value "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateNewExceptionWithFactoryForUnexpectedCall(): void { $exception = ResolverNotFoundExceptionFactory::createUnexpectedCall('fake'); - static::assertEquals( + self::assertEquals( 'Expected method "fake" to be called only if it has a resolver.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php index 8ac1e9bd9..537420bac 100644 --- a/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\ResolverNotFoundException + * @internal */ class ResolverNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(ResolverNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(ResolverNotFoundException::class, LogicException::class, true)); } public function testIsNotAResolutionThrowable(): void { - static::assertFalse(is_a(ResolverNotFoundException::class, ResolutionThrowable::class, true)); + self::assertFalse(is_a(ResolverNotFoundException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildResolverNotFoundException(); - static::assertInstanceOf(ChildResolverNotFoundException::class, $exception); + self::assertInstanceOf(ChildResolverNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactoryTest.php index 2128c8168..d61108192 100644 --- a/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionFactoryTest.php @@ -19,6 +19,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UniqueValueGenerationLimitReachedExceptionFactory + * @internal */ class UniqueValueGenerationLimitReachedExceptionFactoryTest extends TestCase { @@ -26,14 +27,14 @@ public function testCreateNewExceptionWithFactory(): void { $exception = UniqueValueGenerationLimitReachedExceptionFactory::create( new UniqueValue('unique_id', new stdClass()), - 10 + 10, ); - static::assertEquals( + self::assertEquals( 'Could not generate a unique value after 10 attempts for "unique_id".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php index 11ba08173..a69b0f759 100644 --- a/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UniqueValueGenerationLimitReachedException + * @internal */ class UniqueValueGenerationLimitReachedExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(UniqueValueGenerationLimitReachedException::class, RuntimeException::class, true)); + self::assertTrue(is_a(UniqueValueGenerationLimitReachedException::class, RuntimeException::class, true)); } public function testIsAResolutionThrowable(): void { - static::assertTrue(is_a(UniqueValueGenerationLimitReachedException::class, ResolutionThrowable::class, true)); + self::assertTrue(is_a(UniqueValueGenerationLimitReachedException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildUniqueValueGenerationLimitReachedException(); - static::assertInstanceOf(ChildUniqueValueGenerationLimitReachedException::class, $exception); + self::assertInstanceOf(ChildUniqueValueGenerationLimitReachedException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactoryTest.php index e1c81d5e4..f150d73c1 100644 --- a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionFactoryTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueDuringGenerationExceptionFactory + * @internal */ class UnresolvableValueDuringGenerationExceptionFactoryTest extends TestCase { @@ -27,11 +28,11 @@ public function testCreateFromResolutionThrowable(): void $exception = UnresolvableValueDuringGenerationExceptionFactory::createFromResolutionThrowable($previous); - static::assertEquals( + self::assertEquals( 'Could not resolve value during the generation process.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionTest.php index 3e267472f..b62abebc9 100644 --- a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueDuringGenerationExceptionTest.php @@ -19,27 +19,28 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueDuringGenerationException + * @internal */ class UnresolvableValueDuringGenerationExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(UnresolvableValueDuringGenerationException::class, RuntimeException::class, true)); + self::assertTrue(is_a(UnresolvableValueDuringGenerationException::class, RuntimeException::class, true)); } public function testIsAnUnresolvableValueException(): void { - static::assertTrue(is_a(UnresolvableValueDuringGenerationException::class, UnresolvableValueException::class, true)); + self::assertTrue(is_a(UnresolvableValueDuringGenerationException::class, UnresolvableValueException::class, true)); } public function testIsAResolutionThrowable(): void { - static::assertTrue(is_a(UnresolvableValueDuringGenerationException::class, ResolutionThrowable::class, true)); + self::assertTrue(is_a(UnresolvableValueDuringGenerationException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildUnresolvableValueDuringGenerationException(); - static::assertInstanceOf(ChildUnresolvableValueDuringGenerationException::class, $exception); + self::assertInstanceOf(ChildUnresolvableValueDuringGenerationException::class, $exception); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactoryTest.php b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactoryTest.php index abc1e5416..2286aedf4 100644 --- a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionFactoryTest.php @@ -20,6 +20,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueExceptionFactory + * @internal */ class UnresolvableValueExceptionFactoryTest extends TestCase { @@ -27,131 +28,125 @@ public function testCreate(): void { $exception = UnresolvableValueExceptionFactory::create(new DummyValue('dummy')); - static::assertEquals( + self::assertEquals( 'Could not resolve value "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = UnresolvableValueExceptionFactory::create(new DummyValue('dummy'), $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not resolve value "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForInvalidReferenceId(): void { $exception = UnresolvableValueExceptionFactory::createForInvalidReferenceId(new DummyValue('dummy'), 100); - static::assertEquals( + self::assertEquals( 'Expected fixture reference value "dummy" to be resolved into a string. Got "(integer) 100" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $exception = UnresolvableValueExceptionFactory::createForInvalidReferenceId(new DummyValue('dummy'), 'alice'); - static::assertEquals( + self::assertEquals( 'Expected fixture reference value "dummy" to be resolved into a string. Got "(string) alice" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $exception = UnresolvableValueExceptionFactory::createForInvalidReferenceId(new DummyValue('dummy'), new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected fixture reference value "dummy" to be resolved into a string. Got "stdClass" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = UnresolvableValueExceptionFactory::createForInvalidReferenceId(new DummyValue('dummy'), 100, $code, $previous); - static::assertEquals( + self::assertEquals( 'Expected fixture reference value "dummy" to be resolved into a string. Got "(integer) 100" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForCouldNotEvaluateExpression(): void { $exception = UnresolvableValueExceptionFactory::createForCouldNotEvaluateExpression(new DummyValue('dummy')); - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = UnresolvableValueExceptionFactory::createForCouldNotEvaluateExpression(new DummyValue('dummy'), $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not evaluate the expression "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForCouldNotFindVariable(): void { $exception = UnresolvableValueExceptionFactory::createForCouldNotFindVariable(new DummyValue('dummy')); - static::assertEquals( + self::assertEquals( 'Could not find a variable "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = UnresolvableValueExceptionFactory::createForCouldNotFindVariable(new DummyValue('dummy'), $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not find a variable "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForCouldNotFindParameter(): void { $exception = UnresolvableValueExceptionFactory::createForCouldNotFindParameter('foo'); - static::assertEquals( + self::assertEquals( 'Could not find the parameter "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidResolvedQuantifierTypeForOptionalValue(): void @@ -160,48 +155,46 @@ public function testCreateForInvalidResolvedQuantifierTypeForOptionalValue(): vo $exception = UnresolvableValueExceptionFactory::createForInvalidResolvedQuantifierTypeForOptionalValue($quantifier, null); - static::assertEquals( + self::assertEquals( 'Expected the quantifier "Nelmio\Alice\Definition\Value\DummyValue" for the optional value to be resolved ' .'into a string, got "NULL" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $exception = UnresolvableValueExceptionFactory::createForInvalidResolvedQuantifierTypeForOptionalValue($quantifier, new stdClass()); - static::assertEquals( + self::assertEquals( 'Expected the quantifier "Nelmio\Alice\Definition\Value\DummyValue" for the optional value to be resolved ' .'into a string, got "stdClass" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $exception = UnresolvableValueExceptionFactory::createForInvalidResolvedQuantifierTypeForOptionalValue($quantifier, []); - static::assertEquals( + self::assertEquals( 'Expected the quantifier "Nelmio\Alice\Definition\Value\DummyValue" for the optional value to be resolved ' .'into a string, got "array" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForNoFixtureOrObjectMatchingThePattern(): void { $exception = UnresolvableValueExceptionFactory::createForNoFixtureOrObjectMatchingThePattern( - new DummyValue('/foo/') + new DummyValue('/foo/'), ); - static::assertEquals( + self::assertEquals( 'Could not find a fixture or object ID matching the pattern "/foo/".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionTest.php b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionTest.php index d6e4b3bf8..cd23dcc4a 100644 --- a/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionTest.php +++ b/tests/Throwable/Exception/Generator/Resolver/UnresolvableValueExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException + * @internal */ class UnresolvableValueExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(UnresolvableValueException::class, RuntimeException::class, true)); + self::assertTrue(is_a(UnresolvableValueException::class, RuntimeException::class, true)); } public function testIsAResolutionThrowable(): void { - static::assertTrue(is_a(UnresolvableValueException::class, ResolutionThrowable::class, true)); + self::assertTrue(is_a(UnresolvableValueException::class, ResolutionThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildUnresolvableValueException(); - static::assertInstanceOf(ChildUnresolvableValueException::class, $exception); + self::assertInstanceOf(ChildUnresolvableValueException::class, $exception); } } diff --git a/tests/Throwable/Exception/InvalidArgumentExceptionFactoryTest.php b/tests/Throwable/Exception/InvalidArgumentExceptionFactoryTest.php index 1e86d1c8c..e324ebb89 100644 --- a/tests/Throwable/Exception/InvalidArgumentExceptionFactoryTest.php +++ b/tests/Throwable/Exception/InvalidArgumentExceptionFactoryTest.php @@ -20,282 +20,282 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\InvalidArgumentExceptionFactory + * @internal */ class InvalidArgumentExceptionFactoryTest extends TestCase { public function testCreateForInvalidReferenceType(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidReferenceType('foo'); - - static::assertEquals( + + self::assertEquals( 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got "foo"' .' instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForReferenceKeyMismatch(): void { $exception = InvalidArgumentExceptionFactory::createForReferenceKeyMismatch('foo', 'bar'); - static::assertEquals( + self::assertEquals( 'Reference key mismatch, the keys "foo" and "bar" refers to the same fixture but the keys are different.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForFlagBagKeyMismatch(): void { $exception = InvalidArgumentExceptionFactory::createForFlagBagKeyMismatch( new DummyFixture('foo'), - new FlagBag('bar') + new FlagBag('bar'), ); - static::assertEquals( + self::assertEquals( 'Expected the fixture ID and the flags key to be the same. Got "foo" and "bar" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidSeedConfigurationValue(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidSeedConfigurationValue(10); - static::assertEquals( + self::assertEquals( 'Expected value to be either null or a strictly positive integer but got "10" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForExpectedConfigurationStringValue(): void { $exception = InvalidArgumentExceptionFactory::createForExpectedConfigurationStringValue(10); - static::assertEquals( + self::assertEquals( 'Expected a string value but got "integer" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForExpectedConfigurationPositiveIntegerValue(): void { $exception = InvalidArgumentExceptionFactory::createForExpectedConfigurationPositiveIntegerValue(-1); - static::assertEquals( + self::assertEquals( 'Expected a strictly positive integer but got "-1" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForExpectedConfigurationArrayOfStringValue(): void { $exception = InvalidArgumentExceptionFactory::createForExpectedConfigurationArrayOfStringValue(10); - static::assertEquals( + self::assertEquals( 'Expected an array of strings but got "integer" element in the array instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForRedundantUniqueValue(): void { $exception = InvalidArgumentExceptionFactory::createForRedundantUniqueValue('foo'); - static::assertEquals( + self::assertEquals( 'Cannot create a unique value of a unique value for value "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidExpressionLanguageTokenType(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageTokenType('foo'); - static::assertEquals( + self::assertEquals( 'Expected type to be a known token type but got "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidExpressionLanguageToken(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageToken('foo'); - static::assertEquals( + self::assertEquals( 'Invalid token "foo" found.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForNoIncludeStatementInData(): void { $exception = InvalidArgumentExceptionFactory::createForNoIncludeStatementInData('foo'); - static::assertEquals( + self::assertEquals( 'Could not find any include statement in the file "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForEmptyIncludedFileInData(): void { $exception = InvalidArgumentExceptionFactory::createForEmptyIncludedFileInData('foo'); - static::assertEquals( + self::assertEquals( 'Expected elements of include statement to be file names. Got empty string instead in file "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForFileCouldNotBeFound(): void { $exception = InvalidArgumentExceptionFactory::createForFileCouldNotBeFound('foo'); - static::assertEquals( + self::assertEquals( 'The file "foo" could not be found.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = InvalidArgumentExceptionFactory::createForFileCouldNotBeFound('foo', $code, $previous); - static::assertEquals( + self::assertEquals( 'The file "foo" could not be found.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForInvalidLimitValue(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidLimitValue(10); - static::assertEquals( + self::assertEquals( 'Expected limit value to be a strictly positive integer, got "10" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidLimitValueForRecursiveCalls(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidLimitValueForRecursiveCalls(10); - static::assertEquals( + self::assertEquals( 'Expected limit for recursive calls to be of at least 2. Got "10" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidFakerFormatter(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidFakerFormatter('foo'); - static::assertEquals( + self::assertEquals( 'Invalid faker formatter "foo" found.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForFixtureExtendingANonTemplateFixture(): void { $exception = InvalidArgumentExceptionFactory::createForFixtureExtendingANonTemplateFixture( new DummyFixture('foo'), - 'bar' + 'bar', ); - static::assertEquals( + self::assertEquals( 'Fixture "foo" extends "bar" but "bar" is not a template.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForUnsupportedTypeForIdenticalValuesCheck(): void { $exception = InvalidArgumentExceptionFactory::createForUnsupportedTypeForIdenticalValuesCheck(true); - static::assertEquals( + self::assertEquals( 'Unsupported type "boolean": cannot determine if two values of this type are identical.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidConstructorMethod(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidConstructorMethod('foo'); - static::assertEquals( + self::assertEquals( 'Invalid constructor method "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidOptionalFlagBoundaries(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidOptionalFlagBoundaries(200); - static::assertEquals( + self::assertEquals( 'Expected optional flag to be an integer element of [0;100]. Got "200" instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForInvalidDynamicArrayQuantifier(): void { $exception = InvalidArgumentExceptionFactory::createForInvalidDynamicArrayQuantifier( new DummyFixture('dummy'), - 200 + 200, ); - static::assertEquals( + self::assertEquals( 'Expected quantifier to be a positive integer. Got "200" for "dummy", check you dynamic arrays ' .'declarations (e.g. "x @user*").', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/LogicExceptionFactoryTest.php b/tests/Throwable/Exception/LogicExceptionFactoryTest.php index 7d3ee23b2..3d86e0d74 100644 --- a/tests/Throwable/Exception/LogicExceptionFactoryTest.php +++ b/tests/Throwable/Exception/LogicExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\LogicExceptionFactory + * @internal */ class LogicExceptionFactoryTest extends TestCase { @@ -24,36 +25,36 @@ public function testCreateForUncallableMethod(): void { $exception = LogicExceptionFactory::createForUncallableMethod('foo'); - static::assertEquals( + self::assertEquals( 'By its nature, "foo()" should not be called.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForCannotDenormalizerForChainableFixtureBuilderDenormalizer(): void { $exception = LogicExceptionFactory::createForCannotDenormalizerForChainableFixtureBuilderDenormalizer('foo'); - static::assertEquals( + self::assertEquals( 'As a chainable denormalizer, "foo" should be called only if "::canDenormalize() returns true. Got ' .'false instead.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForCannotHaveBothConstructorAndFactory(): void { $exception = LogicExceptionFactory::createForCannotHaveBothConstructorAndFactory(); - static::assertEquals( + self::assertEquals( 'Cannot use the fixture property "__construct" and "__factory" together.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/NoValueForCurrentExceptionFactoryTest.php b/tests/Throwable/Exception/NoValueForCurrentExceptionFactoryTest.php index c32ce453d..461b710f9 100644 --- a/tests/Throwable/Exception/NoValueForCurrentExceptionFactoryTest.php +++ b/tests/Throwable/Exception/NoValueForCurrentExceptionFactoryTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\NoValueForCurrentExceptionFactory + * @internal */ class NoValueForCurrentExceptionFactoryTest extends TestCase { @@ -25,11 +26,11 @@ public function testCreateException(): void { $exception = NoValueForCurrentExceptionFactory::create(new DummyFixture('dummy')); - static::assertEquals( + self::assertEquals( 'No value for \'\' found for the fixture "dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/NoValueForCurrentExceptionTest.php b/tests/Throwable/Exception/NoValueForCurrentExceptionTest.php index 679e8b6e8..b3d27cfb3 100644 --- a/tests/Throwable/Exception/NoValueForCurrentExceptionTest.php +++ b/tests/Throwable/Exception/NoValueForCurrentExceptionTest.php @@ -18,17 +18,18 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\NoValueForCurrentException + * @internal */ class NoValueForCurrentExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(NoValueForCurrentException::class, RuntimeException::class, true)); + self::assertTrue(is_a(NoValueForCurrentException::class, RuntimeException::class, true)); } public function testIsExtensible(): void { $exception = new ChildNoValueForCurrentException(); - static::assertInstanceOf(ChildNoValueForCurrentException::class, $exception); + self::assertInstanceOf(ChildNoValueForCurrentException::class, $exception); } } diff --git a/tests/Throwable/Exception/ObjectNotFoundExceptionFactoryTest.php b/tests/Throwable/Exception/ObjectNotFoundExceptionFactoryTest.php index de362c04e..0dc805306 100644 --- a/tests/Throwable/Exception/ObjectNotFoundExceptionFactoryTest.php +++ b/tests/Throwable/Exception/ObjectNotFoundExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\ObjectNotFoundExceptionFactory + * @internal */ class ObjectNotFoundExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateNewExceptionWithFactory(): void { $exception = ObjectNotFoundExceptionFactory::create('foo', 'Dummy'); - static::assertEquals( + self::assertEquals( 'Could not find the object "foo" of the class "Dummy".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/ObjectNotFoundExceptionTest.php b/tests/Throwable/Exception/ObjectNotFoundExceptionTest.php index 18058031a..9a35f932a 100644 --- a/tests/Throwable/Exception/ObjectNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/ObjectNotFoundExceptionTest.php @@ -18,17 +18,18 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\ObjectNotFoundException + * @internal */ class ObjectNotFoundExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(ObjectNotFoundException::class, RuntimeException::class, true)); + self::assertTrue(is_a(ObjectNotFoundException::class, RuntimeException::class, true)); } public function testIsExtensible(): void { $exception = new ChildObjectNotFoundException(); - static::assertInstanceOf(ChildObjectNotFoundException::class, $exception); + self::assertInstanceOf(ChildObjectNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/ParameterNotFoundExceptionFactoryTest.php b/tests/Throwable/Exception/ParameterNotFoundExceptionFactoryTest.php index 27a95e951..42445c04d 100644 --- a/tests/Throwable/Exception/ParameterNotFoundExceptionFactoryTest.php +++ b/tests/Throwable/Exception/ParameterNotFoundExceptionFactoryTest.php @@ -19,38 +19,39 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\ParameterNotFoundExceptionFactory + * @internal */ class ParameterNotFoundExceptionFactoryTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(ParameterNotFoundException::class, RuntimeException::class, true)); + self::assertTrue(is_a(ParameterNotFoundException::class, RuntimeException::class, true)); } public function testCreateNewExceptionWithFactory(): void { $exception = ParameterNotFoundExceptionFactory::create('foo'); - static::assertEquals( + self::assertEquals( 'Could not find the parameter "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForWhenResolvingParameter(): void { $exception = ParameterNotFoundExceptionFactory::createForWhenResolvingParameter( 'foo', - new Parameter('bar', 'baz') + new Parameter('bar', 'baz'), ); - static::assertEquals( + self::assertEquals( 'Could not find the parameter "foo" when resolving "bar".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/ParameterNotFoundExceptionTest.php b/tests/Throwable/Exception/ParameterNotFoundExceptionTest.php index 1626ca781..9d34e848d 100644 --- a/tests/Throwable/Exception/ParameterNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/ParameterNotFoundExceptionTest.php @@ -18,17 +18,18 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\ParameterNotFoundException + * @internal */ class ParameterNotFoundExceptionTest extends TestCase { public function testIsARuntimeException(): void { - static::assertTrue(is_a(ParameterNotFoundException::class, RuntimeException::class, true)); + self::assertTrue(is_a(ParameterNotFoundException::class, RuntimeException::class, true)); } public function testIsExtensible(): void { $exception = new ChildParameterNotFoundException(); - static::assertInstanceOf(ChildParameterNotFoundException::class, $exception); + self::assertInstanceOf(ChildParameterNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Parser/ParseExceptionFactoryTest.php b/tests/Throwable/Exception/Parser/ParseExceptionFactoryTest.php index fc3e9a5a6..f049f00ba 100644 --- a/tests/Throwable/Exception/Parser/ParseExceptionFactoryTest.php +++ b/tests/Throwable/Exception/Parser/ParseExceptionFactoryTest.php @@ -18,6 +18,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Parser\ParseExceptionFactory + * @internal */ class ParseExceptionFactoryTest extends TestCase { @@ -25,61 +26,59 @@ public function testCreateForParserNoFoundForFile(): void { $exception = ParseExceptionFactory::createForParserNoFoundForFile('foo'); - static::assertEquals( + self::assertEquals( 'No suitable parser found for the file "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } public function testCreateForUnparsableFile(): void { $exception = ParseExceptionFactory::createForUnparsableFile('foo'); - static::assertEquals( + self::assertEquals( 'Could not parse the file "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = ParseExceptionFactory::createForUnparsableFile('foo', $code, $previous); - static::assertEquals( + self::assertEquals( 'Could not parse the file "foo".', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } public function testCreateForInvalidYaml(): void { $exception = ParseExceptionFactory::createForInvalidYaml('foo'); - static::assertEquals( + self::assertEquals( 'The file "foo" does not contain valid YAML.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); - + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); $code = 500; $previous = new Error(); $exception = ParseExceptionFactory::createForInvalidYaml('foo', $code, $previous); - static::assertEquals( + self::assertEquals( 'The file "foo" does not contain valid YAML.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals($code, $exception->getCode()); - static::assertSame($previous, $exception->getPrevious()); + self::assertEquals($code, $exception->getCode()); + self::assertSame($previous, $exception->getPrevious()); } } diff --git a/tests/Throwable/Exception/Parser/ParserNotFoundExceptionTest.php b/tests/Throwable/Exception/Parser/ParserNotFoundExceptionTest.php index e536b9ff3..6ea728b8f 100644 --- a/tests/Throwable/Exception/Parser/ParserNotFoundExceptionTest.php +++ b/tests/Throwable/Exception/Parser/ParserNotFoundExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Parser\ParserNotFoundException + * @internal */ class ParserNotFoundExceptionTest extends TestCase { public function testIsALogicException(): void { - static::assertTrue(is_a(ParserNotFoundException::class, LogicException::class, true)); + self::assertTrue(is_a(ParserNotFoundException::class, LogicException::class, true)); } public function testIsNotAParseThrowable(): void { - static::assertFalse(is_a(ParserNotFoundException::class, ParseThrowable::class, true)); + self::assertFalse(is_a(ParserNotFoundException::class, ParseThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildParserNotFoundException(); - static::assertInstanceOf(ChildParserNotFoundException::class, $exception); + self::assertInstanceOf(ChildParserNotFoundException::class, $exception); } } diff --git a/tests/Throwable/Exception/Parser/UnparsableFileExceptionTest.php b/tests/Throwable/Exception/Parser/UnparsableFileExceptionTest.php index f01d5ba0c..b3a45b90a 100644 --- a/tests/Throwable/Exception/Parser/UnparsableFileExceptionTest.php +++ b/tests/Throwable/Exception/Parser/UnparsableFileExceptionTest.php @@ -19,22 +19,23 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\Parser\UnparsableFileException + * @internal */ class UnparsableFileExceptionTest extends TestCase { public function testIsAnException(): void { - static::assertTrue(is_a(UnparsableFileException::class, Exception::class, true)); + self::assertTrue(is_a(UnparsableFileException::class, Exception::class, true)); } public function testIsAParseThrowable(): void { - static::assertTrue(is_a(UnparsableFileException::class, ParseThrowable::class, true)); + self::assertTrue(is_a(UnparsableFileException::class, ParseThrowable::class, true)); } public function testIsExtensible(): void { $exception = new ChildUnparsableFileException(); - static::assertInstanceOf(ChildUnparsableFileException::class, $exception); + self::assertInstanceOf(ChildUnparsableFileException::class, $exception); } } diff --git a/tests/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactoryTest.php b/tests/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactoryTest.php index 8d22a4f7e..2cb371296 100644 --- a/tests/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactoryTest.php +++ b/tests/Throwable/Exception/PropertyAccess/NoSuchPropertyExceptionFactoryTest.php @@ -17,6 +17,7 @@ /** * @covers \Nelmio\Alice\Throwable\Exception\PropertyAccess\NoSuchPropertyExceptionFactory + * @internal */ class NoSuchPropertyExceptionFactoryTest extends TestCase { @@ -24,11 +25,11 @@ public function testCreateForUnreadablePropertyFromStdClass(): void { $exception = NoSuchPropertyExceptionFactory::createForUnreadablePropertyFromStdClass('foo'); - static::assertEquals( + self::assertEquals( 'Cannot read property "foo" from stdClass.', - $exception->getMessage() + $exception->getMessage(), ); - static::assertEquals(0, $exception->getCode()); - static::assertNull($exception->getPrevious()); + self::assertEquals(0, $exception->getCode()); + self::assertNull($exception->getPrevious()); } } diff --git a/tests/Throwable/ExpressionLanguageParseThrowableTest.php b/tests/Throwable/ExpressionLanguageParseThrowableTest.php index c0c4ed664..ae51a7fdd 100644 --- a/tests/Throwable/ExpressionLanguageParseThrowableTest.php +++ b/tests/Throwable/ExpressionLanguageParseThrowableTest.php @@ -18,11 +18,12 @@ /** * @coversNothing + * @internal */ class ExpressionLanguageParseThrowableTest extends TestCase { public function testIsABuildThrowable(): void { - static::assertTrue(is_a(RootExpressionLanguageParseException::class, BuildThrowable::class, true)); + self::assertTrue(is_a(RootExpressionLanguageParseException::class, BuildThrowable::class, true)); } } diff --git a/tests/Throwable/GenerationThrowableTest.php b/tests/Throwable/GenerationThrowableTest.php index 867557d83..81dc5eab4 100644 --- a/tests/Throwable/GenerationThrowableTest.php +++ b/tests/Throwable/GenerationThrowableTest.php @@ -18,11 +18,12 @@ /** * @coversNothing + * @internal */ class GenerationThrowableTest extends TestCase { public function testIsABuildThrowable(): void { - static::assertTrue(is_a(RootGenerationException::class, LoadingThrowable::class, true)); + self::assertTrue(is_a(RootGenerationException::class, LoadingThrowable::class, true)); } } diff --git a/tests/Throwable/InstantiationThrowableTest.php b/tests/Throwable/InstantiationThrowableTest.php index 087f648c7..0180ea24c 100644 --- a/tests/Throwable/InstantiationThrowableTest.php +++ b/tests/Throwable/InstantiationThrowableTest.php @@ -18,11 +18,12 @@ /** * @coversNothing + * @internal */ class InstantiationThrowableTest extends TestCase { public function testIsABuildThrowable(): void { - static::assertTrue(is_a(RootInstantiationException::class, GenerationThrowable::class, true)); + self::assertTrue(is_a(RootInstantiationException::class, GenerationThrowable::class, true)); } } diff --git a/tests/Throwable/ParseThrowableTest.php b/tests/Throwable/ParseThrowableTest.php index 2f0e2bb74..c43688871 100644 --- a/tests/Throwable/ParseThrowableTest.php +++ b/tests/Throwable/ParseThrowableTest.php @@ -18,11 +18,12 @@ /** * @coversNothing + * @internal */ class ParseThrowableTest extends TestCase { public function testIsABuildThrowable(): void { - static::assertTrue(is_a(RootParseException::class, LoadingThrowable::class, true)); + self::assertTrue(is_a(RootParseException::class, LoadingThrowable::class, true)); } } diff --git a/tests/Throwable/ResolutionThrowableTest.php b/tests/Throwable/ResolutionThrowableTest.php index 47f379281..7a13cb0b1 100644 --- a/tests/Throwable/ResolutionThrowableTest.php +++ b/tests/Throwable/ResolutionThrowableTest.php @@ -18,11 +18,12 @@ /** * @coversNothing + * @internal */ class ResolutionThrowableTest extends TestCase { public function testIsABuildThrowable(): void { - static::assertTrue(is_a(RootResolutionException::class, GenerationThrowable::class, true)); + self::assertTrue(is_a(RootResolutionException::class, GenerationThrowable::class, true)); } } diff --git a/vendor-bin/php-cs-fixer/composer.json b/vendor-bin/php-cs-fixer/composer.json index ead968503..aef022263 100644 --- a/vendor-bin/php-cs-fixer/composer.json +++ b/vendor-bin/php-cs-fixer/composer.json @@ -1,6 +1,7 @@ { "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0" + "friendsofphp/php-cs-fixer": "^3.0", + "fidry/php-cs-fixer-config": "^1.2" }, "config": { "bin-dir": "bin",