From a86d176515494e8fbddb54f20db44bc74e4cb326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Poirier=20Th=C3=A9or=C3=AAt?= Date: Sun, 29 Sep 2024 13:49:20 -0400 Subject: [PATCH] [Internal] Update php-cs rules, use more default rules from PhpCsFixer, PhpCsFixer:risky --- .php-cs-fixer.dist.php | 39 ++--- app/src/Command/NullCommand.php | 3 +- .../Controller/Admin/AddRolesAminAction.php | 5 +- app/src/Controller/Admin/MakeAdminAction.php | 9 +- app/src/DataFixtures/AppFixtures.php | 42 ++++-- app/src/Entity/User.php | 2 +- .../UserSetCommentNullMigration.php | 13 +- app/src/Form/AddRolesForm.php | 3 +- app/src/Kernel.php | 3 +- app/src/Maker/MakeDrawPackage.php | 17 ++- app/src/Sonata/Admin/BaseObjectAdmin.php | 9 +- app/src/Sonata/Admin/TagAdmin.php | 9 +- app/src/Sonata/Admin/UserAdmin.php | 20 ++- app/src/Sonata/Admin/UserTagAdmin.php | 6 +- .../ConfigurationIntegration.php | 2 +- .../FeatureIntegration.php | 2 +- .../SystemMonitoringIntegration.php | 23 +-- .../VersioningIntegration.php | 5 +- .../Feature/FeatureInitializer.php | 3 +- .../Command/SystemStatusesCommand.php | 5 +- .../SystemMonitoring/MonitoredService.php | 2 +- .../SystemMonitoring/MonitoringResult.php | 2 +- .../DoctrineConfigurationRegistryTest.php | 12 +- .../Tests/Configuration/Entity/ConfigTest.php | 3 + .../ConfigurationIntegrationTest.php | 2 + .../FeatureIntegrationTest.php | 2 + .../SystemMonitoringIntegrationTest.php | 2 + .../VersioningIntegrationTest.php | 4 +- .../UpdateDeployedVersionCommandTest.php | 12 +- .../Event/FetchRunningVersionEventTest.php | 3 + .../FetchRunningVersionListenerTest.php | 3 + .../Tests/Versioning/VersionManagerTest.php | 23 ++- .../Command/UpdateDeployedVersionCommand.php | 6 +- .../Command/CloudWatchLogsDownloadCommand.php | 6 +- .../AwsToolKitIntegration.php | 7 +- ...AddNewestInstanceRoleCommandOptionPass.php | 3 +- .../CloudWatchLogsDownloadCommandTest.php | 22 ++- .../AwsToolKitIntegrationTest.php | 2 + ...ewestInstanceRoleCommandOptionPassTest.php | 3 + .../NewestInstanceRoleListenerCheckTest.php | 45 ++++-- .../Tests/Imds/ImdsClientV1Test.php | 9 +- .../Tests/Imds/ImdsClientV2Test.php | 12 +- .../Command/GenerateDocumentationCommand.php | 3 +- .../console/Command/PurgeExecutionCommand.php | 3 +- .../ConsoleIntegration.php | 14 +- .../EventListener/CommandFlowListener.php | 14 +- ...ocumentationFilterCommandEventListener.php | 2 +- .../Command/PurgeExecutionCommandTest.php | 12 +- ...ommandExecutionOptionsCompilerPassTest.php | 3 + .../ConsoleIntegrationTest.php | 6 +- .../console/Tests/Entity/ExecutionTest.php | 6 +- .../Tests/Event/CommandErrorEventTest.php | 3 + .../EventListener/CommandFlowListenerTest.php | 141 ++++++++++++------ .../Output/BufferedConsoleOutputTest.php | 9 +- packages/core/DataAccessor.php | 5 +- packages/core/FilterExpression/Evaluator.php | 2 +- .../CompositeExpressionEvaluator.php | 2 +- .../ConstraintExpressionEvaluator.php | 3 +- packages/core/Tests/DateTimeUtilsTest.php | 3 + .../Tests/FilterExpression/EvaluatorTest.php | 3 + .../CompositeExpressionEvaluatorTest.php | 9 +- .../ConstraintExpressionEvaluatorTest.php | 3 + .../Tests/FilterExpression/ExpressionTest.php | 3 + .../core/Tests/FilterExpression/QueryTest.php | 3 + packages/core/Tests/FunctionTest.php | 3 + .../Reflection/ReflectionAccessorTest.php | 3 + .../Command/QueueCronJobByNameCommand.php | 6 +- .../Command/QueueDueCronJobsCommand.php | 6 +- .../AddPostCronJobExecutionOptionPass.php | 3 +- .../CronJobIntegration.php | 2 +- packages/cron-job/Entity/CronJob.php | 3 +- packages/cron-job/Entity/CronJobExecution.php | 9 +- .../PostExecutionQueueCronJobListener.php | 3 +- .../Command/QueueCronJobByNameCommandTest.php | 24 ++- .../Command/QueueDueCronJobsCommandTest.php | 24 ++- .../cron-job/Tests/CronJobProcessorTest.php | 89 +++++++---- .../CronJobIntegrationTest.php | 3 + .../Tests/Entity/CronJobExecutionTest.php | 3 + .../ExecuteCronJobMessageHandlerTest.php | 8 +- .../Integration/IntegrationTrait.php | 8 +- .../Integration/Test/IntegrationTestCase.php | 10 +- .../DependencyInjectionIntegrationTest.php | 3 + .../DoctrineExtraIntegration.php | 11 +- .../ORM/Command/MysqlDumpCommand.php | 6 +- .../ORM/Command/MysqlImportFileCommand.php | 6 +- packages/doctrine-extra/ORM/EntityHandler.php | 6 +- .../DataFixtures/ObjectReferenceTraitTest.php | 15 +- .../DoctrineExtraIntegrationTest.php | 2 + .../entity-migrator/Command/BaseCommand.php | 2 +- .../Command/MigrateCommand.php | 6 +- .../Command/QueueBatchCommand.php | 29 ++-- .../Compiler/EntityMigratorCompilerPass.php | 6 +- .../EntityMigratorIntegration.php | 14 +- .../EventListener/WorkflowListener.php | 6 +- packages/entity-migrator/Migrator.php | 6 +- .../Repository/EntityMigrationRepository.php | 3 +- .../Message/MigrateEntityCommandTest.php | 3 + .../Tests/ClassPrivateStaticCallFixerTest.php | 3 + .../fixer/Tests/ClassStaticCallFixerTest.php | 3 + .../DependencyInjection/Configuration.php | 6 +- .../DrawFrameworkExtraBundle.php | 1 - .../DependencyInjection/ConfigurationTest.php | 3 + .../DrawFrameworkExtraExtensionTest.php | 3 + .../Tests/DrawFrameworkExtraBundleTest.php | 15 +- .../Compiler/LoggerDecoratorPass.php | 6 +- .../DependencyInjection/LogIntegration.php | 21 ++- packages/log/Tests/DecoratedLoggerTest.php | 12 +- .../LogIntegrationTest.php | 4 +- .../Monolog/Processor/DelayProcessorTest.php | 3 + .../EventListener/SlowRequestLoggerTest.php | 15 +- .../Processor/RequestHeadersProcessorTest.php | 9 +- .../Symfony/Processor/TokenProcessorTest.php | 9 +- .../mailer/Command/SendTestEmailCommand.php | 3 +- .../Compiler/EmailWriterCompilerPass.php | 6 +- .../DependencyInjection/MailerIntegration.php | 16 +- .../Command/SendTestEmailCommandTest.php | 9 +- .../MailerIntegrationTest.php | 4 +- .../Tests/Email/CallToActionEmailTest.php | 3 + packages/mailer/Tests/EmailComposerTest.php | 21 ++- .../AddTemplateHeaderEmailWriterTest.php | 3 + .../DefaultFromEmailWriterTest.php | 3 + .../EmailComposerListenerTest.php | 18 ++- .../EmailCssInlinerListenerTest.php | 15 +- .../EmailSubjectFromHtmlTitleListenerTest.php | 33 ++-- .../Tests/Twig/TranslationExtensionTest.php | 9 +- packages/mailer/Twig/TranslationExtension.php | 2 +- .../Command/StartMessengerBrokerCommand.php | 23 +-- .../StopBrokerOnSigtermSignalListener.php | 2 +- packages/messenger/Counter/CpuCounter.php | 3 +- .../MessengerIntegration.php | 68 +++++---- .../PropertyReferenceEncodingListener.php | 3 +- .../EnvelopeFactory/BasicEnvelopeFactory.php | 3 +- .../EnvelopeFactoryDelayStampListener.php | 3 +- ...ryDispatchAfterCurrentBusStampListener.php | 3 +- .../Model/MessageHolderTrait.php | 2 +- .../Command/PurgeExpiredMessageCommand.php | 3 +- .../Action/ClickMessageAction.php | 11 +- .../RetryFailedMessageMessageHandler.php | 3 +- .../Retry/EventDrivenRetryStrategy.php | 6 +- .../AutoStampEnvelopeListenerTest.php | 3 + .../messenger/Tests/Broker/BrokerTest.php | 48 ++++-- .../StartMessengerBrokerCommandTest.php | 11 +- .../Broker/Event/BrokerRunningEventTest.php | 3 + .../Broker/Event/BrokerStartedEventTest.php | 3 + .../Event/NewConsumerProcessEventTest.php | 3 + .../BrokerDefaultValuesListenerTest.php | 3 + .../StopBrokerOnSigtermSignalListenerTest.php | 6 +- .../MessengerIntegrationTest.php | 10 +- .../PropertyReferenceEncodingListenerTest.php | 3 + .../Entity/MessageHolderTraitTest.php | 3 + .../BasicEnvelopeFactoryTest.php | 6 +- .../Event/EnvelopeCreatedEventTest.php | 3 + .../DoctrineBusMessageListenerTest.php | 54 ++++--- .../EnvelopeFactoryDelayStampListenerTest.php | 3 + ...spatchAfterCurrentBusStampListenerTest.php | 3 + .../Tests/Entity/DrawMessageTagTraitTest.php | 3 + .../Tests/Entity/DrawMessageTraitTest.php | 3 + .../StopOnNewVersionListenerTest.php | 3 + .../MessageNotFoundExceptionTest.php | 3 + .../PurgeExpiredMessageCommandTest.php | 33 ++-- .../Expirable/Stamp/ExpirationStampTest.php | 3 + .../Action/ClickMessageActionTest.php | 60 +++++--- .../Event/MessageLinkErrorEventTest.php | 3 + ...pManuallyTriggeredEnvelopeListenerTest.php | 3 + .../RedirectToRouteMessageTraitTest.php | 6 +- .../RedirectToRouteMessageHandlerTest.php | 6 +- .../Stamp/ManualTriggerStampTest.php | 3 + .../RetryFailedMessageMessageHandlerTest.php | 9 +- .../Retry/EventDrivenRetryStrategyTest.php | 44 ++++-- .../Tests/Searchable/EnvelopeFinderTest.php | 21 ++- .../Stamp/FindFromTransportStampTest.php | 3 + .../Stamp/SearchableTagStampTest.php | 3 + .../Event/BaseSerializerEventTest.php | 3 + .../Event/PreEncodeEventTest.php | 3 + ...EventDispatcherSerializerDecoratorTest.php | 15 +- packages/messenger/Tests/TestCase.php | 3 + .../Transport/DrawTransportFactoryTest.php | 3 + .../Tests/Transport/DrawTransportTest.php | 18 ++- .../messenger/Transport/DrawTransport.php | 59 +++++--- .../Transport/DrawTransportFactory.php | 18 +-- .../Command/InstallSandboxCommand.php | 3 +- .../open-api/Controller/OpenApiController.php | 5 +- .../OpenApiIntegration.php | 131 ++++++++++------ .../DefinitionAliasCleanerListener.php | 2 +- .../RequestQueryParameterFetcherListener.php | 11 +- .../ResponseApiExceptionListener.php | 2 +- .../SchemaCleanRequiredReadOnlyListener.php | 2 +- .../EventListener/SchemaSorterListener.php | 2 +- .../EventListener/TagCleanerListener.php | 2 +- .../open-api/Extraction/ExtractionContext.php | 3 - .../Caching/FileTrackingExtractor.php | 1 - .../Caching/LoadFromCacheExtractor.php | 3 +- .../Caching/StoreInCacheExtractor.php | 3 +- .../Constraint/BaseConstraintExtractor.php | 15 +- .../NotBlankConstraintExtractor.php | 2 +- .../Constraint/NotNullConstraintExtractor.php | 2 +- .../JmsSerializer/PropertiesExtractor.php | 2 +- .../TypeHandler/ArrayHandler.php | 4 +- .../DoctrineObjectReferenceSchemaHandler.php | 5 +- .../TypeHandler/DynamicObjectHandler.php | 2 +- .../TypeHandler/GenericTemplateHandler.php | 10 +- .../OpenApi/JsonRootSchemaExtractor.php | 4 +- .../Extractor/OpenApi/ParameterExtractor.php | 2 +- .../SerializationConfigurationExtractor.php | 3 +- .../OpenApi/VendorAttributeExtractor.php | 9 +- .../VersionLinkDocumentationExtractor.php | 3 +- .../Extractor/PhpDoc/OperationExtractor.php | 8 +- .../OperationResponseExtractor.php | 2 +- .../Symfony/RouteOperationExtractor.php | 2 +- .../Symfony/RouterRootSchemaExtractor.php | 4 +- .../Extractor/TypeSchemaExtractor.php | 12 +- .../Extraction/ExtractorInterface.php | 6 - .../Naming/AliasesClassNamingFilter.php | 2 +- packages/open-api/OpenApi.php | 10 +- packages/open-api/Schema/QueryParameter.php | 3 +- packages/open-api/Schema/Root.php | 3 +- .../open-api/Schema/SecurityRequirement.php | 3 - packages/open-api/Schema/Tag.php | 1 - .../DoctrineObjectConstructor.php | 2 +- .../Handler/GenericSerializerHandler.php | 2 +- .../Handler/ObjectReferenceHandler.php | 6 +- .../Command/InstallSandboxCommandTest.php | 16 +- .../Controller/OpenApiControllerTest.php | 21 ++- .../OpenApiIntegrationTest.php | 18 ++- .../Event/PreDumpRootSchemaEventTest.php | 3 + .../Event/PreSerializerResponseEventTest.php | 3 + .../EventListener/BaseCleanerTestCase.php | 2 +- .../DefinitionAliasCleanerListenerTest.php | 3 + ...finitionAliasSchemaCleanerListenerTest.php | 3 + ...questQueryParameterFetcherListenerTest.php | 6 +- .../RequestValidationListenerTest.php | 18 ++- .../ResponseApiExceptionListenerTest.php | 9 +- .../ResponseSerializerListenerTest.php | 30 ++-- .../SchemaAddDefaultHeadersListenerTest.php | 3 + .../UnReferenceCleanerListenerTest.php | 3 + .../ConstraintViolationListExceptionTest.php | 3 + .../ExtractionImpossibleExceptionTest.php | 3 + .../NotBlankConstraintExtractorTest.php | 3 + .../JmsSerializer/PropertiesExtractorTest.php | 6 + .../OpenApi/RootSchemaExtractorTest.php | 3 + .../PhpDoc/OperationExtractorTest.php | 8 +- .../Extractor/TypeSchemaExtractorTest.php | 3 + ...nfigurableErrorToHttpCodeConverterTest.php | 3 + .../HttpExceptionToHttpCodeConverterTest.php | 3 + .../Naming/AliasesClassNamingFilterTest.php | 3 + packages/open-api/Tests/OpenApiTest.php | 3 + .../Tests/Serializer/SerializationTest.php | 3 + ...RouteDefaultApiRouteVersionMatcherTest.php | 3 + .../ProcessIntegration.php | 2 +- .../ProcessIntegrationTest.php | 2 + packages/process/Tests/ProcessFactoryTest.php | 3 + packages/profiling/Sql/SqlMetricBuilder.php | 2 +- .../Tests/ProfilerCoordinatorTest.php | 3 + .../Tests/Sql/SqlAssertionBuilderTest.php | 9 +- packages/profiling/Tests/Sql/SqlLogTest.php | 5 +- .../Tests/Sql/SqlMetricBuilderTest.php | 7 +- .../profiling/Tests/Sql/SqlMetricTest.php | 7 +- .../profiling/Tests/Sql/SqlProfilerTest.php | 6 +- .../Core/Authentication/Token/SystemToken.php | 8 - .../SystemConsoleAuthenticatorListener.php | 3 +- .../Compiler/UserCheckerDecoratorPass.php | 3 +- .../Factory/JwtAuthenticatorFactory.php | 6 +- .../MessengerMessageAuthenticatorFactory.php | 6 +- .../SecurityIntegration.php | 26 ++-- .../Http/Authenticator/JwtAuthenticator.php | 8 +- .../Authenticator/MessageAuthenticator.php | 2 +- .../RoleRestrictedAuthenticatorListener.php | 2 +- .../Core/Event/CheckPostAuthEventTest.php | 3 + .../Core/Event/CheckPreAuthEventTest.php | 3 + ...SystemConsoleAuthenticatorListenerTest.php | 48 ++++-- ...stemMessengerAuthenticatorListenerTest.php | 18 ++- .../Core/User/EventDrivenUserCheckerTest.php | 15 +- .../Compiler/UserCheckerDecoratorPassTest.php | 3 + .../SecurityIntegrationTest.php | 8 +- .../Authenticator/JwtAuthenticatorTest.php | 66 +++++--- .../MessageAuthenticatorTest.php | 54 ++++--- .../Passport/Badge/JwtPayloadBadgeTest.php | 3 + .../Badge/RoleRestrictedBadgeTest.php | 3 + ...oleRestrictedAuthenticatorListenerTest.php | 30 ++-- .../security/Tests/Jwt/JwtEncoderTest.php | 3 + .../ActionableAdmin/Action/DeleteAction.php | 5 +- .../ActionableAdmin/AdminAction.php | 6 +- .../AdminAction/DeleteAdminAction.php | 3 +- .../ActionableAdmin/AdminActionLoader.php | 2 +- .../ActionableAdmin/ExecutionNotifier.php | 14 +- .../Extension/ActionableAdminExtension.php | 3 +- .../ActionableAdminExtensionInterface.php | 3 +- .../ActionableAdmin/GenericFormHandler.php | 11 +- .../ObjectActionExecutioner.php | 3 +- .../Block/MonitoringBlockService.php | 6 +- .../SonataAdminNodeConfiguration.php | 8 +- .../Controller/BatchAdminController.php | 3 +- .../Controller/ControllerTrait.php | 12 +- .../AutoConfigureSubClassesCompilerClass.php | 3 +- .../Compiler/DecoratesCompilerPass.php | 6 +- .../DependencyInjection/Configuration.php | 34 +++-- .../DrawSonataExtraExtension.php | 20 ++- ...PreObjectDeleteBatchEventEventListener.php | 3 +- .../Extension/BatchActionExtension.php | 3 +- .../DoctrineInheritanceExtension.php | 4 +- .../Extension/GridExtension.php | 2 +- .../Extension/ListFieldPriorityExtension.php | 3 +- .../SubClassFieldDescriptionFactory.php | 6 +- .../Extension/PreventDeleteExtension.php | 9 +- .../PreventDelete/PreventDelete.php | 18 ++- .../PreventDeleteRelationLoader.php | 3 +- .../Security/Voter/PreventDeleteVoter.php | 2 +- .../Compiler/DecorateCompilerPassTest.php | 3 + .../DependencyInjection/ConfigurationTest.php | 3 + ...ataExtraExtensionAutoActionEnabledTest.php | 3 + ...onataExtraExtensionAutoHelpEnabledTest.php | 3 + ...raExtensionBatchDeleteCheckEnabledTest.php | 3 + ...ExtensionCanSecurityHandlerEnabledTest.php | 3 + ...taExtraExtensionFixMenuDeptEnabledTest.php | 3 + ...onataExtraExtensionNotifierEnabledTest.php | 3 + ...xtraExtensionSessionTimeoutEnabledTest.php | 3 + .../DrawSonataExtraExtensionTest.php | 11 +- .../SessionTimeoutRequestListenerTest.php | 21 ++- .../Extension/PreventDeleteExtensionTest.php | 9 +- .../Admin/ColumnAdmin.php | 3 +- .../Admin/ImportAdmin.php | 9 +- .../DoctrineAssociationColumnExtractor.php | 11 +- .../DoctrineFieldColumnExtractor.php | 8 +- .../DoctrineTranslationColumnExtractor.php | 5 +- .../Column/ColumnFactory.php | 3 +- .../Extractor/ExactMatchColumnExtractor.php | 5 +- .../SetterMethodReflectionColumnExtractor.php | 5 +- .../Controller/ImportController.php | 3 +- .../Compiler/CompilerPass.php | 3 +- .../DependencyInjection/Configuration.php | 8 +- .../DrawSonataImportExtension.php | 6 +- .../sonata-import-bundle/Entity/Import.php | 12 +- .../sonata-import-bundle/Import/Importer.php | 16 +- ...DoctrineAssociationColumnExtractorTest.php | 12 +- .../DoctrineFieldColumnExtractorTest.php | 6 +- ...DoctrineTranslationColumnExtractorTest.php | 6 +- .../ExactMatchColumnExtractorTest.php | 15 +- .../PropertyPathColumnExtractorTest.php | 3 + ...terMethodReflectionColumnExtractorTest.php | 6 +- .../Tests/ColumnFactoryTest.php | 9 +- .../Tests/Entity/ImportTest.php | 3 + .../Configuration/Admin/ConfigAdmin.php | 13 +- .../Console/Admin/ExecutionAdmin.php | 20 ++- .../Controller/ExecutionController.php | 3 +- .../CronJob/Admin/CronJobAdmin.php | 12 +- .../CronJob/Admin/CronJobExecutionAdmin.php | 10 +- .../DependencyInjection/Configuration.php | 26 ++-- .../DrawSonataIntegrationExtension.php | 66 +++++--- .../Factory/Security/AdminLoginFactory.php | 3 +- .../Admin/BaseEntityMigrationAdmin.php | 12 +- .../EntityMigrator/Admin/MigrationAdmin.php | 9 +- .../Messenger/Admin/MessengerMessageAdmin.php | 9 +- ...FinalizeContextQueueCountEventListener.php | 1 - .../DependencyInjection/ConfigurationTest.php | 3 + ...ationExtensionConfigurationEnabledTest.php | 3 + ...IntegrationExtensionConsoleEnabledTest.php | 3 + ...IntegrationExtensionCronJobEnabledTest.php | 3 + ...tegrationExtensionMessengerEnabledTest.php | 3 + .../DrawSonataIntegrationExtensionTest.php | 3 + ...xtensionUser2faEnabledEmailEnabledTest.php | 3 + ...IntegrationExtensionUser2faEnabledTest.php | 3 + ...ataIntegrationExtensionUserEnabledTest.php | 3 + ...ntegrationExtensionUserLockEnabledTest.php | 3 + ...ctorAuthenticationResendCodeActionTest.php | 12 +- .../User/Action/UnlockUserAction.php | 6 +- .../PasswordChangeEnforcerExtension.php | 3 +- .../Extension/RefreshUserLockExtension.php | 2 +- .../Extension/UnlockUserLockExtension.php | 2 +- .../User/Admin/UserLockAdmin.php | 9 +- .../User/Block/UserCountBlock.php | 3 +- .../TwoFactorAuthenticationExtension.php | 5 +- .../User/Form/AdminLoginForm.php | 6 +- .../User/Form/ChangePasswordForm.php | 3 +- .../User/Form/Enable2faForm.php | 9 +- .../User/Form/ForgotPasswordForm.php | 6 +- .../DependencyInjection/CompilerPass.php | 6 +- .../DependencyInjection/Configuration.php | 3 +- .../DrawTesterExtension.php | 6 +- .../JsonResponseAssertionsTrait.php | 6 +- .../Messenger/TransportTester.php | 4 +- .../DeleteTemporaryEntityExtension.php | 6 +- .../DoctrineTransactionExtension.php | 2 +- .../SetUpAutowire/AutowireClient.php | 8 +- .../SetUpAutowire/AutowireEntity.php | 3 +- .../Compiler/MessengerPassTest.php | 3 + .../DependencyInjection/ConfigurationTest.php | 3 + .../DrawTesterExtensionTest.php | 3 + ...rawTesterExtensionWithoutProfilingTest.php | 3 + .../Tests/Messenger/TransportTesterTest.php | 3 + packages/tester-bundle/Tests/TestCase.php | 3 + .../tester/Application/CommandDataTester.php | 3 +- packages/tester/AssertTrait.php | 35 ----- .../Command/DumpAssertMethodsCommand.php | 19 +-- ...enerateAssertsDocumentationPageCommand.php | 5 +- .../tester/Command/GenerateTraitCommand.php | 3 +- .../Command/TestsCoverageCheckCommand.php | 3 +- .../tester/Data/AgainstJsonFileTester.php | 4 +- packages/tester/Data/ViolationListTester.php | 2 +- .../DependencyInjection/TesterIntegration.php | 3 +- packages/tester/DoctrineOrmTrait.php | 1 - .../ConfigurationTestCase.php | 2 +- .../DependencyInjection/ExtensionTestCase.php | 4 +- .../Command/TestsCoverageCheckCommandTest.php | 3 + .../Tests/Data/AgainstJsonFileTesterTest.php | 31 ++-- packages/tester/Tests/DataTesterTest.php | 10 +- .../TesterIntegrationTest.php | 2 + packages/tester/Tests/ExampleTest.php | 51 ++++--- packages/user-bundle/AccountLocker.php | 2 +- .../Command/RefreshUserLocksCommand.php | 6 +- .../ExcludeDoctrineEntitiesCompilerPass.php | 3 +- .../DependencyInjection/Configuration.php | 17 ++- .../DependencyInjection/DrawUserExtension.php | 54 ++++--- .../EmailWriter/ForgotPasswordEmailWriter.php | 9 +- .../PasswordChangeRequestedMessage.php | 3 - .../Message/RedirectToSecuredRouteMessage.php | 1 - .../Message/RefreshUserLockMessage.php | 3 - .../user-bundle/Message/ResetPassword.php | 3 - .../RefreshUserLockMessageHandler.php | 6 +- .../RolesTwoFactorAuthenticationEnforcer.php | 2 +- .../Entity/ByEmailTrait.php | 2 +- .../Entity/ByTimeBaseOneTimePasswordTrait.php | 4 +- .../Entity/ConfigurationTrait.php | 4 +- .../QrCodeGenerator.php | 3 +- .../Entity/LockableUserTraitTest.php | 3 + .../AccountLocker/Entity/UserLockTest.php | 3 + .../DependencyInjection/ConfigurationTest.php | 3 + .../DrawUserExtensionTest.php | 3 + ...rExtensionWithAccountLockerEnabledTest.php | 3 + ...erExtensionWithEmailWritersEnabledTest.php | 3 + .../DrawUserExtensionWithEnforce2faTest.php | 3 + ...onWithEnforce2faWithEnforcingRolesTest.php | 3 + ...UserExtensionWithOnboardingEnabledTest.php | 3 + ...nWithPasswordChangeEnforcerEnabledTest.php | 3 + ...sionWithoutEncryptPasswordListenerTest.php | 3 + .../Tests/Entity/ConfigurationTraitTest.php | 3 + .../TwoFactorAuthenticationListenerTest.php | 32 ++-- .../Message/TemporaryUnlockedMessageTest.php | 6 +- .../Constraints/PhpCallableValidator.php | 3 +- .../Constraints/RemoteFileExistsValidator.php | 3 +- .../Constraints/ValueIsNotUsedValidator.php | 9 +- .../ValidatorIntegration.php | 2 +- .../Tests/Constraints/PhpCallableTest.php | 3 + .../Constraints/PhpCallableValidatorTest.php | 7 +- .../Constraints/RemoteFileExistsTest.php | 3 + .../RemoteFileExistsValidatorTest.php | 5 +- .../Tests/Constraints/StrtotimeTest.php | 3 + .../ValidatorIntegrationTest.php | 2 + .../WorkflowIntegration.php | 2 +- .../WorkflowIntegrationTest.php | 2 + ...AddTransitionNameToContextListenerTest.php | 3 + .../AddUserToContextListenerTest.php | 6 +- public/index.php | 2 +- tests/AppKernelTest.php | 3 + tests/Command/NullCommandTest.php | 6 +- .../GenerateDocumentationCommandTest.php | 8 +- .../Api/ConnectionTokensControllerTest.php | 6 +- .../Api/TestDocumentControllerTest.php | 12 +- tests/Controller/Api/UsersControllerTest.php | 33 ++-- tests/Controller/OpenApiControllerTest.php | 3 + tests/Controller/PingActionTest.php | 3 + .../Security/TwoFactorAuthorizationTest.php | 3 + .../UserRequestInterceptedSubscriberTest.php | 6 +- .../PostExecutionQueueCronJobListenerTest.php | 15 +- tests/Entity/UserTest.php | 6 +- tests/Feature/DemoFeatureTest.php | 3 + .../MessageHandler/NullMessageHandlerTest.php | 3 + .../PropertyReferenceEncodingListenerTest.php | 3 + .../Retry/EventDrivenRetryStrategyTest.php | 6 +- .../ResponseApiExceptionListenerTest.php | 3 + ...bjectDeleteBatchEventEventListenerTest.php | 12 +- .../RelationPreventDeleteCanVoterTest.php | 3 + tests/SonataImportBundle/ImporterTest.php | 12 +- .../Action/RetryFailedMessageActionTest.php | 6 +- .../User/Action/UnlockUserActionTest.php | 3 + tests/TestCase.php | 2 +- .../SetUpAutowireExtensionTest.php | 3 + .../ValueIsNotUsedValidatorTest.php | 6 +- 477 files changed, 2760 insertions(+), 1329 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 86557ef99..6d4edf033 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -10,38 +10,27 @@ $config = (new \PhpCsFixer\Config()) ->setRules([ - '@PHP74Migration' => true, - '@PHP74Migration:risky' => true, + '@PHP80Migration:risky' => true, + '@PHP82Migration' => true, + '@PhpCsFixer' => true, + '@PhpCsFixer:risky' => true, '@Symfony' => true, '@Symfony:risky' => true, '@PHPUnit57Migration:risky' => true, '@PHPUnit60Migration:risky' => true, '@PHPUnit75Migration:risky' => true, '@PHPUnit84Migration:risky' => true, - 'array_indentation' => true, - 'combine_consecutive_issets' => true, - 'combine_consecutive_unsets' => true, - 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], - 'php_unit_test_case_static_method_calls' => true, - 'phpdoc_order' => true, - 'header_comment' => [ - 'header' => '', - ], - 'logical_operators' => true, - 'no_useless_return' => true, - 'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], - 'list_syntax' => ['syntax' => 'short'], - 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], - 'no_extra_blank_lines' => true, - 'no_superfluous_phpdoc_tags' => ['allow_unused_params' => true, 'allow_mixed' => true, 'remove_inheritdoc' => true], - 'no_useless_else' => true, - 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], - 'phpdoc_add_missing_param_annotation' => ['only_untyped' => true], - 'single_line_throw' => false, - '@DoctrineAnnotation' => true, - // Disabled risky for now + '@PHPUnit91Migration:risky' => true, + '@PHPUnit100Migration:risky' => true, + 'header_comment' => ['header' => '',], // Make sure we remove any header comments + 'phpdoc_add_missing_param_annotation' => ['only_untyped' => true], // @PhpCsFixer use default 'true', we don't want php doc that are already typed + 'method_chaining_indentation' => false, // @PhpCsFixer use default 'true' impact readability on symfony configuration and sonata admin + 'phpdoc_no_empty_return' => false, // @PhpCsFixer use default 'true' draw/open-api require empty phpdoc for documentation + 'final_internal_class' => false, // All test case are made internal, but we do not want them to be final + // Disabled for now + 'strict_comparison' => false, // @PhpCsFixer:risky change this, we do need to loosely compare 2 object at some places, might find a way to fix this. + 'php_unit_test_class_requires_covers' => false, // @PhpCsFixer use default 'true' putting covers nothing by default 'declare_strict_types' => false, - 'phpdoc_separation' => false, ]) ->setFinder($finder); ; diff --git a/app/src/Command/NullCommand.php b/app/src/Command/NullCommand.php index efb462f21..7dd64b7fa 100644 --- a/app/src/Command/NullCommand.php +++ b/app/src/Command/NullCommand.php @@ -20,7 +20,8 @@ protected function configure(): void InputOption::VALUE_REQUIRED, 'The exit code to return.', Command::SUCCESS - ); + ) + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/app/src/Controller/Admin/AddRolesAminAction.php b/app/src/Controller/Admin/AddRolesAminAction.php index e55daf776..1baf20680 100644 --- a/app/src/Controller/Admin/AddRolesAminAction.php +++ b/app/src/Controller/Admin/AddRolesAminAction.php @@ -22,7 +22,7 @@ public function __invoke( $request, AddRolesForm::class, null, - function (User $user, array $data) use ($objectActionExecutioner): void { + static function (User $user, array $data) use ($objectActionExecutioner): void { $roles = $data['roles']; $missingRoles = array_diff($roles, $user->getRoles()); @@ -34,6 +34,7 @@ function (User $user, array $data) use ($objectActionExecutioner): void { $objectActionExecutioner->skip('all-roles-already-set'); } } - ); + ) + ; } } diff --git a/app/src/Controller/Admin/MakeAdminAction.php b/app/src/Controller/Admin/MakeAdminAction.php index 286fba872..8556e38e0 100644 --- a/app/src/Controller/Admin/MakeAdminAction.php +++ b/app/src/Controller/Admin/MakeAdminAction.php @@ -15,10 +15,10 @@ public function __invoke( return $objectActionExecutioner ->execute( [ - 'execution' => function (User $user) use ($objectActionExecutioner): void { + 'execution' => static function (User $user) use ($objectActionExecutioner): void { $currentRoles = $user->getRoles(); - if (\in_array('ROLE_ADMIN', $currentRoles)) { + if (\in_array('ROLE_ADMIN', $currentRoles, true)) { $objectActionExecutioner->skip('already-admin'); return; @@ -31,10 +31,11 @@ public function __invoke( $objectActionExecutioner->getAdmin()->update($user); }, - 'onExecutionError' => function (ExecutionErrorEvent $event): void { + 'onExecutionError' => static function (ExecutionErrorEvent $event): void { $event->setStopExecution(false); }, ] - ); + ) + ; } } diff --git a/app/src/DataFixtures/AppFixtures.php b/app/src/DataFixtures/AppFixtures.php index 2ca58335b..26179b24c 100644 --- a/app/src/DataFixtures/AppFixtures.php +++ b/app/src/DataFixtures/AppFixtures.php @@ -63,7 +63,8 @@ private function loadTags(): iterable ->getTranslatable() ->translate('fr') ->setLabel('Administrateur') - ->getTranslatable(); + ->getTranslatable() + ; yield 'inactive' => (new Tag()) ->setName('inactive') @@ -73,7 +74,8 @@ private function loadTags(): iterable ->getTranslatable() ->translate('fr') ->setLabel('Inactif') - ->getTranslatable(); + ->getTranslatable() + ; yield 'not-use' => (new Tag()) ->setName('not-use') @@ -82,7 +84,8 @@ private function loadTags(): iterable ->getTranslatable() ->translate('fr') ->setLabel('Non Utilisé') - ->getTranslatable(); + ->getTranslatable() + ; } private function loadUsers(): iterable @@ -107,38 +110,44 @@ private function loadUsers(): iterable (new Address()) ->setStreet('201 Secondary Acme') ) - ); + ) + ; yield (new User()) ->setEmail('2fa-admin@example.com') ->setPlainPassword('2fa-admin') ->setLevel(User::LEVEL_ADMIN) - ->setRoles(['ROLE_2FA_ADMIN']); + ->setRoles(['ROLE_2FA_ADMIN']) + ; yield (new User()) ->setEmail('need-change-password@example.com') ->setNeedChangePassword(true) ->setLevel(User::LEVEL_ADMIN) - ->setRoles(['ROLE_ADMIN']); + ->setRoles(['ROLE_ADMIN']) + ; yield (new User()) ->setEmail('locked@example.com') ->setPlainPassword('locked') ->setLevel(User::LEVEL_ADMIN) ->setRoles(['ROLE_ADMIN']) - ->setManualLock(true); + ->setManualLock(true) + ; $inactiveTag = $this->getObjectReference(Tag::class, 'inactive'); foreach (range(1, 4) as $number) { $user = (new User()) ->setEmail('user-'.str_pad((string) $number, 4, '0', \STR_PAD_LEFT).'@example.com') - ->setPlainPassword('password'); + ->setPlainPassword('password') + ; if (1 === $number) { $user ->setTags([$inactiveTag]) - ->setPreferredLocale('fr'); + ->setPreferredLocale('fr') + ; } yield $user; @@ -154,27 +163,32 @@ private function loadChildObject2(): iterable $user ->setOnDeleteRestrict( $objects[] = (new ChildObject2())->setAttribute2('on-delete-restrict') - ); + ) + ; $user ->setOnDeleteCascade( $objects[] = (new ChildObject2())->setAttribute2('on-delete-cascade') - ); + ) + ; $user ->setOnDeleteSetNull( $objects[] = (new ChildObject2())->setAttribute2('on-delete-set-null') - ); + ) + ; $user ->setOnDeleteCascadeConfigOverridden( $objects[] = (new ChildObject2())->setAttribute2('on-delete-cascade-config-overridden') - ); + ) + ; $user ->setOnDeleteCascadeAttributeOverridden( $objects[] = (new ChildObject2())->setAttribute2('on-delete-cascade-attribute-overridden') - ); + ) + ; yield from $objects; } diff --git a/app/src/Entity/User.php b/app/src/Entity/User.php index dc920cbc9..2f97ba989 100644 --- a/app/src/Entity/User.php +++ b/app/src/Entity/User.php @@ -207,7 +207,7 @@ public function setRoles(array $roles): static $this->roles = array_values( array_filter( $roles, - fn ($role) => \is_string($role) && '' !== $role && 'ROLE_USER' !== $role + static fn ($role) => \is_string($role) && '' !== $role && 'ROLE_USER' !== $role ) ); diff --git a/app/src/EntityMigration/UserSetCommentNullMigration.php b/app/src/EntityMigration/UserSetCommentNullMigration.php index 60838a8b0..67d597bfc 100644 --- a/app/src/EntityMigration/UserSetCommentNullMigration.php +++ b/app/src/EntityMigration/UserSetCommentNullMigration.php @@ -22,7 +22,6 @@ public static function getName(): string public function __construct(private ManagerRegistry $managerRegistry) { - } public static function getTargetEntityClass(): string @@ -46,7 +45,8 @@ public function findAllThatNeedMigration(): iterable \assert($manager instanceof EntityManagerInterface); $query = $manager - ->createQuery('SELECT user.id FROM '.User::class.' user WHERE user.comment != :comment'); + ->createQuery('SELECT user.id FROM '.User::class.' user WHERE user.comment != :comment') + ; foreach ($query->toIterable(['comment' => ''], $query::HYDRATE_SCALAR) as $userId) { yield $manager->getReference(User::class, $userId['id']); @@ -61,7 +61,8 @@ public function countAllThatNeedMigration(): ?int return (int) $manager ->createQuery('SELECT count(user) FROM '.User::class.' user WHERE user.comment != :comment') ->setParameter('comment', '') - ->getSingleScalarResult(); + ->getSingleScalarResult() + ; } public function migrationIsCompleted(): bool @@ -75,7 +76,8 @@ public function migrationIsCompleted(): bool ->where('user.comment != ""') ->setMaxResults(1) ->getQuery() - ->getOneOrNullResult(); + ->getOneOrNullResult() + ; } public function createSelectIdQueryBuilder(): QueryBuilder @@ -88,6 +90,7 @@ public function createSelectIdQueryBuilder(): QueryBuilder ->from(User::class, 'user') ->select('user.id as id') ->where('user.comment != :comment') - ->setParameter('comment', ''); + ->setParameter('comment', '') + ; } } diff --git a/app/src/Form/AddRolesForm.php b/app/src/Form/AddRolesForm.php index 34b49b82c..120222c08 100644 --- a/app/src/Form/AddRolesForm.php +++ b/app/src/Form/AddRolesForm.php @@ -28,6 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'submit', SubmitType::class, ['label' => 'submit'] - ); + ) + ; } } diff --git a/app/src/Kernel.php b/app/src/Kernel.php index b42440048..0a379e240 100755 --- a/app/src/Kernel.php +++ b/app/src/Kernel.php @@ -23,7 +23,8 @@ public function process(ContainerBuilder $container): void $container ->getDefinition('test.client') ->setClass(TestKernelBrowser::class) - ->setAutowired(true); + ->setAutowired(true) + ; } } } diff --git a/app/src/Maker/MakeDrawPackage.php b/app/src/Maker/MakeDrawPackage.php index 5e2068fe3..54e2ef1c4 100644 --- a/app/src/Maker/MakeDrawPackage.php +++ b/app/src/Maker/MakeDrawPackage.php @@ -33,7 +33,8 @@ public function configureCommand(Command $command, InputConfiguration $inputConf $command ->addArgument('type', InputArgument::REQUIRED, 'The type of the package:: (component|bundle)') ->addArgument('name', InputArgument::REQUIRED, 'The name of the package: Example: my-package') - ->addArgument('description', InputArgument::REQUIRED, 'The description of the package'); + ->addArgument('description', InputArgument::REQUIRED, 'The description of the package') + ; } public function configureDependencies(DependencyBuilder $dependencies): void @@ -45,7 +46,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen $type = $input->getArgument('type'); $packageName = $input->getArgument('name'); - if (!\in_array($type, ['component', 'bundle'])) { + if (!\in_array($type, ['component', 'bundle'], true)) { $io->error('Invalid package type'); return; @@ -85,25 +86,29 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen 'type' => $type, ] ) - ); + ) + ; $generator ->dumpFile( 'packages/'.$packageName.'/phpunit.xml.dist', file_get_contents(__DIR__.'/../Resources/skeleton/draw-package/phpunit.xml.dist') - ); + ) + ; $generator ->dumpFile( $this->kernelProjectDir.'/composer.json', $this->getNewComposerContents($packageName, $namespace) - ); + ) + ; $generator ->dumpFile( $this->kernelProjectDir.'/.github/workflows/after_splitting_test.yaml', $this->getNewGithubWorkflowsAfterSplittingTestContents($packageName) - ); + ) + ; $generator->writeChanges(); } diff --git a/app/src/Sonata/Admin/BaseObjectAdmin.php b/app/src/Sonata/Admin/BaseObjectAdmin.php index 89b81cbbc..a52c0e430 100644 --- a/app/src/Sonata/Admin/BaseObjectAdmin.php +++ b/app/src/Sonata/Admin/BaseObjectAdmin.php @@ -69,7 +69,8 @@ protected function configureDatagridFilters(DatagridMapper $filter): void filterOptions: [ 'show_filter' => true, ] - ); + ) + ; } protected function configureListFields(ListMapper $list): void @@ -83,7 +84,8 @@ protected function configureListFields(ListMapper $list): void ] ) ->add('dateTimeImmutable') - ->add('attribute2'); + ->add('attribute2') + ; } protected function configureFormFields(FormMapper $form): void @@ -97,6 +99,7 @@ protected function configureFormFields(FormMapper $form): void ->ifEnd() ->ifTrue($subject instanceof ChildObject2) ->add('attribute2') - ->ifEnd(); + ->ifEnd() + ; } } diff --git a/app/src/Sonata/Admin/TagAdmin.php b/app/src/Sonata/Admin/TagAdmin.php index 0a196cf86..d96931ded 100644 --- a/app/src/Sonata/Admin/TagAdmin.php +++ b/app/src/Sonata/Admin/TagAdmin.php @@ -26,7 +26,8 @@ protected function configureListFields(ListMapper $list): void ->addIdentifier('id') ->add('name') ->add('label') - ->add('active'); + ->add('active') + ; } protected function configureShowFields(ShowMapper $show): void @@ -35,7 +36,8 @@ protected function configureShowFields(ShowMapper $show): void ->add('id') ->add('name') ->add('label') - ->add('active'); + ->add('active') + ; } protected function configureFormFields(FormMapper $form): void @@ -43,7 +45,8 @@ protected function configureFormFields(FormMapper $form): void $form ->add('name') ->add('label') - ->add('active'); + ->add('active') + ; } public function configureGridFields(array $fields): array diff --git a/app/src/Sonata/Admin/UserAdmin.php b/app/src/Sonata/Admin/UserAdmin.php index 2d94de841..032dc6aca 100644 --- a/app/src/Sonata/Admin/UserAdmin.php +++ b/app/src/Sonata/Admin/UserAdmin.php @@ -72,7 +72,8 @@ protected function configureDatagridFilters(DatagridMapper $filter): void ) ->add( 'userTags.tag' - ); + ) + ; } protected function configureListFields(ListMapper $list): void @@ -85,18 +86,21 @@ protected function configureListFields(ListMapper $list): void ->add('userTags', 'list') ->add('tags', 'list') ->add('roles', 'list') - ->add('isLocked', 'boolean', ['inverse' => true]); + ->add('isLocked', 'boolean', ['inverse' => true]) + ; } protected function configureShowFields(ShowMapper $show): void { /** @var TagAdmin $tagAdmin */ $tagAdmin = $this->getConfigurationPool() - ->getAdminByClass(Tag::class); + ->getAdminByClass(Tag::class) + ; /** @var UserLockAdmin $userLockAdmin */ $userLockAdmin = $this->getConfigurationPool() - ->getAdminByClass(UserLock::class); + ->getAdminByClass(UserLock::class) + ; $show ->add('id') @@ -125,7 +129,8 @@ protected function configureShowFields(ShowMapper $show): void 'colspan' => true, 'fields' => $userLockAdmin->configureGridFields([]), ] - ); + ) + ; } protected function configureFormFields(FormMapper $form): void @@ -169,7 +174,7 @@ protected function configureFormFields(FormMapper $form): void ChoiceType::class, [ 'choices' => ['email' => 'email', 'totp' => 'totp'], - 'choice_label' => fn ($choice) => new TranslatableMessage('enabledProviders.choice.'.$choice), + 'choice_label' => static fn ($choice) => new TranslatableMessage('enabledProviders.choice.'.$choice), 'multiple' => true, 'expanded' => true, ] @@ -201,7 +206,8 @@ protected function configureFormFields(FormMapper $form): void ] ) ->end() - ->end(); + ->end() + ; } public function getActions(): array diff --git a/app/src/Sonata/Admin/UserTagAdmin.php b/app/src/Sonata/Admin/UserTagAdmin.php index ae88eca66..730fe2f45 100644 --- a/app/src/Sonata/Admin/UserTagAdmin.php +++ b/app/src/Sonata/Admin/UserTagAdmin.php @@ -21,13 +21,15 @@ class UserTagAdmin extends AbstractAdmin protected function configureFormFields(FormMapper $form): void { $form - ->add('tag'); + ->add('tag') + ; } protected function configureRoutes(RouteCollectionInterface $collection): void { $collection ->remove('edit') - ->remove('show'); + ->remove('show') + ; } } diff --git a/packages/application/DependencyInjection/ConfigurationIntegration.php b/packages/application/DependencyInjection/ConfigurationIntegration.php index 642dbcdec..923fb8273 100644 --- a/packages/application/DependencyInjection/ConfigurationIntegration.php +++ b/packages/application/DependencyInjection/ConfigurationIntegration.php @@ -25,7 +25,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Application\\Configuration\\', + $namespace = 'Draw\Component\Application\Configuration\\', \dirname((new \ReflectionClass(DoctrineConfigurationRegistry::class))->getFileName()) ); diff --git a/packages/application/DependencyInjection/FeatureIntegration.php b/packages/application/DependencyInjection/FeatureIntegration.php index d7fbc7571..40990e64d 100644 --- a/packages/application/DependencyInjection/FeatureIntegration.php +++ b/packages/application/DependencyInjection/FeatureIntegration.php @@ -22,7 +22,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Application\\Feature\\', + $namespace = 'Draw\Component\Application\Feature\\', \dirname((new \ReflectionClass(FeatureInitializer::class))->getFileName()) ); diff --git a/packages/application/DependencyInjection/SystemMonitoringIntegration.php b/packages/application/DependencyInjection/SystemMonitoringIntegration.php index d45a14a5b..77c06e1e6 100644 --- a/packages/application/DependencyInjection/SystemMonitoringIntegration.php +++ b/packages/application/DependencyInjection/SystemMonitoringIntegration.php @@ -35,7 +35,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Application\\SystemMonitoring\\', + $namespace = 'Draw\Component\Application\SystemMonitoring\\', $directory = \dirname((new \ReflectionClass(System::class))->getFileName()), [ $directory.'/Error.php', @@ -69,15 +69,18 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $container ->getDefinition(System::class) - ->setArgument('$monitoredServices', new IteratorArgument($monitoredServices)); + ->setArgument('$monitoredServices', new IteratorArgument($monitoredServices)) + ; $container ->registerForAutoconfiguration(ConnectionStatusProviderInterface::class) - ->addTag(ConnectionStatusProviderInterface::class); + ->addTag(ConnectionStatusProviderInterface::class) + ; $container ->getDefinition(DoctrineConnectionServiceStatusProvider::class) - ->setArgument('$connectionTesters', new TaggedIteratorArgument(ConnectionStatusProviderInterface::class)); + ->setArgument('$connectionTesters', new TaggedIteratorArgument(ConnectionStatusProviderInterface::class)) + ; $this->renameDefinitions( $container, @@ -99,7 +102,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $container ->getDefinition('draw.system_monitoring.action.ping_action') - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; } public function prepend(ContainerBuilder $container, array $config): void @@ -139,7 +143,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->children() ->arrayNode('service_status_providers') ->beforeNormalization() - ->always(function ($config) { + ->always(static function ($config) { foreach ($config as $name => $configuration) { if (!isset($configuration['name'])) { $config[$name]['name'] = $name; @@ -155,7 +159,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->children() ->scalarNode('name') ->validate() - ->ifTrue(fn ($value) => \is_int($value)) + ->ifTrue(static fn ($value) => \is_int($value)) ->thenInvalid('You must specify a name for the service status provider. Can be via the attribute or the key.') ->end() ->isRequired() @@ -168,7 +172,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->booleanNode('any_contexts')->defaultFalse()->end() ->arrayNode('contexts') ->validate() - ->ifTrue(function ($values) { + ->ifTrue(static function ($values) { foreach ($values as $value) { if (str_starts_with($value, '_')) { return true; @@ -184,6 +188,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->end() ->end() ->end() - ->end(); + ->end() + ; } } diff --git a/packages/application/DependencyInjection/VersioningIntegration.php b/packages/application/DependencyInjection/VersioningIntegration.php index 12e4e0193..e877ea8c2 100644 --- a/packages/application/DependencyInjection/VersioningIntegration.php +++ b/packages/application/DependencyInjection/VersioningIntegration.php @@ -25,13 +25,14 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Application\\Versioning\\', + $namespace = 'Draw\Component\Application\Versioning\\', \dirname((new \ReflectionClass(VersionManager::class))->getFileName()) ); $container ->getDefinition(FetchRunningVersionListener::class) - ->setArgument('$projectDirectory', new Parameter('kernel.project_dir')); + ->setArgument('$projectDirectory', new Parameter('kernel.project_dir')) + ; $container->setAlias(VersionVerificationInterface::class, VersionManager::class); diff --git a/packages/application/Feature/FeatureInitializer.php b/packages/application/Feature/FeatureInitializer.php index d9ea61ab2..1e0ae6a4b 100644 --- a/packages/application/Feature/FeatureInitializer.php +++ b/packages/application/Feature/FeatureInitializer.php @@ -15,7 +15,8 @@ public function __construct(private ConfigurationRegistryInterface $configuratio public function initialize(FeatureInterface $feature): void { $configuration = $this->configurationRegistry - ->get($feature->getName(), []); + ->get($feature->getName(), []) + ; $properties = (new \ReflectionObject($feature))->getProperties(); diff --git a/packages/application/SystemMonitoring/Command/SystemStatusesCommand.php b/packages/application/SystemMonitoring/Command/SystemStatusesCommand.php index 33747e71a..bf6cff94b 100644 --- a/packages/application/SystemMonitoring/Command/SystemStatusesCommand.php +++ b/packages/application/SystemMonitoring/Command/SystemStatusesCommand.php @@ -25,7 +25,8 @@ protected function configure(): void 'context', InputArgument::OPTIONAL, 'The context to use to validate the system statuses.', - ); + ) + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -41,7 +42,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->title('System Statuses'); foreach ($monitoringResult->getServiceStatuses() as $name => $serviceStatuses) { - $io->section('Service '.$name); foreach ($serviceStatuses as $serviceStatus) { @@ -59,7 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int break; } } - } $io->section('Results'); diff --git a/packages/application/SystemMonitoring/MonitoredService.php b/packages/application/SystemMonitoring/MonitoredService.php index d48b16b5b..c05618413 100644 --- a/packages/application/SystemMonitoring/MonitoredService.php +++ b/packages/application/SystemMonitoring/MonitoredService.php @@ -31,7 +31,7 @@ public function supports(?string $context = null): bool return true; } - return \in_array($context, $this->contexts); + return \in_array($context, $this->contexts, true); } public function getServiceStatuses(?string $context = null): iterable diff --git a/packages/application/SystemMonitoring/MonitoringResult.php b/packages/application/SystemMonitoring/MonitoringResult.php index 0db52b9d5..eb3212c73 100644 --- a/packages/application/SystemMonitoring/MonitoringResult.php +++ b/packages/application/SystemMonitoring/MonitoringResult.php @@ -13,7 +13,7 @@ public function __construct( private array $serviceStatuses, private ?string $context = null, ) { - /* @var ServiceStatus $serviceStatus */ + /** @var ServiceStatus $serviceStatus */ foreach (array_merge(...array_values($this->serviceStatuses)) as $serviceStatus) { switch ($serviceStatus->getStatus()) { case Status::OK: diff --git a/packages/application/Tests/Configuration/DoctrineConfigurationRegistryTest.php b/packages/application/Tests/Configuration/DoctrineConfigurationRegistryTest.php index 1b919df6e..870eca4a1 100644 --- a/packages/application/Tests/Configuration/DoctrineConfigurationRegistryTest.php +++ b/packages/application/Tests/Configuration/DoctrineConfigurationRegistryTest.php @@ -15,6 +15,9 @@ use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(DoctrineConfigurationRegistry::class)] class DoctrineConfigurationRegistryTest extends TestCase { @@ -35,7 +38,8 @@ public static function setUpBeforeClass(): void ->delete(Config::class, 'config') ->andWhere('config.id = :name') ->getQuery() - ->execute(['name' => 'value']); + ->execute(['name' => 'value']) + ; } protected function setUp(): void @@ -108,7 +112,8 @@ public function testGetValueChangeFromOtherScope(): void ->getQuery() ->execute( ['name' => 'value', 'data' => json_encode(['value' => 'new-value'])] - ); + ) + ; static::assertSame('new-value', $this->object->get('value')); } @@ -127,7 +132,8 @@ public function testGetValueInvalidState(): void ->getQuery() ->execute( ['name' => 'value', 'data' => json_encode(['value' => 'new-value'])] - ); + ) + ; self::$entityManager->clear(); diff --git a/packages/application/Tests/Configuration/Entity/ConfigTest.php b/packages/application/Tests/Configuration/Entity/ConfigTest.php index bf91e769d..763f47a12 100644 --- a/packages/application/Tests/Configuration/Entity/ConfigTest.php +++ b/packages/application/Tests/Configuration/Entity/ConfigTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(Config::class)] class ConfigTest extends TestCase { diff --git a/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php b/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php index da9f72de7..3458db349 100644 --- a/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php +++ b/packages/application/Tests/DependencyInjection/ConfigurationIntegrationTest.php @@ -14,6 +14,8 @@ /** * @property ConfigurationIntegration $integration + * + * @internal */ #[CoversClass(ConfigurationIntegration::class)] class ConfigurationIntegrationTest extends IntegrationTestCase diff --git a/packages/application/Tests/DependencyInjection/FeatureIntegrationTest.php b/packages/application/Tests/DependencyInjection/FeatureIntegrationTest.php index f75c54665..c5e9484c0 100644 --- a/packages/application/Tests/DependencyInjection/FeatureIntegrationTest.php +++ b/packages/application/Tests/DependencyInjection/FeatureIntegrationTest.php @@ -12,6 +12,8 @@ /** * @property ConfigurationIntegration $integration + * + * @internal */ #[CoversClass(FeatureIntegration::class)] class FeatureIntegrationTest extends IntegrationTestCase diff --git a/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php b/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php index ba65da3b1..c028e73ab 100644 --- a/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php +++ b/packages/application/Tests/DependencyInjection/SystemMonitoringIntegrationTest.php @@ -18,6 +18,8 @@ /** * @property SystemMonitoringIntegration $integration + * + * @internal */ #[CoversClass(SystemMonitoringIntegration::class)] class SystemMonitoringIntegrationTest extends IntegrationTestCase diff --git a/packages/application/Tests/DependencyInjection/VersioningIntegrationTest.php b/packages/application/Tests/DependencyInjection/VersioningIntegrationTest.php index 51baf73b0..3a56d68cc 100644 --- a/packages/application/Tests/DependencyInjection/VersioningIntegrationTest.php +++ b/packages/application/Tests/DependencyInjection/VersioningIntegrationTest.php @@ -16,6 +16,8 @@ /** * @property VersioningIntegration $integration + * + * @internal */ #[CoversClass(VersioningIntegration::class)] class VersioningIntegrationTest extends IntegrationTestCase @@ -57,7 +59,7 @@ public static function provideTestLoad(): iterable [ FetchRunningVersionListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { $parameter = $definition->getArgument('$projectDirectory'); static::assertInstanceOf(Parameter::class, $parameter); diff --git a/packages/application/Tests/Versioning/Command/UpdateDeployedVersionCommandTest.php b/packages/application/Tests/Versioning/Command/UpdateDeployedVersionCommandTest.php index 6d17454f7..102931541 100644 --- a/packages/application/Tests/Versioning/Command/UpdateDeployedVersionCommandTest.php +++ b/packages/application/Tests/Versioning/Command/UpdateDeployedVersionCommandTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(UpdateDeployedVersionCommand::class)] class UpdateDeployedVersionCommandTest extends TestCase { @@ -43,12 +46,14 @@ public function testExecute(): void { $this->versionManager ->expects(static::once()) - ->method('updateDeployedVersion'); + ->method('updateDeployedVersion') + ; $this->versionManager ->expects(static::once()) ->method('getRunningVersion') - ->willReturn($deployedVersion = uniqid('version-')); + ->willReturn($deployedVersion = uniqid('version-')) + ; $this->execute([]) ->test( @@ -56,6 +61,7 @@ public function testExecute(): void 0, ['Deployed Version set to: '.$deployedVersion] ) - ); + ) + ; } } diff --git a/packages/application/Tests/Versioning/Event/FetchRunningVersionEventTest.php b/packages/application/Tests/Versioning/Event/FetchRunningVersionEventTest.php index 8b23ef976..15cde261d 100644 --- a/packages/application/Tests/Versioning/Event/FetchRunningVersionEventTest.php +++ b/packages/application/Tests/Versioning/Event/FetchRunningVersionEventTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(FetchRunningVersionEvent::class)] class FetchRunningVersionEventTest extends TestCase { diff --git a/packages/application/Tests/Versioning/EventListener/FetchRunningVersionListenerTest.php b/packages/application/Tests/Versioning/EventListener/FetchRunningVersionListenerTest.php index 1dab2b09a..5c29aeb58 100644 --- a/packages/application/Tests/Versioning/EventListener/FetchRunningVersionListenerTest.php +++ b/packages/application/Tests/Versioning/EventListener/FetchRunningVersionListenerTest.php @@ -9,6 +9,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * @internal + */ #[CoversClass(FetchRunningVersionListener::class)] class FetchRunningVersionListenerTest extends TestCase { diff --git a/packages/application/Tests/Versioning/VersionManagerTest.php b/packages/application/Tests/Versioning/VersionManagerTest.php index 06d012410..a23abffd4 100644 --- a/packages/application/Tests/Versioning/VersionManagerTest.php +++ b/packages/application/Tests/Versioning/VersionManagerTest.php @@ -12,6 +12,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ #[CoversClass(VersionManager::class)] class VersionManagerTest extends TestCase { @@ -51,7 +54,8 @@ public function testGetRunningVersionNotFound(): void ->expects(static::once()) ->method('dispatch') ->with(static::isInstanceOf(FetchRunningVersionEvent::class)) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; static::assertNull($this->service->getRunningVersion()); @@ -67,13 +71,14 @@ public function testGetRunningVersion(): void ->expects(static::once()) ->method('dispatch') ->with( - static::callback(function (FetchRunningVersionEvent $event) use ($version) { + static::callback(static function (FetchRunningVersionEvent $event) use ($version) { $event->setRunningVersion($version); return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; static::assertSame( $version, @@ -94,7 +99,8 @@ public function testUpdateDeployedVersion(): void $this->configurationRegistry ->expects(static::once()) ->method('set') - ->with($this->service::CONFIG, $version); + ->with($this->service::CONFIG, $version) + ; $this->service->updateDeployedVersion(); } @@ -105,7 +111,8 @@ public function testGetDeployedVersion(): void ->expects(static::once()) ->method('get') ->with($this->service::CONFIG) - ->willReturn($version = uniqid('version-')); + ->willReturn($version = uniqid('version-')) + ; static::assertSame( $version, @@ -119,7 +126,8 @@ public function testIsUpToDate(): void ->expects(static::once()) ->method('get') ->with($this->service::CONFIG) - ->willReturn($version = uniqid('version-')); + ->willReturn($version = uniqid('version-')) + ; ReflectionAccessor::setPropertyValue( $this->service, @@ -136,7 +144,8 @@ public function testIsUpToDateFalse(): void ->expects(static::once()) ->method('get') ->with($this->service::CONFIG) - ->willReturn(uniqid('version-')); + ->willReturn(uniqid('version-')) + ; ReflectionAccessor::setPropertyValue( $this->service, diff --git a/packages/application/Versioning/Command/UpdateDeployedVersionCommand.php b/packages/application/Versioning/Command/UpdateDeployedVersionCommand.php index 13d0c1971..c0117e548 100644 --- a/packages/application/Versioning/Command/UpdateDeployedVersionCommand.php +++ b/packages/application/Versioning/Command/UpdateDeployedVersionCommand.php @@ -19,7 +19,8 @@ protected function configure(): void { $this ->setName('draw:application:update-deployed-version') - ->setDescription('You should run this after every successful application deployment.'); + ->setDescription('You should run this after every successful application deployment.') + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -27,7 +28,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->versionManager->updateDeployedVersion(); (new SymfonyStyle($input, $output)) - ->success('Deployed Version set to: '.$this->versionManager->getRunningVersion()); + ->success('Deployed Version set to: '.$this->versionManager->getRunningVersion()) + ; return 0; } diff --git a/packages/aws-tool-kit/Command/CloudWatchLogsDownloadCommand.php b/packages/aws-tool-kit/Command/CloudWatchLogsDownloadCommand.php index 4404e735b..3ac74d98e 100644 --- a/packages/aws-tool-kit/Command/CloudWatchLogsDownloadCommand.php +++ b/packages/aws-tool-kit/Command/CloudWatchLogsDownloadCommand.php @@ -26,7 +26,8 @@ protected function configure(): void ->addArgument('output', InputArgument::REQUIRED, 'The output file name') ->addOption('startTime', null, InputOption::VALUE_REQUIRED, 'Since when the log need to be downloaded.', '- 1 days') ->addOption('endTime', null, InputOption::VALUE_REQUIRED, 'End time of the download.', 'now') - ->addOption('fileMode', null, InputOption::VALUE_REQUIRED, 'Mode in which the output file will be open to write to.', 'w+'); + ->addOption('fileMode', null, InputOption::VALUE_REQUIRED, 'Mode in which the output file will be open to write to.', 'w+') + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -56,7 +57,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $events = $this ->cloudWatchClient - ->getLogEvents($arguments); + ->getLogEvents($arguments) + ; foreach ($events['events'] as $event) { fwrite($handle, $event['message'].\PHP_EOL); diff --git a/packages/aws-tool-kit/DependencyInjection/AwsToolKitIntegration.php b/packages/aws-tool-kit/DependencyInjection/AwsToolKitIntegration.php index 9538a7782..f38983925 100644 --- a/packages/aws-tool-kit/DependencyInjection/AwsToolKitIntegration.php +++ b/packages/aws-tool-kit/DependencyInjection/AwsToolKitIntegration.php @@ -32,7 +32,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\AwsToolKit\\', + $namespace = 'Draw\Component\AwsToolKit\\', \dirname( (new \ReflectionClass(ImdsClientInterface::class))->getFileName(), 2 @@ -69,7 +69,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void { $node ->validate() - ->ifTrue(fn (array $config) => match (true) { + ->ifTrue(static fn (array $config) => match (true) { !$config['newest_instance_role_check']['enabled'], null !== $config['imds_version'] => false, default => true, }) @@ -80,6 +80,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->arrayNode('newest_instance_role_check') ->canBeEnabled() ->end() - ->end(); + ->end() + ; } } diff --git a/packages/aws-tool-kit/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPass.php b/packages/aws-tool-kit/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPass.php index d8908fe3b..6177aa69a 100644 --- a/packages/aws-tool-kit/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPass.php +++ b/packages/aws-tool-kit/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPass.php @@ -29,7 +29,8 @@ public function process(ContainerBuilder $container): void InputOption::VALUE_REQUIRED, 'The instance role the server must be the newest of to run the command.', ] - ); + ) + ; } } } diff --git a/packages/aws-tool-kit/Tests/Command/CloudWatchLogsDownloadCommandTest.php b/packages/aws-tool-kit/Tests/Command/CloudWatchLogsDownloadCommandTest.php index f29756369..80ad353d2 100644 --- a/packages/aws-tool-kit/Tests/Command/CloudWatchLogsDownloadCommandTest.php +++ b/packages/aws-tool-kit/Tests/Command/CloudWatchLogsDownloadCommandTest.php @@ -14,6 +14,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +/** + * @internal + */ #[CoversClass(CloudWatchLogsDownloadCommand::class)] class CloudWatchLogsDownloadCommandTest extends TestCase { @@ -29,7 +32,8 @@ protected function setUp(): void ->disableOriginalConstructor() ->disableOriginalClone() ->onlyMethods(['__call']) - ->getMock(); + ->getMock() + ; $this->command = new CloudWatchLogsDownloadCommand($this->cloudWatchLogsClient); } @@ -124,7 +128,8 @@ public function testExecuteNewFile(): void ], 'nextForwardToken' => 'next-token', ] - ); + ) + ; $this->execute( compact('logGroupName', 'logStreamName', 'output') @@ -133,9 +138,10 @@ public function testExecuteNewFile(): void '--endTime' => $endTime->format('Y-m-d H:i:s'), ] ) - ->test(CommandDataTester::create()); + ->test(CommandDataTester::create()) + ; - static::assertEquals( + static::assertSame( "Line 1\nLine 2\n", file_get_contents($output) ); @@ -173,7 +179,8 @@ public function testExecuteAppendFile(): void ], 'nextForwardToken' => null, ] - ); + ) + ; $this->execute( compact('logGroupName', 'logStreamName', 'output') @@ -183,9 +190,10 @@ public function testExecuteAppendFile(): void '--fileMode' => 'a+', ] ) - ->test(CommandDataTester::create()); + ->test(CommandDataTester::create()) + ; - static::assertEquals( + static::assertSame( "Before\nLine 1\n", file_get_contents($output) ); diff --git a/packages/aws-tool-kit/Tests/DependencyInjection/AwsToolKitIntegrationTest.php b/packages/aws-tool-kit/Tests/DependencyInjection/AwsToolKitIntegrationTest.php index 1347d23e9..338e09d33 100644 --- a/packages/aws-tool-kit/Tests/DependencyInjection/AwsToolKitIntegrationTest.php +++ b/packages/aws-tool-kit/Tests/DependencyInjection/AwsToolKitIntegrationTest.php @@ -15,6 +15,8 @@ /** * @property AwsToolKitIntegration $integration + * + * @internal */ #[CoversClass(AwsToolKitIntegration::class)] class AwsToolKitIntegrationTest extends IntegrationTestCase diff --git a/packages/aws-tool-kit/Tests/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPassTest.php b/packages/aws-tool-kit/Tests/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPassTest.php index 14d2a1204..34c2fc9e1 100644 --- a/packages/aws-tool-kit/Tests/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPassTest.php +++ b/packages/aws-tool-kit/Tests/DependencyInjection/Compiler/AddNewestInstanceRoleCommandOptionPassTest.php @@ -10,6 +10,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +/** + * @internal + */ #[CoversClass(AddNewestInstanceRoleCommandOptionPass::class)] class AddNewestInstanceRoleCommandOptionPassTest extends TestCase { diff --git a/packages/aws-tool-kit/Tests/EventListener/NewestInstanceRoleListenerCheckTest.php b/packages/aws-tool-kit/Tests/EventListener/NewestInstanceRoleListenerCheckTest.php index dd1cd7021..6c07977c4 100644 --- a/packages/aws-tool-kit/Tests/EventListener/NewestInstanceRoleListenerCheckTest.php +++ b/packages/aws-tool-kit/Tests/EventListener/NewestInstanceRoleListenerCheckTest.php @@ -14,6 +14,9 @@ use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * @internal + */ #[CoversClass(NewestInstanceRoleCheckListener::class)] class NewestInstanceRoleListenerCheckTest extends TestCase { @@ -53,7 +56,8 @@ public function testCheckNewestInstanceNoOption(): void { $this->imdsClient ->expects(static::never()) - ->method('getCurrentInstanceId'); + ->method('getCurrentInstanceId') + ; $this->service->checkNewestInstance( $event = new ConsoleCommandEvent( @@ -70,7 +74,8 @@ public function testCheckNewestInstanceOptionNull(): void { $this->imdsClient ->expects(static::never()) - ->method('getCurrentInstanceId'); + ->method('getCurrentInstanceId') + ; $this->service->checkNewestInstance( $event = new ConsoleCommandEvent( @@ -89,7 +94,8 @@ public function testCheckNewestInstanceCurrentInstanceIdError(): void ->expects(static::once()) ->method('getCurrentInstanceId') ->with() - ->willThrowException(new \Exception()); + ->willThrowException(new \Exception()) + ; $this->service->checkNewestInstance( $event = new ConsoleCommandEvent( @@ -108,7 +114,8 @@ public function testCheckNewestInstanceCurrentInstanceIdEmpty(): void ->expects(static::once()) ->method('getCurrentInstanceId') ->with() - ->willReturn(null); + ->willReturn(null) + ; $this->service->checkNewestInstance( $event = new ConsoleCommandEvent( @@ -128,7 +135,8 @@ public function testCheckNewestInstanceNoInstance(): void ->expects(static::once()) ->method('getCurrentInstanceId') ->with() - ->willReturn(uniqid('instance-id-')); + ->willReturn(uniqid('instance-id-')) + ; $this->mockEc2ClientDescribeInstances( $role, @@ -153,7 +161,8 @@ public function testCheckNewestInstanceNotNewestInstance(): void ->expects(static::once()) ->method('getCurrentInstanceId') ->with() - ->willReturn($instanceId = uniqid('instance-id-')); + ->willReturn($instanceId = uniqid('instance-id-')) + ; $this->mockEc2ClientDescribeInstances( $role, @@ -187,7 +196,8 @@ public function testCheckNewestInstanceError(): void ->expects(static::once()) ->method('getCurrentInstanceId') ->with() - ->willReturn(uniqid('instance-id-')); + ->willReturn(uniqid('instance-id-')) + ; $this->mockEc2ClientDescribeInstances( $role, @@ -213,7 +223,8 @@ public function testCheckNewestInstanceNewestInstance(): void ->expects(static::once()) ->method('getCurrentInstanceId') ->with() - ->willReturn($instanceId = uniqid('instance-id-')); + ->willReturn($instanceId = uniqid('instance-id-')) + ; $this->mockEc2ClientDescribeInstances( $role, @@ -248,7 +259,8 @@ private function mockEc2ClientDescribeInstances( $ec2Client = $this->getMockBuilder(Ec2Client::class) ->disableOriginalConstructor() ->onlyMethods(['__call']) - ->getMock(); + ->getMock() + ; ReflectionAccessor::setPropertyValue( $this->service, @@ -276,7 +288,8 @@ private function mockEc2ClientDescribeInstances( ], ], ] - ); + ) + ; if ($error) { $invocationMocker->willThrowException($error); @@ -290,7 +303,8 @@ private function mockEc2ClientDescribeInstances( ], ], ] - ); + ) + ; } } @@ -301,17 +315,20 @@ private function createInput(bool $hasOption, ?string $optionValue = null): Inpu $input->expects(static::once()) ->method('hasOption') ->with($this->service::OPTION_AWS_NEWEST_INSTANCE_ROLE) - ->willReturn($hasOption); + ->willReturn($hasOption) + ; if ($hasOption) { $input->expects(static::once()) ->method('getOption') ->with($this->service::OPTION_AWS_NEWEST_INSTANCE_ROLE) - ->willReturn($optionValue); + ->willReturn($optionValue) + ; } else { $input->expects(static::never()) ->method('getOption') - ->with($this->service::OPTION_AWS_NEWEST_INSTANCE_ROLE); + ->with($this->service::OPTION_AWS_NEWEST_INSTANCE_ROLE) + ; } return $input; diff --git a/packages/aws-tool-kit/Tests/Imds/ImdsClientV1Test.php b/packages/aws-tool-kit/Tests/Imds/ImdsClientV1Test.php index fa6dee3a0..e26ca3810 100644 --- a/packages/aws-tool-kit/Tests/Imds/ImdsClientV1Test.php +++ b/packages/aws-tool-kit/Tests/Imds/ImdsClientV1Test.php @@ -9,6 +9,9 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; +/** + * @internal + */ #[CoversClass(ImdsClientV1::class)] class ImdsClientV1Test extends TestCase { @@ -32,13 +35,15 @@ public function testGetCurrentInstanceId(): void 'GET', 'http://169.254.169.254/latest/meta-data/instance-id' ) - ->willReturn($response = $this->createMock(ResponseInterface::class)); + ->willReturn($response = $this->createMock(ResponseInterface::class)) + ; $response ->expects(static::once()) ->method('getContent') ->with() - ->willReturn($instanceId = uniqid('instance-id-')); + ->willReturn($instanceId = uniqid('instance-id-')) + ; static::assertSame( $instanceId, diff --git a/packages/aws-tool-kit/Tests/Imds/ImdsClientV2Test.php b/packages/aws-tool-kit/Tests/Imds/ImdsClientV2Test.php index 79b680143..d51a5bbf8 100644 --- a/packages/aws-tool-kit/Tests/Imds/ImdsClientV2Test.php +++ b/packages/aws-tool-kit/Tests/Imds/ImdsClientV2Test.php @@ -10,6 +10,9 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; +/** + * @internal + */ #[CoversClass(ImdsClientV2::class)] class ImdsClientV2Test extends TestCase { @@ -33,14 +36,16 @@ public function testGetCurrentInstanceId(): void ->expects(static::once()) ->method('getContent') ->with() - ->willReturn($token = uniqid('token-')); + ->willReturn($token = uniqid('token-')) + ; $instanceIdResponse = $this->createMock(ResponseInterface::class); $instanceIdResponse ->expects(static::once()) ->method('getContent') ->with() - ->willReturn($instanceId = uniqid('instance-id-')); + ->willReturn($instanceId = uniqid('instance-id-')) + ; $this->httpClient ->expects(static::exactly(2)) @@ -70,7 +75,8 @@ public function testGetCurrentInstanceId(): void ->willReturnOnConsecutiveCalls( $tokenResponse, $instanceIdResponse, - ); + ) + ; static::assertSame( $instanceId, diff --git a/packages/console/Command/GenerateDocumentationCommand.php b/packages/console/Command/GenerateDocumentationCommand.php index 42de7b553..3538fe291 100644 --- a/packages/console/Command/GenerateDocumentationCommand.php +++ b/packages/console/Command/GenerateDocumentationCommand.php @@ -30,7 +30,8 @@ protected function configure(): void $this ->setDescription('Generate a documentation for all the command of the application.') ->addArgument('path', InputArgument::REQUIRED, 'The path where the documentation will be generated.') - ->addOption('format', 'f', InputArgument::OPTIONAL, 'The format of the documentation (txt|md|json|xml).', 'txt'); + ->addOption('format', 'f', InputArgument::OPTIONAL, 'The format of the documentation (txt|md|json|xml).', 'txt') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/packages/console/Command/PurgeExecutionCommand.php b/packages/console/Command/PurgeExecutionCommand.php index bd5c4d974..c992133e2 100644 --- a/packages/console/Command/PurgeExecutionCommand.php +++ b/packages/console/Command/PurgeExecutionCommand.php @@ -51,7 +51,8 @@ protected function configure(): void InputOption::VALUE_OPTIONAL, 'The delete loop will sleep this long in seconds between iteration.', self::DEFAULT_WAIT_SECOND - ); + ) + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/packages/console/DependencyInjection/ConsoleIntegration.php b/packages/console/DependencyInjection/ConsoleIntegration.php index 8a45575c4..126172acd 100644 --- a/packages/console/DependencyInjection/ConsoleIntegration.php +++ b/packages/console/DependencyInjection/ConsoleIntegration.php @@ -37,7 +37,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Console\\', + $namespace = 'Draw\Component\Console\\', $directory = \dirname( (new \ReflectionClass(PurgeExecutionCommand::class))->getFileName(), 2 @@ -49,7 +49,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $container ->getDefinition(CommandFlowListener::class) - ->setArgument('$ignoreDisabledCommand', $config['ignore_disabled_command']); + ->setArgument('$ignoreDisabledCommand', $config['ignore_disabled_command']) + ; if (!$config['documentation']['command_names']) { $container->removeDefinition(DocumentationFilterCommandEventListener::class); @@ -57,7 +58,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $container ->getDefinition(DocumentationFilterCommandEventListener::class) ->setArgument('$commandNames', $config['documentation']['command_names']) - ->setArgument('$filter', $config['documentation']['filter']); + ->setArgument('$filter', $config['documentation']['filter']) + ; } $this->renameDefinitions( @@ -74,7 +76,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con ->addMethodCall( 'register', ['txt', new Reference(TextDescriptor::class)] - ); + ) + ; $container->setAlias( DescriptorHelper::class, @@ -96,7 +99,8 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->end() ->end() ->end() - ->end(); + ->end() + ; } public function prepend(ContainerBuilder $container, array $config): void diff --git a/packages/console/EventListener/CommandFlowListener.php b/packages/console/EventListener/CommandFlowListener.php index 0f438935a..f68e98601 100644 --- a/packages/console/EventListener/CommandFlowListener.php +++ b/packages/console/EventListener/CommandFlowListener.php @@ -87,7 +87,7 @@ public function configureOptions(ConsoleCommandEvent $event): void public function checkIgnoredCommands(LoadExecutionIdEvent $event): void { - if (\in_array($event->getCommand()->getName(), $this->commandsToIgnore)) { + if (\in_array($event->getCommand()->getName(), $this->commandsToIgnore, true)) { $event->ignoreTracking(); } } @@ -126,7 +126,7 @@ public function generateFromDatabase(LoadExecutionIdEvent $event): void $parameters = $input->getArguments(); // We want to keep 0 value - $options = array_filter($input->getOptions(), fn ($value) => false !== $value && null !== $value); + $options = array_filter($input->getOptions(), static fn ($value) => false !== $value && null !== $value); foreach ($options as $key => $value) { $parameters['--'.$key] = $value; @@ -225,7 +225,8 @@ public function logCommandError(Event\ConsoleErrorEvent $event): void } $commandErrorEvent = $this->eventDispatcher - ->dispatch(new CommandErrorEvent($executionId, $outputString)); + ->dispatch(new CommandErrorEvent($executionId, $outputString)) + ; $executionState = $commandErrorEvent->isAutoAcknowledge() ? Execution::STATE_AUTO_ACKNOWLEDGE @@ -260,7 +261,8 @@ private function updateState( if ($this->ignoreDisabledCommand && Execution::STATE_DISABLED === $state) { $this->connection ->prepare('DELETE FROM command__execution WHERE id = :id') - ->executeStatement(['id' => $executionId]); + ->executeStatement(['id' => $executionId]) + ; if ($reconnectToSlave && $this->connection instanceof PrimaryReadReplicaConnection) { $this->connection->ensureConnectedToReplica(); @@ -301,8 +303,8 @@ private function updateState( command__execution SET updated_at = :updated_at, - $setOutput - $setAutoAcknowledgeReason + {$setOutput} + {$setAutoAcknowledgeReason} state = IF(state != 'error', :state, state) WHERE id = :id diff --git a/packages/console/EventListener/DocumentationFilterCommandEventListener.php b/packages/console/EventListener/DocumentationFilterCommandEventListener.php index 0186d731d..35b42c41a 100644 --- a/packages/console/EventListener/DocumentationFilterCommandEventListener.php +++ b/packages/console/EventListener/DocumentationFilterCommandEventListener.php @@ -17,7 +17,7 @@ public function __construct(private array $commandNames, private string $filter #[AsEventListener] public function onGenerateDocumentationEvent(GenerateDocumentationEvent $event): void { - $match = \in_array($event->getCommand()->getName(), $this->commandNames); + $match = \in_array($event->getCommand()->getName(), $this->commandNames, true); if ($match && self::FILTER_OUT === $this->filter) { $event->ignore(); diff --git a/packages/console/Tests/Command/PurgeExecutionCommandTest.php b/packages/console/Tests/Command/PurgeExecutionCommandTest.php index 5abffc088..e9edd567f 100644 --- a/packages/console/Tests/Command/PurgeExecutionCommandTest.php +++ b/packages/console/Tests/Command/PurgeExecutionCommandTest.php @@ -13,6 +13,9 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Console\Input\InputOption; +/** + * @internal + */ #[CoversClass(PurgeExecutionCommand::class)] class PurgeExecutionCommandTest extends TestCase { @@ -104,7 +107,8 @@ public function testExecute(): void ['record_count' => 1002], ] ) - ); + ) + ; $this->connection->expects(static::exactly(2)) ->method('executeStatement') @@ -122,9 +126,11 @@ public function testExecute(): void ] ) ) - ->willReturnOnConsecutiveCalls(1000, 2); + ->willReturnOnConsecutiveCalls(1000, 2) + ; $this->execute(['--delay' => $date, '--sleep' => 0]) - ->test(CommandDataTester::create()); + ->test(CommandDataTester::create()) + ; } } diff --git a/packages/console/Tests/DependencyInjection/Compiler/AddCommandExecutionOptionsCompilerPassTest.php b/packages/console/Tests/DependencyInjection/Compiler/AddCommandExecutionOptionsCompilerPassTest.php index 01c88ad6b..57f99c52c 100644 --- a/packages/console/Tests/DependencyInjection/Compiler/AddCommandExecutionOptionsCompilerPassTest.php +++ b/packages/console/Tests/DependencyInjection/Compiler/AddCommandExecutionOptionsCompilerPassTest.php @@ -10,6 +10,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +/** + * @internal + */ #[CoversClass(AddCommandExecutionOptionsCompilerPass::class)] class AddCommandExecutionOptionsCompilerPassTest extends TestCase { diff --git a/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php b/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php index 16bcf5c58..8807990b2 100644 --- a/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php +++ b/packages/console/Tests/DependencyInjection/ConsoleIntegrationTest.php @@ -19,6 +19,8 @@ /** * @property ConsoleIntegration $integration + * + * @internal */ #[CoversClass(ConsoleIntegration::class)] class ConsoleIntegrationTest extends IntegrationTestCase @@ -133,7 +135,7 @@ public static function provideTestLoad(): iterable [ CommandFlowListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertTrue( $definition->getArgument('$ignoreDisabledCommand') ); @@ -144,7 +146,7 @@ function (Definition $definition): void { [ DocumentationFilterCommandEventListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( 'out', $definition->getArgument('$filter') diff --git a/packages/console/Tests/Entity/ExecutionTest.php b/packages/console/Tests/Entity/ExecutionTest.php index 02e42cf1c..9446ecccb 100644 --- a/packages/console/Tests/Entity/ExecutionTest.php +++ b/packages/console/Tests/Entity/ExecutionTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(Execution::class)] class ExecutionTest extends TestCase { @@ -269,7 +272,8 @@ public function testUpdateTimestampAlreadyChanged(): void $event->expects(static::once()) ->method('hasChangedField') ->with('updatedAt') - ->willReturn(true); + ->willReturn(true) + ; $this->entity->updateTimestamp($event); diff --git a/packages/console/Tests/Event/CommandErrorEventTest.php b/packages/console/Tests/Event/CommandErrorEventTest.php index 380650b08..20f3144be 100644 --- a/packages/console/Tests/Event/CommandErrorEventTest.php +++ b/packages/console/Tests/Event/CommandErrorEventTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(CommandErrorEvent::class)] class CommandErrorEventTest extends TestCase { diff --git a/packages/console/Tests/EventListener/CommandFlowListenerTest.php b/packages/console/Tests/EventListener/CommandFlowListenerTest.php index 95822890c..df24e5cf5 100644 --- a/packages/console/Tests/EventListener/CommandFlowListenerTest.php +++ b/packages/console/Tests/EventListener/CommandFlowListenerTest.php @@ -34,6 +34,9 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ #[CoversClass(CommandFlowListener::class)] class CommandFlowListenerTest extends TestCase { @@ -167,7 +170,8 @@ public function testCheckIgnoredCommandsIgnored(): void $command ->expects(static::once()) ->method('getName') - ->willReturn('help'); + ->willReturn('help') + ; $this->object->checkIgnoredCommands($event); @@ -186,7 +190,8 @@ public function testCheckIgnoredCommandsNotIgnored(): void $command ->expects(static::once()) ->method('getName') - ->willReturn(uniqid('command-')); + ->willReturn(uniqid('command-')) + ; $this->object->checkIgnoredCommands($event); @@ -206,13 +211,15 @@ public function testCheckHelpIgnored(): void ->expects(static::once()) ->method('hasOption') ->with('help') - ->willReturn(true); + ->willReturn(true) + ; $input ->expects(static::once()) ->method('getOption') ->with('help') - ->willReturn(true); + ->willReturn(true) + ; $this->object->checkHelp($event); @@ -232,7 +239,8 @@ public function testCheckHelpNotIgnored(): void ->expects(static::once()) ->method('hasOption') ->with('help') - ->willReturn(false); + ->willReturn(false) + ; $this->object->checkHelp($event); @@ -257,13 +265,15 @@ public function testCheckTableExistIgnoredTableDoesNotExists(): void $connection ->expects(static::once()) ->method('createSchemaManager') - ->willReturn($schemaManager = $this->createMock(MySQLSchemaManager::class)); + ->willReturn($schemaManager = $this->createMock(MySQLSchemaManager::class)) + ; $schemaManager ->expects(static::once()) ->method('tablesExist') ->with(['command__execution']) - ->willReturn(false); + ->willReturn(false) + ; $this->object->checkTableExist($event); @@ -288,7 +298,8 @@ public function testCheckTableExistIgnoredException(): void $connection ->expects(static::once()) ->method('createSchemaManager') - ->willThrowException(new DBALException()); + ->willThrowException(new DBALException()) + ; $this->object->checkTableExist($event); @@ -308,7 +319,8 @@ public function testLoadIdFromInputNotFound(): void ->expects(static::once()) ->method('hasOption') ->with($this->object::OPTION_EXECUTION_ID) - ->willReturn(false); + ->willReturn(false) + ; $this->object->loadIdFromInput($event); @@ -341,17 +353,20 @@ public function testGenerateFromDatabaseIgnoredException(): void $command ->expects(static::once()) ->method('getName') - ->willReturn(uniqid('command-')); + ->willReturn(uniqid('command-')) + ; $input ->expects(static::once()) ->method('getArguments') - ->willReturn([]); + ->willReturn([]) + ; $input ->expects(static::once()) ->method('getOptions') - ->willReturn([]); + ->willReturn([]) + ; $connection = $this->mockProperty( $this->object, @@ -362,16 +377,19 @@ public function testGenerateFromDatabaseIgnoredException(): void $connection ->expects(static::once()) ->method('isConnectedToPrimary') - ->willReturn(false); + ->willReturn(false) + ; $connection ->expects(static::once()) ->method('insert') - ->willThrowException($error = new \Exception()); + ->willThrowException($error = new \Exception()) + ; $connection ->expects(static::once()) - ->method('ensureConnectedToReplica'); + ->method('ensureConnectedToReplica') + ; $this->logger ->expects(static::once()) @@ -379,7 +397,8 @@ public function testGenerateFromDatabaseIgnoredException(): void ->with( 'Command flow listener error while generating execution id', ['error' => $error] - ); + ) + ; $this->object->generateFromDatabase($event); @@ -398,17 +417,20 @@ public function testGenerateFromDatabase(): void $command ->expects(static::once()) ->method('getName') - ->willReturn($commandName = uniqid('command-')); + ->willReturn($commandName = uniqid('command-')) + ; $input ->expects(static::once()) ->method('getArguments') - ->willReturn(['keyName' => 'keyValue']); + ->willReturn(['keyName' => 'keyValue']) + ; $input ->expects(static::once()) ->method('getOptions') - ->willReturn(['null' => null, 'zero' => 0, 'false' => false, 'other' => 'value']); + ->willReturn(['null' => null, 'zero' => 0, 'false' => false, 'other' => 'value']) + ; $connection = $this->mockProperty( $this->object, @@ -419,7 +441,8 @@ public function testGenerateFromDatabase(): void $connection ->expects(static::once()) ->method('isConnectedToPrimary') - ->willReturn(false); + ->willReturn(false) + ; $connection ->expects(static::once()) @@ -469,11 +492,13 @@ public function testGenerateFromDatabase(): void return true; }) - ); + ) + ; $connection ->expects(static::once()) - ->method('ensureConnectedToReplica'); + ->method('ensureConnectedToReplica') + ; $this->object->generateFromDatabase($event); @@ -492,17 +517,20 @@ public function testGenerateFromDatabaseReal(): Execution $command ->expects(static::once()) ->method('getName') - ->willReturn(uniqid('command-')); + ->willReturn(uniqid('command-')) + ; $input ->expects(static::once()) ->method('getArguments') - ->willReturn([]); + ->willReturn([]) + ; $input ->expects(static::once()) ->method('getOptions') - ->willReturn([]); + ->willReturn([]) + ; $this->object->generateFromDatabase($event); @@ -519,7 +547,8 @@ public function testLogCommandStartNoExecutionId(): void $this->eventDispatcher ->expects(static::once()) ->method('dispatch') - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $event = new ConsoleCommandEvent( $command = $this->createMock(Command::class), @@ -529,7 +558,8 @@ public function testLogCommandStartNoExecutionId(): void $command ->expects(static::never()) - ->method('getDefinition'); + ->method('getDefinition') + ; $this->object->logCommandStart($event); } @@ -541,13 +571,14 @@ public function testLogCommandStart(Execution $execution): void ->expects(static::once()) ->method('dispatch') ->with( - static::callback(function (LoadExecutionIdEvent $event) use ($execution) { + static::callback(static function (LoadExecutionIdEvent $event) use ($execution) { $event->setExecutionId($execution->getId()); return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $event = new ConsoleCommandEvent( $command = $this->createMock(Command::class), @@ -558,7 +589,8 @@ public function testLogCommandStart(Execution $execution): void $command ->expects(static::once()) ->method('getDefinition') - ->willReturn($definition = new InputDefinition()); + ->willReturn($definition = new InputDefinition()) + ; $definition->addOption( $option = new InputOption($this->object::OPTION_EXECUTION_ID, null, InputOption::VALUE_REQUIRED) @@ -587,11 +619,13 @@ public function testLogCommandTerminateReplication(): void $connection ->expects(static::once()) ->method('isConnectedToPrimary') - ->willReturn(false); + ->willReturn(false) + ; $connection ->expects(static::once()) - ->method('ensureConnectedToReplica'); + ->method('ensureConnectedToReplica') + ; $event = new Event\ConsoleTerminateEvent( $this->createMock(Command::class), @@ -614,7 +648,8 @@ public function testLogCommandTerminateNoExecutionId(): void $output ->expects(static::never()) - ->method('fetch'); + ->method('fetch') + ; $this->object->logCommandTerminate($event); } @@ -632,7 +667,8 @@ public function testLogCommandTerminate(Execution $execution): void $output ->expects(static::once()) ->method('fetch') - ->willReturn($output = uniqid('output-')); + ->willReturn($output = uniqid('output-')) + ; $this->object->logCommandTerminate($event); @@ -655,7 +691,8 @@ public function testLogCommandTerminateLongOutput(Execution $execution): void $output ->expects(static::once()) ->method('fetch') - ->willReturn(str_repeat('Z', 50001)); + ->willReturn(str_repeat('Z', 50001)) + ; $execution->setOutput(''); self::$entityManager->flush(); @@ -681,7 +718,8 @@ public function testLogCommandErrorNoExecutionId(): void $this->eventDispatcher ->expects(static::never()) - ->method('dispatch'); + ->method('dispatch') + ; $this->object->logCommandError($event); } @@ -699,7 +737,8 @@ public function testLogCommandError(Execution $execution): void $command ->expects(static::once()) ->method('getApplication') - ->willReturn($application = $this->createMock(Application::class)); + ->willReturn($application = $this->createMock(Application::class)) + ; $outputString = uniqid('output-string-'); @@ -708,12 +747,13 @@ public function testLogCommandError(Execution $execution): void ->method('renderThrowable') ->with( $error, - static::callback(function (BufferedOutput $output) use ($outputString) { + static::callback(static function (BufferedOutput $output) use ($outputString) { $output->write($outputString); return true; }) - ); + ) + ; $this->eventDispatcher ->expects(static::once()) @@ -726,7 +766,8 @@ public function testLogCommandError(Execution $execution): void return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->object->logCommandError($event); @@ -751,13 +792,14 @@ public function testLogCommandErrorAutoAcknowledge(Execution $execution): void ->expects(static::once()) ->method('dispatch') ->with( - static::callback(function (CommandErrorEvent $event) use ($reason) { + static::callback(static function (CommandErrorEvent $event) use ($reason) { $event->acknowledge($reason); return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; // If current state is error, state will not be changed $execution->setState(Execution::STATE_TERMINATED); @@ -784,7 +826,8 @@ public function testLogCommandTerminateDisabled(Execution $execution): void $output ->expects(static::once()) ->method('fetch') - ->willReturn(uniqid('output-')); + ->willReturn(uniqid('output-')) + ; $this->object->logCommandTerminate($event); @@ -806,14 +849,16 @@ public function testLogCommandTerminateDisabledIgnored(Execution $execution): vo $output ->expects(static::once()) ->method('fetch') - ->willReturn(uniqid('output-')); + ->willReturn(uniqid('output-')) + ; ReflectionAccessor::setPropertyValue($this->object, 'ignoreDisabledCommand', true); $this->object->logCommandTerminate($event); $execution = self::$entityManager->getRepository(Execution::class) - ->findOneBy(['id' => $execution->getId()]); + ->findOneBy(['id' => $execution->getId()]) + ; static::assertNull($execution); } @@ -826,13 +871,15 @@ private function createOptionExecutionIdInput(string $id): InputInterface ->expects(static::once()) ->method('hasOption') ->with($this->object::OPTION_EXECUTION_ID) - ->willReturn(true); + ->willReturn(true) + ; $input ->expects(static::once()) ->method('getOption') ->with($this->object::OPTION_EXECUTION_ID) - ->willReturn($id); + ->willReturn($id) + ; return $input; } diff --git a/packages/console/Tests/Output/BufferedConsoleOutputTest.php b/packages/console/Tests/Output/BufferedConsoleOutputTest.php index ce2b11e07..8ba25c35a 100644 --- a/packages/console/Tests/Output/BufferedConsoleOutputTest.php +++ b/packages/console/Tests/Output/BufferedConsoleOutputTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; +/** + * @internal + */ #[CoversClass(BufferedConsoleOutput::class)] class BufferedConsoleOutputTest extends TestCase { @@ -41,12 +44,14 @@ public function testSetDecorated(): void $formatter ->expects(static::exactly(3)) ->method('isDecorated') - ->willReturnOnConsecutiveCalls(false, true, true); + ->willReturnOnConsecutiveCalls(false, true, true) + ; $formatter ->expects(static::once()) ->method('setDecorated') - ->with(true); + ->with(true) + ; $this->object->setDecorated(true); diff --git a/packages/core/DataAccessor.php b/packages/core/DataAccessor.php index 9111cd215..0b59a5b25 100644 --- a/packages/core/DataAccessor.php +++ b/packages/core/DataAccessor.php @@ -18,7 +18,8 @@ protected static function getPropertyAccessor(): PropertyAccessorInterface if (null === self::$propertyAccessor) { self::$propertyAccessor = PropertyAccess::createPropertyAccessorBuilder() ->enableExceptionOnInvalidIndex() - ->getPropertyAccessor(); + ->getPropertyAccessor() + ; } return self::$propertyAccessor; @@ -36,8 +37,6 @@ final public function __construct( * Return the data value of what is currently tested. * * @param $path null|string|PropertyPathInterface - * - * @return mixed */ public function getData($path = null) { diff --git a/packages/core/FilterExpression/Evaluator.php b/packages/core/FilterExpression/Evaluator.php index 56c19ca95..edddd7629 100644 --- a/packages/core/FilterExpression/Evaluator.php +++ b/packages/core/FilterExpression/Evaluator.php @@ -16,7 +16,7 @@ class Evaluator public function __construct(?ServiceProviderInterface $serviceProvider = null) { $this->serviceProvider = $serviceProvider ?: new ServiceLocator([ - ConstraintExpressionEvaluator::class => fn () => new ConstraintExpressionEvaluator(), + ConstraintExpressionEvaluator::class => static fn () => new ConstraintExpressionEvaluator(), CompositeExpressionEvaluator::class => fn () => new CompositeExpressionEvaluator($this), ]); } diff --git a/packages/core/FilterExpression/Expression/CompositeExpressionEvaluator.php b/packages/core/FilterExpression/Expression/CompositeExpressionEvaluator.php index c35798b5a..4d190c18d 100644 --- a/packages/core/FilterExpression/Expression/CompositeExpressionEvaluator.php +++ b/packages/core/FilterExpression/Expression/CompositeExpressionEvaluator.php @@ -18,7 +18,7 @@ public function evaluate($data, Expression $expression): bool $type = $expression->getType(); - if (!\in_array($type, [CompositeExpression::TYPE_AND, CompositeExpression::TYPE_OR])) { + if (!\in_array($type, [CompositeExpression::TYPE_AND, CompositeExpression::TYPE_OR], true)) { throw new \InvalidArgumentException('Unsupported CompositeExpression type ['.$type.']'); } diff --git a/packages/core/FilterExpression/Expression/ConstraintExpressionEvaluator.php b/packages/core/FilterExpression/Expression/ConstraintExpressionEvaluator.php index a7a77d06a..8640dcdc5 100644 --- a/packages/core/FilterExpression/Expression/ConstraintExpressionEvaluator.php +++ b/packages/core/FilterExpression/Expression/ConstraintExpressionEvaluator.php @@ -20,7 +20,8 @@ public function __construct(?PropertyAccessor $propertyAccessor = null, ?Validat $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessorBuilder() ->enableExceptionOnInvalidPropertyPath() ->enableExceptionOnInvalidIndex() - ->getPropertyAccessor(); + ->getPropertyAccessor() + ; } public function evaluate($data, Expression $expression): bool diff --git a/packages/core/Tests/DateTimeUtilsTest.php b/packages/core/Tests/DateTimeUtilsTest.php index 43f4089be..dce0ad232 100644 --- a/packages/core/Tests/DateTimeUtilsTest.php +++ b/packages/core/Tests/DateTimeUtilsTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class DateTimeUtilsTest extends TestCase { public static function provideTestIsSameTimestamp(): array diff --git a/packages/core/Tests/FilterExpression/EvaluatorTest.php b/packages/core/Tests/FilterExpression/EvaluatorTest.php index b2f74671b..1956c0f26 100644 --- a/packages/core/Tests/FilterExpression/EvaluatorTest.php +++ b/packages/core/Tests/FilterExpression/EvaluatorTest.php @@ -9,6 +9,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\EqualTo; +/** + * @internal + */ class EvaluatorTest extends TestCase { private const SAMPLE_DATA = [ diff --git a/packages/core/Tests/FilterExpression/Expression/CompositeExpressionEvaluatorTest.php b/packages/core/Tests/FilterExpression/Expression/CompositeExpressionEvaluatorTest.php index 0bef8e938..9fc669711 100644 --- a/packages/core/Tests/FilterExpression/Expression/CompositeExpressionEvaluatorTest.php +++ b/packages/core/Tests/FilterExpression/Expression/CompositeExpressionEvaluatorTest.php @@ -11,6 +11,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(CompositeExpressionEvaluator::class)] class CompositeExpressionEvaluatorTest extends TestCase { @@ -45,7 +48,8 @@ public function testEvaluateNoExpression(): void { $this->evaluator ->expects(static::never()) - ->method('evaluate'); + ->method('evaluate') + ; static::assertTrue( $this->object->evaluate(null, new CompositeExpression(CompositeExpression::TYPE_AND, [])) @@ -61,7 +65,8 @@ public function testEvaluateInvalidType(): void $this->evaluator ->expects(static::never()) - ->method('evaluate'); + ->method('evaluate') + ; static::assertTrue( $this->object->evaluate(null, new CompositeExpression($type, [])) diff --git a/packages/core/Tests/FilterExpression/Expression/ConstraintExpressionEvaluatorTest.php b/packages/core/Tests/FilterExpression/Expression/ConstraintExpressionEvaluatorTest.php index d92c2d094..322e20493 100644 --- a/packages/core/Tests/FilterExpression/Expression/ConstraintExpressionEvaluatorTest.php +++ b/packages/core/Tests/FilterExpression/Expression/ConstraintExpressionEvaluatorTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(ConstraintExpressionEvaluator::class)] class ConstraintExpressionEvaluatorTest extends TestCase { diff --git a/packages/core/Tests/FilterExpression/ExpressionTest.php b/packages/core/Tests/FilterExpression/ExpressionTest.php index 3f1d8337b..c8f960d1b 100644 --- a/packages/core/Tests/FilterExpression/ExpressionTest.php +++ b/packages/core/Tests/FilterExpression/ExpressionTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\EqualTo; +/** + * @internal + */ class ExpressionTest extends TestCase { public function testEqual(): void diff --git a/packages/core/Tests/FilterExpression/QueryTest.php b/packages/core/Tests/FilterExpression/QueryTest.php index 4daf79c62..17ad80989 100644 --- a/packages/core/Tests/FilterExpression/QueryTest.php +++ b/packages/core/Tests/FilterExpression/QueryTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(Query::class)] class QueryTest extends TestCase { diff --git a/packages/core/Tests/FunctionTest.php b/packages/core/Tests/FunctionTest.php index 8b73322f1..c130874a0 100644 --- a/packages/core/Tests/FunctionTest.php +++ b/packages/core/Tests/FunctionTest.php @@ -6,6 +6,9 @@ use function Draw\Component\Core\use_trait; +/** + * @internal + */ class FunctionTest extends TestCase { public function testUseTraitNotExistsTrait(): void diff --git a/packages/core/Tests/Reflection/ReflectionAccessorTest.php b/packages/core/Tests/Reflection/ReflectionAccessorTest.php index 98693734e..adf49131a 100644 --- a/packages/core/Tests/Reflection/ReflectionAccessorTest.php +++ b/packages/core/Tests/Reflection/ReflectionAccessorTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(ReflectionAccessor::class)] class ReflectionAccessorTest extends TestCase { diff --git a/packages/cron-job/Command/QueueCronJobByNameCommand.php b/packages/cron-job/Command/QueueCronJobByNameCommand.php index 3b16cdcb4..a43dba5d6 100644 --- a/packages/cron-job/Command/QueueCronJobByNameCommand.php +++ b/packages/cron-job/Command/QueueCronJobByNameCommand.php @@ -28,7 +28,8 @@ protected function configure(): void { $this ->setDescription('Queues cron job by name') - ->addArgument('name', InputArgument::REQUIRED, 'Cron job name'); + ->addArgument('name', InputArgument::REQUIRED, 'Cron job name') + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -37,7 +38,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $cronJob = $this->managerRegistry ->getRepository(CronJob::class) - ->findOneBy(['name' => $input->getArgument('name')]); + ->findOneBy(['name' => $input->getArgument('name')]) + ; if (null === $cronJob) { $io->error('Cron job could not be found.'); diff --git a/packages/cron-job/Command/QueueDueCronJobsCommand.php b/packages/cron-job/Command/QueueDueCronJobsCommand.php index 36bd7a45d..cc98b8942 100644 --- a/packages/cron-job/Command/QueueDueCronJobsCommand.php +++ b/packages/cron-job/Command/QueueDueCronJobsCommand.php @@ -26,7 +26,8 @@ public function __construct( protected function configure(): void { $this - ->setDescription('Queues due cron jobs'); + ->setDescription('Queues due cron jobs') + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -36,7 +37,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $cronJobs = $this->managerRegistry ->getRepository(CronJob::class) - ->findBy(['active' => true]); + ->findBy(['active' => true]) + ; foreach ($cronJobs as $cronJob) { if (!$cronJob->isDue()) { diff --git a/packages/cron-job/DependencyInjection/Compiler/AddPostCronJobExecutionOptionPass.php b/packages/cron-job/DependencyInjection/Compiler/AddPostCronJobExecutionOptionPass.php index 236443306..2e5ab5ab7 100644 --- a/packages/cron-job/DependencyInjection/Compiler/AddPostCronJobExecutionOptionPass.php +++ b/packages/cron-job/DependencyInjection/Compiler/AddPostCronJobExecutionOptionPass.php @@ -29,7 +29,8 @@ public function process(ContainerBuilder $container): void InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Queue does cron job by name after execution of the command.', ] - ); + ) + ; } } } diff --git a/packages/cron-job/DependencyInjection/CronJobIntegration.php b/packages/cron-job/DependencyInjection/CronJobIntegration.php index d8713f596..3e283af13 100644 --- a/packages/cron-job/DependencyInjection/CronJobIntegration.php +++ b/packages/cron-job/DependencyInjection/CronJobIntegration.php @@ -33,7 +33,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\CronJob\\', + $namespace = 'Draw\Component\CronJob\\', \dirname((new \ReflectionClass(CronJobProcessor::class))->getFileName()) ); diff --git a/packages/cron-job/Entity/CronJob.php b/packages/cron-job/Entity/CronJob.php index fee49ba55..775cd87f2 100644 --- a/packages/cron-job/Entity/CronJob.php +++ b/packages/cron-job/Entity/CronJob.php @@ -201,7 +201,8 @@ public function getRecentExecutions(): Selectable&Collection Criteria::create() ->orderBy(['requestedAt' => 'DESC']) ->setMaxResults(10) - ); + ) + ; } public function isDue(): bool diff --git a/packages/cron-job/Entity/CronJobExecution.php b/packages/cron-job/Entity/CronJobExecution.php index 02277e606..46f3b062b 100644 --- a/packages/cron-job/Entity/CronJobExecution.php +++ b/packages/cron-job/Entity/CronJobExecution.php @@ -200,7 +200,8 @@ public function start(): void $this ->setState(self::STATE_RUNNING) ->setExecutionStartedAt(new \DateTimeImmutable()) - ->setExecutionEndedAt(null); + ->setExecutionEndedAt(null) + ; } public function end(): static @@ -211,7 +212,8 @@ public function end(): static ->setExecutionEndedAt($executionEndedAt = new \DateTimeImmutable()) ->setExecutionDelay( $executionEndedAt->getTimestamp() - $this->getExecutionStartedAt()->getTimestamp() - ); + ) + ; return $this; } @@ -222,7 +224,8 @@ public function fail(?int $exitCode, string $error): void ->end() ->setState(self::STATE_ERRORED) ->setExitCode($exitCode) - ->setError($error); + ->setError($error) + ; } public function acknowledge(): void diff --git a/packages/cron-job/EventListener/PostExecutionQueueCronJobListener.php b/packages/cron-job/EventListener/PostExecutionQueueCronJobListener.php index b059e3518..d914a857c 100644 --- a/packages/cron-job/EventListener/PostExecutionQueueCronJobListener.php +++ b/packages/cron-job/EventListener/PostExecutionQueueCronJobListener.php @@ -47,7 +47,8 @@ public function triggerCronJob(ConsoleTerminateEvent $event): void foreach ($cronJobNames as $cronJobName) { $cronJob = $cronJobRepository - ->findOneBy(['name' => $cronJobName]); + ->findOneBy(['name' => $cronJobName]) + ; if (null === $cronJob) { $this->logger->error(\sprintf('Cron job "%s" could not be found.', $cronJobName)); diff --git a/packages/cron-job/Tests/Command/QueueCronJobByNameCommandTest.php b/packages/cron-job/Tests/Command/QueueCronJobByNameCommandTest.php index a60dcf989..c205d6cf6 100644 --- a/packages/cron-job/Tests/Command/QueueCronJobByNameCommandTest.php +++ b/packages/cron-job/Tests/Command/QueueCronJobByNameCommandTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; +/** + * @internal + */ #[CoversClass(QueueCronJobByNameCommand::class)] class QueueCronJobByNameCommandTest extends TestCase { @@ -35,7 +38,8 @@ protected function setUp(): void ->expects(static::any()) ->method('getRepository') ->with(CronJob::class) - ->willReturn($this->repository = $this->createMock(EntityRepository::class)); + ->willReturn($this->repository = $this->createMock(EntityRepository::class)) + ; $this->command = new QueueCronJobByNameCommand( $this->managerRegistry, @@ -64,12 +68,14 @@ public function testExecuteWithExistingCronJob(): void ->expects(static::once()) ->method('findOneBy') ->with(['name' => $cronJobName = 'Existing Cron Job']) - ->willReturn($cronJob = new CronJob()); + ->willReturn($cronJob = new CronJob()) + ; $this->cronJobProcessor ->expects(static::once()) ->method('queue') - ->with($cronJob, true); + ->with($cronJob, true) + ; $this ->execute(['name' => $cronJobName]) @@ -81,7 +87,8 @@ public function testExecuteWithExistingCronJob(): void 'Cron job successfully queued.', ] ) - ); + ) + ; } public function testExecuteWithoutExistingCronJob(): void @@ -90,11 +97,13 @@ public function testExecuteWithoutExistingCronJob(): void ->expects(static::once()) ->method('findOneBy') ->with(['name' => $cronJobName = 'Invalid Cron Job']) - ->willReturn(null); + ->willReturn(null) + ; $this->cronJobProcessor ->expects(static::never()) - ->method('queue'); + ->method('queue') + ; $this ->execute(['name' => $cronJobName]) @@ -105,6 +114,7 @@ public function testExecuteWithoutExistingCronJob(): void '[ERROR] Cron job could not be found.', ] ) - ); + ) + ; } } diff --git a/packages/cron-job/Tests/Command/QueueDueCronJobsCommandTest.php b/packages/cron-job/Tests/Command/QueueDueCronJobsCommandTest.php index e0edacc83..14ef066d4 100644 --- a/packages/cron-job/Tests/Command/QueueDueCronJobsCommandTest.php +++ b/packages/cron-job/Tests/Command/QueueDueCronJobsCommandTest.php @@ -18,6 +18,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; +/** + * @internal + */ #[CoversClass(QueueDueCronJobsCommand::class)] class QueueDueCronJobsCommandTest extends TestCase { @@ -62,7 +65,8 @@ public function testExecute(array $rawCronJobs, array $expectedDisplay): void ->expects(static::any()) ->method('getRepository') ->with(CronJob::class) - ->willReturn($repository = $this->createMock(EntityRepository::class)); + ->willReturn($repository = $this->createMock(EntityRepository::class)) + ; $repository ->expects(static::once()) @@ -76,7 +80,8 @@ public function testExecute(array $rawCronJobs, array $expectedDisplay): void ), $rawCronJobs ) - ); + ) + ; $dueCronJobs = array_filter( $cronJobs, @@ -86,7 +91,8 @@ public function testExecute(array $rawCronJobs, array $expectedDisplay): void if (0 === $numDueCronJobs = \count($dueCronJobs)) { $this->cronJobProcessor ->expects(static::never()) - ->method('queue'); + ->method('queue') + ; } else { $this->cronJobProcessor ->expects(static::exactly($numDueCronJobs)) @@ -96,7 +102,8 @@ public function testExecute(array $rawCronJobs, array $expectedDisplay): void static fn (CronJob $cronJob): array => [$cronJob, false], $dueCronJobs )) - ); + ) + ; } $this @@ -115,7 +122,8 @@ public function testExecute(array $rawCronJobs, array $expectedDisplay): void ] ) ) - ); + ) + ; } public static function provideDataForTestExecute(): iterable @@ -170,11 +178,13 @@ private function createCronJob(string $name, bool $due): CronJob&MockObject $cronJob ->expects(static::any()) ->method('getName') - ->willReturn($name); + ->willReturn($name) + ; $cronJob ->expects(static::any()) ->method('isDue') - ->willReturn($due); + ->willReturn($due) + ; return $cronJob; } diff --git a/packages/cron-job/Tests/CronJobProcessorTest.php b/packages/cron-job/Tests/CronJobProcessorTest.php index 5fa12c613..36a417211 100644 --- a/packages/cron-job/Tests/CronJobProcessorTest.php +++ b/packages/cron-job/Tests/CronJobProcessorTest.php @@ -25,6 +25,9 @@ use Symfony\Component\Process\Process; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ #[CoversClass(CronJobProcessor::class)] class CronJobProcessorTest extends TestCase { @@ -47,7 +50,8 @@ protected function setUp(): void ->expects(static::any()) ->method('getManagerForClass') ->with(CronJobExecution::class) - ->willReturn($this->entityManager = $this->createMock(EntityManagerInterface::class)); + ->willReturn($this->entityManager = $this->createMock(EntityManagerInterface::class)) + ; $this->cronJobProcessor = new CronJobProcessor( $managerRegistry, @@ -68,22 +72,26 @@ public function testQueue(bool $force): void ->expects(static::any()) ->method('newExecution') ->with($force) - ->willReturn($execution = $this->createCronJobExecution()); + ->willReturn($execution = $this->createCronJobExecution()) + ; $this->entityManager ->expects(static::once()) ->method('persist') - ->with($execution); + ->with($execution) + ; $this->entityManager ->expects(static::once()) - ->method('flush'); + ->method('flush') + ; $this->messageBus ->expects(static::once()) ->method('dispatch') ->with($message = new ExecuteCronJobMessage($execution)) - ->willReturn(new Envelope($message, [])); + ->willReturn(new Envelope($message, [])) + ; $this->cronJobProcessor->queue($cronJob, $force); } @@ -127,22 +135,26 @@ public function testProcess( ->willReturnOnConsecutiveCalls( $returnedPreCronJobExecutionEvent, $postExecutionEvent - ); + ) + ; $this->entityManager ->expects(static::exactly(2)) - ->method('flush'); + ->method('flush') + ; $this->entityManager ->expects(static::once()) ->method('getConnection') ->willReturn( $connection = $this->createMock(Connection::class) - ); + ) + ; $connection ->expects(static::once()) - ->method('close'); + ->method('close') + ; $this->processFactory ->expects(static::once()) @@ -154,22 +166,24 @@ public function testProcess( null, $executionTimeout, ) - ->willReturn($process = $this->createMock(Process::class)); + ->willReturn($process = $this->createMock(Process::class)) + ; $process ->expects(static::once()) - ->method('mustRun'); + ->method('mustRun') + ; $this->cronJobProcessor->process($execution); - static::assertEquals(CronJobExecution::STATE_TERMINATED, $execution->getState()); + static::assertSame(CronJobExecution::STATE_TERMINATED, $execution->getState()); static::assertNotNull($execution->getExecutionStartedAt()); static::assertNotNull($execution->getExecutionEndedAt()); - static::assertEquals( + static::assertSame( $execution->getExecutionEndedAt()->getTimestamp() - $execution->getExecutionStartedAt()->getTimestamp(), $execution->getExecutionDelay() ); - static::assertEquals(0, $execution->getExitCode()); + static::assertSame(0, $execution->getExitCode()); static::assertNull($execution->getError()); } @@ -205,28 +219,33 @@ public function testProcessWithError(): void ] ) ) - ->willReturnOnConsecutiveCalls($preExecutionEvent, $postExecutionEvent); + ->willReturnOnConsecutiveCalls($preExecutionEvent, $postExecutionEvent) + ; $this->entityManager ->expects(static::exactly(2)) - ->method('flush'); + ->method('flush') + ; $this->entityManager ->expects(static::once()) ->method('getConnection') ->willReturn( $connection = $this->createMock(Connection::class) - ); + ) + ; $connection ->expects(static::once()) - ->method('close'); + ->method('close') + ; $process = $this->createMock(Process::class); $process ->expects(static::any()) ->method('getExitCode') - ->willReturn($exitCode = 127); + ->willReturn($exitCode = 127) + ; $process ->expects(static::any()) ->method('mustRun') @@ -235,7 +254,8 @@ public function testProcessWithError(): void 'Exception while processing command.', previous: new \Exception('Nested exception.') ) - ); + ) + ; $this->processFactory ->expects(static::once()) @@ -247,15 +267,16 @@ public function testProcessWithError(): void null, $execution->getCronJob()->getExecutionTimeout() ) - ->willReturn($process); + ->willReturn($process) + ; $this->cronJobProcessor->process($execution); - static::assertEquals(CronJobExecution::STATE_ERRORED, $execution->getState()); + static::assertSame(CronJobExecution::STATE_ERRORED, $execution->getState()); static::assertNotNull($execution->getExecutionStartedAt()); static::assertNotNull($execution->getExecutionEndedAt()); static::assertNotNull($execution->getExecutionDelay()); - static::assertEquals($exitCode, $execution->getExitCode()); + static::assertSame($exitCode, $execution->getExitCode()); static::assertNotNull($execution->getError()); } @@ -263,15 +284,18 @@ public function testProcessWithInactiveCronJob(): void { $this->eventDispatcher ->expects(static::never()) - ->method('dispatch'); + ->method('dispatch') + ; $this->entityManager ->expects(static::once()) - ->method('flush'); + ->method('flush') + ; $this->processFactory ->expects(static::never()) - ->method('createFromShellCommandLine'); + ->method('createFromShellCommandLine') + ; $this->cronJobProcessor->process( $execution = (new CronJob()) @@ -279,7 +303,7 @@ public function testProcessWithInactiveCronJob(): void ->newExecution() ); - static::assertEquals(CronJobExecution::STATE_SKIPPED, $execution->getState()); + static::assertSame(CronJobExecution::STATE_SKIPPED, $execution->getState()); } public function testProcessWithCancelledExecution(): void @@ -292,19 +316,22 @@ public function testProcessWithCancelledExecution(): void ) ->willReturn( new PreCronJobExecutionEvent($execution, true) - ); + ) + ; $this->entityManager ->expects(static::once()) - ->method('flush'); + ->method('flush') + ; $this->processFactory ->expects(static::never()) - ->method('createFromShellCommandLine'); + ->method('createFromShellCommandLine') + ; $this->cronJobProcessor->process($execution); - static::assertEquals(CronJobExecution::STATE_SKIPPED, $execution->getState()); + static::assertSame(CronJobExecution::STATE_SKIPPED, $execution->getState()); } private function createCronJobExecution(string $command = 'bin/console draw:test:execute'): CronJobExecution diff --git a/packages/cron-job/Tests/DependencyInjection/CronJobIntegrationTest.php b/packages/cron-job/Tests/DependencyInjection/CronJobIntegrationTest.php index 5bb360f02..69def6f1a 100644 --- a/packages/cron-job/Tests/DependencyInjection/CronJobIntegrationTest.php +++ b/packages/cron-job/Tests/DependencyInjection/CronJobIntegrationTest.php @@ -15,6 +15,9 @@ use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(CronJobIntegration::class)] class CronJobIntegrationTest extends IntegrationTestCase { diff --git a/packages/cron-job/Tests/Entity/CronJobExecutionTest.php b/packages/cron-job/Tests/Entity/CronJobExecutionTest.php index a09eef824..4c84469fc 100644 --- a/packages/cron-job/Tests/Entity/CronJobExecutionTest.php +++ b/packages/cron-job/Tests/Entity/CronJobExecutionTest.php @@ -11,6 +11,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(CronJobExecution::class)] class CronJobExecutionTest extends TestCase { diff --git a/packages/cron-job/Tests/MessageHandler/ExecuteCronJobMessageHandlerTest.php b/packages/cron-job/Tests/MessageHandler/ExecuteCronJobMessageHandlerTest.php index 44b79db27..c695e9482 100644 --- a/packages/cron-job/Tests/MessageHandler/ExecuteCronJobMessageHandlerTest.php +++ b/packages/cron-job/Tests/MessageHandler/ExecuteCronJobMessageHandlerTest.php @@ -13,6 +13,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(ExecuteCronJobMessageHandler::class)] class ExecuteCronJobMessageHandlerTest extends TestCase { @@ -34,13 +37,14 @@ public function testHandleExecuteCronJobMessage(): void $this->cronJobProcessor ->expects(static::once()) ->method('process') - ->with($execution = (new CronJob())->newExecution()); + ->with($execution = (new CronJob())->newExecution()) + ; $this->handler->handleExecuteCronJobMessage( new ExecuteCronJobMessage($execution) ); - static::assertEquals(CronJobExecution::STATE_REQUESTED, $execution->getState()); + static::assertSame(CronJobExecution::STATE_REQUESTED, $execution->getState()); static::assertNotNull($execution->getRequestedAt()); } } diff --git a/packages/dependency-injection/Integration/IntegrationTrait.php b/packages/dependency-injection/Integration/IntegrationTrait.php index cf6105ad5..5ff983a47 100644 --- a/packages/dependency-injection/Integration/IntegrationTrait.php +++ b/packages/dependency-injection/Integration/IntegrationTrait.php @@ -37,7 +37,8 @@ protected function registerClasses( ): void { $prototype = $prototype ?: (new Definition()) ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; foreach ($this->getDefaultExcludedDirectories() as $defaultExcludedDirectory) { $exclude[] = $directory.'/'.$defaultExcludedDirectory; @@ -51,7 +52,8 @@ protected function registerClasses( ); $container = (new \ReflectionProperty($loader, 'container')) - ->getValue($loader); + ->getValue($loader) + ; \assert($container instanceof ContainerBuilder); @@ -143,7 +145,7 @@ protected function serviceIdClassToNameConvention(string $input): string { $originalInput = $input; $input = str_replace('\\', '.', $input); - $input = preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $input); + $input = preg_replace('~(?<=\w)([A-Z])~u', '_$1', $input); if (null === $input) { throw new \RuntimeException(\sprintf('preg_replace returned null for value "%s"', $originalInput)); diff --git a/packages/dependency-injection/Integration/Test/IntegrationTestCase.php b/packages/dependency-injection/Integration/Test/IntegrationTestCase.php index b9a672848..71ceab9b9 100644 --- a/packages/dependency-injection/Integration/Test/IntegrationTestCase.php +++ b/packages/dependency-injection/Integration/Test/IntegrationTestCase.php @@ -32,12 +32,14 @@ protected function mockExtension(string $name): ExtensionInterface $extension->expects(static::any()) ->method('getAlias') - ->willReturn($name); + ->willReturn($name) + ; $extension ->expects(static::any()) ->method('getNamespace') - ->willReturn($name); + ->willReturn($name) + ; return $extension; } @@ -59,7 +61,7 @@ public function testDefaultConfiguration(): void { $config = $this->processConfiguration([[]]); - static::assertEquals( + static::assertEqualsCanonicalizing( $this->getDefaultConfiguration(), $config ); @@ -163,7 +165,7 @@ public static function assertContainerBuilderServices( 'Available service ids: '.implode(', ', $definedServiceIds) ); - unset($definedServiceIds[array_search($service->getId(), $definedServiceIds)]); + unset($definedServiceIds[array_search($service->getId(), $definedServiceIds, true)]); static::assertSame( $service->getAliases(), diff --git a/packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php b/packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php index d657f217f..13431cb77 100644 --- a/packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php +++ b/packages/dependency-injection/Tests/DependencyInjection/DependencyInjectionIntegrationTest.php @@ -6,6 +6,9 @@ use Draw\Component\DependencyInjection\Integration\IntegrationInterface; use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase; +/** + * @internal + */ class DependencyInjectionIntegrationTest extends IntegrationTestCase { public function createIntegration(): IntegrationInterface diff --git a/packages/doctrine-extra/DependencyInjection/DoctrineExtraIntegration.php b/packages/doctrine-extra/DependencyInjection/DoctrineExtraIntegration.php index be38a6fed..64d00ab99 100644 --- a/packages/doctrine-extra/DependencyInjection/DoctrineExtraIntegration.php +++ b/packages/doctrine-extra/DependencyInjection/DoctrineExtraIntegration.php @@ -35,11 +35,12 @@ private function loadORM(array $config, PhpFileLoader $loader, ContainerBuilder } $container - ->registerAliasForArgument('doctrine', ManagerRegistry::class, 'ormManagerRegistry'); + ->registerAliasForArgument('doctrine', ManagerRegistry::class, 'ormManagerRegistry') + ; $this->registerClasses( $loader, - $namespace = 'Draw\\DoctrineExtra\\ORM\\', + $namespace = 'Draw\DoctrineExtra\ORM\\', \dirname((new \ReflectionClass(EntityHandler::class))->getFileName()), ); @@ -63,7 +64,8 @@ private function loadMongoODM(array $config, PhpFileLoader $loader, ContainerBui } $container - ->registerAliasForArgument('doctrine_mongodb', ManagerRegistry::class, 'odmManagerRegistry'); + ->registerAliasForArgument('doctrine_mongodb', ManagerRegistry::class, 'odmManagerRegistry') + ; } public function addConfiguration(ArrayNodeDefinition $node): void @@ -72,7 +74,8 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->children() ->append($this->createORMNode()) ->append($this->createMongoODMNode()) - ->end(); + ->end() + ; } private function createMongoODMNode(): ArrayNodeDefinition diff --git a/packages/doctrine-extra/ORM/Command/MysqlDumpCommand.php b/packages/doctrine-extra/ORM/Command/MysqlDumpCommand.php index b16702f94..cf3674a54 100644 --- a/packages/doctrine-extra/ORM/Command/MysqlDumpCommand.php +++ b/packages/doctrine-extra/ORM/Command/MysqlDumpCommand.php @@ -22,13 +22,15 @@ protected function configure(): void $this ->setDescription('Dump a mysql database to a file') ->addArgument('file', InputArgument::REQUIRED, 'The file path to dump') - ->addOption('connection', 'c', InputOption::VALUE_REQUIRED, 'The connection to use', 'default'); + ->addOption('connection', 'c', InputOption::VALUE_REQUIRED, 'The connection to use', 'default') + ; } protected function execute(InputInterface $input, OutputInterface $output): int { $connectionParameter = $this->ormManagerRegistry->getConnection($input->getOption('connection')) - ->getParams()['primary']; + ->getParams()['primary'] + ; Process::fromShellCommandline( \sprintf( diff --git a/packages/doctrine-extra/ORM/Command/MysqlImportFileCommand.php b/packages/doctrine-extra/ORM/Command/MysqlImportFileCommand.php index dd77886ec..ba561a0f3 100644 --- a/packages/doctrine-extra/ORM/Command/MysqlImportFileCommand.php +++ b/packages/doctrine-extra/ORM/Command/MysqlImportFileCommand.php @@ -22,14 +22,16 @@ protected function configure(): void $this ->setDescription('Import a files in the database') ->addArgument('files', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'The files to import', null) - ->addOption('connection', 'c', InputOption::VALUE_REQUIRED, 'The connection to use', 'default'); + ->addOption('connection', 'c', InputOption::VALUE_REQUIRED, 'The connection to use', 'default') + ; } protected function execute(InputInterface $input, OutputInterface $output): int { $connectionParameter = $this->ormManagerRegistry ->getConnection($input->getOption('connection')) - ->getParams()['primary']; + ->getParams()['primary'] + ; foreach ($input->getArgument('files') as $file) { Process::fromShellCommandline( diff --git a/packages/doctrine-extra/ORM/EntityHandler.php b/packages/doctrine-extra/ORM/EntityHandler.php index 5fae1872d..c2ca6fecf 100644 --- a/packages/doctrine-extra/ORM/EntityHandler.php +++ b/packages/doctrine-extra/ORM/EntityHandler.php @@ -14,17 +14,19 @@ public function __construct(private ManagerRegistry $managerRegistry) public function getManagerForClass(string $class): ?EntityManagerInterface { - /** @var ?EntityManagerInterface $manager */ $manager = $this->managerRegistry->getManagerForClass($class); + \assert($manager instanceof EntityManagerInterface || null === $manager); + return $manager; } public function getRepository(string $class): EntityRepository { - /** @var EntityRepository $repository */ $repository = $this->managerRegistry->getRepository($class); + \assert($repository instanceof EntityRepository); + return $repository; } diff --git a/packages/doctrine-extra/Tests/Common/DataFixtures/ObjectReferenceTraitTest.php b/packages/doctrine-extra/Tests/Common/DataFixtures/ObjectReferenceTraitTest.php index 8c95664b4..9e1e5dc20 100644 --- a/packages/doctrine-extra/Tests/Common/DataFixtures/ObjectReferenceTraitTest.php +++ b/packages/doctrine-extra/Tests/Common/DataFixtures/ObjectReferenceTraitTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class ObjectReferenceTraitTest extends TestCase { /** @@ -47,7 +50,8 @@ public function testAddObjectReference(): void $name = uniqid('name-') ), $object = new \stdClass() - ); + ) + ; $this->trait->addObjectReference($class, $name, $object); } @@ -64,7 +68,8 @@ public function testHasObjectReference(): void $name = uniqid('name-') ) ) - ->willReturn(false); + ->willReturn(false) + ; static::assertFalse( $this->trait->hasObjectReference($class, $name) @@ -83,7 +88,8 @@ public function testGetObjectReference(): void $name = uniqid('name-') ) ) - ->willReturn($object = new \stdClass()); + ->willReturn($object = new \stdClass()) + ; static::assertSame( $object, @@ -103,7 +109,8 @@ public function testSetObjectReference(): void $name = uniqid('name-') ), $object = new \stdClass() - ); + ) + ; $this->trait->setObjectReference($class, $name, $object); } diff --git a/packages/doctrine-extra/Tests/DependencyInjection/DoctrineExtraIntegrationTest.php b/packages/doctrine-extra/Tests/DependencyInjection/DoctrineExtraIntegrationTest.php index f8d71c5c6..7320b5a8b 100644 --- a/packages/doctrine-extra/Tests/DependencyInjection/DoctrineExtraIntegrationTest.php +++ b/packages/doctrine-extra/Tests/DependencyInjection/DoctrineExtraIntegrationTest.php @@ -16,6 +16,8 @@ /** * @property DoctrineExtraIntegration $integration + * + * @internal */ #[CoversClass(DoctrineExtraIntegration::class)] class DoctrineExtraIntegrationTest extends IntegrationTestCase diff --git a/packages/entity-migrator/Command/BaseCommand.php b/packages/entity-migrator/Command/BaseCommand.php index 3aa3c0e88..f53d70a71 100644 --- a/packages/entity-migrator/Command/BaseCommand.php +++ b/packages/entity-migrator/Command/BaseCommand.php @@ -40,7 +40,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi $question = new ChoiceQuestion( 'Select which migration', array_map( - fn (Migration $migration) => $migration->getName(), + static fn (Migration $migration) => $migration->getName(), $this->managerRegistry->getRepository(Migration::class)->findAll() ) ); diff --git a/packages/entity-migrator/Command/MigrateCommand.php b/packages/entity-migrator/Command/MigrateCommand.php index 6fbeb3272..c6fb9b85a 100644 --- a/packages/entity-migrator/Command/MigrateCommand.php +++ b/packages/entity-migrator/Command/MigrateCommand.php @@ -20,7 +20,8 @@ class MigrateCommand extends BaseCommand protected function configure(): void { $this - ->addArgument('migration-name', null, 'The migration name to migrate'); + ->addArgument('migration-name', null, 'The migration name to migrate') + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -34,7 +35,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $migrationEntity = $this->managerRegistry ->getRepository(Migration::class) - ->findOneBy(['name' => $migration::getName()]); + ->findOneBy(['name' => $migration::getName()]) + ; $count = $migration->countAllThatNeedMigration(); diff --git a/packages/entity-migrator/Command/QueueBatchCommand.php b/packages/entity-migrator/Command/QueueBatchCommand.php index b5da3c7ae..abd9cebb2 100644 --- a/packages/entity-migrator/Command/QueueBatchCommand.php +++ b/packages/entity-migrator/Command/QueueBatchCommand.php @@ -39,7 +39,8 @@ public function __construct( protected function configure(): void { $this - ->addArgument('migration-name', null, 'The migration name to migrate'); + ->addArgument('migration-name', null, 'The migration name to migrate') + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -67,15 +68,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int $migrationEntity = $manager ->getRepository(Migration::class) - ->findOneBy(['name' => $migration::getName()]); + ->findOneBy(['name' => $migration::getName()]) + ; $metadata = $manager ->getMetadataFactory() - ->getMetadataFor($migration::getTargetEntityClass()); + ->getMetadataFor($migration::getTargetEntityClass()) + ; $entityMigrationClass = $metadata->getReflectionClass() ->getMethod('getEntityMigrationClass') - ->invoke(null); + ->invoke(null) + ; $entityMigrationMetadata = $manager->getClassMetadata($entityMigrationClass); @@ -88,7 +92,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $queryBuilder->expr()->literal(date('Y-m-d H:i:s')).' as created_at', ) ->getQuery() - ->getSQL(); + ->getSQL() + ; $manager ->getConnection() @@ -99,21 +104,24 @@ protected function execute(InputInterface $input, OutputInterface $output): int $sql ), array_map( - fn (Parameter $parameter) => $parameter->getValue(), + static fn (Parameter $parameter) => $parameter->getValue(), $queryBuilder->getParameters()->toArray() ) - ); + ) + ; $queryBuilder = $manager ->createQueryBuilder() ->from($entityMigrationClass, 'entity_migration') ->andWhere('entity_migration.state = :state') - ->setParameter('state', BaseEntityMigration::STATE_NEW); + ->setParameter('state', BaseEntityMigration::STATE_NEW) + ; $count = (int) (clone $queryBuilder) ->select('count(entity_migration.id)') ->getQuery() - ->getSingleScalarResult(); + ->getSingleScalarResult() + ; if (0 === $count) { $io->warning('No new entity need migration'); @@ -124,7 +132,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $result = $queryBuilder ->select('entity_migration.id as id') ->getQuery() - ->toIterable(); + ->toIterable() + ; $progress = $io->createProgressBar($count); $progress->setFormat(ProgressBar::FORMAT_DEBUG); diff --git a/packages/entity-migrator/DependencyInjection/Compiler/EntityMigratorCompilerPass.php b/packages/entity-migrator/DependencyInjection/Compiler/EntityMigratorCompilerPass.php index b8e0ecc1b..6146cec00 100644 --- a/packages/entity-migrator/DependencyInjection/Compiler/EntityMigratorCompilerPass.php +++ b/packages/entity-migrator/DependencyInjection/Compiler/EntityMigratorCompilerPass.php @@ -24,7 +24,8 @@ public function process(ContainerBuilder $container): void foreach (array_keys($container->findTaggedServiceIds(MigrationInterface::class)) as $id) { $name = $container ->getDefinition($id) - ->getClass()::getName(); + ->getClass()::getName() + ; $references[$name] = new Reference($id); } @@ -38,6 +39,7 @@ public function process(ContainerBuilder $container): void ->setArgument( '$migrationNames', array_keys($references) - ); + ) + ; } } diff --git a/packages/entity-migrator/DependencyInjection/EntityMigratorIntegration.php b/packages/entity-migrator/DependencyInjection/EntityMigratorIntegration.php index 0f00e06c4..c04b0cb1d 100644 --- a/packages/entity-migrator/DependencyInjection/EntityMigratorIntegration.php +++ b/packages/entity-migrator/DependencyInjection/EntityMigratorIntegration.php @@ -38,21 +38,24 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $container ->registerForAutoconfiguration(MigrationInterface::class) - ->addTag(MigrationInterface::class); + ->addTag(MigrationInterface::class) + ; $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\EntityMigrator\\', + $namespace = 'Draw\Component\EntityMigrator\\', \dirname((new \ReflectionClass(Migrator::class))->getFileName()), ); $container ->getDefinition(MigrateCommand::class) - ->setArgument('$servicesResetter', new Reference('services_resetter')); + ->setArgument('$servicesResetter', new Reference('services_resetter')) + ; $container ->getDefinition(QueueBatchCommand::class) - ->setArgument('$servicesResetter', new Reference('services_resetter')); + ->setArgument('$servicesResetter', new Reference('services_resetter')) + ; $this->renameDefinitions( $container, @@ -66,7 +69,8 @@ public function addConfiguration(ArrayNodeDefinition $node): void $node ->children() ->scalarNode('transport')->defaultValue('async_low_priority')->end() - ->end(); + ->end() + ; } public function prepend(ContainerBuilder $container, array $config): void diff --git a/packages/entity-migrator/EventListener/WorkflowListener.php b/packages/entity-migrator/EventListener/WorkflowListener.php index 707240a8c..fab88be3b 100644 --- a/packages/entity-migrator/EventListener/WorkflowListener.php +++ b/packages/entity-migrator/EventListener/WorkflowListener.php @@ -53,7 +53,8 @@ public function process(Event $event): void $this ->getMigration($event) - ->migrate($subject->getEntity()); + ->migrate($subject->getEntity()) + ; } #[AsEventListener('workflow.entity_migration.completed.queue')] @@ -70,7 +71,8 @@ public function flush(Event $event): void $this->managerRegistry ->getManagerForClass( $this->getSubject($event)->getEntity()::class - )->flush(); + )->flush() + ; } private function getSubject(GuardEvent|Event $event): EntityMigrationInterface diff --git a/packages/entity-migrator/Migrator.php b/packages/entity-migrator/Migrator.php index e492417f0..d1cd6d13f 100644 --- a/packages/entity-migrator/Migrator.php +++ b/packages/entity-migrator/Migrator.php @@ -41,7 +41,8 @@ public function migrateEntity(MigrationTargetEntityInterface $entity, string $mi $migration = $this->managerRegistry ->getRepository(Migration::class) - ->findOneBy(['name' => $migrationName]); + ->findOneBy(['name' => $migrationName]) + ; if (null === $migration) { $this->entityMigratorLogger?->warning('Migration "{migration}" not found', ['migration' => $migrationName]); @@ -93,7 +94,8 @@ public function migrate(EntityMigrationInterface $entityMigration, bool $wait = sleep(1); // Wait for database replication $this->managerRegistry ->getManagerForClass($entityMigration::class) - ->refresh($entityMigration); + ->refresh($entityMigration) + ; } $transitionApplied = false; diff --git a/packages/entity-migrator/Repository/EntityMigrationRepository.php b/packages/entity-migrator/Repository/EntityMigrationRepository.php index ce3abfaaf..1828a0626 100644 --- a/packages/entity-migrator/Repository/EntityMigrationRepository.php +++ b/packages/entity-migrator/Repository/EntityMigrationRepository.php @@ -19,7 +19,8 @@ public function load(MigrationTargetEntityInterface $entity, Migration $migratio $entityMigrationClass = $entity::getEntityMigrationClass(); $entityMigration = $this->managerRegistry->getRepository($entityMigrationClass) - ->findOneBy(['entity' => $entity, 'migration' => $migration]); + ->findOneBy(['entity' => $entity, 'migration' => $migration]) + ; if (null === $entityMigration) { $entityMigration = new $entityMigrationClass($entity, $migration); diff --git a/packages/entity-migrator/Tests/Message/MigrateEntityCommandTest.php b/packages/entity-migrator/Tests/Message/MigrateEntityCommandTest.php index 4f5569706..b5131e55f 100644 --- a/packages/entity-migrator/Tests/Message/MigrateEntityCommandTest.php +++ b/packages/entity-migrator/Tests/Message/MigrateEntityCommandTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException; use Symfony\Component\Messenger\Stamp\DelayStamp; +/** + * @internal + */ #[CoversClass(MigrateEntityCommand::class)] class MigrateEntityCommandTest extends TestCase { diff --git a/packages/fixer/Tests/ClassPrivateStaticCallFixerTest.php b/packages/fixer/Tests/ClassPrivateStaticCallFixerTest.php index 604c7f320..93aacfa89 100644 --- a/packages/fixer/Tests/ClassPrivateStaticCallFixerTest.php +++ b/packages/fixer/Tests/ClassPrivateStaticCallFixerTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class ClassPrivateStaticCallFixerTest extends TestCase { private ClassPrivateStaticCallFixer $object; diff --git a/packages/fixer/Tests/ClassStaticCallFixerTest.php b/packages/fixer/Tests/ClassStaticCallFixerTest.php index a5b32aad1..67c077d83 100644 --- a/packages/fixer/Tests/ClassStaticCallFixerTest.php +++ b/packages/fixer/Tests/ClassStaticCallFixerTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class ClassStaticCallFixerTest extends TestCase { private ClassStaticCallFixer $object; diff --git a/packages/framework-extra-bundle/DependencyInjection/Configuration.php b/packages/framework-extra-bundle/DependencyInjection/Configuration.php index f07bc53dc..5c4b1003c 100755 --- a/packages/framework-extra-bundle/DependencyInjection/Configuration.php +++ b/packages/framework-extra-bundle/DependencyInjection/Configuration.php @@ -24,11 +24,13 @@ public function getConfigTreeBuilder(): TreeBuilder $node ->children() - ->scalarNode('symfony_console_path')->defaultNull()->end(); + ->scalarNode('symfony_console_path')->defaultNull()->end() + ; foreach ($this->integrations as $integration) { $integrationNode = (new ArrayNodeDefinition($integration->getConfigSectionName())) - ->canBeEnabled(); + ->canBeEnabled() + ; $integration->addConfiguration($integrationNode); $node->append($integrationNode); diff --git a/packages/framework-extra-bundle/DrawFrameworkExtraBundle.php b/packages/framework-extra-bundle/DrawFrameworkExtraBundle.php index 3ecd929be..9c2b89e48 100644 --- a/packages/framework-extra-bundle/DrawFrameworkExtraBundle.php +++ b/packages/framework-extra-bundle/DrawFrameworkExtraBundle.php @@ -20,6 +20,5 @@ public function build(ContainerBuilder $container): void $integration->buildContainer($container); } } - } } diff --git a/packages/framework-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php b/packages/framework-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php index 2e98208fb..bdebe5299 100644 --- a/packages/framework-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/packages/framework-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php @@ -6,6 +6,9 @@ use Draw\Component\Tester\Test\DependencyInjection\ConfigurationTestCase; use Symfony\Component\Config\Definition\ConfigurationInterface; +/** + * @internal + */ class ConfigurationTest extends ConfigurationTestCase { public function createConfiguration(): ConfigurationInterface diff --git a/packages/framework-extra-bundle/Tests/DependencyInjection/DrawFrameworkExtraExtensionTest.php b/packages/framework-extra-bundle/Tests/DependencyInjection/DrawFrameworkExtraExtensionTest.php index 93dc78ae8..756dbf9fe 100644 --- a/packages/framework-extra-bundle/Tests/DependencyInjection/DrawFrameworkExtraExtensionTest.php +++ b/packages/framework-extra-bundle/Tests/DependencyInjection/DrawFrameworkExtraExtensionTest.php @@ -6,6 +6,9 @@ use Draw\Component\Tester\Test\DependencyInjection\ExtensionTestCase; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawFrameworkExtraExtensionTest extends ExtensionTestCase { public function createExtension(): Extension diff --git a/packages/framework-extra-bundle/Tests/DrawFrameworkExtraBundleTest.php b/packages/framework-extra-bundle/Tests/DrawFrameworkExtraBundleTest.php index 327228731..c83dadee9 100644 --- a/packages/framework-extra-bundle/Tests/DrawFrameworkExtraBundleTest.php +++ b/packages/framework-extra-bundle/Tests/DrawFrameworkExtraBundleTest.php @@ -21,6 +21,9 @@ use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; +/** + * @internal + */ class DrawFrameworkExtraBundleTest extends TestCase { use MockTrait; @@ -93,19 +96,22 @@ public function testBuild(): void ], ) ) - ->willReturnSelf(); + ->willReturnSelf() + ; $containerBuilder ->expects(static::once()) ->method('hasExtension') ->with('security') - ->willReturn(true); + ->willReturn(true) + ; $containerBuilder ->expects(static::once()) ->method('getExtension') ->with('security') - ->willReturn($extension = $this->createMock(SecurityExtension::class)); + ->willReturn($extension = $this->createMock(SecurityExtension::class)) + ; $extension ->expects(static::exactly(2)) @@ -115,7 +121,8 @@ public function testBuild(): void [static::isInstanceOf(JwtAuthenticatorFactory::class)], [static::isInstanceOf(MessengerMessageAuthenticatorFactory::class)], ) - ); + ) + ; $this->bundle->build($containerBuilder); } diff --git a/packages/log/DependencyInjection/Compiler/LoggerDecoratorPass.php b/packages/log/DependencyInjection/Compiler/LoggerDecoratorPass.php index c7f01c34c..7224cbdc6 100644 --- a/packages/log/DependencyInjection/Compiler/LoggerDecoratorPass.php +++ b/packages/log/DependencyInjection/Compiler/LoggerDecoratorPass.php @@ -46,7 +46,8 @@ public function process(ContainerBuilder $container): void } $calls[$i][1][$index] = (clone $decoratorDefinition) - ->setArgument('$logger', $argument); + ->setArgument('$logger', $argument) + ; } } $definition->setMethodCalls($calls); @@ -97,6 +98,7 @@ private function createDecoratorLoggerDefinition(array $tag): Definition return (new Definition(DecoratedLogger::class)) ->setArgument('defaultContext', $tag) ->setArgument('decorateMessage', $message) - ->addTag('kernel.reset', ['method' => 'reset']); + ->addTag('kernel.reset', ['method' => 'reset']) + ; } } diff --git a/packages/log/DependencyInjection/LogIntegration.php b/packages/log/DependencyInjection/LogIntegration.php index c1e7cf922..2e0408150 100644 --- a/packages/log/DependencyInjection/LogIntegration.php +++ b/packages/log/DependencyInjection/LogIntegration.php @@ -66,7 +66,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con new Definition($class) ) ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; $definition->addTag('monolog.processor'); $container->setAlias($class, $serviceName); @@ -96,7 +97,8 @@ private function loadSlowRequest( (new Definition(SlowRequestLoggerListener::class)) ->setAutowired(true) ->setAutoconfigured(true) - ); + ) + ; $defaultDuration = $config['default_duration']; $requestMatchers = $config['request_matchers'] ?? []; @@ -150,7 +152,8 @@ private function loadSlowRequest( $container ->getDefinition(SlowRequestLoggerListener::class) - ->setArgument('$requestMatchers', $requestMatcherReferences); + ->setArgument('$requestMatchers', $requestMatcherReferences) + ; $this->renameDefinitions( $container, @@ -216,7 +219,8 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createRequestMatcherNode(string $name, bool $multiple = true): ArrayNodeDefinition @@ -239,18 +243,19 @@ private function createRequestMatcherNode(string $name, bool $multiple = true): ->scalarNode('host')->defaultNull()->end() ->integerNode('port')->defaultNull()->end() ->arrayNode('schemes') - ->beforeNormalization()->ifString()->then(fn ($v) => [$v])->end() + ->beforeNormalization()->ifString()->then(static fn ($v) => [$v])->end() ->prototype('scalar')->end() ->end() ->arrayNode('ips') - ->beforeNormalization()->ifString()->then(fn ($v) => [$v])->end() + ->beforeNormalization()->ifString()->then(static fn ($v) => [$v])->end() ->prototype('scalar')->end() ->end() ->arrayNode('methods') - ->beforeNormalization()->ifString()->then(fn ($v) => preg_split('/\s*,\s*/', (string) $v))->end() + ->beforeNormalization()->ifString()->then(static fn ($v) => preg_split('/\s*,\s*/', (string) $v))->end() ->prototype('scalar')->end() ->end() - ->end(); + ->end() + ; return $node; } diff --git a/packages/log/Tests/DecoratedLoggerTest.php b/packages/log/Tests/DecoratedLoggerTest.php index df447fb78..6e4043df3 100644 --- a/packages/log/Tests/DecoratedLoggerTest.php +++ b/packages/log/Tests/DecoratedLoggerTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; +/** + * @internal + */ class DecoratedLoggerTest extends TestCase { private DecoratedLogger $object; @@ -43,7 +46,8 @@ public function testLog(): void $level = uniqid(), str_replace('{message}', $message = uniqid(), $this->decorateMessage), $this->defaultContext, - ); + ) + ; $this->object->log($level, $message); } @@ -57,7 +61,8 @@ public function testLogWitContext(): void $level = uniqid(), str_replace('{message}', $message = uniqid(), $this->decorateMessage), array_merge($this->defaultContext, $context = ['otherKey' => uniqid()]), - ); + ) + ; $this->object->log($level, $message, $context); } @@ -77,7 +82,8 @@ public function testLogNoMessageToken(): void $level = uniqid(), $this->decorateMessage.' '.$message = uniqid(), $this->defaultContext, - ); + ) + ; $this->object->log($level, $message); } diff --git a/packages/log/Tests/DependencyInjection/LogIntegrationTest.php b/packages/log/Tests/DependencyInjection/LogIntegrationTest.php index a9af64faa..93852d0b1 100644 --- a/packages/log/Tests/DependencyInjection/LogIntegrationTest.php +++ b/packages/log/Tests/DependencyInjection/LogIntegrationTest.php @@ -21,6 +21,8 @@ /** * @property LogIntegration $integration + * + * @internal */ #[CoversClass(LogIntegration::class)] class LogIntegrationTest extends IntegrationTestCase @@ -131,7 +133,7 @@ public static function provideTestLoad(): iterable [ SlowRequestLoggerListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { $chainRequestMatcherDefinitions = $definition->getArgument('$requestMatchers'); static::assertCount(2, $chainRequestMatcherDefinitions); diff --git a/packages/log/Tests/Monolog/Processor/DelayProcessorTest.php b/packages/log/Tests/Monolog/Processor/DelayProcessorTest.php index 1b8e57339..91156a260 100644 --- a/packages/log/Tests/Monolog/Processor/DelayProcessorTest.php +++ b/packages/log/Tests/Monolog/Processor/DelayProcessorTest.php @@ -7,6 +7,9 @@ use Monolog\LogRecord; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class DelayProcessorTest extends TestCase { private DelayProcessor $delayProcessor; diff --git a/packages/log/Tests/Symfony/EventListener/SlowRequestLoggerTest.php b/packages/log/Tests/Symfony/EventListener/SlowRequestLoggerTest.php index 22d513e73..4cebf9d26 100644 --- a/packages/log/Tests/Symfony/EventListener/SlowRequestLoggerTest.php +++ b/packages/log/Tests/Symfony/EventListener/SlowRequestLoggerTest.php @@ -14,6 +14,9 @@ use Symfony\Component\HttpKernel\Event\TerminateEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; +/** + * @internal + */ class SlowRequestLoggerTest extends TestCase { private SlowRequestLoggerListener $object; @@ -67,7 +70,8 @@ public function testOnKernelTerminateMatch(): void ->expects(static::exactly(2)) ->method('matches') ->with($request = new Request()) - ->willReturn(true); + ->willReturn(true) + ; $event = new TerminateEvent( $this->createMock(HttpKernelInterface::class), @@ -100,7 +104,8 @@ public function testOnKernelTerminateMatch(): void return true; }) - ); + ) + ; $request->server->set('REQUEST_TIME_FLOAT', microtime(true) - (max($this->durations) / 1000) - 1); @@ -113,7 +118,8 @@ public function testOnKernelTerminateNoMatch(): void ->expects(static::exactly(2)) ->method('matches') ->with($request = new Request()) - ->willReturn(false); + ->willReturn(false) + ; $event = new TerminateEvent( $this->createMock(HttpKernelInterface::class), @@ -123,7 +129,8 @@ public function testOnKernelTerminateNoMatch(): void $this->logger ->expects(static::never()) - ->method('log'); + ->method('log') + ; $request->server->set('REQUEST_TIME_FLOAT', microtime(true) - (max($this->durations) / 1000) - 1); diff --git a/packages/log/Tests/Symfony/Processor/RequestHeadersProcessorTest.php b/packages/log/Tests/Symfony/Processor/RequestHeadersProcessorTest.php index 582071baa..e28adc59e 100644 --- a/packages/log/Tests/Symfony/Processor/RequestHeadersProcessorTest.php +++ b/packages/log/Tests/Symfony/Processor/RequestHeadersProcessorTest.php @@ -10,6 +10,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +/** + * @internal + */ class RequestHeadersProcessorTest extends TestCase { public static function provideTestInvoke(): iterable @@ -85,12 +88,14 @@ public function testInvoke( $requestStack ->expects(static::once()) ->method('getMainRequest') - ->willReturn(null); + ->willReturn(null) + ; } else { $requestStack ->expects(static::once()) ->method('getMainRequest') - ->willReturn($mainRequest = new Request()); + ->willReturn($mainRequest = new Request()) + ; $mainRequest->headers->replace($requestHeaders); } diff --git a/packages/log/Tests/Symfony/Processor/TokenProcessorTest.php b/packages/log/Tests/Symfony/Processor/TokenProcessorTest.php index 56e385607..9ee1d87ef 100644 --- a/packages/log/Tests/Symfony/Processor/TokenProcessorTest.php +++ b/packages/log/Tests/Symfony/Processor/TokenProcessorTest.php @@ -13,6 +13,9 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; +/** + * @internal + */ class TokenProcessorTest extends TestCase { private TokenProcessor $service; @@ -50,7 +53,8 @@ public function testInvokeNotIdentifiedToken(): void ->method('getToken') ->willReturn( new NullToken() - ); + ) + ; static::assertSame( [ @@ -114,7 +118,8 @@ public function setUserIdentifier(string $userIdentifier): self uniqid(), $roles = [uniqid()] ) - ); + ) + ; static::assertSame( [ diff --git a/packages/mailer/Command/SendTestEmailCommand.php b/packages/mailer/Command/SendTestEmailCommand.php index bdef98db8..35c3de14f 100644 --- a/packages/mailer/Command/SendTestEmailCommand.php +++ b/packages/mailer/Command/SendTestEmailCommand.php @@ -21,7 +21,8 @@ protected function configure(): void $this ->setName('draw:mailer:send-test-email') ->setDescription('Send a test email.') - ->addArgument('to', InputArgument::REQUIRED, 'Email to send to'); + ->addArgument('to', InputArgument::REQUIRED, 'Email to send to') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/packages/mailer/DependencyInjection/Compiler/EmailWriterCompilerPass.php b/packages/mailer/DependencyInjection/Compiler/EmailWriterCompilerPass.php index 25e463618..9a1359f92 100644 --- a/packages/mailer/DependencyInjection/Compiler/EmailWriterCompilerPass.php +++ b/packages/mailer/DependencyInjection/Compiler/EmailWriterCompilerPass.php @@ -39,7 +39,8 @@ public function process(ContainerBuilder $container): void foreach ($emailTypes as $emailType) { $emailWriterListenerDefinition - ->addMethodCall('addWriter', [$emailType, $id, $methodName, $priority]); + ->addMethodCall('addWriter', [$emailType, $id, $methodName, $priority]) + ; } } } @@ -48,6 +49,7 @@ public function process(ContainerBuilder $container): void ->setArgument( '$serviceLocator', ServiceLocatorTagPass::register($container, $writers) - ); + ) + ; } } diff --git a/packages/mailer/DependencyInjection/MailerIntegration.php b/packages/mailer/DependencyInjection/MailerIntegration.php index d0fa81b0b..b3cd231ec 100644 --- a/packages/mailer/DependencyInjection/MailerIntegration.php +++ b/packages/mailer/DependencyInjection/MailerIntegration.php @@ -39,7 +39,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Mailer\\', + $namespace = 'Draw\Component\Mailer\\', \dirname( (new \ReflectionClass(EmailComposer::class))->getFileName(), ), @@ -51,11 +51,13 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con 'twig.mime_body_renderer', 'draw.mailer.body_renderer.localize_body_renderer.inner' ) - ->setArgument('$bodyRenderer', new Reference('draw.mailer.body_renderer.localize_body_renderer.inner')); + ->setArgument('$bodyRenderer', new Reference('draw.mailer.body_renderer.localize_body_renderer.inner')) + ; $container ->registerForAutoconfiguration(EmailWriterInterface::class) - ->addTag(EmailWriterInterface::class); + ->addTag(EmailWriterInterface::class) + ; if (!$this->isConfigEnabled($container, $config['subject_from_html_title'])) { $container->removeDefinition(EmailSubjectFromHtmlTitleListener::class); @@ -74,7 +76,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con '$defaultFrom', (new Definition(Address::class)) ->setArguments([$config['default_from']['email'], $config['default_from']['name'] ?? '']) - ); + ) + ; } $this->renameDefinitions( @@ -94,7 +97,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->arrayNode('css_inliner') ->canBeEnabled() ->validate() - ->ifTrue(fn ($value) => $value['enabled'] && !class_exists(CssInliner::class)) + ->ifTrue(static fn ($value) => $value['enabled'] && !class_exists(CssInliner::class)) ->thenInvalid('The css inliner is base on the [pelago/emogrifier] package. Install it if you want to enable this feature.') ->end() ->end() @@ -105,7 +108,8 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->scalarNode('name')->end() ->end() ->end() - ->end(); + ->end() + ; } public function prepend(ContainerBuilder $container, array $config): void diff --git a/packages/mailer/Tests/Command/SendTestEmailCommandTest.php b/packages/mailer/Tests/Command/SendTestEmailCommandTest.php index d9e04d02b..19876e39e 100644 --- a/packages/mailer/Tests/Command/SendTestEmailCommandTest.php +++ b/packages/mailer/Tests/Command/SendTestEmailCommandTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mime\Email; +/** + * @internal + */ #[CoversClass(SendTestEmailCommand::class)] class SendTestEmailCommandTest extends TestCase { @@ -60,9 +63,11 @@ function (Email $email) use ($to) { return true; } ) - ); + ) + ; $this->execute(['to' => $to]) - ->test(CommandDataTester::create()); + ->test(CommandDataTester::create()) + ; } } diff --git a/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php b/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php index 9d1264d5a..a997d520b 100644 --- a/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php +++ b/packages/mailer/Tests/DependencyInjection/MailerIntegrationTest.php @@ -22,6 +22,8 @@ /** * @property MailerIntegration $integration + * + * @internal */ #[CoversClass(MailerIntegration::class)] class MailerIntegrationTest extends IntegrationTestCase @@ -182,7 +184,7 @@ public static function provideTestLoad(): iterable [ DefaultFromEmailWriter::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { $defaultFromDefinition = $definition->getArgument('$defaultFrom'); static::assertInstanceOf( diff --git a/packages/mailer/Tests/Email/CallToActionEmailTest.php b/packages/mailer/Tests/Email/CallToActionEmailTest.php index 3c0fe3b7c..b764f0236 100644 --- a/packages/mailer/Tests/Email/CallToActionEmailTest.php +++ b/packages/mailer/Tests/Email/CallToActionEmailTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(CallToActionEmail::class)] class CallToActionEmailTest extends TestCase { diff --git a/packages/mailer/Tests/EmailComposerTest.php b/packages/mailer/Tests/EmailComposerTest.php index bd430072c..e19ec2bbf 100644 --- a/packages/mailer/Tests/EmailComposerTest.php +++ b/packages/mailer/Tests/EmailComposerTest.php @@ -18,6 +18,9 @@ use Symfony\Component\Mime\Message; use Symfony\Component\Translation\Translator; +/** + * @internal + */ #[CoversClass(EmailComposer::class)] class EmailComposerTest extends TestCase { @@ -87,7 +90,8 @@ public function testComposeMessage(): void ) ->willReturn( $emailWriter = $this->createMock(EmailWriterStub::class) - ); + ) + ; $emailWriter ->expects(static::once()) @@ -95,7 +99,8 @@ public function testComposeMessage(): void ->with( $message, $envelope - ); + ) + ; $emailWriter ->expects(static::once()) @@ -103,7 +108,8 @@ public function testComposeMessage(): void ->with( $message, $envelope - ); + ) + ; $this->object->compose($message, $envelope); } @@ -156,7 +162,8 @@ public function compose2(Message $email): void $this->serviceLocator ->expects(static::never()) - ->method('get'); + ->method('get') + ; $this->object->compose($message, $envelope); @@ -176,7 +183,8 @@ public function getLocale(): ?string $this->translator ->expects(static::once()) ->method('getLocale') - ->willReturn('en'); + ->willReturn('en') + ; $this->translator ->expects(static::exactly(2)) @@ -186,7 +194,8 @@ public function getLocale(): ?string ['fr'], ['en'] ) - ); + ) + ; $this->object->compose( $message, diff --git a/packages/mailer/Tests/EmailWriter/AddTemplateHeaderEmailWriterTest.php b/packages/mailer/Tests/EmailWriter/AddTemplateHeaderEmailWriterTest.php index bff7df320..c3d097b2f 100644 --- a/packages/mailer/Tests/EmailWriter/AddTemplateHeaderEmailWriterTest.php +++ b/packages/mailer/Tests/EmailWriter/AddTemplateHeaderEmailWriterTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Mime\TemplatedEmail; +/** + * @internal + */ #[CoversClass(AddTemplateHeaderEmailWriter::class)] class AddTemplateHeaderEmailWriterTest extends TestCase { diff --git a/packages/mailer/Tests/EmailWriter/DefaultFromEmailWriterTest.php b/packages/mailer/Tests/EmailWriter/DefaultFromEmailWriterTest.php index fb2f53358..7d438ebab 100644 --- a/packages/mailer/Tests/EmailWriter/DefaultFromEmailWriterTest.php +++ b/packages/mailer/Tests/EmailWriter/DefaultFromEmailWriterTest.php @@ -9,6 +9,9 @@ use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Email; +/** + * @internal + */ #[CoversClass(DefaultFromEmailWriter::class)] class DefaultFromEmailWriterTest extends TestCase { diff --git a/packages/mailer/Tests/EventListener/EmailComposerListenerTest.php b/packages/mailer/Tests/EventListener/EmailComposerListenerTest.php index a482132f5..fab5a22d2 100644 --- a/packages/mailer/Tests/EventListener/EmailComposerListenerTest.php +++ b/packages/mailer/Tests/EventListener/EmailComposerListenerTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Mime\Message; use Symfony\Component\Mime\RawMessage; +/** + * @internal + */ #[CoversClass(EmailComposerListener::class)] class EmailComposerListenerTest extends TestCase { @@ -37,7 +40,8 @@ public function testComposeMessageNotMessage(): void { $this->emailComposer ->expects(static::never()) - ->method('compose'); + ->method('compose') + ; $this->object->composeMessage( $this->createMessageEvent( @@ -50,14 +54,16 @@ public function testComposeMessageComposed(): void { $this->emailComposer ->expects(static::never()) - ->method('compose'); + ->method('compose') + ; $message = $this->createMock(Message::class); $message ->expects(static::once()) ->method('getHeaders') - ->willReturn($headers = new Headers()); + ->willReturn($headers = new Headers()) + ; $headers->add(new UnstructuredHeader('X-DrawEmail', '1')); @@ -72,7 +78,8 @@ public function testComposeMessage(): void $this->emailComposer ->expects(static::once()) - ->method('compose'); + ->method('compose') + ; $this->object->composeMessage($event); @@ -85,7 +92,8 @@ public function testComposeMessageQueued(): void { $this->emailComposer ->expects(static::never()) - ->method('compose'); + ->method('compose') + ; $message = $this->createMock(Message::class); diff --git a/packages/mailer/Tests/EventListener/EmailCssInlinerListenerTest.php b/packages/mailer/Tests/EventListener/EmailCssInlinerListenerTest.php index 978734d05..edd036249 100644 --- a/packages/mailer/Tests/EventListener/EmailCssInlinerListenerTest.php +++ b/packages/mailer/Tests/EventListener/EmailCssInlinerListenerTest.php @@ -13,6 +13,9 @@ use Symfony\Component\Mime\Email; use Symfony\Component\Mime\RawMessage; +/** + * @internal + */ #[CoversClass(EmailCssInlinerListener::class)] class EmailCssInlinerListenerTest extends TestCase { @@ -65,11 +68,13 @@ public function testInlineEmailCssNoHtmlBody(): void $message ->expects(static::once()) ->method('getHtmlBody') - ->willReturn(''); + ->willReturn('') + ; $message ->expects(static::never()) - ->method('html'); + ->method('html') + ; $this->object->inlineEmailCss($event); } @@ -88,14 +93,16 @@ public function testInlineEmailCss(): void $message ->expects(static::once()) ->method('getHtmlBody') - ->willReturn('
'); + ->willReturn('
') + ; $message ->expects(static::once()) ->method('html') ->with('
-'); +') + ; $this->object->inlineEmailCss($event); } diff --git a/packages/mailer/Tests/EventListener/EmailSubjectFromHtmlTitleListenerTest.php b/packages/mailer/Tests/EventListener/EmailSubjectFromHtmlTitleListenerTest.php index bd74f3dc9..7059a89e5 100644 --- a/packages/mailer/Tests/EventListener/EmailSubjectFromHtmlTitleListenerTest.php +++ b/packages/mailer/Tests/EventListener/EmailSubjectFromHtmlTitleListenerTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Mime\Email; use Symfony\Component\Mime\RawMessage; +/** + * @internal + */ #[CoversClass(EmailSubjectFromHtmlTitleListener::class)] class EmailSubjectFromHtmlTitleListenerTest extends TestCase { @@ -58,11 +61,13 @@ public function testAssignSubjectFromHtmlTitleAlreadyASubject(): void $message ->expects(static::once()) ->method('getSubject') - ->willReturn('Subject'); + ->willReturn('Subject') + ; $message ->expects(static::never()) - ->method('subject'); + ->method('subject') + ; $this->object->assignSubjectFromHtmlTitle($this->createMessageEvent($message)); } @@ -74,11 +79,13 @@ public function testAssignSubjectFromHtmlTitleNoHtmlBody(): void $message ->expects(static::once()) ->method('getHtmlBody') - ->willReturn(''); + ->willReturn('') + ; $message ->expects(static::never()) - ->method('subject'); + ->method('subject') + ; $this->object->assignSubjectFromHtmlTitle($this->createMessageEvent($message)); } @@ -90,11 +97,13 @@ public function testAssignSubjectFromHtmlTitleNoTitle(): void $message ->expects(static::once()) ->method('getHtmlBody') - ->willReturn('
'); + ->willReturn('
') + ; $message ->expects(static::never()) - ->method('subject'); + ->method('subject') + ; $this->object->assignSubjectFromHtmlTitle($this->createMessageEvent($message)); } @@ -106,11 +115,13 @@ public function testAssignSubjectFromHtmlTitleTitleEmpty(): void $message ->expects(static::once()) ->method('getHtmlBody') - ->willReturn(''); + ->willReturn('') + ; $message ->expects(static::never()) - ->method('subject'); + ->method('subject') + ; $this->object->assignSubjectFromHtmlTitle($this->createMessageEvent($message)); } @@ -122,12 +133,14 @@ public function testAssignSubjectFromHtmlTitle(): void $message ->expects(static::once()) ->method('getHtmlBody') - ->willReturn('Title'); + ->willReturn('Title') + ; $message ->expects(static::once()) ->method('subject') - ->with('Title'); + ->with('Title') + ; $this->object->assignSubjectFromHtmlTitle($this->createMessageEvent($message)); } diff --git a/packages/mailer/Tests/Twig/TranslationExtensionTest.php b/packages/mailer/Tests/Twig/TranslationExtensionTest.php index d6f952005..03111b0de 100644 --- a/packages/mailer/Tests/Twig/TranslationExtensionTest.php +++ b/packages/mailer/Tests/Twig/TranslationExtensionTest.php @@ -11,6 +11,9 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFilter; +/** + * @internal + */ #[CoversClass(TranslationExtension::class)] class TranslationExtensionTest extends TestCase { @@ -73,7 +76,8 @@ public function testTrans(): void $domain, $locale ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; static::assertSame( $message, @@ -104,7 +108,8 @@ public function testTransMultipleMessage(): void ->willReturnOnConsecutiveCalls( $message1, $result = uniqid('result-') - ); + ) + ; static::assertSame( $result, diff --git a/packages/mailer/Twig/TranslationExtension.php b/packages/mailer/Twig/TranslationExtension.php index 53dbc5ab1..3d23f118a 100644 --- a/packages/mailer/Twig/TranslationExtension.php +++ b/packages/mailer/Twig/TranslationExtension.php @@ -48,7 +48,7 @@ public function trans(string|\Stringable|array|TranslatableInterface|null $messa } $result = $this->translator->trans($message, $arguments, $domain, $locale); - if ($result != $message) { + if ($result !== $message) { return $result; } } diff --git a/packages/messenger/Broker/Command/StartMessengerBrokerCommand.php b/packages/messenger/Broker/Command/StartMessengerBrokerCommand.php index 6f014e514..7fef3b455 100644 --- a/packages/messenger/Broker/Command/StartMessengerBrokerCommand.php +++ b/packages/messenger/Broker/Command/StartMessengerBrokerCommand.php @@ -85,7 +85,8 @@ protected function configure(): void InputOption::VALUE_REQUIRED, 'The timeout in seconds before sending a sig kill when stopping. Default to 10.', 10 - ); + ) + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -124,10 +125,7 @@ private function getConcurrent(InputInterface $input): int $concurrent = (int) $concurrent; if ($concurrent <= 0) { - throw new InvalidOptionException(\sprintf( - 'Concurrent value [%d] is invalid. Must be 1 or greater', - $concurrent - )); + throw new InvalidOptionException(\sprintf('Concurrent value [%d] is invalid. Must be 1 or greater', $concurrent)); } return $concurrent; @@ -137,18 +135,12 @@ private function calculateAutoConcurrent(InputInterface $input): int { $processesPerCore = (float) $input->getOption('processes-per-core'); if ($processesPerCore <= 0) { - throw new InvalidOptionException(\sprintf( - 'Processes per core value [%f] is invalid. Must be greater than 0', - $processesPerCore - )); + throw new InvalidOptionException(\sprintf('Processes per core value [%f] is invalid. Must be greater than 0', $processesPerCore)); } $minProcesses = (int) $input->getOption('minimum-processes'); if ($minProcesses <= 0) { - throw new InvalidOptionException(\sprintf( - 'Minimum processes value [%d] is invalid. Must be greater than 0', - $minProcesses - )); + throw new InvalidOptionException(\sprintf('Minimum processes value [%d] is invalid. Must be greater than 0', $minProcesses)); } $process = max([$minProcesses, (int) round($processesPerCore * $this->cpuCounter->count())]); @@ -159,10 +151,7 @@ private function calculateAutoConcurrent(InputInterface $input): int $maxProcesses = (int) $input->getOption('maximum-processes'); if ($maxProcesses <= 0) { - throw new InvalidOptionException(\sprintf( - 'Maximum processes value [%d] is invalid. Must be greater than 0', - $maxProcesses - )); + throw new InvalidOptionException(\sprintf('Maximum processes value [%d] is invalid. Must be greater than 0', $maxProcesses)); } return min([$maxProcesses, $process]); diff --git a/packages/messenger/Broker/EventListener/StopBrokerOnSigtermSignalListener.php b/packages/messenger/Broker/EventListener/StopBrokerOnSigtermSignalListener.php index 8c4308518..bc692a402 100644 --- a/packages/messenger/Broker/EventListener/StopBrokerOnSigtermSignalListener.php +++ b/packages/messenger/Broker/EventListener/StopBrokerOnSigtermSignalListener.php @@ -20,7 +20,7 @@ public static function getSubscribedEvents(): array public function onBrokerStarted(BrokerStartedEvent $event): void { $broker = $event->getBroker(); - pcntl_signal(\SIGTERM, function () use ($broker): void { + pcntl_signal(\SIGTERM, static function () use ($broker): void { $broker->stop(); }); } diff --git a/packages/messenger/Counter/CpuCounter.php b/packages/messenger/Counter/CpuCounter.php index e1041b710..ef50e3196 100644 --- a/packages/messenger/Counter/CpuCounter.php +++ b/packages/messenger/Counter/CpuCounter.php @@ -11,7 +11,8 @@ public function count(): int { try { return (new CpuCoreCounter()) - ->getCount(); + ->getCount() + ; } catch (NumberOfCpuCoreNotFound) { return 1; } diff --git a/packages/messenger/DependencyInjection/MessengerIntegration.php b/packages/messenger/DependencyInjection/MessengerIntegration.php index 5555622b4..ec3ad7081 100644 --- a/packages/messenger/DependencyInjection/MessengerIntegration.php +++ b/packages/messenger/DependencyInjection/MessengerIntegration.php @@ -59,7 +59,7 @@ public function buildContainer(ContainerBuilder $container): void public function load(array $config, PhpFileLoader $loader, ContainerBuilder $container): void { - $namespace = 'Draw\\Component\\Messenger\\'; + $namespace = 'Draw\Component\Messenger\\'; $rootDirectory = \dirname((new \ReflectionClass(Broker::class))->getFileName(), 2); $directories = glob($rootDirectory.'/*', \GLOB_ONLYDIR); @@ -78,7 +78,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con foreach ($directories as $directory) { $dirname = basename($directory); - if (\in_array($dirname, $ignoreFolders)) { + if (\in_array($dirname, $ignoreFolders, true)) { continue; } @@ -108,7 +108,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $container ->getDefinition(DrawTransportFactory::class) - ->setArgument('$registry', new Reference('doctrine')); + ->setArgument('$registry', new Reference('doctrine')) + ; $container ->getDefinition(TransportRepository::class) @@ -117,13 +118,16 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con ContainerInterface::class.' $transportLocator' => new Reference('messenger.receiver_locator'), '$transportNames' => new Parameter('draw.messenger.transport_names'), ] - ); + ) + ; $container - ->setAlias(TransportRepositoryInterface::class, TransportRepository::class); + ->setAlias(TransportRepositoryInterface::class, TransportRepository::class) + ; $container - ->setAlias(EnvelopeFinderInterface::class, EnvelopeFinder::class); + ->setAlias(EnvelopeFinderInterface::class, EnvelopeFinder::class) + ; $this->renameDefinitions( $container, @@ -133,7 +137,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $container ->getDefinition('draw.messenger.manual_trigger.action.click_message_action') - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; } private function loadBroker(array $config, PhpFileLoader $loader, ContainerBuilder $container): void @@ -144,7 +149,7 @@ private function loadBroker(array $config, PhpFileLoader $loader, ContainerBuild $this->registerClasses( $loader, - 'Draw\\Component\\Messenger\\Broker\\', + 'Draw\Component\Messenger\Broker\\', $directory = \dirname((new \ReflectionClass(Broker::class))->getFileName()), [ $directory.'/Broker.php', @@ -168,7 +173,8 @@ private function loadBroker(array $config, PhpFileLoader $loader, ContainerBuild $container ->getDefinition(BrokerDefaultValuesListener::class) - ->setArgument('$contexts', $contexts); + ->setArgument('$contexts', $contexts) + ; } private function loadDoctrineMessageBusHook(array $config, PhpFileLoader $loader, ContainerBuilder $container): void @@ -179,7 +185,7 @@ private function loadDoctrineMessageBusHook(array $config, PhpFileLoader $loader $this->registerClasses( $loader, - 'Draw\\Component\\Messenger\\DoctrineMessageBusHook\\', + 'Draw\Component\Messenger\DoctrineMessageBusHook\\', \dirname((new \ReflectionClass(EnvelopeFactoryInterface::class))->getFileName(), 2), ); @@ -191,10 +197,12 @@ private function loadDoctrineMessageBusHook(array $config, PhpFileLoader $loader ->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'postPersist']) ->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'postLoad']) ->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'postFlush']) - ->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'onClear']); + ->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'onClear']) + ; $container - ->setAlias(EnvelopeFactoryInterface::class, BasicEnvelopeFactory::class); + ->setAlias(EnvelopeFactoryInterface::class, BasicEnvelopeFactory::class) + ; $envelopeFactoryConfig = $config['envelope_factory']; if (!$this->isConfigEnabled($container, $envelopeFactoryConfig['dispatch_after_current_bus'])) { @@ -205,7 +213,8 @@ private function loadDoctrineMessageBusHook(array $config, PhpFileLoader $loader $container->removeDefinition(EnvelopeFactoryDelayStampListener::class); } else { $container->getDefinition(EnvelopeFactoryDelayStampListener::class) - ->setArgument('$delay', $envelopeFactoryConfig['delay']['delay_in_milliseconds']); + ->setArgument('$delay', $envelopeFactoryConfig['delay']['delay_in_milliseconds']) + ; } } @@ -238,7 +247,7 @@ private function loadSerializerEventDispatcher(array $config, PhpFileLoader $loa $this->registerClasses( $loader, - 'Draw\\Component\\Messenger\\SerializerEventDispatcher\\', + 'Draw\Component\Messenger\SerializerEventDispatcher\\', \dirname((new \ReflectionClass(EventDispatcherSerializerDecorator::class))->getFileName()), ); @@ -258,7 +267,8 @@ private function loadSerializerEventDispatcher(array $config, PhpFileLoader $loa $serializer.'.inner' ) ->setArgument(0, new Reference($serializer.'.inner')) - ); + ) + ; } } @@ -270,7 +280,7 @@ private function loadVersioning(array $config, PhpFileLoader $loader, ContainerB $this->registerClasses( $loader, - 'Draw\\Component\\Messenger\\Versioning\\', + 'Draw\Component\Messenger\Versioning\\', \dirname((new \ReflectionClass(StopOnNewVersionListener::class))->getFileName(), 2), ); @@ -286,14 +296,14 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->arrayNode('async_routing_configuration')->canBeEnabled()->end() ->scalarNode('entity_class') ->validate() - ->ifTrue(fn ($value) => !class_exists($value) && MessengerMessage::class !== $value) + ->ifTrue(static fn ($value) => !class_exists($value) && MessengerMessage::class !== $value) ->thenInvalid('The class [%s] must exists.') ->end() ->defaultValue(MessengerMessage::class) ->end() ->scalarNode('tag_entity_class') ->validate() - ->ifTrue(fn ($value) => !class_exists($value) && MessengerMessageTag::class !== $value) + ->ifTrue(static fn ($value) => !class_exists($value) && MessengerMessageTag::class !== $value) ->thenInvalid('The class [%s] must exists.') ->end() ->defaultValue(MessengerMessageTag::class) @@ -304,7 +314,8 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->append($this->createDoctrineMessageBusHookNode()) ->append($this->createRetryNode()) ->append($this->createSerializerEventDispatcherNode()) - ->end(); + ->end() + ; } private function createBrokerNode(): ArrayNodeDefinition @@ -314,7 +325,7 @@ private function createBrokerNode(): ArrayNodeDefinition ->children() ->arrayNode('contexts') ->beforeNormalization() - ->always(function ($config) { + ->always(static function ($config) { foreach ($config as $name => $configuration) { if (!isset($configuration['name'])) { $config[$name]['name'] = $name; @@ -341,7 +352,7 @@ private function createBrokerNode(): ArrayNodeDefinition ->arrayNode('default_options') ->normalizeKeys(false) ->beforeNormalization() - ->always(function ($options) { + ->always(static function ($options) { foreach ($options as $name => $configuration) { if (!\is_array($configuration)) { $options[$name] = $configuration = ['name' => $name, 'value' => $configuration]; @@ -368,7 +379,8 @@ private function createBrokerNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createDoctrineMessageBusHookNode(): ArrayNodeDefinition @@ -390,7 +402,8 @@ private function createDoctrineMessageBusHookNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createVersioningNode(): ArrayNodeDefinition @@ -399,7 +412,8 @@ private function createVersioningNode(): ArrayNodeDefinition ->canBeEnabled() ->children() ->arrayNode('stop_on_new_version')->canBeDisabled()->end() - ->end(); + ->end() + ; } private function createRetryNode(): ArrayNodeDefinition @@ -415,7 +429,8 @@ private function createRetryNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createSerializerEventDispatcherNode(): ArrayNodeDefinition @@ -430,7 +445,8 @@ private function createSerializerEventDispatcherNode(): ArrayNodeDefinition ]) ->scalarPrototype()->end() ->end() - ->end(); + ->end() + ; } public function prepend(ContainerBuilder $container, array $config): void diff --git a/packages/messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListener.php b/packages/messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListener.php index 12ee92f55..838a18376 100644 --- a/packages/messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListener.php +++ b/packages/messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListener.php @@ -66,7 +66,8 @@ public function createPropertyReferenceStamps(PreEncodeEvent $event): void ); $metadata = $this->getManagerForClass($object::class) - ->getClassMetadata($object::class); + ->getClassMetadata($object::class) + ; $stamps[] = new PropertyReferenceStamp( $propertyName, diff --git a/packages/messenger/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactory.php b/packages/messenger/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactory.php index 91aa6d548..4319dac5d 100644 --- a/packages/messenger/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactory.php +++ b/packages/messenger/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactory.php @@ -19,7 +19,8 @@ public function createEnvelopes(MessageHolderInterface $messageHolder, array $me foreach ($messages as $message) { $envelopes[] = $this->eventDispatcher ->dispatch(new EnvelopeCreatedEvent($messageHolder, new Envelope($message))) - ->getEnvelope(); + ->getEnvelope() + ; } return $envelopes; diff --git a/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListener.php b/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListener.php index 01321eb44..951b32332 100644 --- a/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListener.php +++ b/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListener.php @@ -30,6 +30,7 @@ public function handleEnvelopeCreatedEvent(EnvelopeCreatedEvent $event): void $event ->setEnvelope( $envelope->with(new DelayStamp($this->delay)) - ); + ) + ; } } diff --git a/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListener.php b/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListener.php index 81ed7aae1..ad2057b4f 100644 --- a/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListener.php +++ b/packages/messenger/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListener.php @@ -20,6 +20,7 @@ public function handleEnvelopeCreatedEvent(EnvelopeCreatedEvent $event): void $event ->setEnvelope( $event->getEnvelope()->with(new DispatchAfterCurrentBusStamp()) - ); + ) + ; } } diff --git a/packages/messenger/DoctrineMessageBusHook/Model/MessageHolderTrait.php b/packages/messenger/DoctrineMessageBusHook/Model/MessageHolderTrait.php index 9ccba8511..3b9d92d11 100644 --- a/packages/messenger/DoctrineMessageBusHook/Model/MessageHolderTrait.php +++ b/packages/messenger/DoctrineMessageBusHook/Model/MessageHolderTrait.php @@ -13,7 +13,7 @@ public function getOnHoldMessages(bool $clear): array { $result = []; - array_walk_recursive($this->onHoldMessages, function ($event) use (&$result): void { + array_walk_recursive($this->onHoldMessages, static function ($event) use (&$result): void { $result[] = $event; }); diff --git a/packages/messenger/Expirable/Command/PurgeExpiredMessageCommand.php b/packages/messenger/Expirable/Command/PurgeExpiredMessageCommand.php index 802e70324..b4732f924 100644 --- a/packages/messenger/Expirable/Command/PurgeExpiredMessageCommand.php +++ b/packages/messenger/Expirable/Command/PurgeExpiredMessageCommand.php @@ -32,7 +32,8 @@ protected function configure(): void InputOption::VALUE_OPTIONAL, 'Records older than this date (compatible with strtotime) will be deleted.', self::DEFAULT_DELAY - ); + ) + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/packages/messenger/ManualTrigger/Action/ClickMessageAction.php b/packages/messenger/ManualTrigger/Action/ClickMessageAction.php index d03c4b696..030a758ba 100644 --- a/packages/messenger/ManualTrigger/Action/ClickMessageAction.php +++ b/packages/messenger/ManualTrigger/Action/ClickMessageAction.php @@ -53,7 +53,8 @@ public function __invoke( } catch (\Throwable $error) { $response = $this->eventDispatcher ->dispatch(new MessageLinkErrorEvent($request, $dMUuid, $error)) - ->getResponse(); + ->getResponse() + ; if ($response) { return $response; @@ -80,9 +81,6 @@ private function addFlash(Request $request, string $type, string $message): void $session->getFlashBag()->add($type, $this->translator->trans($message, [], 'DrawMessenger')); } - /** - * @return mixed - */ private function handle(Envelope $envelope) { $envelope = $this->messageBus->dispatch( @@ -97,7 +95,7 @@ private function handle(Envelope $envelope) $handlers = implode( ', ', array_map( - fn (HandledStamp $stamp): string => \sprintf('"%s"', $stamp->getHandlerName()), + static fn (HandledStamp $stamp): string => \sprintf('"%s"', $stamp->getHandlerName()), $handledStamps ) ); @@ -107,7 +105,8 @@ private function handle(Envelope $envelope) $this->transportRepository ->get($transportName) - ->ack($envelope); + ->ack($envelope) + ; return $handledStamps[0]->getResult(); } diff --git a/packages/messenger/MessageHandler/RetryFailedMessageMessageHandler.php b/packages/messenger/MessageHandler/RetryFailedMessageMessageHandler.php index 556caec11..94224c677 100644 --- a/packages/messenger/MessageHandler/RetryFailedMessageMessageHandler.php +++ b/packages/messenger/MessageHandler/RetryFailedMessageMessageHandler.php @@ -30,6 +30,7 @@ public function handleRetryFailedMessageMessage(RetryFailedMessageMessage $messa '--force', ] ) - ->mustRun(); + ->mustRun() + ; } } diff --git a/packages/messenger/Retry/EventDrivenRetryStrategy.php b/packages/messenger/Retry/EventDrivenRetryStrategy.php index 5b3488489..e9f382878 100644 --- a/packages/messenger/Retry/EventDrivenRetryStrategy.php +++ b/packages/messenger/Retry/EventDrivenRetryStrategy.php @@ -20,7 +20,8 @@ public function isRetryable(Envelope $message, ?\Throwable $throwable = null): b { $isRetryable = $this->eventDispatcher ->dispatch(new IsRetryableEvent($message, $throwable)) - ->getIsRetryable(); + ->getIsRetryable() + ; return $isRetryable ?? $this->fallbackRetryStrategy?->isRetryable($message) ?? false; } @@ -29,7 +30,8 @@ public function getWaitingTime(Envelope $message, ?\Throwable $throwable = null) { $waitingTime = $this->eventDispatcher ->dispatch(new GetWaitingTimeEvent($message, $throwable)) - ->getWaitingTime(); + ->getWaitingTime() + ; return $waitingTime ?? $this->fallbackRetryStrategy?->getWaitingTime($message) ?? 1000; } diff --git a/packages/messenger/Tests/AutoStamp/EventListener/AutoStampEnvelopeListenerTest.php b/packages/messenger/Tests/AutoStamp/EventListener/AutoStampEnvelopeListenerTest.php index dce51cc14..3cdd72d66 100644 --- a/packages/messenger/Tests/AutoStamp/EventListener/AutoStampEnvelopeListenerTest.php +++ b/packages/messenger/Tests/AutoStamp/EventListener/AutoStampEnvelopeListenerTest.php @@ -10,6 +10,9 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent; +/** + * @internal + */ #[CoversClass(AutoStampEnvelopeListener::class)] class AutoStampEnvelopeListenerTest extends TestCase implements StampingAwareInterface { diff --git a/packages/messenger/Tests/Broker/BrokerTest.php b/packages/messenger/Tests/Broker/BrokerTest.php index f22a72563..85540e953 100644 --- a/packages/messenger/Tests/Broker/BrokerTest.php +++ b/packages/messenger/Tests/Broker/BrokerTest.php @@ -14,6 +14,9 @@ use Symfony\Component\Process\Process; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ #[CoversClass(Broker::class)] class BrokerTest extends TestCase { @@ -114,7 +117,8 @@ public function testStart(): void ], ) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->processFactory ->expects(static::exactly($concurrent)) @@ -130,16 +134,19 @@ public function testStart(): void null, null ) - ->willReturn($process = $this->createMock(Process::class)); + ->willReturn($process = $this->createMock(Process::class)) + ; $process ->expects(static::exactly($concurrent)) - ->method('start'); + ->method('start') + ; $process ->expects(static::exactly($concurrent)) ->method('isRunning') - ->willReturn(false); + ->willReturn(false) + ; $this->service->start($concurrent, $timeout); } @@ -162,7 +169,8 @@ public function testStartWithForceStop(): void return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->processFactory ->expects(static::exactly($concurrent)) @@ -178,11 +186,13 @@ public function testStartWithForceStop(): void null, null ) - ->willReturn($process = $this->createMock(Process::class)); + ->willReturn($process = $this->createMock(Process::class)) + ; $process ->expects(static::exactly($concurrent)) - ->method('start'); + ->method('start') + ; $process ->expects(static::exactly(6)) // $concurrent * 3 @@ -194,19 +204,22 @@ public function testStartWithForceStop(): void true, false, true - ); + ) + ; $process ->expects(static::exactly($concurrent)) ->method('signal') ->with(15) - ->willReturnSelf(); + ->willReturnSelf() + ; $process ->expects(static::once()) ->method('stop') ->with(0) - ->willReturn(0); + ->willReturn(0) + ; $this->service->start($concurrent, 0); } @@ -217,7 +230,8 @@ public function testStartNoReceiver(): void $this->processFactory ->expects(static::never()) - ->method('create'); + ->method('create') + ; $this->expectException(\RuntimeException::class); $this->expectExceptionMessage(\sprintf( @@ -254,7 +268,8 @@ public function testStartForBuildOptions(): void return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->processFactory ->expects(static::exactly($concurrent)) @@ -277,16 +292,19 @@ public function testStartForBuildOptions(): void null, null ) - ->willReturn($process = $this->createMock(Process::class)); + ->willReturn($process = $this->createMock(Process::class)) + ; $process ->expects(static::exactly($concurrent)) - ->method('start'); + ->method('start') + ; $process ->expects(static::exactly($concurrent)) ->method('isRunning') - ->willReturn(false); + ->willReturn(false) + ; $this->service->start($concurrent, $timeout); } diff --git a/packages/messenger/Tests/Broker/Command/StartMessengerBrokerCommandTest.php b/packages/messenger/Tests/Broker/Command/StartMessengerBrokerCommandTest.php index f8e87d165..03f06bfbe 100644 --- a/packages/messenger/Tests/Broker/Command/StartMessengerBrokerCommandTest.php +++ b/packages/messenger/Tests/Broker/Command/StartMessengerBrokerCommandTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\EventDispatcher\EventDispatcher; +/** + * @internal + */ #[CoversClass(StartMessengerBrokerCommand::class)] class StartMessengerBrokerCommandTest extends TestCase { @@ -230,11 +233,12 @@ public function testExecuteWithAutoConcurrent( $this ->cpuCounter ->method('count') - ->willReturn($numCpus); + ->willReturn($numCpus) + ; $this->eventDispatcher->addListener( BrokerStartedEvent::class, - function (BrokerStartedEvent $event) use ($concurrent): void { + static function (BrokerStartedEvent $event) use ($concurrent): void { static::assertSame($concurrent, $event->getConcurrent()); $broker = $event->getBroker(); @@ -262,7 +266,8 @@ function (BrokerStartedEvent $event) use ($concurrent): void { '! [NOTE] Timeout 10', '[OK] Broker stopped. ', ] - )); + )) + ; } public static function provideDataForTestExecuteWithAutoConcurrent(): iterable diff --git a/packages/messenger/Tests/Broker/Event/BrokerRunningEventTest.php b/packages/messenger/Tests/Broker/Event/BrokerRunningEventTest.php index 326a85a59..d7b1e0efa 100644 --- a/packages/messenger/Tests/Broker/Event/BrokerRunningEventTest.php +++ b/packages/messenger/Tests/Broker/Event/BrokerRunningEventTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(BrokerRunningEvent::class)] class BrokerRunningEventTest extends TestCase { diff --git a/packages/messenger/Tests/Broker/Event/BrokerStartedEventTest.php b/packages/messenger/Tests/Broker/Event/BrokerStartedEventTest.php index 96fd2543d..b30054ff2 100644 --- a/packages/messenger/Tests/Broker/Event/BrokerStartedEventTest.php +++ b/packages/messenger/Tests/Broker/Event/BrokerStartedEventTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(BrokerStartedEvent::class)] class BrokerStartedEventTest extends TestCase { diff --git a/packages/messenger/Tests/Broker/Event/NewConsumerProcessEventTest.php b/packages/messenger/Tests/Broker/Event/NewConsumerProcessEventTest.php index fb15fa516..1298de8b8 100644 --- a/packages/messenger/Tests/Broker/Event/NewConsumerProcessEventTest.php +++ b/packages/messenger/Tests/Broker/Event/NewConsumerProcessEventTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(NewConsumerProcessEvent::class)] class NewConsumerProcessEventTest extends TestCase { diff --git a/packages/messenger/Tests/Broker/EventListener/BrokerDefaultValuesListenerTest.php b/packages/messenger/Tests/Broker/EventListener/BrokerDefaultValuesListenerTest.php index 53d280f72..20a135398 100644 --- a/packages/messenger/Tests/Broker/EventListener/BrokerDefaultValuesListenerTest.php +++ b/packages/messenger/Tests/Broker/EventListener/BrokerDefaultValuesListenerTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * @internal + */ #[CoversClass(BrokerDefaultValuesListener::class)] class BrokerDefaultValuesListenerTest extends TestCase { diff --git a/packages/messenger/Tests/Broker/EventListener/StopBrokerOnSigtermSignalListenerTest.php b/packages/messenger/Tests/Broker/EventListener/StopBrokerOnSigtermSignalListenerTest.php index 0f0ab09e6..1b8ff03b0 100644 --- a/packages/messenger/Tests/Broker/EventListener/StopBrokerOnSigtermSignalListenerTest.php +++ b/packages/messenger/Tests/Broker/EventListener/StopBrokerOnSigtermSignalListenerTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(StopBrokerOnSigtermSignalListener::class)] class StopBrokerOnSigtermSignalListenerTest extends TestCase { @@ -34,7 +37,8 @@ public function testOnBrokerStarted(): void $event ->expects(static::once()) ->method('getBroker') - ->willReturn($this->createMock(Broker::class)); + ->willReturn($this->createMock(Broker::class)) + ; $this->service->onBrokerStarted($event); } diff --git a/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php b/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php index 398be074e..d0058d465 100644 --- a/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php +++ b/packages/messenger/Tests/DependencyInjection/MessengerIntegrationTest.php @@ -43,6 +43,8 @@ /** * @property MessengerIntegration $integration + * + * @internal */ #[CoversClass(MessengerIntegration::class)] class MessengerIntegrationTest extends IntegrationTestCase @@ -225,7 +227,7 @@ public static function provideTestLoad(): iterable new ServiceConfiguration( 'draw.messenger.serializer_event_dispatcher0', [], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( ['messenger.transport.serializer', 'messenger.transport.serializer.inner', 0], $definition->getDecoratedService(), @@ -295,7 +297,7 @@ function (Definition $definition): void { [ BrokerDefaultValuesListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( [ 'default' => [ @@ -339,7 +341,7 @@ function (Definition $definition): void { [ DoctrineBusMessageListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( [ 'doctrine.event_listener' => [ @@ -376,7 +378,7 @@ function (Definition $definition): void { [ EnvelopeFactoryDelayStampListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( [ '$delay' => 5000, diff --git a/packages/messenger/Tests/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php b/packages/messenger/Tests/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php index 9ed715222..a2ca0a647 100644 --- a/packages/messenger/Tests/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php +++ b/packages/messenger/Tests/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * @internal + */ class PropertyReferenceEncodingListenerTest extends TestCase { private PropertyReferenceEncodingListener $object; diff --git a/packages/messenger/Tests/DoctrineMessageBusHook/Entity/MessageHolderTraitTest.php b/packages/messenger/Tests/DoctrineMessageBusHook/Entity/MessageHolderTraitTest.php index fdb6640fb..8c61676d1 100644 --- a/packages/messenger/Tests/DoctrineMessageBusHook/Entity/MessageHolderTraitTest.php +++ b/packages/messenger/Tests/DoctrineMessageBusHook/Entity/MessageHolderTraitTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(MessageHolderTrait::class)] class MessageHolderTraitTest extends TestCase { diff --git a/packages/messenger/Tests/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactoryTest.php b/packages/messenger/Tests/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactoryTest.php index 202f18468..847ef7432 100644 --- a/packages/messenger/Tests/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactoryTest.php +++ b/packages/messenger/Tests/DoctrineMessageBusHook/EnvelopeFactory/BasicEnvelopeFactoryTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ class BasicEnvelopeFactoryTest extends TestCase { use MockTrait; @@ -66,7 +69,8 @@ function (EnvelopeCreatedEvent $event) use ($messages, $messageHolder) { ] ) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $envelopes = $this->object->createEnvelopes($messageHolder, $messages); diff --git a/packages/messenger/Tests/DoctrineMessageBusHook/Event/EnvelopeCreatedEventTest.php b/packages/messenger/Tests/DoctrineMessageBusHook/Event/EnvelopeCreatedEventTest.php index 1e236bb60..78d25bfd1 100644 --- a/packages/messenger/Tests/DoctrineMessageBusHook/Event/EnvelopeCreatedEventTest.php +++ b/packages/messenger/Tests/DoctrineMessageBusHook/Event/EnvelopeCreatedEventTest.php @@ -10,6 +10,9 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(EnvelopeCreatedEvent::class)] class EnvelopeCreatedEventTest extends TestCase { diff --git a/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/DoctrineBusMessageListenerTest.php b/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/DoctrineBusMessageListenerTest.php index afe8fc265..41788e197 100644 --- a/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/DoctrineBusMessageListenerTest.php +++ b/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/DoctrineBusMessageListenerTest.php @@ -21,6 +21,9 @@ use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Contracts\Service\ResetInterface; +/** + * @internal + */ #[CoversClass(DoctrineBusMessageListener::class)] class DoctrineBusMessageListenerTest extends TestCase { @@ -60,7 +63,8 @@ public function testPostPersist(): void ->expects(static::once()) ->method('getClassMetadata') ->with($messageHolder::class) - ->willReturn($classMetadata = new ClassMetadata(uniqid())); + ->willReturn($classMetadata = new ClassMetadata(uniqid())) + ; $classMetadata->rootEntityName = $messageHolder::class; @@ -83,7 +87,8 @@ public function testPostPersistNotMessageHolderEntity(): void $this->entityManager ->expects(static::never()) - ->method('getClassMetadata'); + ->method('getClassMetadata') + ; $this->object->postPersist( new LifecycleEventArgs( @@ -106,7 +111,8 @@ public function testPostLoad(): void ->expects(static::once()) ->method('getClassMetadata') ->with($messageHolder::class) - ->willReturn($classMetadata = new ClassMetadata(uniqid())); + ->willReturn($classMetadata = new ClassMetadata(uniqid())) + ; $classMetadata->rootEntityName = $messageHolder::class; @@ -169,11 +175,13 @@ public function testPostFlushEmpty(): void { $this->envelopeFactory ->expects(static::never()) - ->method('createEnvelopes'); + ->method('createEnvelopes') + ; $this->messageBus ->expects(static::never()) - ->method('dispatch'); + ->method('dispatch') + ; $this->object->postFlush(); } @@ -181,8 +189,7 @@ public function testPostFlushEmpty(): void public function testPostFlushOnlyUninitializedProxy(): void { $this->addMessageHolder( - new class implements Proxy, - MessageHolderInterface { + new class implements Proxy, MessageHolderInterface { public function getOnHoldMessages(bool $clear): array { return []; @@ -201,11 +208,13 @@ public function __isInitialized(): bool $this->envelopeFactory ->expects(static::never()) - ->method('createEnvelopes'); + ->method('createEnvelopes') + ; $this->messageBus ->expects(static::never()) - ->method('dispatch'); + ->method('dispatch') + ; $this->object->postFlush(); } @@ -225,28 +234,33 @@ public function testPostFlushWithOneMessage(): void // Arbitrary interface just to add preSend method without implementing LifeCycleAwareMessageInterface $message2 = $this->createMock(PreSendAwareMessageInterface::class), ] - ); + ) + ; $message1 ->expects(static::once()) ->method('preSend') - ->with($messageHolder); + ->with($messageHolder) + ; $message2 ->expects(static::never()) - ->method('preSend'); + ->method('preSend') + ; $this->envelopeFactory ->expects(static::once()) ->method('createEnvelopes') ->with($messageHolder, $messages) - ->willReturn([$envelope = new Envelope((object) [])]); + ->willReturn([$envelope = new Envelope((object) [])]) + ; $this->messageBus ->expects(static::once()) ->method('dispatch') ->with($envelope) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->object->postFlush(); } @@ -261,7 +275,8 @@ public function testPostFlushWithMultipleMessageHolder(): void ->expects(static::once()) ->method('getOnHoldMessages') ->with(true) - ->willReturn([(object) []]); + ->willReturn([(object) []]) + ; $messageHolder = $this->createMock(MessageHolderInterface::class); @@ -271,18 +286,21 @@ public function testPostFlushWithMultipleMessageHolder(): void ->expects(static::once()) ->method('getOnHoldMessages') ->with(true) - ->willReturn([(object) []]); + ->willReturn([(object) []]) + ; $this->envelopeFactory ->expects(static::exactly(2)) ->method('createEnvelopes') - ->willReturn([$envelope = new Envelope((object) [])]); + ->willReturn([$envelope = new Envelope((object) [])]) + ; $this->messageBus ->expects(static::exactly(2)) ->method('dispatch') ->with($envelope) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->object->postFlush(); } diff --git a/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListenerTest.php b/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListenerTest.php index ca51166f1..8554095fd 100644 --- a/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListenerTest.php +++ b/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDelayStampListenerTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Stamp\DelayStamp; +/** + * @internal + */ #[CoversClass(EnvelopeFactoryDelayStampListener::class)] class EnvelopeFactoryDelayStampListenerTest extends TestCase { diff --git a/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListenerTest.php b/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListenerTest.php index 83fdf4e3e..7e2e9da73 100644 --- a/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListenerTest.php +++ b/packages/messenger/Tests/DoctrineMessageBusHook/EventListener/EnvelopeFactoryDispatchAfterCurrentBusStampListenerTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Stamp\DispatchAfterCurrentBusStamp; +/** + * @internal + */ #[CoversClass(EnvelopeFactoryDispatchAfterCurrentBusStampListener::class)] class EnvelopeFactoryDispatchAfterCurrentBusStampListenerTest extends TestCase { diff --git a/packages/messenger/Tests/Entity/DrawMessageTagTraitTest.php b/packages/messenger/Tests/Entity/DrawMessageTagTraitTest.php index 00f4f9e8e..01f6303a4 100644 --- a/packages/messenger/Tests/Entity/DrawMessageTagTraitTest.php +++ b/packages/messenger/Tests/Entity/DrawMessageTagTraitTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(DrawMessageTagTrait::class)] class DrawMessageTagTraitTest extends TestCase { diff --git a/packages/messenger/Tests/Entity/DrawMessageTraitTest.php b/packages/messenger/Tests/Entity/DrawMessageTraitTest.php index cc899284b..110677389 100644 --- a/packages/messenger/Tests/Entity/DrawMessageTraitTest.php +++ b/packages/messenger/Tests/Entity/DrawMessageTraitTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(DrawMessageTrait::class)] class DrawMessageTraitTest extends TestCase { diff --git a/packages/messenger/Tests/EventListener/StopOnNewVersionListenerTest.php b/packages/messenger/Tests/EventListener/StopOnNewVersionListenerTest.php index ffd32fb59..168d34524 100644 --- a/packages/messenger/Tests/EventListener/StopOnNewVersionListenerTest.php +++ b/packages/messenger/Tests/EventListener/StopOnNewVersionListenerTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Messenger\Event\WorkerStartedEvent; use Symfony\Component\Messenger\Worker; +/** + * @internal + */ #[CoversClass(StopOnNewVersionListener::class)] class StopOnNewVersionListenerTest extends TestCase implements VersionVerificationInterface { diff --git a/packages/messenger/Tests/Exception/MessageNotFoundExceptionTest.php b/packages/messenger/Tests/Exception/MessageNotFoundExceptionTest.php index b2c5052bd..f6a0422bf 100644 --- a/packages/messenger/Tests/Exception/MessageNotFoundExceptionTest.php +++ b/packages/messenger/Tests/Exception/MessageNotFoundExceptionTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(MessageNotFoundException::class)] class MessageNotFoundExceptionTest extends TestCase { diff --git a/packages/messenger/Tests/Expirable/Command/PurgeExpiredMessageCommandTest.php b/packages/messenger/Tests/Expirable/Command/PurgeExpiredMessageCommandTest.php index fd330577c..6ee90215d 100644 --- a/packages/messenger/Tests/Expirable/Command/PurgeExpiredMessageCommandTest.php +++ b/packages/messenger/Tests/Expirable/Command/PurgeExpiredMessageCommandTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +/** + * @internal + */ #[CoversClass(PurgeExpiredMessageCommand::class)] class PurgeExpiredMessageCommandTest extends TestCase { @@ -59,7 +62,8 @@ public function testExecuteInvalidTransport(): void ->expects(static::once()) ->method('has') ->with($transport = uniqid('transport-invalid-')) - ->willReturn(false); + ->willReturn(false) + ; $this->expectException(\RuntimeException::class); $this->expectExceptionMessage(\sprintf('The "%s" transport does not exist.', $transport)); @@ -72,7 +76,8 @@ public function testExecute(): void $this->transportRepository ->expects(static::once()) ->method('getTransportNames') - ->willReturn($transportNames = [uniqid('transport1-'), uniqid('transport2-')]); + ->willReturn($transportNames = [uniqid('transport1-'), uniqid('transport2-')]) + ; $this->transportRepository ->expects(static::exactly(2)) @@ -86,7 +91,8 @@ public function testExecute(): void ->willReturnOnConsecutiveCalls( $transport1 = $this->createMock(PurgeableTransportInterface::class), $transport2 = $this->createMock(PurgeAwareTransportInterface::class) - ); + ) + ; $transport1 ->expects(static::once()) @@ -94,11 +100,13 @@ public function testExecute(): void ->with( static::equalToWithDelta(new \DateTime('- 1 month'), 1) ) - ->willReturn($count = random_int(1, 10)); + ->willReturn($count = random_int(1, 10)) + ; $transport2 ->expects(static::never()) - ->method('purgeObsoleteMessages'); + ->method('purgeObsoleteMessages') + ; $this->execute([], []) ->test( @@ -116,7 +124,8 @@ public function testExecute(): void ), ] ) - ); + ) + ; } public function testExecuteWithInputs(): void @@ -125,7 +134,8 @@ public function testExecuteWithInputs(): void ->expects(static::once()) ->method('has') ->with($transportName = uniqid('transport-')) - ->willReturn(true); + ->willReturn(true) + ; $this->transportRepository ->expects(static::once()) @@ -133,7 +143,8 @@ public function testExecuteWithInputs(): void ->with($transportName) ->willReturn( $transport = $this->createMock(PurgeableTransportInterface::class), - ); + ) + ; $delay = '- 4 months'; @@ -143,7 +154,8 @@ public function testExecuteWithInputs(): void ->with( static::equalToWithDelta(new \DateTime($delay), 1) ) - ->willReturn($count = random_int(1, 10)); + ->willReturn($count = random_int(1, 10)) + ; $this->execute(['transport' => $transportName, '--delay' => $delay], []) ->test( @@ -157,6 +169,7 @@ public function testExecuteWithInputs(): void ), ] ) - ); + ) + ; } } diff --git a/packages/messenger/Tests/Expirable/Stamp/ExpirationStampTest.php b/packages/messenger/Tests/Expirable/Stamp/ExpirationStampTest.php index 967b5ff1f..279843a76 100644 --- a/packages/messenger/Tests/Expirable/Stamp/ExpirationStampTest.php +++ b/packages/messenger/Tests/Expirable/Stamp/ExpirationStampTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Stamp\StampInterface; +/** + * @internal + */ #[CoversClass(ExpirationStamp::class)] class ExpirationStampTest extends TestCase { diff --git a/packages/messenger/Tests/ManualTrigger/Action/ClickMessageActionTest.php b/packages/messenger/Tests/ManualTrigger/Action/ClickMessageActionTest.php index c5e60e507..1e7e9533d 100644 --- a/packages/messenger/Tests/ManualTrigger/Action/ClickMessageActionTest.php +++ b/packages/messenger/Tests/ManualTrigger/Action/ClickMessageActionTest.php @@ -29,6 +29,9 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\Translation\TranslatorInterface; +/** + * @internal + */ #[CoversClass(ClickMessageAction::class)] class ClickMessageActionTest extends TestCase { @@ -101,13 +104,15 @@ public function testClickEnvelopeError( ): void { $this->messageBus ->expects(static::never()) - ->method('dispatch'); + ->method('dispatch') + ; $this->envelopeFinder ->expects(static::once()) ->method('findById') ->with($messageId = uniqid('message-Id')) - ->willThrowException(new MessageNotFoundException($messageId)); + ->willThrowException(new MessageNotFoundException($messageId)) + ; $this->eventDispatcher ->expects(static::once()) @@ -136,19 +141,22 @@ function (MessageLinkErrorEvent $event) use ($messageId, $exceptionClass) { } ) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; if ($translatedMessage) { $this->translator ->expects(static::once()) ->method('trans') ->with($translatedMessage, [], 'DrawMessenger') - ->willReturn($message = uniqid('translation-')); + ->willReturn($message = uniqid('translation-')) + ; } else { $this->request->setSession($this->createMock(SessionInterface::class)); $this->translator ->expects(static::never()) - ->method('trans'); + ->method('trans') + ; } $response = \call_user_func($this->object, $messageId, $this->request); @@ -181,7 +189,8 @@ public function testClick(): void ->expects(static::once()) ->method('findById') ->with($messageId = uniqid('message-Id')) - ->willReturn(new Envelope((object) [], [new FoundFromTransportStamp($transportName)])); + ->willReturn(new Envelope((object) [], [new FoundFromTransportStamp($transportName)])) + ; $this->messageBus ->expects(static::once()) @@ -200,24 +209,28 @@ public function testClick(): void (object) [], [new TransportMessageIdStamp($messageId), new HandledStamp(null, uniqid('handler-'))] ) - ); + ) + ; $this->translator ->expects(static::once()) ->method('trans') ->with('link.processed', [], 'DrawMessenger') - ->willReturn($message = uniqid('translation-')); + ->willReturn($message = uniqid('translation-')) + ; $this->transportRepository ->expects(static::once()) ->method('get') ->with($transportName) - ->willReturn($transport = $this->createMock(TransportInterface::class)); + ->willReturn($transport = $this->createMock(TransportInterface::class)) + ; $transport ->expects(static::once()) ->method('ack') - ->with($envelope); + ->with($envelope) + ; $response = \call_user_func($this->object, $messageId, $this->request); @@ -247,7 +260,8 @@ public function testClickWithResponse(): void ->expects(static::once()) ->method('findById') ->with($messageId = uniqid('message-Id')) - ->willReturn(new Envelope((object) [], [new FoundFromTransportStamp($transportName)])); + ->willReturn(new Envelope((object) [], [new FoundFromTransportStamp($transportName)])) + ; $this->messageBus ->expects(static::once()) @@ -260,22 +274,26 @@ public function testClickWithResponse(): void new HandledStamp($response = new Response(), uniqid('handler-')), ] ) - ); + ) + ; $this->translator ->expects(static::never()) - ->method('trans'); + ->method('trans') + ; $this->transportRepository ->expects(static::once()) ->method('get') ->with($transportName) - ->willReturn($transport = $this->createMock(TransportInterface::class)); + ->willReturn($transport = $this->createMock(TransportInterface::class)) + ; $transport ->expects(static::once()) ->method('ack') - ->with($envelope); + ->with($envelope) + ; static::assertSame( $response, @@ -296,7 +314,8 @@ public function testClickInvalidHandler(): void (object) [], [new FoundFromTransportStamp($transportName)] ) - ); + ) + ; $this->messageBus ->expects(static::once()) @@ -310,11 +329,13 @@ public function testClickInvalidHandler(): void new HandledStamp(null, $handler2 = uniqid('handler-2-')), ] ) - ); + ) + ; $this->translator ->expects(static::never()) - ->method('trans'); + ->method('trans') + ; $response = new Response(); @@ -340,7 +361,8 @@ function (MessageLinkErrorEvent $event) use ($response, $handler1, $handler2) { } ) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; static::assertSame( $response, diff --git a/packages/messenger/Tests/ManualTrigger/Event/MessageLinkErrorEventTest.php b/packages/messenger/Tests/ManualTrigger/Event/MessageLinkErrorEventTest.php index bca69ba57..da1e81d1f 100644 --- a/packages/messenger/Tests/ManualTrigger/Event/MessageLinkErrorEventTest.php +++ b/packages/messenger/Tests/ManualTrigger/Event/MessageLinkErrorEventTest.php @@ -9,6 +9,9 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(MessageLinkErrorEvent::class)] class MessageLinkErrorEventTest extends TestCase { diff --git a/packages/messenger/Tests/ManualTrigger/EventListener/StampManuallyTriggeredEnvelopeListenerTest.php b/packages/messenger/Tests/ManualTrigger/EventListener/StampManuallyTriggeredEnvelopeListenerTest.php index ab6f45783..a618fe7b4 100644 --- a/packages/messenger/Tests/ManualTrigger/EventListener/StampManuallyTriggeredEnvelopeListenerTest.php +++ b/packages/messenger/Tests/ManualTrigger/EventListener/StampManuallyTriggeredEnvelopeListenerTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent; +/** + * @internal + */ #[CoversClass(StampManuallyTriggeredEnvelopeListener::class)] class StampManuallyTriggeredEnvelopeListenerTest extends TestCase { diff --git a/packages/messenger/Tests/ManualTrigger/Message/RedirectToRouteMessageTraitTest.php b/packages/messenger/Tests/ManualTrigger/Message/RedirectToRouteMessageTraitTest.php index 02a79fc9f..638f507da 100644 --- a/packages/messenger/Tests/ManualTrigger/Message/RedirectToRouteMessageTraitTest.php +++ b/packages/messenger/Tests/ManualTrigger/Message/RedirectToRouteMessageTraitTest.php @@ -8,6 +8,9 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +/** + * @internal + */ #[CoversClass(RedirectToRouteMessageTrait::class)] class RedirectToRouteMessageTraitTest extends TestCase { @@ -28,7 +31,8 @@ public function testGetRedirectResponse(): void $this->urlParameters, UrlGeneratorInterface::ABSOLUTE_URL ) - ->willReturn($url = uniqid('url-')); + ->willReturn($url = uniqid('url-')) + ; $response = $this->getRedirectResponse($urlGenerator); diff --git a/packages/messenger/Tests/ManualTrigger/MessageHandler/RedirectToRouteMessageHandlerTest.php b/packages/messenger/Tests/ManualTrigger/MessageHandler/RedirectToRouteMessageHandlerTest.php index a6fd95912..d1632123a 100644 --- a/packages/messenger/Tests/ManualTrigger/MessageHandler/RedirectToRouteMessageHandlerTest.php +++ b/packages/messenger/Tests/ManualTrigger/MessageHandler/RedirectToRouteMessageHandlerTest.php @@ -9,6 +9,9 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +/** + * @internal + */ #[CoversClass(RedirectToRouteMessageHandler::class)] class RedirectToRouteMessageHandlerTest extends TestCase { @@ -31,7 +34,8 @@ public function testInvoke(): void ->expects(static::once()) ->method('getRedirectResponse') ->with($this->urlGenerator) - ->willReturn($response = new RedirectResponse('/')); + ->willReturn($response = new RedirectResponse('/')) + ; static::assertSame( $response, diff --git a/packages/messenger/Tests/ManualTrigger/Stamp/ManualTriggerStampTest.php b/packages/messenger/Tests/ManualTrigger/Stamp/ManualTriggerStampTest.php index cbc388dde..e66e5ab30 100644 --- a/packages/messenger/Tests/ManualTrigger/Stamp/ManualTriggerStampTest.php +++ b/packages/messenger/Tests/ManualTrigger/Stamp/ManualTriggerStampTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Stamp\StampInterface; +/** + * @internal + */ #[CoversClass(ManualTriggerStamp::class)] class ManualTriggerStampTest extends TestCase { diff --git a/packages/messenger/Tests/MessageHandler/RetryFailedMessageMessageHandlerTest.php b/packages/messenger/Tests/MessageHandler/RetryFailedMessageMessageHandlerTest.php index b315ba6ed..48e454972 100644 --- a/packages/messenger/Tests/MessageHandler/RetryFailedMessageMessageHandlerTest.php +++ b/packages/messenger/Tests/MessageHandler/RetryFailedMessageMessageHandlerTest.php @@ -13,6 +13,9 @@ use Ramsey\Uuid\Uuid; use Symfony\Component\Process\Process; +/** + * @internal + */ #[ CoversClass(RetryFailedMessageMessage::class), CoversClass(RetryFailedMessageMessageHandler::class), @@ -48,11 +51,13 @@ public function testHandleRetryFailedMessageMessage(): void '--force', ] ) - ->willReturn($process = $this->createMock(Process::class)); + ->willReturn($process = $this->createMock(Process::class)) + ; $process ->expects(static::once()) - ->method('mustRun'); + ->method('mustRun') + ; $this->handler->handleRetryFailedMessageMessage( new RetryFailedMessageMessage($messageId) diff --git a/packages/messenger/Tests/Retry/EventDrivenRetryStrategyTest.php b/packages/messenger/Tests/Retry/EventDrivenRetryStrategyTest.php index a62e09a4d..9b61dc53a 100644 --- a/packages/messenger/Tests/Retry/EventDrivenRetryStrategyTest.php +++ b/packages/messenger/Tests/Retry/EventDrivenRetryStrategyTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Messenger\Retry\RetryStrategyInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ class EventDrivenRetryStrategyTest extends TestCase { use MockTrait; @@ -43,12 +46,13 @@ public function testIsRetryableDefault(): void ->expects(static::once()) ->method('dispatch') ->willReturnCallback( - function (IsRetryableEvent $event) use ($envelope) { + static function (IsRetryableEvent $event) use ($envelope) { static::assertSame($envelope, $event->getEnvelope()); return $event; } - ); + ) + ; static::assertFalse($this->object->isRetryable($envelope)); } @@ -61,14 +65,15 @@ public function testIsRetryableViaEventTrue(): void ->expects(static::once()) ->method('dispatch') ->willReturnCallback( - function (IsRetryableEvent $event) use ($envelope) { + static function (IsRetryableEvent $event) use ($envelope) { static::assertSame($envelope, $event->getEnvelope()); $event->setIsRetryable(true); return $event; } - ); + ) + ; static::assertTrue($this->object->isRetryable($envelope)); } @@ -81,14 +86,15 @@ public function testIsRetryableViaEventFalse(): void ->expects(static::once()) ->method('dispatch') ->willReturnCallback( - function (IsRetryableEvent $event) use ($envelope) { + static function (IsRetryableEvent $event) use ($envelope) { static::assertSame($envelope, $event->getEnvelope()); $event->setIsRetryable(false); return $event; } - ); + ) + ; static::assertFalse($this->object->isRetryable($envelope)); } @@ -101,12 +107,13 @@ public function testIsRetryableFallback(): void ->expects(static::once()) ->method('dispatch') ->willReturnCallback( - function (IsRetryableEvent $event) use ($envelope) { + static function (IsRetryableEvent $event) use ($envelope) { static::assertSame($envelope, $event->getEnvelope()); return $event; } - ); + ) + ; $this->mockProperty( $this->object, @@ -116,7 +123,8 @@ function (IsRetryableEvent $event) use ($envelope) { ->expects(static::once()) ->method('isRetryable') ->with($envelope) - ->willReturn(true); + ->willReturn(true) + ; static::assertTrue($this->object->isRetryable($envelope)); } @@ -129,12 +137,13 @@ public function testGetWaitingTimeDefault(): void ->expects(static::once()) ->method('dispatch') ->willReturnCallback( - function (GetWaitingTimeEvent $event) use ($envelope) { + static function (GetWaitingTimeEvent $event) use ($envelope) { static::assertSame($envelope, $event->getEnvelope()); return $event; } - ); + ) + ; static::assertSame( 1000, @@ -150,14 +159,15 @@ public function testGetWaitingTimeEvent(): void ->expects(static::once()) ->method('dispatch') ->willReturnCallback( - function (GetWaitingTimeEvent $event) use ($envelope) { + static function (GetWaitingTimeEvent $event) use ($envelope) { static::assertSame($envelope, $event->getEnvelope()); $event->setWaitingTime(2000); return $event; } - ); + ) + ; static::assertSame( 2000, @@ -173,12 +183,13 @@ public function testGetWaitingTimeFallback(): void ->expects(static::once()) ->method('dispatch') ->willReturnCallback( - function (GetWaitingTimeEvent $event) use ($envelope) { + static function (GetWaitingTimeEvent $event) use ($envelope) { static::assertSame($envelope, $event->getEnvelope()); return $event; } - ); + ) + ; $this->mockProperty( $this->object, @@ -188,7 +199,8 @@ function (GetWaitingTimeEvent $event) use ($envelope) { ->expects(static::once()) ->method('getWaitingTime') ->with($envelope) - ->willReturn(5000); + ->willReturn(5000) + ; static::assertSame( 5000, diff --git a/packages/messenger/Tests/Searchable/EnvelopeFinderTest.php b/packages/messenger/Tests/Searchable/EnvelopeFinderTest.php index dde99e2ee..4db5c70d2 100644 --- a/packages/messenger/Tests/Searchable/EnvelopeFinderTest.php +++ b/packages/messenger/Tests/Searchable/EnvelopeFinderTest.php @@ -14,6 +14,9 @@ use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Transport\Receiver\ListableReceiverInterface; +/** + * @internal + */ #[CoversClass(EnvelopeFinder::class)] class EnvelopeFinderTest extends TestCase { @@ -40,13 +43,15 @@ public function testFindByIdNotFound(): void $transport = $this->createMock(ListableReceiverInterface::class), $transport, ] - ); + ) + ; $transport ->expects(static::exactly(\count($transports))) ->method('find') ->with($messageId = uniqid('message-id')) - ->willReturn(null); + ->willReturn(null) + ; static::expectException(MessageNotFoundException::class); @@ -63,11 +68,13 @@ public function testFindByIdNotListableReceiver(): void $transport = $this->createMock(FindAwareTransportInterface::class), $transport, ] - ); + ) + ; $transport ->expects(static::never()) - ->method('find'); + ->method('find') + ; static::expectException(MessageNotFoundException::class); @@ -83,13 +90,15 @@ public function testFindById(): void [ ($transportName = uniqid('transport-')) => $transport = $this->createMock(ListableReceiverInterface::class), ] - ); + ) + ; $transport ->expects(static::once()) ->method('find') ->with($messageId = uniqid('message-id-')) - ->willReturn(new Envelope((object) [])); + ->willReturn(new Envelope((object) [])) + ; static::assertNotNull($envelope = $this->service->findById($messageId)); diff --git a/packages/messenger/Tests/Searchable/Stamp/FindFromTransportStampTest.php b/packages/messenger/Tests/Searchable/Stamp/FindFromTransportStampTest.php index ca8a8235d..85818d61b 100644 --- a/packages/messenger/Tests/Searchable/Stamp/FindFromTransportStampTest.php +++ b/packages/messenger/Tests/Searchable/Stamp/FindFromTransportStampTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Stamp\StampInterface; +/** + * @internal + */ #[CoversClass(FoundFromTransportStamp::class)] class FindFromTransportStampTest extends TestCase { diff --git a/packages/messenger/Tests/Searchable/Stamp/SearchableTagStampTest.php b/packages/messenger/Tests/Searchable/Stamp/SearchableTagStampTest.php index cb4a0deb5..268b9ae20 100644 --- a/packages/messenger/Tests/Searchable/Stamp/SearchableTagStampTest.php +++ b/packages/messenger/Tests/Searchable/Stamp/SearchableTagStampTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Stamp\StampInterface; +/** + * @internal + */ #[CoversClass(SearchableTagStamp::class)] class SearchableTagStampTest extends TestCase { diff --git a/packages/messenger/Tests/SerializerEventDispatcher/Event/BaseSerializerEventTest.php b/packages/messenger/Tests/SerializerEventDispatcher/Event/BaseSerializerEventTest.php index 489ec15fc..1a2aae4d3 100644 --- a/packages/messenger/Tests/SerializerEventDispatcher/Event/BaseSerializerEventTest.php +++ b/packages/messenger/Tests/SerializerEventDispatcher/Event/BaseSerializerEventTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Envelope; +/** + * @internal + */ class BaseSerializerEventTest extends TestCase { public static function provideTestConstruct(): iterable diff --git a/packages/messenger/Tests/SerializerEventDispatcher/Event/PreEncodeEventTest.php b/packages/messenger/Tests/SerializerEventDispatcher/Event/PreEncodeEventTest.php index 08c5dfd9c..4dfd3047f 100644 --- a/packages/messenger/Tests/SerializerEventDispatcher/Event/PreEncodeEventTest.php +++ b/packages/messenger/Tests/SerializerEventDispatcher/Event/PreEncodeEventTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Envelope; +/** + * @internal + */ class PreEncodeEventTest extends TestCase { private PreEncodeEvent $object; diff --git a/packages/messenger/Tests/SerializerEventDispatcher/EventDispatcherSerializerDecoratorTest.php b/packages/messenger/Tests/SerializerEventDispatcher/EventDispatcherSerializerDecoratorTest.php index 0e9186c46..e2b38a393 100644 --- a/packages/messenger/Tests/SerializerEventDispatcher/EventDispatcherSerializerDecoratorTest.php +++ b/packages/messenger/Tests/SerializerEventDispatcher/EventDispatcherSerializerDecoratorTest.php @@ -13,6 +13,9 @@ use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ class EventDispatcherSerializerDecoratorTest extends TestCase { use MockTrait; @@ -47,7 +50,8 @@ public function testDecode(): void ->expects(static::once()) ->method('decode') ->with($data) - ->willReturn($envelope = new Envelope((object) [])); + ->willReturn($envelope = new Envelope((object) [])) + ; $this->eventDispatcher ->expects(static::once()) @@ -55,7 +59,8 @@ public function testDecode(): void ->with( new PostDecodeEvent($envelope) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; static::assertSame( $envelope, @@ -76,13 +81,15 @@ public function testEncode(): void [new PostEncodeEvent($envelope)] ) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->serializer ->expects(static::once()) ->method('encode') ->with($envelope) - ->willReturn($data = ['body' => '', 'headers' => '']); + ->willReturn($data = ['body' => '', 'headers' => '']) + ; static::assertSame( $data, diff --git a/packages/messenger/Tests/TestCase.php b/packages/messenger/Tests/TestCase.php index d595a7c39..79949883d 100644 --- a/packages/messenger/Tests/TestCase.php +++ b/packages/messenger/Tests/TestCase.php @@ -7,6 +7,9 @@ use Doctrine\Persistence\ConnectionRegistry; use PHPUnit\Framework\TestCase as BaseTestCase; +/** + * @internal + */ class TestCase extends BaseTestCase implements ConnectionRegistry { private static ?Connection $connection = null; diff --git a/packages/messenger/Tests/Transport/DrawTransportFactoryTest.php b/packages/messenger/Tests/Transport/DrawTransportFactoryTest.php index c5386166f..24d59a25f 100644 --- a/packages/messenger/Tests/Transport/DrawTransportFactoryTest.php +++ b/packages/messenger/Tests/Transport/DrawTransportFactoryTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Messenger\Exception\TransportException; use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer; +/** + * @internal + */ #[CoversClass(DrawTransportFactory::class)] class DrawTransportFactoryTest extends TestCase { diff --git a/packages/messenger/Tests/Transport/DrawTransportTest.php b/packages/messenger/Tests/Transport/DrawTransportTest.php index 4261d17ba..c7d06e013 100644 --- a/packages/messenger/Tests/Transport/DrawTransportTest.php +++ b/packages/messenger/Tests/Transport/DrawTransportTest.php @@ -28,6 +28,9 @@ use Symfony\Component\Messenger\Transport\SetupableTransportInterface; use Symfony\Component\Messenger\Transport\TransportInterface; +/** + * @internal + */ #[CoversClass(DrawTransport::class)] #[NoTransaction] class DrawTransportTest extends TestCase @@ -44,7 +47,8 @@ public static function cleanUp(): void { try { static::loadDefaultConnection() - ->executeStatement('DELETE FROM draw_messenger__message'); + ->executeStatement('DELETE FROM draw_messenger__message') + ; } catch (\Throwable) { // Table may not exist we ignore it } @@ -95,7 +99,8 @@ public function testConstruct(): void public function testSetup(): void { static::loadDefaultConnection() - ->executeStatement('DROP TABLE IF EXISTS draw_messenger__message_tag, draw_messenger__message'); + ->executeStatement('DROP TABLE IF EXISTS draw_messenger__message_tag, draw_messenger__message') + ; $this->service->setup(); static::assertTrue(true); @@ -112,7 +117,8 @@ public function testSendException(): void $driverConnection->expects(static::once()) ->method('createQueryBuilder') - ->willThrowException(new \Exception($exceptionMessage = uniqid('exception-message-'))); + ->willThrowException(new \Exception($exceptionMessage = uniqid('exception-message-'))) + ; $this->expectException(TransportException::class); $this->expectExceptionMessage($exceptionMessage); @@ -138,7 +144,8 @@ public function testSendNegativeDelay(): void [ $id, ] - )->fetchAllAssociative(); + )->fetchAllAssociative() + ; static::assertEqualsWithDelta( strtotime('now - 10 seconds'), @@ -198,7 +205,8 @@ public function testFindByTagsNoTags(): void ); $driverConnection->expects(static::never()) - ->method('createQueryBuilder'); + ->method('createQueryBuilder') + ; static::assertEmpty($this->service->findByTags([])); } diff --git a/packages/messenger/Transport/DrawTransport.php b/packages/messenger/Transport/DrawTransport.php index 93898903a..cc0413da8 100644 --- a/packages/messenger/Transport/DrawTransport.php +++ b/packages/messenger/Transport/DrawTransport.php @@ -38,7 +38,8 @@ public function send(Envelope $envelope): Envelope { $envelope = $envelope ->withoutAll(TransportMessageIdStamp::class) - ->withoutAll(DoctrineReceivedStamp::class); + ->withoutAll(DoctrineReceivedStamp::class) + ; $encodedMessage = $this->serializer->encode($envelope); @@ -68,8 +69,6 @@ public function send(Envelope $envelope): Envelope /** * Override because doctrine transport do not filter by delivered_at date. - * - * @param mixed $id */ public function find($id): ?Envelope { @@ -111,7 +110,8 @@ private function cleanQueue(Envelope $envelope): void $sql = $this->driverConnection->createQueryBuilder() ->delete($this->connection->getConfiguration()['table_name']) ->andWhere('id IN ("'.implode('","', $ids).'")') - ->getSQL(); + ->getSQL() + ; $this->driverConnection->executeStatement($sql); } @@ -154,7 +154,8 @@ private function insert( 'created_at' => '?', 'available_at' => '?', 'expires_at' => '?', - ]); + ]) + ; $this->driverConnection ->prepare($queryBuilder->getSQL()) ->executeStatement([ @@ -166,14 +167,17 @@ private function insert( self::formatDateTime($now), self::formatDateTime($availableAt), self::formatDateTime($expiresAt), - ]); + ]) + ; if ($tags) { $queryBuilder = $this->driverConnection->createQueryBuilder() ->insert($this->connection->getConfiguration()['tag_table_name']) - ->values(['message_id' => '?', 'name' => '?']); + ->values(['message_id' => '?', 'name' => '?']) + ; $statement = $this->driverConnection - ->prepare($queryBuilder->getSQL()); + ->prepare($queryBuilder->getSQL()) + ; foreach ($tags as $tag) { $statement->executeStatement([$id, $tag]); } @@ -247,7 +251,8 @@ private function findEnvelopeIds(array $tags): array $queryBuilder->expr()->neq('message.delivered_at', '?'), $queryBuilder->expr()->isNull('message.delivered_at') ) - ); + ) + ; foreach ($tags as $index => $tag) { $tagAlias = 'tag_'.$index; @@ -258,7 +263,8 @@ private function findEnvelopeIds(array $tags): array $tagAlias, 'message.id = '.$tagAlias.'.message_id' ) - ->andWhere($tagAlias.'.name = ?'); + ->andWhere($tagAlias.'.name = ?') + ; } $rows = $this->driverConnection->executeQuery( @@ -298,31 +304,40 @@ private function getSchema(): Schema $messageTable = $schema->createTable($messagesTableName); $messageTable ->addColumn('id', Types::GUID) - ->setNotnull(true); + ->setNotnull(true) + ; $messageTable ->addColumn('message_class', Types::STRING) - ->setNotnull(false); + ->setNotnull(false) + ; $messageTable ->addColumn('body', Types::TEXT) - ->setNotnull(true); + ->setNotnull(true) + ; $messageTable ->addColumn('headers', Types::TEXT) - ->setNotnull(true); + ->setNotnull(true) + ; $messageTable ->addColumn('queue_name', Types::STRING) - ->setNotnull(true); + ->setNotnull(true) + ; $messageTable ->addColumn('created_at', Types::DATETIME_IMMUTABLE) - ->setNotnull(true); + ->setNotnull(true) + ; $messageTable ->addColumn('available_at', Types::DATETIME_IMMUTABLE) - ->setNotnull(false); + ->setNotnull(false) + ; $messageTable ->addColumn('delivered_at', Types::DATETIME_IMMUTABLE) - ->setNotnull(false); + ->setNotnull(false) + ; $messageTable ->addColumn('expires_at', Types::DATETIME_IMMUTABLE) - ->setNotnull(false); + ->setNotnull(false) + ; $messageTable->setPrimaryKey(['id']); $messageTable->addIndex(['message_class', 'available_at']); $messageTable->addIndex(['queue_name', 'available_at']); @@ -334,10 +349,12 @@ private function getSchema(): Schema $tagTable ->addColumn('message_id', Types::GUID) - ->setNotnull(true); + ->setNotnull(true) + ; $tagTable ->addColumn('name', Types::STRING) - ->setNotnull(true); + ->setNotnull(true) + ; $tagTable->setPrimaryKey(['message_id', 'name']); $tagTable->addIndex(['name']); $tagTable->addForeignKeyConstraint($messagesTableName, ['message_id'], ['id'], ['onDelete' => 'CASCADE']); diff --git a/packages/messenger/Transport/DrawTransportFactory.php b/packages/messenger/Transport/DrawTransportFactory.php index d4ab248f4..db0d42e26 100644 --- a/packages/messenger/Transport/DrawTransportFactory.php +++ b/packages/messenger/Transport/DrawTransportFactory.php @@ -40,11 +40,7 @@ public function createTransport(string $dsn, array $options, SerializerInterface /** @var \Doctrine\DBAL\Connection $driverConnection */ $driverConnection = $this->registry->getConnection($configuration['connection']); } catch (\InvalidArgumentException $error) { - throw new TransportException( - \sprintf('Could not find Doctrine connection from Messenger DSN "%s".', $dsn), - 0, - $error - ); + throw new TransportException(\sprintf('Could not find Doctrine connection from Messenger DSN "%s".', $dsn), 0, $error); } $connection = new Connection($configuration, $driverConnection); @@ -81,21 +77,13 @@ public static function buildConfiguration(string $dsn, array $options = []): arr // check for extra keys in options $optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS)); if (0 < \count($optionsExtraKeys)) { - throw new InvalidArgumentException(\sprintf( - 'Unknown option found : [%s]. Allowed options are [%s]', - implode(', ', $optionsExtraKeys), - implode(', ', array_keys(self::DEFAULT_OPTIONS)) - )); + throw new InvalidArgumentException(\sprintf('Unknown option found : [%s]. Allowed options are [%s]', implode(', ', $optionsExtraKeys), implode(', ', array_keys(self::DEFAULT_OPTIONS)))); } // check for extra keys in options $queryExtraKeys = array_diff(array_keys($query), array_keys(self::DEFAULT_OPTIONS)); if (0 < \count($queryExtraKeys)) { - throw new InvalidArgumentException(\sprintf( - 'Unknown option found in DSN: [%s]. Allowed options are [%s]', - implode(', ', $queryExtraKeys), - implode(', ', array_keys(self::DEFAULT_OPTIONS)) - )); + throw new InvalidArgumentException(\sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s]', implode(', ', $queryExtraKeys), implode(', ', array_keys(self::DEFAULT_OPTIONS)))); } return $configuration; diff --git a/packages/open-api/Command/InstallSandboxCommand.php b/packages/open-api/Command/InstallSandboxCommand.php index af2740837..b905e59c8 100644 --- a/packages/open-api/Command/InstallSandboxCommand.php +++ b/packages/open-api/Command/InstallSandboxCommand.php @@ -25,7 +25,8 @@ protected function configure(): void ->setName('draw:open-api:install-sandbox') ->addArgument('path', InputArgument::REQUIRED, 'Path were to extract the zip') ->setDescription('Install Open Api Sandbox from downloaded zip base on tag version.') - ->addOption('tag', null, InputOption::VALUE_REQUIRED, 'Swagger UI tag to install (eg. "v3.52.5")', 'master'); + ->addOption('tag', null, InputOption::VALUE_REQUIRED, 'Swagger UI tag to install (eg. "v3.52.5")', 'master') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/packages/open-api/Controller/OpenApiController.php b/packages/open-api/Controller/OpenApiController.php index 3e0d85fed..e0b9d8b56 100644 --- a/packages/open-api/Controller/OpenApiController.php +++ b/packages/open-api/Controller/OpenApiController.php @@ -25,7 +25,7 @@ public function apiDocAction(Request $request, ?string $version = null): Respons { $scope = $request->query->get('scope'); - if ('json' != $request->getRequestFormat()) { + if ('json' !== $request->getRequestFormat()) { $parameters = ['_format' => 'json']; if ($version) { $parameters['version'] = $version; @@ -41,7 +41,8 @@ public function apiDocAction(Request $request, ?string $version = null): Respons $currentRoute, $parameters, UrlGeneratorInterface::ABSOLUTE_URL - ); + ) + ; return new RedirectResponse($this->sandboxUrl.'/index.html?url='.urlencode($currentUrl)); } diff --git a/packages/open-api/DependencyInjection/OpenApiIntegration.php b/packages/open-api/DependencyInjection/OpenApiIntegration.php index f48a91d1e..7ff7c2658 100644 --- a/packages/open-api/DependencyInjection/OpenApiIntegration.php +++ b/packages/open-api/DependencyInjection/OpenApiIntegration.php @@ -77,14 +77,16 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->append($this->createOpenApiNode()) ->append($this->createRequestNode()) ->append($this->createResponseNode()) - ->end(); + ->end() + ; } public function load(array $config, PhpFileLoader $loader, ContainerBuilder $container): void { $container ->registerForAutoconfiguration(ReferenceCleanerInterface::class) - ->addTag('draw.open_api.reference_cleaner'); + ->addTag('draw.open_api.reference_cleaner') + ; $this->configOpenApi($config['openApi'], $loader, $container); $this->configResponse($config['response'], $loader, $container); @@ -110,19 +112,19 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $this->renameDefinitions( $container, - 'Draw\\Component\\OpenApi\\Extraction\\Extractor\\', + 'Draw\Component\OpenApi\Extraction\Extractor\\', 'draw.open_api.extractor.' ); $this->renameDefinitions( $container, - 'Draw\\Component\\OpenApi\\Serializer\\', + 'Draw\Component\OpenApi\Serializer\\', 'draw.open_api.jms_serializer.' ); $this->renameDefinitions( $container, - 'Draw\\Component\\OpenApi\\', + 'Draw\Component\OpenApi\\', 'draw.open_api.' ); } @@ -147,11 +149,13 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu $container ->registerForAutoconfiguration(ExtractorInterface::class) - ->addTag(ExtractorInterface::class); + ->addTag(ExtractorInterface::class) + ; $container ->registerForAutoconfiguration(TypeToSchemaHandlerInterface::class) - ->addTag(TypeToSchemaHandlerInterface::class); + ->addTag(TypeToSchemaHandlerInterface::class) + ; $directory = \dirname((new \ReflectionClass(OpenApi::class))->getFileName()); @@ -168,14 +172,14 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu $this->registerClasses( $loader, - 'Draw\\Component\\OpenApi\\', + 'Draw\Component\OpenApi\\', $directory, $exclude, ); $this->registerClasses( $loader, - 'Draw\\Component\\OpenApi\\Controller\\', + 'Draw\Component\OpenApi\Controller\\', $directory.'/Controller', prototype: (new Definition()) ->setAutowired(true) @@ -185,19 +189,23 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu $container ->getDefinition(TagCleanerListener::class) - ->setArgument('$tagsToClean', $config['tags_to_clean']); + ->setArgument('$tagsToClean', $config['tags_to_clean']) + ; $container ->getDefinition(UnReferenceCleanerListener::class) - ->setArgument('$referenceCleaners', new TaggedIteratorArgument('draw.open_api.reference_cleaner')); + ->setArgument('$referenceCleaners', new TaggedIteratorArgument('draw.open_api.reference_cleaner')) + ; if ($this->isConfigEnabled($container, $config['versioning'])) { $container ->getDefinition(VersionLinkDocumentationExtractor::class) - ->setArgument('$versions', $config['versioning']['versions']); + ->setArgument('$versions', $config['versioning']['versions']) + ; $container - ->setAlias(RouteVersionMatcherInterface::class, RouteDefaultApiRouteVersionMatcher::class); + ->setAlias(RouteVersionMatcherInterface::class, RouteDefaultApiRouteVersionMatcher::class) + ; } else { $container->removeDefinition(VersionLinkDocumentationExtractor::class); $container->removeDefinition(RouteDefaultApiRouteVersionMatcher::class); @@ -208,12 +216,14 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu foreach ($config['scoped']['scopes'] as $scope) { $scopes[] = (new Definition(Scope::class)) ->setArgument('$name', $scope['name']) - ->setArgument('$tags', $scope['tags'] ?: null); + ->setArgument('$tags', $scope['tags'] ?: null) + ; } $container ->getDefinition(OpenApi::class) - ->setArgument('$scopes', $scopes); + ->setArgument('$scopes', $scopes) + ; } if (!class_exists(DoctrineBundle::class)) { @@ -226,14 +236,16 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu new Definition(SymfonySchemaBuilder::class) ) ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; $container ->addAliases( [ SchemaBuilderInterface::class => SymfonySchemaBuilder::class, ] - ); + ) + ; if ($config['caching_enabled']) { $arguments = [ @@ -243,31 +255,37 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu $container ->getDefinition(LoadFromCacheExtractor::class) - ->setArguments($arguments); + ->setArguments($arguments) + ; $container ->getDefinition(StoreInCacheExtractor::class) - ->setArguments($arguments); + ->setArguments($arguments) + ; } $container ->getDefinition(OpenApi::class) - ->setArgument('$extractors', new TaggedIteratorArgument(ExtractorInterface::class)); + ->setArgument('$extractors', new TaggedIteratorArgument(ExtractorInterface::class)) + ; $container ->getDefinition(OpenApiController::class) - ->setArgument('$sandboxUrl', $config['sandbox_url']); + ->setArgument('$sandboxUrl', $config['sandbox_url']) + ; $container ->getDefinition(PropertiesExtractor::class) - ->setArgument('$typeToSchemaHandlers', new TaggedIteratorArgument(TypeToSchemaHandlerInterface::class)); + ->setArgument('$typeToSchemaHandlers', new TaggedIteratorArgument(TypeToSchemaHandlerInterface::class)) + ; if (!$config['headers']) { $container->removeDefinition(SchemaAddDefaultHeadersListener::class); } else { $container ->getDefinition(SchemaAddDefaultHeadersListener::class) - ->setArgument('$headers', $config['headers']); + ->setArgument('$headers', $config['headers']) + ; } if (!$config['sort_schema']) { @@ -280,7 +298,8 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu $config['classNamingFilters'][] = AliasesClassNamingFilter::class; $container ->getDefinition(AliasesClassNamingFilter::class) - ->setArgument('$definitionAliases', $config['definitionAliases']); + ->setArgument('$definitionAliases', $config['definitionAliases']) + ; } $container @@ -288,7 +307,8 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu ->setArgument( '$fallbackConstructor', new Reference('jms_serializer.unserialize_object_constructor') - ); + ) + ; $namingFilterServices = []; foreach (array_unique($config['classNamingFilters']) as $serviceName) { @@ -297,7 +317,8 @@ private function configOpenApi(array $config, PhpFileLoader $loader, ContainerBu $container ->getDefinition(TypeSchemaExtractor::class) - ->setArgument('$classNamingFilters', $namingFilterServices); + ->setArgument('$classNamingFilters', $namingFilterServices) + ; $container->setAlias( 'jms_serializer.object_constructor', @@ -320,11 +341,12 @@ private function configResponse(array $config, PhpFileLoader $loader, ContainerB $definition = (new Definition()) ->setAutoconfigured(true) - ->setAutowired(true); + ->setAutowired(true) + ; $loader->registerClasses( $definition, - 'Draw\\Component\\OpenApi\\EventListener\\', + 'Draw\Component\OpenApi\EventListener\\', $openApiComponentDir.'/EventListener/{Response}*', ); @@ -332,7 +354,8 @@ private function configResponse(array $config, PhpFileLoader $loader, ContainerB $container ->getDefinition(ResponseSerializerListener::class) - ->setArgument('$serializeNull', new Parameter('draw_open_api.response.serialize_null')); + ->setArgument('$serializeNull', new Parameter('draw_open_api.response.serialize_null')) + ; $this->configResponseExceptionHandler($config['exceptionHandler'], $loader, $container); } @@ -367,13 +390,15 @@ private function configResponseExceptionHandler(array $config, PhpFileLoader $lo ->setArgument( '$violationKey', $config['violationKey'] - ); + ) + ; $container->getDefinition(ConfigurableErrorToHttpCodeConverter::class) ->setArgument( '$errorCodes', $codes - ); + ) + ; $operationExtractorDefinition = $container->getDefinition(OperationExtractor::class); @@ -382,7 +407,8 @@ private function configResponseExceptionHandler(array $config, PhpFileLoader $lo ->addMethodCall( 'registerExceptionResponseCodes', [$exceptionClass, $code] - ); + ) + ; } } @@ -396,17 +422,18 @@ private function configRequest(array $config, PhpFileLoader $loader, ContainerBu $definition = (new Definition()) ->setAutoconfigured(true) - ->setAutowired(true); + ->setAutowired(true) + ; $loader->registerClasses( $definition, - 'Draw\\Component\\OpenApi\\EventListener\\', + 'Draw\Component\OpenApi\EventListener\\', $openApiComponentDir.'/EventListener/{Request}*', ); $loader->registerClasses( $definition, - 'Draw\\Component\\OpenApi\\Request\\', + 'Draw\Component\OpenApi\Request\\', $openApiComponentDir.'/Request', ); @@ -418,7 +445,8 @@ private function configRequest(array $config, PhpFileLoader $loader, ContainerBu '$prefixes', $config['validation']['pathPrefixes'] ?? ['query' => '$.query', 'body' => '$.body'] - ); + ) + ; if (!$config['queryParameter']['enabled']) { $container->removeDefinition(RequestQueryParameterFetcherListener::class); @@ -447,7 +475,8 @@ private function createOpenApiNode(): ArrayNodeDefinition ->append($this->createHeadersNode()) ->append($this->createDefinitionAliasesNode()) ->append($this->createNamingFiltersNode()) - ->end(); + ->end() + ; } private function createVersioningNode(): ArrayNodeDefinition @@ -459,7 +488,8 @@ private function createVersioningNode(): ArrayNodeDefinition ->defaultValue([]) ->scalarPrototype()->end() ->end() - ->end(); + ->end() + ; } private function createScopedNode(): ArrayNodeDefinition @@ -470,7 +500,7 @@ private function createScopedNode(): ArrayNodeDefinition ->arrayNode('scopes') ->requiresAtLeastOneElement() ->beforeNormalization() - ->always(function ($config) { + ->always(static function ($config) { foreach ($config as $name => $configuration) { if (!isset($configuration['name'])) { $config[$name]['name'] = $name; @@ -485,7 +515,7 @@ private function createScopedNode(): ArrayNodeDefinition ->children() ->scalarNode('name') ->validate() - ->ifTrue(fn ($value) => \is_int($value)) + ->ifTrue(static fn ($value) => \is_int($value)) ->thenInvalid('You must specify a name for the scope. Can be via the attribute or the key.') ->end() ->isRequired() @@ -496,7 +526,8 @@ private function createScopedNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createRequestNode(): ArrayNodeDefinition @@ -523,7 +554,8 @@ private function createRequestNode(): ArrayNodeDefinition ->arrayNode('userRequestInterceptedException') ->canBeEnabled() ->end() - ->end(); + ->end() + ; } private function createResponseNode(): ArrayNodeDefinition @@ -547,7 +579,8 @@ private function createResponseNode(): ArrayNodeDefinition ->scalarNode('violationKey')->defaultValue('errors')->end() ->end() ->end() - ->end(); + ->end() + ; } private function createDefinitionAliasesNode(): ArrayNodeDefinition @@ -559,7 +592,8 @@ private function createDefinitionAliasesNode(): ArrayNodeDefinition ->scalarNode('class')->isRequired()->end() ->scalarNode('alias')->isRequired()->end() ->end() - ->end(); + ->end() + ; } private function createNamingFiltersNode(): ArrayNodeDefinition @@ -567,7 +601,8 @@ private function createNamingFiltersNode(): ArrayNodeDefinition return (new ArrayNodeDefinition('classNamingFilters')) ->defaultValue([AliasesClassNamingFilter::class]) ->scalarPrototype() - ->end(); + ->end() + ; } private function createSchemaNode(): ArrayNodeDefinition @@ -587,7 +622,8 @@ private function createSchemaNode(): ArrayNodeDefinition ->end() ->end() ->scalarNode('basePath')->end() - ->end(); + ->end() + ; } private function createHeadersNode(): ArrayNodeDefinition @@ -596,6 +632,7 @@ private function createHeadersNode(): ArrayNodeDefinition ->arrayPrototype() ->normalizeKeys(false) ->ignoreExtraKeys(false) - ->end(); + ->end() + ; } } diff --git a/packages/open-api/EventListener/DefinitionAliasCleanerListener.php b/packages/open-api/EventListener/DefinitionAliasCleanerListener.php index 56489b315..2cf499bda 100644 --- a/packages/open-api/EventListener/DefinitionAliasCleanerListener.php +++ b/packages/open-api/EventListener/DefinitionAliasCleanerListener.php @@ -41,7 +41,7 @@ private function clean(Root $rootSchema): Root function ($name, $index) use ($objectName, $rootSchema): void { $replaceWith = $objectName.($index ? '?'.$index : ''); // If the replacement name is the same as the current index we do not do anything - if ($replaceWith == $name) { + if ($replaceWith === $name) { return; } $rootSchema->definitions[$replaceWith] = $rootSchema->definitions[$name]; diff --git a/packages/open-api/EventListener/RequestQueryParameterFetcherListener.php b/packages/open-api/EventListener/RequestQueryParameterFetcherListener.php index 6be73c0a3..f8ea9d7b8 100644 --- a/packages/open-api/EventListener/RequestQueryParameterFetcherListener.php +++ b/packages/open-api/EventListener/RequestQueryParameterFetcherListener.php @@ -43,11 +43,7 @@ public function onKernelController(ControllerEvent $event): void $name = $queryParameter->name; if ($request->attributes->has($name) && null !== $request->attributes->get($name)) { - throw new \InvalidArgumentException(\sprintf( - 'QueryParameterFetcherSubscriber parameter conflicts with a path parameter [%s] for route [%s]', - $name, - $request->attributes->get('_route') - )); + throw new \InvalidArgumentException(\sprintf('QueryParameterFetcherSubscriber parameter conflicts with a path parameter [%s] for route [%s]', $name, $request->attributes->get('_route'))); } if ($request->query->has($name)) { @@ -72,10 +68,7 @@ public function onKernelController(ControllerEvent $event): void 'tsv' => "\t", 'pipes' => '|', // no break - default => throw new \RuntimeException(\sprintf( - 'Unsupported collection format [%s]', - $queryParameter->collectionFormat - )), + default => throw new \RuntimeException(\sprintf('Unsupported collection format [%s]', $queryParameter->collectionFormat)), }; $value = explode($separator, (string) $request->query->get($name)); break; diff --git a/packages/open-api/EventListener/ResponseApiExceptionListener.php b/packages/open-api/EventListener/ResponseApiExceptionListener.php index 8e4636b13..08971aaf6 100644 --- a/packages/open-api/EventListener/ResponseApiExceptionListener.php +++ b/packages/open-api/EventListener/ResponseApiExceptionListener.php @@ -118,7 +118,7 @@ private function getConstraintViolationData(ConstraintViolationListException $ex { $errors = []; foreach ($exception->getViolationList() as $constraintViolation) { - /* @var $constraintViolation ConstraintViolationInterface */ + /** @var ConstraintViolationInterface $constraintViolation */ $errorData = [ 'propertyPath' => $constraintViolation->getPropertyPath(), 'message' => $constraintViolation->getMessage(), diff --git a/packages/open-api/EventListener/SchemaCleanRequiredReadOnlyListener.php b/packages/open-api/EventListener/SchemaCleanRequiredReadOnlyListener.php index 332314b69..898407b95 100644 --- a/packages/open-api/EventListener/SchemaCleanRequiredReadOnlyListener.php +++ b/packages/open-api/EventListener/SchemaCleanRequiredReadOnlyListener.php @@ -31,7 +31,7 @@ public function cleanReadOnly(PreDumpRootSchemaEvent $event): void $definition->required = array_values( array_filter( $definition->required, - fn ($requiredPropertyName) => $requiredPropertyName !== $propertyNane + static fn ($requiredPropertyName) => $requiredPropertyName !== $propertyNane ) ); } diff --git a/packages/open-api/EventListener/SchemaSorterListener.php b/packages/open-api/EventListener/SchemaSorterListener.php index 417aed733..2d0fec12d 100644 --- a/packages/open-api/EventListener/SchemaSorterListener.php +++ b/packages/open-api/EventListener/SchemaSorterListener.php @@ -25,7 +25,7 @@ public function sortSchema(PreDumpRootSchemaEvent $event): void foreach ($root->paths as $path) { foreach ($path->getOperations() as $operation) { ksort($operation->responses); - usort($operation->parameters, fn (BaseParameter $a, BaseParameter $b) => $a->compareTo($b)); + usort($operation->parameters, static fn (BaseParameter $a, BaseParameter $b) => $a->compareTo($b)); } } } diff --git a/packages/open-api/EventListener/TagCleanerListener.php b/packages/open-api/EventListener/TagCleanerListener.php index 4138181dc..9fb5a2a0e 100644 --- a/packages/open-api/EventListener/TagCleanerListener.php +++ b/packages/open-api/EventListener/TagCleanerListener.php @@ -29,7 +29,7 @@ public function onClean(CleanEvent $event): void foreach ($schema->paths as $path) { foreach ($path->getOperations() as $operation) { foreach ($operation->tags ?? [] as $index => $tag) { - if (\in_array($tag, $this->tagsToClean)) { + if (\in_array($tag, $this->tagsToClean, true)) { unset($operation->tags[$index]); } } diff --git a/packages/open-api/Extraction/ExtractionContext.php b/packages/open-api/Extraction/ExtractionContext.php index 384881011..e9b3c5df8 100644 --- a/packages/open-api/Extraction/ExtractionContext.php +++ b/packages/open-api/Extraction/ExtractionContext.php @@ -44,9 +44,6 @@ public function getParameters(): array return $this->parameters; } - /** - * @param mixed $value - */ public function setParameter(string $name, $value): void { $this->parameters[$name] = $value; diff --git a/packages/open-api/Extraction/Extractor/Caching/FileTrackingExtractor.php b/packages/open-api/Extraction/Extractor/Caching/FileTrackingExtractor.php index ba9a58e1c..73164496f 100644 --- a/packages/open-api/Extraction/Extractor/Caching/FileTrackingExtractor.php +++ b/packages/open-api/Extraction/Extractor/Caching/FileTrackingExtractor.php @@ -20,7 +20,6 @@ public function canExtract($source, $target, ExtractionContextInterface $extract /** * @param \ReflectionMethod|\ReflectionClass $source - * @param mixed $target */ public function extract($source, $target, ExtractionContextInterface $extractionContext): void { diff --git a/packages/open-api/Extraction/Extractor/Caching/LoadFromCacheExtractor.php b/packages/open-api/Extraction/Extractor/Caching/LoadFromCacheExtractor.php index 13c9eb76c..95c4aa652 100644 --- a/packages/open-api/Extraction/Extractor/Caching/LoadFromCacheExtractor.php +++ b/packages/open-api/Extraction/Extractor/Caching/LoadFromCacheExtractor.php @@ -30,8 +30,7 @@ public function canExtract($source, $target, ExtractionContextInterface $extract } /** - * @param Root $target - * @param mixed $source + * @param Root $target */ public function extract($source, $target, ExtractionContextInterface $extractionContext): void { diff --git a/packages/open-api/Extraction/Extractor/Caching/StoreInCacheExtractor.php b/packages/open-api/Extraction/Extractor/Caching/StoreInCacheExtractor.php index 548bad438..db863a131 100644 --- a/packages/open-api/Extraction/Extractor/Caching/StoreInCacheExtractor.php +++ b/packages/open-api/Extraction/Extractor/Caching/StoreInCacheExtractor.php @@ -33,8 +33,7 @@ public function canExtract($source, $target, ExtractionContextInterface $extract } /** - * @param Root $target - * @param mixed $source + * @param Root $target */ public function extract($source, $target, ExtractionContextInterface $extractionContext): void { diff --git a/packages/open-api/Extraction/Extractor/Constraint/BaseConstraintExtractor.php b/packages/open-api/Extraction/Extractor/Constraint/BaseConstraintExtractor.php index 450f5f3a0..73d48fd22 100644 --- a/packages/open-api/Extraction/Extractor/Constraint/BaseConstraintExtractor.php +++ b/packages/open-api/Extraction/Extractor/Constraint/BaseConstraintExtractor.php @@ -28,11 +28,7 @@ abstract public function extractConstraint(Constraint $constraint, ConstraintExt protected function assertSupportConstraint(Constraint $constraint): void { if (!$this->supportConstraint($constraint)) { - throw new \InvalidArgumentException(\sprintf( - 'The constraint of type [%s] is not supported by [%s]', - $constraint::class, - static::class - )); + throw new \InvalidArgumentException(\sprintf('The constraint of type [%s] is not supported by [%s]', $constraint::class, static::class)); } } @@ -87,10 +83,7 @@ private function getPropertiesConstraints( $classMetadata = $this->validator->getMetadataFor($class); if (!$classMetadata instanceof ClassMetadataInterface) { - throw new \LogicException(\sprintf( - 'Validator::getMetadataFor expect class return to be of type [%s]', - ClassMetadataInterface::class - )); + throw new \LogicException(\sprintf('Validator::getMetadataFor expect class return to be of type [%s]', ClassMetadataInterface::class)); } foreach ($classMetadata->getConstrainedProperties() as $propertyName) { @@ -101,8 +94,6 @@ private function getPropertiesConstraints( $constraints[$propertyName] = []; foreach ($classMetadata->getPropertyMetadata($propertyName) as $propertyMetadata) { - /* @var $propertyMetadata */ - $propertyConstraints = []; foreach ($groups as $group) { $propertyConstraints = array_merge( @@ -114,7 +105,7 @@ private function getPropertiesConstraints( $finalPropertyConstraints = []; foreach ($propertyConstraints as $current) { - if (!\in_array($current, $finalPropertyConstraints)) { + if (!\in_array($current, $finalPropertyConstraints, true)) { $finalPropertyConstraints[] = $current; } } diff --git a/packages/open-api/Extraction/Extractor/Constraint/NotBlankConstraintExtractor.php b/packages/open-api/Extraction/Extractor/Constraint/NotBlankConstraintExtractor.php index ca061cf8e..81f2c81d5 100644 --- a/packages/open-api/Extraction/Extractor/Constraint/NotBlankConstraintExtractor.php +++ b/packages/open-api/Extraction/Extractor/Constraint/NotBlankConstraintExtractor.php @@ -34,7 +34,7 @@ public function extractConstraint(Constraint $constraint, ConstraintExtractionCo return; } - if (!$context->classSchema->required || !\in_array($context->propertyName, $context->classSchema->required)) { + if (!$context->classSchema->required || !\in_array($context->propertyName, $context->classSchema->required, true)) { $context->classSchema->required[] = $context->propertyName; } } diff --git a/packages/open-api/Extraction/Extractor/Constraint/NotNullConstraintExtractor.php b/packages/open-api/Extraction/Extractor/Constraint/NotNullConstraintExtractor.php index 6dd927fc5..a3d0d11e2 100644 --- a/packages/open-api/Extraction/Extractor/Constraint/NotNullConstraintExtractor.php +++ b/packages/open-api/Extraction/Extractor/Constraint/NotNullConstraintExtractor.php @@ -26,7 +26,7 @@ public function extractConstraint(Constraint $constraint, ConstraintExtractionCo return; } - if (!$context->classSchema->required || !\in_array($context->propertyName, $context->classSchema->required)) { + if (!$context->classSchema->required || !\in_array($context->propertyName, $context->classSchema->required, true)) { $context->classSchema->required[] = $context->propertyName; } } diff --git a/packages/open-api/Extraction/Extractor/JmsSerializer/PropertiesExtractor.php b/packages/open-api/Extraction/Extractor/JmsSerializer/PropertiesExtractor.php index d00912501..3aa149c5e 100644 --- a/packages/open-api/Extraction/Extractor/JmsSerializer/PropertiesExtractor.php +++ b/packages/open-api/Extraction/Extractor/JmsSerializer/PropertiesExtractor.php @@ -108,7 +108,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction foreach ($meta->propertyMetadata as $propertyMetadata) { // This is to prevent property of discriminator field name to not being complete if (isset($meta->discriminatorFieldName) - && $propertyMetadata->name == $meta->discriminatorFieldName + && $propertyMetadata->name === $meta->discriminatorFieldName && !isset($propertyMetadata->type['name']) ) { $propertyMetadata->type = ['name' => 'string', 'params' => []]; diff --git a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/ArrayHandler.php b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/ArrayHandler.php index 1e84bdcb4..dfcee29b7 100644 --- a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/ArrayHandler.php +++ b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/ArrayHandler.php @@ -28,13 +28,13 @@ private function getNestedTypeInArray(PropertyMetadata $item): ?string { switch (true) { case !isset($item->type['name']): - case !\in_array($item->type['name'], ['array', 'ArrayCollection']): + case !\in_array($item->type['name'], ['array', 'ArrayCollection'], true): case !isset($item->type['params'][0]['name']): return null; } if (isset($item->type['params'][1]['name']) - && !\in_array($item->type['params'][0]['name'], ['int', 'integer']) + && !\in_array($item->type['params'][0]['name'], ['int', 'integer'], true) ) { return null; } diff --git a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DoctrineObjectReferenceSchemaHandler.php b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DoctrineObjectReferenceSchemaHandler.php index 7ccf757b3..739ee7266 100644 --- a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DoctrineObjectReferenceSchemaHandler.php +++ b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DoctrineObjectReferenceSchemaHandler.php @@ -36,7 +36,7 @@ private function getReferenceType(PropertyMetadata $item): ?array { switch (true) { case !isset($item->type['name']): - case 'ObjectReference' != $item->type['name']: + case 'ObjectReference' !== $item->type['name']: case !isset($item->type['params'][0]['name']): return null; } @@ -45,7 +45,8 @@ private function getReferenceType(PropertyMetadata $item): ?array $metadataFor = $this->managerRegistry->getManagerForClass($class) ->getMetadataFactory() - ->getMetadataFor($class); + ->getMetadataFor($class) + ; return $this->getTypeFromJsmFactory( $class, diff --git a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DynamicObjectHandler.php b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DynamicObjectHandler.php index 93b37caf4..6081eea5d 100644 --- a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DynamicObjectHandler.php +++ b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/DynamicObjectHandler.php @@ -27,7 +27,7 @@ public function extractSchemaFromType( private function getDynamicObjectType(PropertyMetadata $item): ?string { return match (true) { - !isset($item->type['name']), !\in_array($item->type['name'], ['array', 'ArrayCollection']), !isset($item->type['params'][0]['name']), 'string' != $item->type['params'][0]['name'], !isset($item->type['params'][1]['name']) => null, + !isset($item->type['name']), !\in_array($item->type['name'], ['array', 'ArrayCollection'], true), !isset($item->type['params'][0]['name']), 'string' !== $item->type['params'][0]['name'], !isset($item->type['params'][1]['name']) => null, default => $item->type['params'][1]['name'], }; } diff --git a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/GenericTemplateHandler.php b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/GenericTemplateHandler.php index a78570bcd..cd3dd7006 100644 --- a/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/GenericTemplateHandler.php +++ b/packages/open-api/Extraction/Extractor/JmsSerializer/TypeHandler/GenericTemplateHandler.php @@ -18,12 +18,13 @@ public function extractSchemaFromType( $propertyMetadata->type['name'].'<'.$genericType.'>', $propertySchema = new Schema(), $extractionContext - ); + ) + ; return $propertySchema; } - if (($propertyMetadata->type['name'] ?? null) != 'generic') { + if (($propertyMetadata->type['name'] ?? null) !== 'generic') { return null; } @@ -38,7 +39,8 @@ public function extractSchemaFromType( $genericTemplate, $propertySchema = new Schema(), $extractionContext - ); + ) + ; return $propertySchema; } @@ -46,7 +48,7 @@ public function extractSchemaFromType( private function getGenericType(PropertyMetadata $item): ?string { return match (true) { - !isset($item->type['name']), \in_array($item->type['name'], ['array', 'ArrayCollection']), !class_exists($item->type['name']), !isset($item->type['params'][0]['name']), isset($item->type['params'][1]['name']) => null, + !isset($item->type['name']), \in_array($item->type['name'], ['array', 'ArrayCollection'], true), !class_exists($item->type['name']), !isset($item->type['params'][0]['name']), isset($item->type['params'][1]['name']) => null, default => $item->type['params'][0]['name'], }; } diff --git a/packages/open-api/Extraction/Extractor/OpenApi/JsonRootSchemaExtractor.php b/packages/open-api/Extraction/Extractor/OpenApi/JsonRootSchemaExtractor.php index 456ea7ae9..d5619f655 100644 --- a/packages/open-api/Extraction/Extractor/OpenApi/JsonRootSchemaExtractor.php +++ b/packages/open-api/Extraction/Extractor/OpenApi/JsonRootSchemaExtractor.php @@ -34,7 +34,7 @@ public function canExtract($source, $target, ExtractionContextInterface $extract } $schema = json_decode($source, true); - if (\JSON_ERROR_NONE != json_last_error()) { + if (\JSON_ERROR_NONE !== json_last_error()) { return false; } @@ -42,7 +42,7 @@ public function canExtract($source, $target, ExtractionContextInterface $extract return false; } - if ('2.0' != $schema['swagger']) { + if ('2.0' !== $schema['swagger']) { return false; } diff --git a/packages/open-api/Extraction/Extractor/OpenApi/ParameterExtractor.php b/packages/open-api/Extraction/Extractor/OpenApi/ParameterExtractor.php index dabd0f014..e0a0efc1c 100644 --- a/packages/open-api/Extraction/Extractor/OpenApi/ParameterExtractor.php +++ b/packages/open-api/Extraction/Extractor/OpenApi/ParameterExtractor.php @@ -40,7 +40,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction $exists = false; foreach ($target->parameters as $index => $parameter) { - if ($parameter->name == $attribute->name) { + if ($parameter->name === $attribute->name) { $exists = true; $target->parameters[$index] = $attribute; diff --git a/packages/open-api/Extraction/Extractor/OpenApi/SerializationConfigurationExtractor.php b/packages/open-api/Extraction/Extractor/OpenApi/SerializationConfigurationExtractor.php index 8dc37be8e..be28bb8cb 100644 --- a/packages/open-api/Extraction/Extractor/OpenApi/SerializationConfigurationExtractor.php +++ b/packages/open-api/Extraction/Extractor/OpenApi/SerializationConfigurationExtractor.php @@ -69,7 +69,8 @@ public function extract($source, $target, ExtractionContextInterface $extraction private function getSerialization(\ReflectionMethod $reflectionMethod): ?Serialization { $attribute = $reflectionMethod - ->getAttributes(Serialization::class, \ReflectionAttribute::IS_INSTANCEOF)[0] ?? null; + ->getAttributes(Serialization::class, \ReflectionAttribute::IS_INSTANCEOF)[0] ?? null + ; return $attribute?->newInstance(); } diff --git a/packages/open-api/Extraction/Extractor/OpenApi/VendorAttributeExtractor.php b/packages/open-api/Extraction/Extractor/OpenApi/VendorAttributeExtractor.php index 78a783b9c..70600ca31 100644 --- a/packages/open-api/Extraction/Extractor/OpenApi/VendorAttributeExtractor.php +++ b/packages/open-api/Extraction/Extractor/OpenApi/VendorAttributeExtractor.php @@ -58,16 +58,17 @@ private function getAttributes(\ReflectionMethod|\ReflectionClass|\ReflectionPro if ($reflector instanceof \ReflectionMethod || $reflector instanceof \ReflectionProperty) { $classLevelAttributes = $reflector ->getDeclaringClass() - ->getAttributes(Vendor::class, \ReflectionAttribute::IS_INSTANCEOF); + ->getAttributes(Vendor::class, \ReflectionAttribute::IS_INSTANCEOF) + ; } $classLevelAttributes = array_map( - fn (\ReflectionAttribute $attribute) => $attribute->newInstance(), + static fn (\ReflectionAttribute $attribute) => $attribute->newInstance(), $classLevelAttributes ); $attributes = array_map( - fn (\ReflectionAttribute $attribute) => $attribute->newInstance(), + static fn (\ReflectionAttribute $attribute) => $attribute->newInstance(), $attributes ); @@ -88,7 +89,7 @@ private function mergeWithClassAnnotations(array $currentAttributes, array $clas ); $classAttributes = array_map( - fn (Vendor $annotation) => clone $annotation, + static fn (Vendor $annotation) => clone $annotation, $classAttributes ); diff --git a/packages/open-api/Extraction/Extractor/OpenApi/VersionLinkDocumentationExtractor.php b/packages/open-api/Extraction/Extractor/OpenApi/VersionLinkDocumentationExtractor.php index a814fcb47..5492a9789 100644 --- a/packages/open-api/Extraction/Extractor/OpenApi/VersionLinkDocumentationExtractor.php +++ b/packages/open-api/Extraction/Extractor/OpenApi/VersionLinkDocumentationExtractor.php @@ -59,7 +59,8 @@ public function extract($source, $target, ExtractionContextInterface $extraction 'draw_open_api.versioned_api_doc', ['version' => $otherVersion], UrlGeneratorInterface::ABSOLUTE_URL - ); + ) + ; $target->info->description .= 'Go to Version '.$otherVersion.'
'; } diff --git a/packages/open-api/Extraction/Extractor/PhpDoc/OperationExtractor.php b/packages/open-api/Extraction/Extractor/PhpDoc/OperationExtractor.php index 7ee53d7cb..ed3eb313e 100644 --- a/packages/open-api/Extraction/Extractor/PhpDoc/OperationExtractor.php +++ b/packages/open-api/Extraction/Extractor/PhpDoc/OperationExtractor.php @@ -95,7 +95,8 @@ private function createDocBlock(\Reflector $reflector): DocBlock ->create( $reflector, $this->contextFactory->createFromReflector($reflector) - ); + ) + ; } private function getExceptionInformation(\Exception $exception): array @@ -115,7 +116,7 @@ private function extractStatusCode( ExtractionContextInterface $extractionContext, \ReflectionMethod $source, ): int { - if (\in_array((string) $type, ['void', 'null'])) { + if (\in_array((string) $type, ['void', 'null'], true)) { return 204; } @@ -247,7 +248,8 @@ private function extractParameters( (string) $paramTag->getType(), $parameter, $subContext - ); + ) + ; } } } diff --git a/packages/open-api/Extraction/Extractor/PhpReflection/OperationResponseExtractor.php b/packages/open-api/Extraction/Extractor/PhpReflection/OperationResponseExtractor.php index b395eb4a3..67af85f08 100644 --- a/packages/open-api/Extraction/Extractor/PhpReflection/OperationResponseExtractor.php +++ b/packages/open-api/Extraction/Extractor/PhpReflection/OperationResponseExtractor.php @@ -45,7 +45,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction return; } - if (\in_array($returnType->getName(), ['void', 'null'])) { + if (\in_array($returnType->getName(), ['void', 'null'], true)) { if (\array_key_exists(204, $target->responses)) { return; } diff --git a/packages/open-api/Extraction/Extractor/Symfony/RouteOperationExtractor.php b/packages/open-api/Extraction/Extractor/Symfony/RouteOperationExtractor.php index 5017906af..4b3764ffe 100644 --- a/packages/open-api/Extraction/Extractor/Symfony/RouteOperationExtractor.php +++ b/packages/open-api/Extraction/Extractor/Symfony/RouteOperationExtractor.php @@ -43,7 +43,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction foreach ($source->compile()->getPathVariables() as $pathVariable) { foreach ($target->parameters as $parameter) { - if ($parameter->name == $pathVariable) { + if ($parameter->name === $pathVariable) { continue 2; } } diff --git a/packages/open-api/Extraction/Extractor/Symfony/RouterRootSchemaExtractor.php b/packages/open-api/Extraction/Extractor/Symfony/RouterRootSchemaExtractor.php index b5240a016..3978c2227 100644 --- a/packages/open-api/Extraction/Extractor/Symfony/RouterRootSchemaExtractor.php +++ b/packages/open-api/Extraction/Extractor/Symfony/RouterRootSchemaExtractor.php @@ -50,7 +50,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction $versioning = $extractionContext->getParameter(PropertiesExtractor::CONTEXT_PARAMETER_ENABLE_VERSION_EXCLUSION_STRATEGY); foreach ($source->getRouteCollection() as $routeName => $route) { - /* @var Route $route */ + /** @var Route $route */ if (!($path = $route->getPath())) { continue; } @@ -69,7 +69,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction $controller = explode('::', $controller); - if (2 != \count($controller)) { + if (2 !== \count($controller)) { continue; } diff --git a/packages/open-api/Extraction/Extractor/TypeSchemaExtractor.php b/packages/open-api/Extraction/Extractor/TypeSchemaExtractor.php index 847c280c7..30e1e1333 100644 --- a/packages/open-api/Extraction/Extractor/TypeSchemaExtractor.php +++ b/packages/open-api/Extraction/Extractor/TypeSchemaExtractor.php @@ -61,7 +61,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction $target->type = $primitiveType['type']; - if ('array' == $target->type) { + if ('array' === $target->type) { $target->items = $itemsSchema = new Schema(); if (isset($primitiveType['subType'])) { $extractionContext->getOpenApi()->extract( @@ -74,7 +74,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction return; } - if ('generic' == $target->type) { + if ('generic' === $target->type) { $target->type = 'object'; $reflectionClass = new \ReflectionClass($primitiveType['class']); $subContext = $extractionContext->createSubContext(); @@ -88,7 +88,7 @@ public function extract($source, $target, ExtractionContextInterface $extraction return; } - if ('object' == $target->type) { + if ('object' === $target->type) { $target->type = null; $reflectionClass = new \ReflectionClass($primitiveType['class']); $rootSchema = $extractionContext->getRootSchema(); @@ -140,11 +140,11 @@ private function getHash(string $modelName, ?array $context = null): string $this->definitionHashes[$modelName] = []; } - if (!\in_array($hash, $this->definitionHashes[$modelName])) { + if (!\in_array($hash, $this->definitionHashes[$modelName], true)) { $this->definitionHashes[$modelName][] = $hash; } - return array_search($hash, $this->definitionHashes[$modelName]); + return array_search($hash, $this->definitionHashes[$modelName], true); } public static function getPrimitiveType(mixed $type, ?ExtractionContextInterface $extractionContext = null): ?array @@ -161,7 +161,7 @@ public static function getPrimitiveType(mixed $type, ?ExtractionContextInterface $type = substr($type, 1); } - if ('generic' == $type) { + if ('generic' === $type) { $type = $extractionContext->getParameter('generic-template'); } diff --git a/packages/open-api/Extraction/ExtractorInterface.php b/packages/open-api/Extraction/ExtractorInterface.php index 35ea6b186..1411b9a12 100644 --- a/packages/open-api/Extraction/ExtractorInterface.php +++ b/packages/open-api/Extraction/ExtractorInterface.php @@ -6,9 +6,6 @@ interface ExtractorInterface { /** * Return if the extractor can extract the requested data or not. - * - * @param mixed $source - * @param mixed $target */ public function canExtract($source, $target, ExtractionContextInterface $extractionContext): bool; @@ -17,9 +14,6 @@ public function canExtract($source, $target, ExtractionContextInterface $extract * * The system is a incrementing extraction system. A extractor can be call before you and you must complete the * extraction. - * - * @param mixed $source - * @param mixed $target */ public function extract($source, $target, ExtractionContextInterface $extractionContext): void; } diff --git a/packages/open-api/Naming/AliasesClassNamingFilter.php b/packages/open-api/Naming/AliasesClassNamingFilter.php index f61a0fb0d..8aacbdb1b 100644 --- a/packages/open-api/Naming/AliasesClassNamingFilter.php +++ b/packages/open-api/Naming/AliasesClassNamingFilter.php @@ -24,7 +24,7 @@ public function filterClassName(string $originalClassName, array $context = [], continue; } - if ($class == $className) { + if ($class === $className) { return $alias; } } diff --git a/packages/open-api/OpenApi.php b/packages/open-api/OpenApi.php index 27e33f438..d61127b5f 100644 --- a/packages/open-api/OpenApi.php +++ b/packages/open-api/OpenApi.php @@ -44,16 +44,17 @@ public function __construct( if (null === $serializer) { $serializer = SerializerBuilder::create() ->configureListeners( - function (EventDispatcher $dispatcher): void { + static function (EventDispatcher $dispatcher): void { $dispatcher->addSubscriber(new OpenApiSubscriber()); } ) ->configureHandlers( - function (HandlerRegistry $handlerRegistry): void { + static function (HandlerRegistry $handlerRegistry): void { $handlerRegistry->registerSubscribingHandler(new OpenApiHandler()); } ) - ->build(); + ->build() + ; } $this->eventDispatcher ??= new SymfonyEventDispatcher(); @@ -109,7 +110,8 @@ public function validate(Schema $schema): void $result = Validation::createValidatorBuilder() ->enableAnnotationMapping() ->getValidator() - ->validate($schema, null, [Constraint::DEFAULT_GROUP]); + ->validate($schema, null, [Constraint::DEFAULT_GROUP]) + ; if (\count($result)) { throw new ConstraintViolationListException($result); diff --git a/packages/open-api/Schema/QueryParameter.php b/packages/open-api/Schema/QueryParameter.php index 4f2736250..6d9eb4b06 100644 --- a/packages/open-api/Schema/QueryParameter.php +++ b/packages/open-api/Schema/QueryParameter.php @@ -71,7 +71,8 @@ public static function fromReflectionMethod(\ReflectionMethod $reflectionMethod) $parameters = []; foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $attributes = $reflectionParameter - ->getAttributes(self::class, \ReflectionAttribute::IS_INSTANCEOF); + ->getAttributes(self::class, \ReflectionAttribute::IS_INSTANCEOF) + ; foreach ($attributes as $attribute) { $attribute = $attribute->newInstance(); diff --git a/packages/open-api/Schema/Root.php b/packages/open-api/Schema/Root.php index f0062b54d..10c108066 100644 --- a/packages/open-api/Schema/Root.php +++ b/packages/open-api/Schema/Root.php @@ -203,7 +203,8 @@ public function validateDuplicateOperationId(ExecutionContextInterface $context) $context->buildViolation('Duplicate operationId: '.$operationId) ->atPath('paths.'.$path.'.'.$method.'.operationId') ->setInvalidValue($operationId) - ->addViolation(); + ->addViolation() + ; } $operationsIds[] = $operationId; diff --git a/packages/open-api/Schema/SecurityRequirement.php b/packages/open-api/Schema/SecurityRequirement.php index 344a33cc8..6d0c60d12 100644 --- a/packages/open-api/Schema/SecurityRequirement.php +++ b/packages/open-api/Schema/SecurityRequirement.php @@ -7,9 +7,6 @@ */ class SecurityRequirement { - /** - * @var mixed - */ private $data; public function getData() diff --git a/packages/open-api/Schema/Tag.php b/packages/open-api/Schema/Tag.php index d610ba081..75e60179b 100644 --- a/packages/open-api/Schema/Tag.php +++ b/packages/open-api/Schema/Tag.php @@ -3,7 +3,6 @@ namespace Draw\Component\OpenApi\Schema; use JMS\Serializer\Annotation as JMS; - use Symfony\Component\Validator\Constraints as Assert; #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] diff --git a/packages/open-api/Serializer/Construction/DoctrineObjectConstructor.php b/packages/open-api/Serializer/Construction/DoctrineObjectConstructor.php index 38f870c31..f5c92d4a9 100644 --- a/packages/open-api/Serializer/Construction/DoctrineObjectConstructor.php +++ b/packages/open-api/Serializer/Construction/DoctrineObjectConstructor.php @@ -95,7 +95,7 @@ private function loadObject(string $class, $data, DeserializationContext $contex $findByIdentifier = true; } - if ($findByIdentifier && !\is_array($data) && 1 == \count($doctrineFindByFields)) { + if ($findByIdentifier && !\is_array($data) && 1 === \count($doctrineFindByFields)) { $object = $objectManager->find($class, $data); } else { if (!\is_array($data)) { diff --git a/packages/open-api/Serializer/Handler/GenericSerializerHandler.php b/packages/open-api/Serializer/Handler/GenericSerializerHandler.php index 16975495a..83c95e440 100644 --- a/packages/open-api/Serializer/Handler/GenericSerializerHandler.php +++ b/packages/open-api/Serializer/Handler/GenericSerializerHandler.php @@ -21,7 +21,7 @@ public static function getSubscribedEvents(): array public function onPreSerialize(PreSerializeEvent $event): void { - if ('generic' != $event->getType()['name']) { + if ('generic' !== $event->getType()['name']) { return; } diff --git a/packages/open-api/Serializer/Handler/ObjectReferenceHandler.php b/packages/open-api/Serializer/Handler/ObjectReferenceHandler.php index 93d7eebb8..bfde6c6b1 100644 --- a/packages/open-api/Serializer/Handler/ObjectReferenceHandler.php +++ b/packages/open-api/Serializer/Handler/ObjectReferenceHandler.php @@ -51,7 +51,8 @@ public function serializeObjectReference( $identifiers = $this->getManagerForClass($class) ->getMetadataFactory() ->getMetadataFor($class) - ->getIdentifierValues($value); + ->getIdentifierValues($value) + ; return current($identifiers); } @@ -67,7 +68,8 @@ public function deserializeObjectReference( } return $this->getManagerForClass($type['params'][0]['name']) - ->find($type['params'][0]['name'], $value); + ->find($type['params'][0]['name'], $value) + ; } private function getManagerForClass(string $class): ObjectManager diff --git a/packages/open-api/Tests/Command/InstallSandboxCommandTest.php b/packages/open-api/Tests/Command/InstallSandboxCommandTest.php index 7dd26fd81..4855c71a3 100644 --- a/packages/open-api/Tests/Command/InstallSandboxCommandTest.php +++ b/packages/open-api/Tests/Command/InstallSandboxCommandTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Filesystem\Filesystem; +/** + * @internal + */ #[CoversClass(InstallSandboxCommand::class)] class InstallSandboxCommandTest extends TestCase { @@ -50,7 +53,7 @@ public function testExecute(): void { $path = sys_get_temp_dir().'/sandbox'; - register_shutdown_function(function () use ($path): void { + register_shutdown_function(static function () use ($path): void { if (is_dir($path)) { (new Filesystem())->remove($path); } @@ -69,7 +72,8 @@ public function testExecute(): void "Downloading Swagger UI... Ok.\n". "Extracting zip file... Ok.\n" ) - ); + ) + ; static::assertDirectoryExists($path); } @@ -78,7 +82,7 @@ public function testExecuteZipError(): void { $path = sys_get_temp_dir().'/sandbox'; - register_shutdown_function(function () use ($path): void { + register_shutdown_function(static function () use ($path): void { if (is_dir($path)) { (new Filesystem())->remove($path); } @@ -92,7 +96,8 @@ public function testExecuteZipError(): void $filesystem ->expects(static::once()) - ->method('dumpFile'); + ->method('dumpFile') + ; $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Cannot open zip file [/tmp/swagger-ui-v3.52.5.zip]. Error code [9].'); @@ -110,6 +115,7 @@ public function testExecuteZipError(): void "Downloading Swagger UI... Ok.\n". "Extracting zip file... Ok.\n" ) - ); + ) + ; } } diff --git a/packages/open-api/Tests/Controller/OpenApiControllerTest.php b/packages/open-api/Tests/Controller/OpenApiControllerTest.php index 7d2a0fee3..95e746e3b 100644 --- a/packages/open-api/Tests/Controller/OpenApiControllerTest.php +++ b/packages/open-api/Tests/Controller/OpenApiControllerTest.php @@ -14,6 +14,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +/** + * @internal + */ class OpenApiControllerTest extends TestCase { private OpenApiController $object; @@ -49,7 +52,8 @@ public function testApiDocAction(): void { $this->openApi ->expects(static::never()) - ->method('dump'); + ->method('dump') + ; $route = uniqid('route-'); @@ -63,7 +67,8 @@ public function testApiDocAction(): void ], UrlGeneratorInterface::ABSOLUTE_URL ) - ->willReturn($url = uniqid('url-')); + ->willReturn($url = uniqid('url-')) + ; $request = new Request(); $request->attributes->set('_route', $route); @@ -94,7 +99,8 @@ public function testApiDocActionVersioned(): void ], UrlGeneratorInterface::ABSOLUTE_URL ) - ->willReturn(uniqid('url-')); + ->willReturn(uniqid('url-')) + ; $request = new Request(); $request->attributes->set('_route', $route); @@ -112,17 +118,20 @@ public function testApiDocActionJson(): void ->with( static::isInstanceOf(ExtractionContextInterface::class) ) - ->willReturn($rootSchema = new Root()); + ->willReturn($rootSchema = new Root()) + ; $this->openApi ->expects(static::once()) ->method('dump') ->with($rootSchema) - ->willReturn($rootSchemaJson = json_encode(['version' => $version], \JSON_THROW_ON_ERROR)); + ->willReturn($rootSchemaJson = json_encode(['version' => $version], \JSON_THROW_ON_ERROR)) + ; $this->urlGenerator ->expects(static::never()) - ->method('generate'); + ->method('generate') + ; $request = new Request(); $request->setRequestFormat('json'); diff --git a/packages/open-api/Tests/DependencyInjection/OpenApiIntegrationTest.php b/packages/open-api/Tests/DependencyInjection/OpenApiIntegrationTest.php index 6dd1fb6f5..1efa83b6b 100644 --- a/packages/open-api/Tests/DependencyInjection/OpenApiIntegrationTest.php +++ b/packages/open-api/Tests/DependencyInjection/OpenApiIntegrationTest.php @@ -76,6 +76,9 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\Security\Core\Exception\AccessDeniedException; +/** + * @internal + */ class OpenApiIntegrationTest extends IntegrationTestCase { public function createIntegration(): IntegrationInterface @@ -165,8 +168,8 @@ public static function provideTestLoad(): iterable ], ], 'definitionAliases' => [ - ['class' => 'App\\Entity\\', 'alias' => ''], - ['class' => 'App\\DTO\\', 'alias' => ''], + ['class' => 'App\Entity\\', 'alias' => ''], + ['class' => 'App\DTO\\', 'alias' => ''], ], 'classNamingFilters' => [ AliasesClassNamingFilter::class, @@ -323,13 +326,12 @@ public static function provideTestLoad(): iterable new ServiceConfiguration( 'draw.open_api.extractor.php_doc.operation_extractor', [OperationExtractor::class], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( [ [ 'registerExceptionResponseCodes', [\Exception::class, 100], - ], [ 'registerExceptionResponseCodes', @@ -397,7 +399,7 @@ function (Definition $definition): void { new ServiceConfiguration( 'draw.open_api.controller.open_api_controller', [OpenApiController::class], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( [ 'controller.service_arguments' => [[]], @@ -430,11 +432,11 @@ function (Definition $definition): void { new ServiceConfiguration( 'draw.open_api.naming.aliases_class_naming_filter', [AliasesClassNamingFilter::class], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( [ - ['class' => 'App\\Entity\\', 'alias' => ''], - ['class' => 'App\\DTO\\', 'alias' => ''], + ['class' => 'App\Entity\\', 'alias' => ''], + ['class' => 'App\DTO\\', 'alias' => ''], ], $definition->getArgument('$definitionAliases') ); diff --git a/packages/open-api/Tests/Event/PreDumpRootSchemaEventTest.php b/packages/open-api/Tests/Event/PreDumpRootSchemaEventTest.php index eea1e09c4..70e50debf 100644 --- a/packages/open-api/Tests/Event/PreDumpRootSchemaEventTest.php +++ b/packages/open-api/Tests/Event/PreDumpRootSchemaEventTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Contracts\EventDispatcher\Event; +/** + * @internal + */ #[CoversClass(PreDumpRootSchemaEvent::class)] class PreDumpRootSchemaEventTest extends TestCase { diff --git a/packages/open-api/Tests/Event/PreSerializerResponseEventTest.php b/packages/open-api/Tests/Event/PreSerializerResponseEventTest.php index 10d9ec6b6..2fd7f4f90 100644 --- a/packages/open-api/Tests/Event/PreSerializerResponseEventTest.php +++ b/packages/open-api/Tests/Event/PreSerializerResponseEventTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(PreSerializerResponseEvent::class)] class PreSerializerResponseEventTest extends TestCase { diff --git a/packages/open-api/Tests/EventListener/BaseCleanerTestCase.php b/packages/open-api/Tests/EventListener/BaseCleanerTestCase.php index dab0f551f..63ceeabd4 100644 --- a/packages/open-api/Tests/EventListener/BaseCleanerTestCase.php +++ b/packages/open-api/Tests/EventListener/BaseCleanerTestCase.php @@ -33,7 +33,7 @@ public function testClean(string $dirty, string $clean): void $cleanedSchema = $event->getRootSchema(); - static::assertEquals( + static::assertEqualsCanonicalizing( json_decode(file_get_contents($clean), true, 512, \JSON_THROW_ON_ERROR), json_decode($openApi->dump($cleanedSchema, false), true, 512, \JSON_THROW_ON_ERROR) ); diff --git a/packages/open-api/Tests/EventListener/DefinitionAliasCleanerListenerTest.php b/packages/open-api/Tests/EventListener/DefinitionAliasCleanerListenerTest.php index ac4e20446..10204e949 100644 --- a/packages/open-api/Tests/EventListener/DefinitionAliasCleanerListenerTest.php +++ b/packages/open-api/Tests/EventListener/DefinitionAliasCleanerListenerTest.php @@ -5,6 +5,9 @@ use Draw\Component\OpenApi\Event\CleanEvent; use Draw\Component\OpenApi\EventListener\DefinitionAliasCleanerListener; +/** + * @internal + */ class DefinitionAliasCleanerListenerTest extends BaseCleanerTestCase { private DefinitionAliasCleanerListener $object; diff --git a/packages/open-api/Tests/EventListener/DuplicateDefinitionAliasSchemaCleanerListenerTest.php b/packages/open-api/Tests/EventListener/DuplicateDefinitionAliasSchemaCleanerListenerTest.php index fb745394f..837ec3ee0 100644 --- a/packages/open-api/Tests/EventListener/DuplicateDefinitionAliasSchemaCleanerListenerTest.php +++ b/packages/open-api/Tests/EventListener/DuplicateDefinitionAliasSchemaCleanerListenerTest.php @@ -6,6 +6,9 @@ use Draw\Component\OpenApi\EventListener\DuplicateDefinitionAliasSchemaCleanerListener; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DuplicateDefinitionAliasSchemaCleanerListener::class)] class DuplicateDefinitionAliasSchemaCleanerListenerTest extends BaseCleanerTestCase { diff --git a/packages/open-api/Tests/EventListener/RequestQueryParameterFetcherListenerTest.php b/packages/open-api/Tests/EventListener/RequestQueryParameterFetcherListenerTest.php index 2c68eb9b9..472e5d503 100644 --- a/packages/open-api/Tests/EventListener/RequestQueryParameterFetcherListenerTest.php +++ b/packages/open-api/Tests/EventListener/RequestQueryParameterFetcherListenerTest.php @@ -14,6 +14,9 @@ use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelInterface; +/** + * @internal + */ #[CoversClass(RequestQueryParameterFetcherListener::class)] class RequestQueryParameterFetcherListenerTest extends TestCase { @@ -52,7 +55,8 @@ public function testOnKernelControllerUnParsableController(): void ); $this->object - ->onKernelController($event); + ->onKernelController($event) + ; static::assertEmpty($request->attributes->all()); } diff --git a/packages/open-api/Tests/EventListener/RequestValidationListenerTest.php b/packages/open-api/Tests/EventListener/RequestValidationListenerTest.php index 548e83a02..3820050cf 100644 --- a/packages/open-api/Tests/EventListener/RequestValidationListenerTest.php +++ b/packages/open-api/Tests/EventListener/RequestValidationListenerTest.php @@ -22,6 +22,9 @@ use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; +/** + * @internal + */ #[CoversClass(RequestValidationListener::class)] class RequestValidationListenerTest extends TestCase { @@ -68,7 +71,8 @@ public function testOnKernelControllerNoValidation(): void $this->validator ->expects(static::never()) - ->method('validate'); + ->method('validate') + ; $this->object->onKernelController($event); } @@ -91,7 +95,8 @@ public function testOnKernelControllerBodyValidationNoError(): void ->expects(static::once()) ->method('validate') ->with($bodyObject, null, ['Default']) - ->willReturn($this->createMock(ConstraintViolationListInterface::class)); + ->willReturn($this->createMock(ConstraintViolationListInterface::class)) + ; $this->object->onKernelController($event); } @@ -115,7 +120,8 @@ public function testOnKernelControllerQueryParametersValidationNoError(): void ->expects(static::once()) ->method('validate') ->with($parameterObject, [], null) - ->willReturn($this->createMock(ConstraintViolationListInterface::class)); + ->willReturn($this->createMock(ConstraintViolationListInterface::class)) + ; $this->object->onKernelController($event); } @@ -137,7 +143,8 @@ public function testOnKernelControllerDoNotValidate(): void $this->validator ->expects(static::never()) - ->method('validate'); + ->method('validate') + ; $this->object->onKernelController($event); } @@ -177,7 +184,8 @@ public function testOnKernelControllerWithError(): void ->willReturnOnConsecutiveCalls( $bodyViolationList = new ConstraintViolationList(), $parameterViolationList = new ConstraintViolationList(), - ); + ) + ; $bodyViolationList->add( $originalBodyViolation = new ConstraintViolation( diff --git a/packages/open-api/Tests/EventListener/ResponseApiExceptionListenerTest.php b/packages/open-api/Tests/EventListener/ResponseApiExceptionListenerTest.php index 92fae3b12..5c4d5b9eb 100644 --- a/packages/open-api/Tests/EventListener/ResponseApiExceptionListenerTest.php +++ b/packages/open-api/Tests/EventListener/ResponseApiExceptionListenerTest.php @@ -20,6 +20,9 @@ use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; +/** + * @internal + */ #[CoversClass(ResponseApiExceptionListener::class)] class ResponseApiExceptionListenerTest extends TestCase { @@ -46,7 +49,8 @@ protected function setUp(): void $this->request ->expects(static::any()) ->method('getRequestFormat') - ->willReturn('json'); + ->willReturn('json') + ; } /** @@ -95,7 +99,8 @@ public function testOnKernelExceptionNoneJsonRequest(): void $this->request ->expects(static::any()) ->method('getRequestFormat') - ->willReturn('html'); + ->willReturn('html') + ; static::assertNull($this->onKernelException()); } diff --git a/packages/open-api/Tests/EventListener/ResponseSerializerListenerTest.php b/packages/open-api/Tests/EventListener/ResponseSerializerListenerTest.php index 1fbc5ba5a..7d853a4ca 100644 --- a/packages/open-api/Tests/EventListener/ResponseSerializerListenerTest.php +++ b/packages/open-api/Tests/EventListener/ResponseSerializerListenerTest.php @@ -22,6 +22,9 @@ use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ #[CoversClass(ResponseSerializerListener::class)] class ResponseSerializerListenerTest extends TestCase { @@ -73,7 +76,8 @@ public function testOnKernelViewAlreadyResponse(): void $this->serializationContextFactory ->expects(static::never()) - ->method('createSerializationContext'); + ->method('createSerializationContext') + ; $this->object->onKernelView($event); } @@ -91,7 +95,8 @@ public function testOnKernelViewRequestNotJson(): void $this->serializationContextFactory ->expects(static::never()) - ->method('createSerializationContext'); + ->method('createSerializationContext') + ; $this->object->onKernelView($event); } @@ -109,7 +114,8 @@ public function testOnKernelViewResponseNull(): void $this->serializationContextFactory ->expects(static::never()) - ->method('createSerializationContext'); + ->method('createSerializationContext') + ; $this->object->onKernelView($event); @@ -133,7 +139,8 @@ public function testOnKernelView(): void $this->serializationContextFactory ->expects(static::once()) ->method('createSerializationContext') - ->willReturn($context = new SerializationContext()); + ->willReturn($context = new SerializationContext()) + ; $request->attributes->set( '_draw_open_api_serialization', @@ -184,13 +191,15 @@ function (PreSerializerResponseEvent $event) use ( return true; } ) - ); + ) + ; $this->serializer ->expects(static::once()) ->method('serialize') ->with($result, 'json', $context) - ->willReturn($jsonResult = json_encode(['key' => uniqid('value-')], \JSON_THROW_ON_ERROR)); + ->willReturn($jsonResult = json_encode(['key' => uniqid('value-')], \JSON_THROW_ON_ERROR)) + ; $this->object->onKernelView($event); @@ -228,12 +237,14 @@ public function testOnKernelResponse(): void $responseHeaderBag ->expects(static::once()) ->method('add') - ->with($headers); + ->with($headers) + ; $headerBag ->expects(static::once()) ->method('allPreserveCase') - ->willReturn($headers); + ->willReturn($headers) + ; $this->object->onKernelResponse($responseEvent); } @@ -266,7 +277,8 @@ public function testSetResponseHeader(): void $key = uniqid('key-'), $values = ['values'], false - ); + ) + ; $this->object::setResponseHeader($request, $key, $values, false); } diff --git a/packages/open-api/Tests/EventListener/SchemaAddDefaultHeadersListenerTest.php b/packages/open-api/Tests/EventListener/SchemaAddDefaultHeadersListenerTest.php index 766022d74..9cf219701 100644 --- a/packages/open-api/Tests/EventListener/SchemaAddDefaultHeadersListenerTest.php +++ b/packages/open-api/Tests/EventListener/SchemaAddDefaultHeadersListenerTest.php @@ -9,6 +9,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * @internal + */ #[CoversClass(SchemaAddDefaultHeadersListener::class)] class SchemaAddDefaultHeadersListenerTest extends TestCase { diff --git a/packages/open-api/Tests/EventListener/UnReferenceCleanerListenerTest.php b/packages/open-api/Tests/EventListener/UnReferenceCleanerListenerTest.php index 322c508db..d067efabd 100644 --- a/packages/open-api/Tests/EventListener/UnReferenceCleanerListenerTest.php +++ b/packages/open-api/Tests/EventListener/UnReferenceCleanerListenerTest.php @@ -6,6 +6,9 @@ use Draw\Component\OpenApi\Event\CleanEvent; use Draw\Component\OpenApi\EventListener\UnReferenceCleanerListener; +/** + * @internal + */ class UnReferenceCleanerListenerTest extends BaseCleanerTestCase { private UnReferenceCleanerListener $object; diff --git a/packages/open-api/Tests/Exception/ConstraintViolationListExceptionTest.php b/packages/open-api/Tests/Exception/ConstraintViolationListExceptionTest.php index 6524306da..266cbb1c1 100644 --- a/packages/open-api/Tests/Exception/ConstraintViolationListExceptionTest.php +++ b/packages/open-api/Tests/Exception/ConstraintViolationListExceptionTest.php @@ -8,6 +8,9 @@ use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Exception\ValidatorException; +/** + * @internal + */ #[CoversClass(ConstraintViolationListException::class)] class ConstraintViolationListExceptionTest extends TestCase { diff --git a/packages/open-api/Tests/Exception/ExtractionImpossibleExceptionTest.php b/packages/open-api/Tests/Exception/ExtractionImpossibleExceptionTest.php index 6ae8ef109..49daa4eeb 100644 --- a/packages/open-api/Tests/Exception/ExtractionImpossibleExceptionTest.php +++ b/packages/open-api/Tests/Exception/ExtractionImpossibleExceptionTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(ExtractionImpossibleException::class)] class ExtractionImpossibleExceptionTest extends TestCase { diff --git a/packages/open-api/Tests/Extraction/Extractor/Constraint/NotBlankConstraintExtractorTest.php b/packages/open-api/Tests/Extraction/Extractor/Constraint/NotBlankConstraintExtractorTest.php index e7416b98f..2a8190599 100644 --- a/packages/open-api/Tests/Extraction/Extractor/Constraint/NotBlankConstraintExtractorTest.php +++ b/packages/open-api/Tests/Extraction/Extractor/Constraint/NotBlankConstraintExtractorTest.php @@ -13,6 +13,9 @@ use Symfony\Component\Validator\Constraints\IsNull; use Symfony\Component\Validator\Constraints\NotBlank; +/** + * @internal + */ #[CoversClass(NotBlankConstraintExtractor::class)] class NotBlankConstraintExtractorTest extends TestCase { diff --git a/packages/open-api/Tests/Extraction/Extractor/JmsSerializer/PropertiesExtractorTest.php b/packages/open-api/Tests/Extraction/Extractor/JmsSerializer/PropertiesExtractorTest.php index a8208cd40..17bdf2c49 100644 --- a/packages/open-api/Tests/Extraction/Extractor/JmsSerializer/PropertiesExtractorTest.php +++ b/packages/open-api/Tests/Extraction/Extractor/JmsSerializer/PropertiesExtractorTest.php @@ -20,6 +20,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; +/** + * @internal + */ #[CoversClass(PropertiesExtractor::class)] class PropertiesExtractorTest extends TestCase { @@ -129,6 +132,7 @@ class JmsExtractorStubModel /** * The simple enum. + * * @var JmsExtractorStubEnum */ #[Serializer\Type('enum<\''.JmsExtractorStubEnum::class.'\'>')] @@ -137,6 +141,7 @@ class JmsExtractorStubModel /** * The backed enum. + * * @var JmsExtractorStubEnum */ #[Serializer\Type('enum<\''.JmsExtractorStubBackedEnum::class.'\'>')] @@ -145,6 +150,7 @@ class JmsExtractorStubModel /** * The backed enum int. + * * @var JmsExtractorStubEnum */ #[Serializer\Type('enum<\''.JmsExtractorStubBackedEnumInt::class.'\'>')] diff --git a/packages/open-api/Tests/Extraction/Extractor/OpenApi/RootSchemaExtractorTest.php b/packages/open-api/Tests/Extraction/Extractor/OpenApi/RootSchemaExtractorTest.php index ccea80585..d17db33ec 100644 --- a/packages/open-api/Tests/Extraction/Extractor/OpenApi/RootSchemaExtractorTest.php +++ b/packages/open-api/Tests/Extraction/Extractor/OpenApi/RootSchemaExtractorTest.php @@ -11,6 +11,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class RootSchemaExtractorTest extends TestCase { use MockTrait; diff --git a/packages/open-api/Tests/Extraction/Extractor/PhpDoc/OperationExtractorTest.php b/packages/open-api/Tests/Extraction/Extractor/PhpDoc/OperationExtractorTest.php index 564a83371..3b7076e37 100644 --- a/packages/open-api/Tests/Extraction/Extractor/PhpDoc/OperationExtractorTest.php +++ b/packages/open-api/Tests/Extraction/Extractor/PhpDoc/OperationExtractorTest.php @@ -15,6 +15,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class OperationExtractorTest extends TestCase { use MockTrait; @@ -164,10 +167,11 @@ class PhpDocOperationExtractorStubClass class PhpDocOperationExtractorStubService { /** - * @throws \Exception When problem occur + * @return PhpDocOperationExtractorStubService + * + * @throws \Exception When problem occur * @throws \LengthException * @throws ExtractionImpossibleException - * @return PhpDocOperationExtractorStubService */ public function operation(self $service, mixed $string, array $array) { diff --git a/packages/open-api/Tests/Extraction/Extractor/TypeSchemaExtractorTest.php b/packages/open-api/Tests/Extraction/Extractor/TypeSchemaExtractorTest.php index 4e37a65ba..5c4a0fa42 100644 --- a/packages/open-api/Tests/Extraction/Extractor/TypeSchemaExtractorTest.php +++ b/packages/open-api/Tests/Extraction/Extractor/TypeSchemaExtractorTest.php @@ -12,6 +12,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class TypeSchemaExtractorTest extends TestCase { private TypeSchemaExtractor $object; diff --git a/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/ConfigurableErrorToHttpCodeConverterTest.php b/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/ConfigurableErrorToHttpCodeConverterTest.php index 246e9fe6b..8338f7041 100644 --- a/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/ConfigurableErrorToHttpCodeConverterTest.php +++ b/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/ConfigurableErrorToHttpCodeConverterTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class ConfigurableErrorToHttpCodeConverterTest extends TestCase { private ConfigurableErrorToHttpCodeConverter $errorToHttpCodeConverter; diff --git a/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/HttpExceptionToHttpCodeConverterTest.php b/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/HttpExceptionToHttpCodeConverterTest.php index c9b0c91e3..97fee6ebf 100644 --- a/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/HttpExceptionToHttpCodeConverterTest.php +++ b/packages/open-api/Tests/HttpFoundation/ErrorToHttpCodeConverter/HttpExceptionToHttpCodeConverterTest.php @@ -9,6 +9,9 @@ use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; +/** + * @internal + */ class HttpExceptionToHttpCodeConverterTest extends TestCase { private HttpExceptionToHttpCodeConverter $httpExceptionToHttpCodeConverter; diff --git a/packages/open-api/Tests/Naming/AliasesClassNamingFilterTest.php b/packages/open-api/Tests/Naming/AliasesClassNamingFilterTest.php index 1bece4c8f..c36cd326a 100644 --- a/packages/open-api/Tests/Naming/AliasesClassNamingFilterTest.php +++ b/packages/open-api/Tests/Naming/AliasesClassNamingFilterTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(AliasesClassNamingFilter::class)] class AliasesClassNamingFilterTest extends TestCase { diff --git a/packages/open-api/Tests/OpenApiTest.php b/packages/open-api/Tests/OpenApiTest.php index 59883017a..884b39088 100644 --- a/packages/open-api/Tests/OpenApiTest.php +++ b/packages/open-api/Tests/OpenApiTest.php @@ -11,6 +11,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(OpenApi::class)] class OpenApiTest extends TestCase { diff --git a/packages/open-api/Tests/Serializer/SerializationTest.php b/packages/open-api/Tests/Serializer/SerializationTest.php index 84525aa69..13e266d2a 100644 --- a/packages/open-api/Tests/Serializer/SerializationTest.php +++ b/packages/open-api/Tests/Serializer/SerializationTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(Serialization::class)] class SerializationTest extends TestCase { diff --git a/packages/open-api/Tests/Versioning/RouteDefaultApiRouteVersionMatcherTest.php b/packages/open-api/Tests/Versioning/RouteDefaultApiRouteVersionMatcherTest.php index d724ff7af..98c23ec77 100644 --- a/packages/open-api/Tests/Versioning/RouteDefaultApiRouteVersionMatcherTest.php +++ b/packages/open-api/Tests/Versioning/RouteDefaultApiRouteVersionMatcherTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Routing\Route; +/** + * @internal + */ #[CoversClass(RouteDefaultApiRouteVersionMatcher::class)] class RouteDefaultApiRouteVersionMatcherTest extends TestCase { diff --git a/packages/process/DependencyInjection/ProcessIntegration.php b/packages/process/DependencyInjection/ProcessIntegration.php index 503b0880a..462a14069 100644 --- a/packages/process/DependencyInjection/ProcessIntegration.php +++ b/packages/process/DependencyInjection/ProcessIntegration.php @@ -23,7 +23,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Process\\', + $namespace = 'Draw\Component\Process\\', \dirname((new \ReflectionClass(ProcessFactory::class))->getFileName()), ); diff --git a/packages/process/Tests/DependencyInjection/ProcessIntegrationTest.php b/packages/process/Tests/DependencyInjection/ProcessIntegrationTest.php index 9e609e95a..5e250b4ea 100644 --- a/packages/process/Tests/DependencyInjection/ProcessIntegrationTest.php +++ b/packages/process/Tests/DependencyInjection/ProcessIntegrationTest.php @@ -13,6 +13,8 @@ /** * @property ConsoleIntegration $integration + * + * @internal */ #[CoversClass(ProcessIntegration::class)] class ProcessIntegrationTest extends IntegrationTestCase diff --git a/packages/process/Tests/ProcessFactoryTest.php b/packages/process/Tests/ProcessFactoryTest.php index d591ab5dc..56c916264 100644 --- a/packages/process/Tests/ProcessFactoryTest.php +++ b/packages/process/Tests/ProcessFactoryTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; +/** + * @internal + */ #[ CoversClass(ProcessFactory::class), CoversClass(ProcessFactoryInterface::class), diff --git a/packages/profiling/Sql/SqlMetricBuilder.php b/packages/profiling/Sql/SqlMetricBuilder.php index 7a8faa621..0bd2c5546 100644 --- a/packages/profiling/Sql/SqlMetricBuilder.php +++ b/packages/profiling/Sql/SqlMetricBuilder.php @@ -19,7 +19,7 @@ public function addLog(SqlLog $sqlLog): void public function build(): SqlMetric { $queries = array_map( - fn (SqlLog $log) => $log->query, + static fn (SqlLog $log) => $log->query, $this->logs ); diff --git a/packages/profiling/Tests/ProfilerCoordinatorTest.php b/packages/profiling/Tests/ProfilerCoordinatorTest.php index d813a8457..caa9a46cb 100644 --- a/packages/profiling/Tests/ProfilerCoordinatorTest.php +++ b/packages/profiling/Tests/ProfilerCoordinatorTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class ProfilerCoordinatorTest extends TestCase { private const PROFILER_TYPE = 'test'; diff --git a/packages/profiling/Tests/Sql/SqlAssertionBuilderTest.php b/packages/profiling/Tests/Sql/SqlAssertionBuilderTest.php index 7dacdfab8..5fbc0f27b 100644 --- a/packages/profiling/Tests/Sql/SqlAssertionBuilderTest.php +++ b/packages/profiling/Tests/Sql/SqlAssertionBuilderTest.php @@ -9,6 +9,9 @@ use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class SqlAssertionBuilderTest extends TestCase { private SqlAssertionBuilder $assertionBuilder; @@ -72,7 +75,8 @@ public function testInvokeFailMessage(): void Failed asserting that 2 matches expected 0.'); (new DataTester(new SqlMetric(['SELECT * FROM test', 'SELECT * FROM test2']))) - ->test(SqlAssertionBuilder::create(0)); + ->test(SqlAssertionBuilder::create(0)) + ; } public function testInvokeNoAssertionException(): void @@ -81,7 +85,8 @@ public function testInvokeNoAssertionException(): void $this->expectExceptionMessage('No assertion configured.'); (new DataTester(new SqlMetric([]))) - ->test(SqlAssertionBuilder::create()); + ->test(SqlAssertionBuilder::create()) + ; } private function invoke(DataTester $dataTester, $shouldFail): void diff --git a/packages/profiling/Tests/Sql/SqlLogTest.php b/packages/profiling/Tests/Sql/SqlLogTest.php index 23c1d9fe9..c3af1525f 100644 --- a/packages/profiling/Tests/Sql/SqlLogTest.php +++ b/packages/profiling/Tests/Sql/SqlLogTest.php @@ -5,11 +5,14 @@ use Draw\Component\Profiling\Sql\SqlLog; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class SqlLogTest extends TestCase { public function test(): void { $log = new SqlLog('query'); - static::assertEquals('query', $log->query); + static::assertSame('query', $log->query); } } diff --git a/packages/profiling/Tests/Sql/SqlMetricBuilderTest.php b/packages/profiling/Tests/Sql/SqlMetricBuilderTest.php index 00671aff2..f73d192f4 100644 --- a/packages/profiling/Tests/Sql/SqlMetricBuilderTest.php +++ b/packages/profiling/Tests/Sql/SqlMetricBuilderTest.php @@ -8,6 +8,9 @@ use Draw\Component\Profiling\Sql\SqlMetricBuilder; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class SqlMetricBuilderTest extends TestCase { private SqlMetricBuilder $metricBuilder; @@ -28,8 +31,8 @@ public function testBuild(): void $metric = $this->metricBuilder->build(); static::assertInstanceOf(SqlMetric::class, $metric); - static::assertEquals(1, $metric->count); - static::assertEquals( + static::assertSame(1, $metric->count); + static::assertSame( ['query'], $metric->queries ); diff --git a/packages/profiling/Tests/Sql/SqlMetricTest.php b/packages/profiling/Tests/Sql/SqlMetricTest.php index 6319c09cb..d1e770145 100644 --- a/packages/profiling/Tests/Sql/SqlMetricTest.php +++ b/packages/profiling/Tests/Sql/SqlMetricTest.php @@ -5,13 +5,16 @@ use Draw\Component\Profiling\Sql\SqlMetric; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class SqlMetricTest extends TestCase { public function test(): void { $metric = new SqlMetric(['query']); - static::assertEquals(1, $metric->count); - static::assertEquals( + static::assertSame(1, $metric->count); + static::assertSame( ['query'], $metric->queries ); diff --git a/packages/profiling/Tests/Sql/SqlProfilerTest.php b/packages/profiling/Tests/Sql/SqlProfilerTest.php index 2b8675376..1f451b2de 100644 --- a/packages/profiling/Tests/Sql/SqlProfilerTest.php +++ b/packages/profiling/Tests/Sql/SqlProfilerTest.php @@ -9,6 +9,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class SqlProfilerTest extends TestCase { use MockTrait; @@ -20,7 +23,8 @@ protected function setUp(): void $this->profiler = $this->createMock(SqlProfiler::class); $this->profiler ->method('getType') - ->willReturn(SqlProfiler::PROFILER_TYPE); + ->willReturn(SqlProfiler::PROFILER_TYPE) + ; } public function testGetType(): void diff --git a/packages/security/Core/Authentication/Token/SystemToken.php b/packages/security/Core/Authentication/Token/SystemToken.php index 0020557b4..9b71b4591 100644 --- a/packages/security/Core/Authentication/Token/SystemToken.php +++ b/packages/security/Core/Authentication/Token/SystemToken.php @@ -50,12 +50,4 @@ public function isAuthenticated(): bool { return true; } - - /** - * @return mixed - */ - public function getCredentials() - { - return null; - } } diff --git a/packages/security/Core/EventListener/SystemConsoleAuthenticatorListener.php b/packages/security/Core/EventListener/SystemConsoleAuthenticatorListener.php index 26ee0c3be..bc6e98594 100644 --- a/packages/security/Core/EventListener/SystemConsoleAuthenticatorListener.php +++ b/packages/security/Core/EventListener/SystemConsoleAuthenticatorListener.php @@ -38,7 +38,8 @@ public function addOptions(ConsoleCommandEvent $consoleCommandEvent): void null, InputOption::VALUE_NONE, 'Execute the current command connected as the system user.', - ); + ) + ; } public function connectSystem(ConsoleCommandEvent $consoleCommandEvent): void diff --git a/packages/security/DependencyInjection/Compiler/UserCheckerDecoratorPass.php b/packages/security/DependencyInjection/Compiler/UserCheckerDecoratorPass.php index 7160fc7f5..8c3a0c0fb 100644 --- a/packages/security/DependencyInjection/Compiler/UserCheckerDecoratorPass.php +++ b/packages/security/DependencyInjection/Compiler/UserCheckerDecoratorPass.php @@ -23,6 +23,7 @@ public function process(ContainerBuilder $container): void ->setAutoconfigured(true) ->setAutowired(true) ->setDecoratedService('security.user_checker', 'draw.security.core.user.event_driven_user_checker.inner') - ->setArgument('$decoratedUserChecker', new Reference('draw.security.core.user.event_driven_user_checker.inner')); + ->setArgument('$decoratedUserChecker', new Reference('draw.security.core.user.event_driven_user_checker.inner')) + ; } } diff --git a/packages/security/DependencyInjection/Factory/JwtAuthenticatorFactory.php b/packages/security/DependencyInjection/Factory/JwtAuthenticatorFactory.php index 93711c9b5..f17b041f0 100644 --- a/packages/security/DependencyInjection/Factory/JwtAuthenticatorFactory.php +++ b/packages/security/DependencyInjection/Factory/JwtAuthenticatorFactory.php @@ -47,7 +47,8 @@ public function createAuthenticator( ->setArgument('$algorithm', $config['algorithm']) ->setArgument('$privateKey', $config['private_key']) ->setArgument('$passphrase', $config['passphrase']) - ); + ) + ; if ($serviceAlias = $config['service_alias'] ?? null) { $container->setAlias($serviceAlias, $serviceId); @@ -76,6 +77,7 @@ public function addConfiguration(NodeDefinition $builder): void ->scalarNode('service_alias')->defaultNull()->end() ->scalarNode('user_identifier_payload_key')->defaultValue('userId')->end() ->scalarNode('user_identifier_getter')->defaultValue('getId')->end() - ->end(); + ->end() + ; } } diff --git a/packages/security/DependencyInjection/Factory/MessengerMessageAuthenticatorFactory.php b/packages/security/DependencyInjection/Factory/MessengerMessageAuthenticatorFactory.php index d85eb22c7..5f61ce63a 100644 --- a/packages/security/DependencyInjection/Factory/MessengerMessageAuthenticatorFactory.php +++ b/packages/security/DependencyInjection/Factory/MessengerMessageAuthenticatorFactory.php @@ -39,7 +39,8 @@ public function createAuthenticator( ->setAutowired(true) ->setArgument('$userProvider', new Reference($userProviderId)) ->setArgument('$envelopeFinder', new Reference(EnvelopeFinderInterface::class)) - ->setArgument('$requestParameterKey', $config['request_parameter_key']); + ->setArgument('$requestParameterKey', $config['request_parameter_key']) + ; if ($serviceAlias = $config['service_alias'] ?? null) { $container->setAlias($serviceAlias, $serviceId); @@ -58,6 +59,7 @@ public function addConfiguration(NodeDefinition $builder): void ->children() ->scalarNode('provider')->end() ->scalarNode('request_parameter_key')->defaultValue(ClickMessageAction::MESSAGE_ID_PARAMETER_NAME)->end() - ->end(); + ->end() + ; } } diff --git a/packages/security/DependencyInjection/SecurityIntegration.php b/packages/security/DependencyInjection/SecurityIntegration.php index 96373c2b5..ac828c873 100644 --- a/packages/security/DependencyInjection/SecurityIntegration.php +++ b/packages/security/DependencyInjection/SecurityIntegration.php @@ -55,7 +55,7 @@ private function loadCore(array $config, PhpFileLoader $loader, ContainerBuilder { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Security\\Core\\', + $namespace = 'Draw\Component\Security\Core\\', $directory = \dirname( (new \ReflectionClass(SystemAuthenticatorInterface::class))->getFileName(), 2 @@ -71,13 +71,15 @@ private function loadCore(array $config, PhpFileLoader $loader, ContainerBuilder $container->removeDefinition(SystemAuthenticator::class); } else { $container->getDefinition(SystemAuthenticator::class) - ->setArgument('$roles', $config['system_authentication']['roles']); + ->setArgument('$roles', $config['system_authentication']['roles']) + ; $container ->setAlias( SystemAuthenticatorInterface::class, SystemAuthenticator::class - ); + ) + ; } if (!$this->isConfigEnabled($container, $config['messenger_authentication']) @@ -90,7 +92,8 @@ private function loadCore(array $config, PhpFileLoader $loader, ContainerBuilder $container->removeDefinition(SystemConsoleAuthenticatorListener::class); } else { $container->getDefinition(SystemConsoleAuthenticatorListener::class) - ->setArgument('$systemAutoLogin', $config['console_authentication']['system_auto_login']); + ->setArgument('$systemAutoLogin', $config['console_authentication']['system_auto_login']) + ; } $this->renameDefinitions( @@ -104,7 +107,7 @@ private function loadJwt(array $config, PhpFileLoader $loader, ContainerBuilder { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Security\\Jwt\\', + $namespace = 'Draw\Component\Security\Jwt\\', \dirname((new \ReflectionClass(JwtEncoder::class))->getFileName()) ); @@ -114,7 +117,8 @@ private function loadJwt(array $config, PhpFileLoader $loader, ContainerBuilder $container ->getDefinition(JwtEncoder::class) ->setArgument('$key', $config['jwt']['encoder']['key']) - ->setArgument('$algorithm', $config['jwt']['encoder']['algorithm']); + ->setArgument('$algorithm', $config['jwt']['encoder']['algorithm']) + ; } $this->renameDefinitions( @@ -128,7 +132,7 @@ private function loadVoters(array $config, PhpFileLoader $loader, ContainerBuild { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Security\\Core\\Authorization\\Voter\\', + $namespace = 'Draw\Component\Security\Core\Authorization\Voter\\', \dirname((new \ReflectionClass(AbstainRoleHierarchyVoter::class))->getFileName()) ); @@ -136,7 +140,8 @@ private function loadVoters(array $config, PhpFileLoader $loader, ContainerBuild $container->removeDefinition(AbstainRoleHierarchyVoter::class); } else { $container - ->setAlias('security.access.role_hierarchy_voter', AbstainRoleHierarchyVoter::class); + ->setAlias('security.access.role_hierarchy_voter', AbstainRoleHierarchyVoter::class) + ; } $this->renameDefinitions( @@ -150,7 +155,7 @@ private function loadHttp(array $config, PhpFileLoader $loader, ContainerBuilder { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Security\\Http\\', + $namespace = 'Draw\Component\Security\Http\\', $directory = \dirname( (new \ReflectionClass(JwtAuthenticator::class))->getFileName(), 2 @@ -213,6 +218,7 @@ public function addConfiguration(ArrayNodeDefinition $node): void ->canBeEnabled() ->end() ->end() - ->end(); + ->end() + ; } } diff --git a/packages/security/Http/Authenticator/JwtAuthenticator.php b/packages/security/Http/Authenticator/JwtAuthenticator.php index a027d5f64..92b549116 100644 --- a/packages/security/Http/Authenticator/JwtAuthenticator.php +++ b/packages/security/Http/Authenticator/JwtAuthenticator.php @@ -114,7 +114,7 @@ public function authenticate(Request $request): Passport } return new SelfValidatingPassport( - new UserBadge($user->getUserIdentifier().'+jwt-token', fn () => $user), + new UserBadge($user->getUserIdentifier().'+jwt-token', static fn () => $user), $badges ); } @@ -126,11 +126,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token, public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response { - throw new HttpException( - Response::HTTP_FORBIDDEN, - $this->translate($exception->getMessageKey(), $exception->getMessageData()), - previous: $exception - ); + throw new HttpException(Response::HTTP_FORBIDDEN, $this->translate($exception->getMessageKey(), $exception->getMessageData()), previous: $exception); } private function translate(string $message, array $data = []): string diff --git a/packages/security/Http/Authenticator/MessageAuthenticator.php b/packages/security/Http/Authenticator/MessageAuthenticator.php index 844494767..457bc8023 100644 --- a/packages/security/Http/Authenticator/MessageAuthenticator.php +++ b/packages/security/Http/Authenticator/MessageAuthenticator.php @@ -45,7 +45,7 @@ public function authenticate(Request $request): Passport } return new SelfValidatingPassport( - new UserBadge($user->getUserIdentifier().'+message-'.$messageId, fn () => $user) + new UserBadge($user->getUserIdentifier().'+message-'.$messageId, static fn () => $user) ); } diff --git a/packages/security/Http/EventListener/RoleRestrictedAuthenticatorListener.php b/packages/security/Http/EventListener/RoleRestrictedAuthenticatorListener.php index be91ece9a..5c515fa92 100644 --- a/packages/security/Http/EventListener/RoleRestrictedAuthenticatorListener.php +++ b/packages/security/Http/EventListener/RoleRestrictedAuthenticatorListener.php @@ -30,7 +30,7 @@ public function checkPassport(CheckPassportEvent $event): void $user = $passport->getBadge(UserBadge::class)->getUser(); - if (!\in_array($badge->getRole(), $this->roleHierarchy->getReachableRoleNames($user->getRoles()))) { + if (!\in_array($badge->getRole(), $this->roleHierarchy->getReachableRoleNames($user->getRoles()), true)) { throw new CustomUserMessageAuthenticationException('Access denied.'); } diff --git a/packages/security/Tests/Core/Event/CheckPostAuthEventTest.php b/packages/security/Tests/Core/Event/CheckPostAuthEventTest.php index a886c0e06..1ba8b0e41 100644 --- a/packages/security/Tests/Core/Event/CheckPostAuthEventTest.php +++ b/packages/security/Tests/Core/Event/CheckPostAuthEventTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\User\UserInterface; +/** + * @internal + */ #[CoversClass(CheckPostAuthEvent::class)] class CheckPostAuthEventTest extends TestCase { diff --git a/packages/security/Tests/Core/Event/CheckPreAuthEventTest.php b/packages/security/Tests/Core/Event/CheckPreAuthEventTest.php index 576d5d0ba..a7c3bea26 100644 --- a/packages/security/Tests/Core/Event/CheckPreAuthEventTest.php +++ b/packages/security/Tests/Core/Event/CheckPreAuthEventTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\User\UserInterface; +/** + * @internal + */ #[CoversClass(CheckPreAuthEvent::class)] class CheckPreAuthEventTest extends TestCase { diff --git a/packages/security/Tests/Core/EventListener/SystemConsoleAuthenticatorListenerTest.php b/packages/security/Tests/Core/EventListener/SystemConsoleAuthenticatorListenerTest.php index a17cec98f..6727847c2 100644 --- a/packages/security/Tests/Core/EventListener/SystemConsoleAuthenticatorListenerTest.php +++ b/packages/security/Tests/Core/EventListener/SystemConsoleAuthenticatorListenerTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +/** + * @internal + */ class SystemConsoleAuthenticatorListenerTest extends TestCase { private SystemConsoleAuthenticatorListener $object; @@ -78,17 +81,20 @@ public function testConnectSystemAutoConnect(): void $this->tokenStorage ->expects(static::once()) ->method('getToken') - ->willReturn(null); + ->willReturn(null) + ; $this->systemAuthenticator ->expects(static::once()) ->method('getTokenForSystem') - ->willReturn($token = $this->createMock(TokenInterface::class)); + ->willReturn($token = $this->createMock(TokenInterface::class)) + ; $this->tokenStorage ->expects(static::once()) ->method('setToken') - ->with($token); + ->with($token) + ; $this->object->connectSystem($consoleCommandEvent); } @@ -102,15 +108,18 @@ public function testConnectSystemAutoConnectDisabled(): void $this->tokenStorage ->expects(static::never()) ->method('getToken') - ->willReturn(null); + ->willReturn(null) + ; $this->systemAuthenticator ->expects(static::never()) - ->method('getTokenForSystem'); + ->method('getTokenForSystem') + ; $this->tokenStorage ->expects(static::never()) - ->method('setToken'); + ->method('setToken') + ; $this->object->connectSystem($consoleCommandEvent); } @@ -124,15 +133,18 @@ public function testConnectSystemAutoConnectAlreadyConnected(): void $this->tokenStorage ->expects(static::once()) ->method('getToken') - ->willReturn($this->createMock(TokenInterface::class)); + ->willReturn($this->createMock(TokenInterface::class)) + ; $this->systemAuthenticator ->expects(static::never()) - ->method('getTokenForSystem'); + ->method('getTokenForSystem') + ; $this->tokenStorage ->expects(static::never()) - ->method('setToken'); + ->method('setToken') + ; $this->object->connectSystem($consoleCommandEvent); } @@ -148,17 +160,20 @@ public function testConnectSystemAutoConnectWithOption(): void $this->tokenStorage ->expects(static::once()) ->method('getToken') - ->willReturn(null); + ->willReturn(null) + ; $this->systemAuthenticator ->expects(static::once()) ->method('getTokenForSystem') - ->willReturn($token = $this->createMock(TokenInterface::class)); + ->willReturn($token = $this->createMock(TokenInterface::class)) + ; $this->tokenStorage ->expects(static::once()) ->method('setToken') - ->with($token); + ->with($token) + ; $this->object->connectSystem($consoleCommandEvent); } @@ -174,17 +189,20 @@ public function testConnectSystemAutoConnectWithOptionAndSystemAutoLogin(): void $this->tokenStorage ->expects(static::once()) ->method('getToken') - ->willReturn(null); + ->willReturn(null) + ; $this->systemAuthenticator ->expects(static::once()) ->method('getTokenForSystem') - ->willReturn($token = $this->createMock(TokenInterface::class)); + ->willReturn($token = $this->createMock(TokenInterface::class)) + ; $this->tokenStorage ->expects(static::once()) ->method('setToken') - ->with($token); + ->with($token) + ; $this->object->connectSystem($consoleCommandEvent); } diff --git a/packages/security/Tests/Core/EventListener/SystemMessengerAuthenticatorListenerTest.php b/packages/security/Tests/Core/EventListener/SystemMessengerAuthenticatorListenerTest.php index 9527ca95e..b796a0327 100644 --- a/packages/security/Tests/Core/EventListener/SystemMessengerAuthenticatorListenerTest.php +++ b/packages/security/Tests/Core/EventListener/SystemMessengerAuthenticatorListenerTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +/** + * @internal + */ class SystemMessengerAuthenticatorListenerTest extends TestCase { private SystemMessengerAuthenticatorListener $object; @@ -50,11 +53,13 @@ public function testConnectSystemAlreadyConnected(): void $this->tokenStorage ->expects(static::once()) ->method('getToken') - ->willReturn($this->createMock(TokenInterface::class)); + ->willReturn($this->createMock(TokenInterface::class)) + ; $this->tokenStorage ->expects(static::never()) - ->method('setToken'); + ->method('setToken') + ; $this->object->connectSystem(); } @@ -64,17 +69,20 @@ public function testConnectSystemNotConnected(): void $this->tokenStorage ->expects(static::once()) ->method('getToken') - ->willReturn(null); + ->willReturn(null) + ; $this->tokenStorage ->expects(static::once()) ->method('setToken') - ->with($token = $this->createMock(TokenInterface::class)); + ->with($token = $this->createMock(TokenInterface::class)) + ; $this->systemAuthenticator ->expects(static::once()) ->method('getTokenForSystem') - ->willReturn($token); + ->willReturn($token) + ; $this->object->connectSystem(); } diff --git a/packages/security/Tests/Core/User/EventDrivenUserCheckerTest.php b/packages/security/Tests/Core/User/EventDrivenUserCheckerTest.php index 9757b5a9f..779def210 100644 --- a/packages/security/Tests/Core/User/EventDrivenUserCheckerTest.php +++ b/packages/security/Tests/Core/User/EventDrivenUserCheckerTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ #[CoversClass(EventDrivenUserChecker::class)] class EventDrivenUserCheckerTest extends TestCase { @@ -44,7 +47,8 @@ public function testCheckPreAuth(): void $this->decoratedUserChecker ->expects(static::once()) ->method('checkPreAuth') - ->with($user); + ->with($user) + ; $this->eventDispatcher ->expects(static::once()) @@ -59,7 +63,8 @@ public function testCheckPreAuth(): void return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->object->checkPreAuth($user); } @@ -71,7 +76,8 @@ public function testCheckPostAuth(): void $this->decoratedUserChecker ->expects(static::once()) ->method('checkPostAuth') - ->with($user); + ->with($user) + ; $this->eventDispatcher ->expects(static::once()) @@ -86,7 +92,8 @@ public function testCheckPostAuth(): void return true; }) ) - ->willReturnArgument(0); + ->willReturnArgument(0) + ; $this->object->checkPostAuth($user); } diff --git a/packages/security/Tests/DependencyInjection/Compiler/UserCheckerDecoratorPassTest.php b/packages/security/Tests/DependencyInjection/Compiler/UserCheckerDecoratorPassTest.php index ac187cf5a..8fcecd194 100644 --- a/packages/security/Tests/DependencyInjection/Compiler/UserCheckerDecoratorPassTest.php +++ b/packages/security/Tests/DependencyInjection/Compiler/UserCheckerDecoratorPassTest.php @@ -10,6 +10,9 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +/** + * @internal + */ #[CoversClass(UserCheckerDecoratorPass::class)] class UserCheckerDecoratorPassTest extends TestCase { diff --git a/packages/security/Tests/DependencyInjection/SecurityIntegrationTest.php b/packages/security/Tests/DependencyInjection/SecurityIntegrationTest.php index 5981a6b4f..9c5786666 100644 --- a/packages/security/Tests/DependencyInjection/SecurityIntegrationTest.php +++ b/packages/security/Tests/DependencyInjection/SecurityIntegrationTest.php @@ -19,6 +19,8 @@ /** * @property SecurityIntegration $integration + * + * @internal */ #[CoversClass(SecurityIntegration::class)] class SecurityIntegrationTest extends IntegrationTestCase @@ -100,7 +102,7 @@ public static function provideTestLoad(): iterable [ SystemConsoleAuthenticatorListener::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertTrue( $definition->getArgument('$systemAutoLogin') ); @@ -128,7 +130,7 @@ function (Definition $definition): void { [ JwtEncoder::class, ], - function (Definition $definition) use ($key): void { + static function (Definition $definition) use ($key): void { static::assertSame( $key, $definition->getArgument('$key') @@ -181,7 +183,7 @@ function (Definition $definition) use ($key): void { [ SystemAuthenticator::class, ], - function (Definition $definition): void { + static function (Definition $definition): void { static::assertSame( ['ROLE_SYSTEM'], $definition->getArgument('$roles') diff --git a/packages/security/Tests/Http/Authenticator/JwtAuthenticatorTest.php b/packages/security/Tests/Http/Authenticator/JwtAuthenticatorTest.php index 047ab5fb8..056ed4765 100644 --- a/packages/security/Tests/Http/Authenticator/JwtAuthenticatorTest.php +++ b/packages/security/Tests/Http/Authenticator/JwtAuthenticatorTest.php @@ -27,6 +27,9 @@ use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken; use Symfony\Contracts\Translation\TranslatorInterface; +/** + * @internal + */ #[CoversClass(JwtAuthenticator::class)] class JwtAuthenticatorTest extends TestCase { @@ -81,7 +84,8 @@ public function testSupportsInvalidToken(): void $this->jwtEncoder ->expects(static::once()) ->method('decode') - ->willThrowException(new \UnexpectedValueException()); + ->willThrowException(new \UnexpectedValueException()) + ; static::assertFalse($this->object->supports($request)); } @@ -98,13 +102,15 @@ public function testGenerateToken(): void $user ->expects(static::once()) ->method(self::$userIdentifierGetter) - ->willReturn($userId = uniqid('id')); + ->willReturn($userId = uniqid('id')) + ; $this->jwtEncoder ->expects(static::once()) ->method('encode') ->with([$this->userIdentifierPayloadKey => $userId], null) - ->willReturn($token = uniqid('token-')); + ->willReturn($token = uniqid('token-')) + ; static::assertSame( $token, @@ -128,13 +134,15 @@ public function testGenerateTokenDefaultNull(): void $user ->expects(static::once()) ->method(self::$userIdentifierGetter) - ->willReturn($userId = uniqid('id')); + ->willReturn($userId = uniqid('id')) + ; $this->jwtEncoder ->expects(static::once()) ->method('encode') ->with([$this->userIdentifierPayloadKey => $userId], null) - ->willReturn($token = uniqid('token-')); + ->willReturn($token = uniqid('token-')) + ; static::assertSame( $token, @@ -151,7 +159,8 @@ public function testGenerateTokenWithExpiration(): void $user ->expects(static::once()) ->method(self::$userIdentifierGetter) - ->willReturn($userId = uniqid('id')); + ->willReturn($userId = uniqid('id')) + ; $this->jwtEncoder ->expects(static::once()) @@ -160,7 +169,8 @@ public function testGenerateTokenWithExpiration(): void [$this->userIdentifierPayloadKey => $userId], static::equalToWithDelta(new \DateTimeImmutable('+ 7 days'), 1) ) - ->willReturn($token = uniqid('token-')); + ->willReturn($token = uniqid('token-')) + ; static::assertSame( $token, @@ -177,7 +187,8 @@ public function testGenerateTokenWithExtraPayload(): void $user ->expects(static::once()) ->method(self::$userIdentifierGetter) - ->willReturn($userId = uniqid('id')); + ->willReturn($userId = uniqid('id')) + ; $extraPayload = [ 'extra-data' => uniqid('value-'), @@ -189,7 +200,8 @@ public function testGenerateTokenWithExtraPayload(): void ->with( [$this->userIdentifierPayloadKey => $userId] + $extraPayload, ) - ->willReturn($token = uniqid('token-')); + ->willReturn($token = uniqid('token-')) + ; static::assertSame( $token, @@ -210,20 +222,23 @@ public function testAuthenticate(): void ->expects(static::any()) ->method('decode') ->with($token) - ->willReturn((object) [$this->userIdentifierPayloadKey => $userId = uniqid('id-')]); + ->willReturn((object) [$this->userIdentifierPayloadKey => $userId = uniqid('id-')]) + ; $user = $this->createMock(UserInterface::class); $user ->expects(static::once()) ->method('getUserIdentifier') - ->willReturn($userId); + ->willReturn($userId) + ; $this->userProvider ->expects(static::once()) ->method('loadUserByIdentifier') ->with($userId) - ->willReturn($user); + ->willReturn($user) + ; $passport = $this->object->authenticate($request); @@ -259,20 +274,23 @@ public function testAuthenticateWithExtraPayload(): void $this->userIdentifierPayloadKey => $userId = uniqid('id-'), $extraKey = uniqid('extra-key-') => $extraValue = uniqid('extra-value-'), ] - ); + ) + ; $user = $this->createMock(UserInterface::class); $user ->expects(static::once()) ->method('getUserIdentifier') - ->willReturn($userId); + ->willReturn($userId) + ; $this->userProvider ->expects(static::once()) ->method('loadUserByIdentifier') ->with($userId) - ->willReturn($user); + ->willReturn($user) + ; $passport = $this->object->authenticate($request); @@ -297,7 +315,8 @@ public function testAuthenticateUserNotFound(): void ->expects(static::any()) ->method('decode') ->with($token) - ->willReturn((object) []); + ->willReturn((object) []) + ; $this->expectException(UserNotFoundException::class); $this->expectExceptionMessage('Token attribute ['.$this->userIdentifierPayloadKey.'] not found'); @@ -314,7 +333,8 @@ public function testAuthenticateInvalidPayload(): void ->expects(static::any()) ->method('decode') ->with($token) - ->willThrowException(new \UnexpectedValueException()); + ->willThrowException(new \UnexpectedValueException()) + ; $this->expectException(\UnexpectedValueException::class); @@ -342,7 +362,8 @@ public function testOnAuthenticationFailure(): void $messageData = ['data' => uniqid()], 'security' ) - ->willReturn($translatedMessage = uniqid('translated-')); + ->willReturn($translatedMessage = uniqid('translated-')) + ; $this->expectException(HttpException::class); $this->expectExceptionMessage($translatedMessage); @@ -376,7 +397,8 @@ public function testOnAuthenticationFailureNoTranslator(): void { $this->translator ->expects(static::never()) - ->method('trans'); + ->method('trans') + ; ReflectionAccessor::setPropertyValue( $this->object, @@ -421,12 +443,14 @@ public function testCreateToken(): void $passport ->expects(static::any()) ->method('getUser') - ->willReturn($user = $this->createMock(UserInterface::class)); + ->willReturn($user = $this->createMock(UserInterface::class)) + ; $user ->expects(static::any()) ->method('getRoles') - ->willReturn($roles = [uniqid('ROLE_')]); + ->willReturn($roles = [uniqid('ROLE_')]) + ; $token = $this->object->createToken( $passport, diff --git a/packages/security/Tests/Http/Authenticator/MessageAuthenticatorTest.php b/packages/security/Tests/Http/Authenticator/MessageAuthenticatorTest.php index 0c9428f0c..6f8cfffc0 100644 --- a/packages/security/Tests/Http/Authenticator/MessageAuthenticatorTest.php +++ b/packages/security/Tests/Http/Authenticator/MessageAuthenticatorTest.php @@ -24,6 +24,9 @@ use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken; +/** + * @internal + */ #[CoversClass(MessageAuthenticator::class)] class MessageAuthenticatorTest extends TestCase { @@ -64,19 +67,22 @@ public function testSupportsNoConnectedUser(): void $this->security ->expects(static::once()) ->method('getUser') - ->willReturn(null); + ->willReturn(null) + ; $this->envelopeFinder ->expects(static::once()) ->method('findById') ->with($messageId) - ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))); + ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))) + ; $this->userProvider ->expects(static::once()) ->method('loadUserByIdentifier') ->with($userIdentifier) - ->willReturn($this->createMock(UserInterface::class)); + ->willReturn($this->createMock(UserInterface::class)) + ; static::assertTrue($this->service->supports($request)); } @@ -89,19 +95,22 @@ public function testSupportsDifferentUser(): void $this->security ->expects(static::once()) ->method('getUser') - ->willReturn($this->createMock(UserInterface::class)); + ->willReturn($this->createMock(UserInterface::class)) + ; $this->envelopeFinder ->expects(static::once()) ->method('findById') ->with($messageId) - ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))); + ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))) + ; $this->userProvider ->expects(static::once()) ->method('loadUserByIdentifier') ->with($userIdentifier) - ->willReturn($this->createMock(UserInterface::class)); + ->willReturn($this->createMock(UserInterface::class)) + ; static::assertTrue($this->service->supports($request)); } @@ -119,19 +128,22 @@ public function testSupportsSameUser(): void $this->security ->expects(static::once()) ->method('getUser') - ->willReturn($user = $this->createMock(UserInterface::class)); + ->willReturn($user = $this->createMock(UserInterface::class)) + ; $this->envelopeFinder ->expects(static::once()) ->method('findById') ->with($messageId) - ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))); + ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))) + ; $this->userProvider ->expects(static::once()) ->method('loadUserByIdentifier') ->with($userIdentifier) - ->willReturn($user); + ->willReturn($user) + ; static::assertFalse($this->service->supports($request)); } @@ -145,7 +157,8 @@ public function testSupportsNoMessage(): void ->expects(static::once()) ->method('findById') ->with($messageId) - ->willThrowException(new MessageNotFoundException($messageId)); + ->willThrowException(new MessageNotFoundException($messageId)) + ; static::assertFalse($this->service->supports($request)); } @@ -159,7 +172,8 @@ public function testAuthenticateNoMessage(): void ->expects(static::once()) ->method('findById') ->with($messageId) - ->willThrowException(new MessageNotFoundException($messageId)); + ->willThrowException(new MessageNotFoundException($messageId)) + ; $this->expectException(CustomUserMessageAuthenticationException::class); $this->expectExceptionMessage('Invalid message id.'); @@ -176,20 +190,23 @@ public function testAuthenticate(): void ->expects(static::once()) ->method('findById') ->with($messageId) - ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))); + ->willReturn(new Envelope($this->createAutoConnectMessage($userIdentifier = uniqid('user-id-')))) + ; $user = $this->createMock(UserInterface::class); $user ->expects(static::once()) ->method('getUserIdentifier') - ->willReturn($userIdentifier); + ->willReturn($userIdentifier) + ; $this->userProvider ->expects(static::once()) ->method('loadUserByIdentifier') ->with($userIdentifier) - ->willReturn($user); + ->willReturn($user) + ; $passport = $this->service->authenticate($request); @@ -243,12 +260,14 @@ public function testCreateToken(): void $passport ->expects(static::any()) ->method('getUser') - ->willReturn($user = $this->createMock(UserInterface::class)); + ->willReturn($user = $this->createMock(UserInterface::class)) + ; $user ->expects(static::any()) ->method('getRoles') - ->willReturn($roles = [uniqid('ROLE_')]); + ->willReturn($roles = [uniqid('ROLE_')]) + ; $token = $this->service->createToken( $passport, @@ -282,7 +301,8 @@ private function createAutoConnectMessage(string $userIdentifier): AutoConnectIn $message->expects(static::any()) ->method('getUserIdentifier') - ->willReturn($userIdentifier); + ->willReturn($userIdentifier) + ; return $message; } diff --git a/packages/security/Tests/Http/Authenticator/Passport/Badge/JwtPayloadBadgeTest.php b/packages/security/Tests/Http/Authenticator/Passport/Badge/JwtPayloadBadgeTest.php index 44aae8a15..9c938f948 100644 --- a/packages/security/Tests/Http/Authenticator/Passport/Badge/JwtPayloadBadgeTest.php +++ b/packages/security/Tests/Http/Authenticator/Passport/Badge/JwtPayloadBadgeTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(JwtPayloadBadge::class)] class JwtPayloadBadgeTest extends TestCase { diff --git a/packages/security/Tests/Http/Authenticator/Passport/Badge/RoleRestrictedBadgeTest.php b/packages/security/Tests/Http/Authenticator/Passport/Badge/RoleRestrictedBadgeTest.php index 356495372..2848b7350 100644 --- a/packages/security/Tests/Http/Authenticator/Passport/Badge/RoleRestrictedBadgeTest.php +++ b/packages/security/Tests/Http/Authenticator/Passport/Badge/RoleRestrictedBadgeTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(RoleRestrictedBadge::class)] class RoleRestrictedBadgeTest extends TestCase { diff --git a/packages/security/Tests/Http/EventListener/RoleRestrictedAuthenticatorListenerTest.php b/packages/security/Tests/Http/EventListener/RoleRestrictedAuthenticatorListenerTest.php index 02c361ba2..090ec290f 100644 --- a/packages/security/Tests/Http/EventListener/RoleRestrictedAuthenticatorListenerTest.php +++ b/packages/security/Tests/Http/EventListener/RoleRestrictedAuthenticatorListenerTest.php @@ -16,6 +16,9 @@ use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; use Symfony\Component\Security\Http\Event\CheckPassportEvent; +/** + * @internal + */ #[CoversClass(RoleRestrictedAuthenticatorListener::class)] class RoleRestrictedAuthenticatorListenerTest extends TestCase { @@ -54,14 +57,17 @@ public function testCheckPassportNoRoleRestrictedBadge(): void { $this->roleHierarchy ->expects(static::never()) - ->method('getReachableRoleNames'); + ->method('getReachableRoleNames') + ; $this->user ->expects(static::never()) - ->method('getRoles'); + ->method('getRoles') + ; $this->service - ->checkPassport($this->createCheckPassportEvent()); + ->checkPassport($this->createCheckPassportEvent()) + ; } public function testCheckPassportRoleDoNotMatch(): void @@ -69,19 +75,22 @@ public function testCheckPassportRoleDoNotMatch(): void $this->user ->expects(static::once()) ->method('getRoles') - ->willReturn($roles = ['ROLE_USER']); + ->willReturn($roles = ['ROLE_USER']) + ; $this->roleHierarchy ->expects(static::once()) ->method('getReachableRoleNames') ->with($roles) - ->willReturn($roles); + ->willReturn($roles) + ; $this->expectException(CustomUserMessageAuthenticationException::class); $this->expectExceptionMessage('Access denied.'); $this->service - ->checkPassport($this->createCheckPassportEvent([new RoleRestrictedBadge(uniqid('ROLE_'))])); + ->checkPassport($this->createCheckPassportEvent([new RoleRestrictedBadge(uniqid('ROLE_'))])) + ; } public function testCheckPassportRoleMatch(): void @@ -89,18 +98,21 @@ public function testCheckPassportRoleMatch(): void $this->user ->expects(static::once()) ->method('getRoles') - ->willReturn($roles = ['ROLE_USER']); + ->willReturn($roles = ['ROLE_USER']) + ; $this->roleHierarchy ->expects(static::once()) ->method('getReachableRoleNames') ->with($roles) - ->willReturn([...$roles, ...[$role = uniqid('ROLE_')]]); + ->willReturn([...$roles, ...[$role = uniqid('ROLE_')]]) + ; $badge = new RoleRestrictedBadge($role); $this->service - ->checkPassport($this->createCheckPassportEvent([$badge])); + ->checkPassport($this->createCheckPassportEvent([$badge])) + ; static::assertTrue($badge->isResolved()); } diff --git a/packages/security/Tests/Jwt/JwtEncoderTest.php b/packages/security/Tests/Jwt/JwtEncoderTest.php index 9bfec2e06..9875d382f 100644 --- a/packages/security/Tests/Jwt/JwtEncoderTest.php +++ b/packages/security/Tests/Jwt/JwtEncoderTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(JwtEncoder::class)] class JwtEncoderTest extends TestCase { diff --git a/packages/sonata-extra-bundle/ActionableAdmin/Action/DeleteAction.php b/packages/sonata-extra-bundle/ActionableAdmin/Action/DeleteAction.php index 25e40e56b..aa576eccc 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/Action/DeleteAction.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/Action/DeleteAction.php @@ -51,10 +51,11 @@ public function __invoke( ) ); }, - 'execution' => function ($object) use ($objectActionExecutioner): void { + 'execution' => static function ($object) use ($objectActionExecutioner): void { $objectActionExecutioner->getAdmin()->delete($object); }, ] - ); + ) + ; } } diff --git a/packages/sonata-extra-bundle/ActionableAdmin/AdminAction.php b/packages/sonata-extra-bundle/ActionableAdmin/AdminAction.php index df788ba84..a763bfe48 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/AdminAction.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/AdminAction.php @@ -36,12 +36,14 @@ public function __construct( $this->access = (new UnicodeString($this->name)) ->snake() ->upper() - ->toString(); + ->toString() + ; $this->urlSuffix = (new UnicodeString($this->name)) ->snake() ->replace('_', '-') - ->toString(); + ->toString() + ; } public function getName(): string diff --git a/packages/sonata-extra-bundle/ActionableAdmin/AdminAction/DeleteAdminAction.php b/packages/sonata-extra-bundle/ActionableAdmin/AdminAction/DeleteAdminAction.php index 92fe684e8..1609100da 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/AdminAction/DeleteAdminAction.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/AdminAction/DeleteAdminAction.php @@ -15,6 +15,7 @@ public function __construct() ->setLabel('execution.action.delete.label') ->setIcon('fas fa-times') ->setController(DeleteAction::class) - ->setTranslationDomain('DrawSonataExtraBundle'); + ->setTranslationDomain('DrawSonataExtraBundle') + ; } } diff --git a/packages/sonata-extra-bundle/ActionableAdmin/AdminActionLoader.php b/packages/sonata-extra-bundle/ActionableAdmin/AdminActionLoader.php index 62de35cf0..0b645f773 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/AdminActionLoader.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/AdminActionLoader.php @@ -29,7 +29,7 @@ public function getActions(AdminInterface $admin): array array_walk( $actions, - function (AdminAction $adminAction) use ($admin): void { + static function (AdminAction $adminAction) use ($admin): void { // Set default translation domain $adminAction->setTranslationDomain($adminAction->getTranslationDomain() ?? $admin->getTranslationDomain()); } diff --git a/packages/sonata-extra-bundle/ActionableAdmin/ExecutionNotifier.php b/packages/sonata-extra-bundle/ActionableAdmin/ExecutionNotifier.php index c6a1b2792..ef8c06558 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/ExecutionNotifier.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/ExecutionNotifier.php @@ -44,7 +44,8 @@ public function notifyExecution(ObjectActionExecutioner $objectActionExecutioner '%count%' => $count, ], 'DrawSonataExtraBundle' - ); + ) + ; $this->notifier->send( (new SonataNotification($subject)) @@ -56,7 +57,7 @@ public function notifyExecution(ObjectActionExecutioner $objectActionExecutioner $skipped = array_filter( $skipped, - fn ($value) => 0 !== $value + static fn ($value) => 0 !== $value ); asort($skipped); @@ -73,7 +74,8 @@ public function notifyExecution(ObjectActionExecutioner $objectActionExecutioner '%reason%' => $this->translator->trans('execution.notification.skipped.reason.'.$reason, [], 'DrawSonataExtraBundle'), ], 'DrawSonataExtraBundle' - ); + ) + ; $this->notifier->send(SonataNotification::info($subject)); } @@ -102,7 +104,8 @@ public function notifyError( '%error%' => $throwable->getMessage(), ], 'DrawSonataExtraBundle' - ); + ) + ; $this->notifier->send(SonataNotification::error($subject)); } @@ -121,7 +124,8 @@ private function getActionLabel(AdminInterface $admin, string $action): string $adminAction->getLabel(), [], $adminAction->getTranslationDomain() - ); + ) + ; } $label ??= $action; diff --git a/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtension.php b/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtension.php index 5dfab8375..e66775ff9 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtension.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtension.php @@ -45,7 +45,8 @@ public function configureRoutes(AdminInterface $admin, RouteCollectionInterface $action->getName(), $pattern, defaults: $defaults - ); + ) + ; } } diff --git a/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtensionInterface.php b/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtensionInterface.php index 4e233351c..2853e65b0 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtensionInterface.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/Extension/ActionableAdminExtensionInterface.php @@ -12,7 +12,8 @@ interface ActionableAdminExtensionInterface { /** - * @param array $actions + * @param array $actions + * * @return array */ public function getActions(array $actions): array; diff --git a/packages/sonata-extra-bundle/ActionableAdmin/GenericFormHandler.php b/packages/sonata-extra-bundle/ActionableAdmin/GenericFormHandler.php index 4ad4176a6..91e405209 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/GenericFormHandler.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/GenericFormHandler.php @@ -31,7 +31,7 @@ public function execute( $previousExecution = $executions['execution']; - $executions['execution'] = function (object $object) use ($objectActionExecutioner, $previousExecution): void { + $executions['execution'] = static function (object $object) use ($objectActionExecutioner, $previousExecution): void { $previousExecution($object, $objectActionExecutioner->options['form.data']); }; @@ -68,7 +68,8 @@ public function execute( : $form->getData(); return $objectActionExecutioner - ->execute($executions); + ->execute($executions) + ; } /** @@ -97,7 +98,8 @@ private function getForm( return $this->formFactory ->createBuilder($formClass, $data) ->setAction($admin->generateObjectUrl($action, $objectActionExecutioner->getSubject())) - ->getForm(); + ->getForm() + ; } $formBuilder = $this->formFactory @@ -126,7 +128,8 @@ private function getForm( [ 'data' => 'ok', ] - ); + ) + ; if ($this->csrfTokenManager) { $formBuilder->add( diff --git a/packages/sonata-extra-bundle/ActionableAdmin/ObjectActionExecutioner.php b/packages/sonata-extra-bundle/ActionableAdmin/ObjectActionExecutioner.php index 99e8179a2..be767a649 100644 --- a/packages/sonata-extra-bundle/ActionableAdmin/ObjectActionExecutioner.php +++ b/packages/sonata-extra-bundle/ActionableAdmin/ObjectActionExecutioner.php @@ -107,7 +107,8 @@ public function getTotalCount(): int $this->totalCount = (clone $this->target) ->select('COUNT(o.id)') ->getQuery() - ->getSingleScalarResult(); + ->getSingleScalarResult() + ; } return $this->totalCount; diff --git a/packages/sonata-extra-bundle/Block/MonitoringBlockService.php b/packages/sonata-extra-bundle/Block/MonitoringBlockService.php index b333eb4d0..4515a5555 100644 --- a/packages/sonata-extra-bundle/Block/MonitoringBlockService.php +++ b/packages/sonata-extra-bundle/Block/MonitoringBlockService.php @@ -51,7 +51,8 @@ public function configureSettings(OptionsResolver $resolver): void ], ], ] - ); + ) + ; } public function execute(BlockContextInterface $blockContext, ?Response $response = null): Response @@ -84,7 +85,8 @@ public function execute(BlockContextInterface $blockContext, ?Response $response ) ) ->setPrivate() - ->setTtl(0); + ->setTtl(0) + ; } private function findThresholdSetting(array $thresholds, ?int $count): array diff --git a/packages/sonata-extra-bundle/Configuration/SonataAdminNodeConfiguration.php b/packages/sonata-extra-bundle/Configuration/SonataAdminNodeConfiguration.php index 4b1a96e4d..aa8ac2d94 100644 --- a/packages/sonata-extra-bundle/Configuration/SonataAdminNodeConfiguration.php +++ b/packages/sonata-extra-bundle/Configuration/SonataAdminNodeConfiguration.php @@ -26,7 +26,8 @@ public function __construct( ->scalarNode('translation_domain')->defaultValue('SonataAdminBundle')->end() ->scalarNode('show_in_dashboard')->defaultTrue()->end() ->enumNode('pager_type')->values(['default', 'simple'])->defaultValue('default')->end() - ->end(); + ->end() + ; } public function labelDefaultValue(?string $value): self @@ -74,8 +75,9 @@ public static function configureFromConfiguration(Definition $definition, array $config, array_flip(['group', 'icon', 'label', 'pager_type', 'show_in_dashboard', 'translation_domain']) ) + ['manager_type' => 'orm', 'model_class' => $config['entity_class'], 'controller' => $config['controller_class']], - fn ($value) => null !== $value + static fn ($value) => null !== $value ) - ); + ) + ; } } diff --git a/packages/sonata-extra-bundle/Controller/BatchAdminController.php b/packages/sonata-extra-bundle/Controller/BatchAdminController.php index b18df6ad1..9d410b0e9 100644 --- a/packages/sonata-extra-bundle/Controller/BatchAdminController.php +++ b/packages/sonata-extra-bundle/Controller/BatchAdminController.php @@ -155,7 +155,8 @@ private function getBatchActionExecutable(string $action): callable // This is to trigger an exception if the controller is not found $this->container ->get('controller_resolver') - ->getController(new Request([], [], ['_controller' => $controller])); + ->getController(new Request([], [], ['_controller' => $controller])) + ; return function (ProxyQueryInterface $query, Request $request) use ($controller) { $request->attributes->set('_controller', $controller); diff --git a/packages/sonata-extra-bundle/Controller/ControllerTrait.php b/packages/sonata-extra-bundle/Controller/ControllerTrait.php index cdf964cff..07e28dff0 100644 --- a/packages/sonata-extra-bundle/Controller/ControllerTrait.php +++ b/packages/sonata-extra-bundle/Controller/ControllerTrait.php @@ -72,7 +72,8 @@ protected function validateCsrfToken(Request $request, string $intention): void } $valid = $this->container->get('security.csrf.token_manager') - ->isTokenValid(new CsrfToken($intention, $request->get('_sonata_csrf_token'))); + ->isTokenValid(new CsrfToken($intention, $request->get('_sonata_csrf_token'))) + ; if (!$valid) { throw new HttpException(Response::HTTP_BAD_REQUEST, 'The csrf token is not valid, CSRF attack?'); @@ -101,7 +102,8 @@ protected function getBaseTemplate(): string return $this->admin ->getTemplateRegistry() - ->getTemplate($this->isXmlHttpRequest($request) ? 'ajax' : 'layout'); + ->getTemplate($this->isXmlHttpRequest($request) ? 'ajax' : 'layout') + ; } final protected function trans( @@ -116,7 +118,8 @@ final protected function trans( $parameters, $domain ?? $this->admin->getTranslationDomain(), $locale - ); + ) + ; } final protected function redirectToList(): RedirectResponse @@ -141,7 +144,8 @@ final protected function setFormTheme(FormView $formView, ?array $theme = null): $this->container ->get('twig') ->getRuntime(FormRenderer::class) - ->setTheme($formView, $theme); + ->setTheme($formView, $theme) + ; } final protected function renderWithExtraParams( diff --git a/packages/sonata-extra-bundle/DependencyInjection/Compiler/AutoConfigureSubClassesCompilerClass.php b/packages/sonata-extra-bundle/DependencyInjection/Compiler/AutoConfigureSubClassesCompilerClass.php index 0b03bd74c..623350785 100644 --- a/packages/sonata-extra-bundle/DependencyInjection/Compiler/AutoConfigureSubClassesCompilerClass.php +++ b/packages/sonata-extra-bundle/DependencyInjection/Compiler/AutoConfigureSubClassesCompilerClass.php @@ -22,7 +22,8 @@ public function process(ContainerBuilder $container): void $container ->getDefinition($serviceId) - ->addMethodCall('setSubClasses', [$subClasses]); + ->addMethodCall('setSubClasses', [$subClasses]) + ; foreach (array_unique($subClasses) as $subClass) { $adminClasses[$subClass][] = $serviceId; diff --git a/packages/sonata-extra-bundle/DependencyInjection/Compiler/DecoratesCompilerPass.php b/packages/sonata-extra-bundle/DependencyInjection/Compiler/DecoratesCompilerPass.php index c169da820..851344a47 100644 --- a/packages/sonata-extra-bundle/DependencyInjection/Compiler/DecoratesCompilerPass.php +++ b/packages/sonata-extra-bundle/DependencyInjection/Compiler/DecoratesCompilerPass.php @@ -20,7 +20,8 @@ public function process(ContainerBuilder $container): void ->setDecoratedService('sonata.admin.builder.orm_form', 'sonata.admin.builder.orm_form.inner') ->setArgument('$decoratedFormContractor', new Reference('sonata.admin.builder.orm_form.inner')) ->setAutoconfigured(true) - ->setAutowired(true); + ->setAutowired(true) + ; $container->setDefinition( 'draw.sonata.admin.field_description_factory.orm', @@ -29,6 +30,7 @@ public function process(ContainerBuilder $container): void ->setDecoratedService('sonata.admin.field_description_factory.orm', 'sonata.admin.field_description_factory.orm.inner') ->setArgument('$decorated', new Reference('sonata.admin.field_description_factory.orm.inner')) ->setAutoconfigured(true) - ->setAutowired(true); + ->setAutowired(true) + ; } } diff --git a/packages/sonata-extra-bundle/DependencyInjection/Configuration.php b/packages/sonata-extra-bundle/DependencyInjection/Configuration.php index d273b3c1c..e024cc29f 100755 --- a/packages/sonata-extra-bundle/DependencyInjection/Configuration.php +++ b/packages/sonata-extra-bundle/DependencyInjection/Configuration.php @@ -28,7 +28,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->append($this->createNotifierNode()) ->append($this->createPreventDeleteExtensionNode()) ->append($this->createSessionTimeoutNode()) - ->end(); + ->end() + ; return $treeBuilder; } @@ -36,7 +37,8 @@ public function getConfigTreeBuilder(): TreeBuilder private function createAutoHelpNode(): ArrayNodeDefinition { return (new ArrayNodeDefinition('auto_help')) - ->canBeEnabled(); + ->canBeEnabled() + ; } private function createBatchDeleteCheckNode(): ArrayNodeDefinition @@ -53,7 +55,8 @@ class_exists(PreObjectDeleteBatchEvent::class) private function createNotifierNode(): ArrayNodeDefinition { return (new ArrayNodeDefinition('notifier')) - ->canBeEnabled(); + ->canBeEnabled() + ; } private function createPreventDeleteExtensionNode(): ArrayNodeDefinition @@ -62,13 +65,15 @@ private function createPreventDeleteExtensionNode(): ArrayNodeDefinition ->canBeEnabled() ->children() ->scalarNode('restrict_to_role')->defaultNull()->end() - ->end(); + ->end() + ; } private function createActionableAdminNode(): ArrayNodeDefinition { return (new ArrayNodeDefinition('actionable_admin')) - ->canBeEnabled(); + ->canBeEnabled() + ; } private function createAutoActionNode(): ArrayNodeDefinition @@ -86,7 +91,8 @@ private function createAutoActionNode(): ArrayNodeDefinition ->ignoreExtraKeys(false) ->end() ->end() - ->end(); + ->end() + ; } private function createCanSecurityHandlerNode(): ArrayNodeDefinition @@ -103,7 +109,7 @@ private function createCanSecurityHandlerNode(): ArrayNodeDefinition ->booleanNode('prevent_delete_from_all_relations')->defaultFalse()->end() ->arrayNode('entities') ->beforeNormalization() - ->always(function ($config) { + ->always(static function ($config) { foreach (array_keys($config) as $class) { $config[$class]['class'] = $class; } @@ -134,13 +140,15 @@ private function createCanSecurityHandlerNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createFixMenuDepthNode(): ArrayNodeDefinition { return (new ArrayNodeDefinition('fix_menu_depth')) - ->canBeEnabled(); + ->canBeEnabled() + ; } private function createListFieldPriorityNode(): ArrayNodeDefinition @@ -151,7 +159,7 @@ private function createListFieldPriorityNode(): ArrayNodeDefinition ->integerNode('default_max_field')->defaultNull()->end() ->arrayNode('default_field_priorities') ->beforeNormalization() - ->always(function ($config) { + ->always(static function ($config) { foreach ($config as $name => $configuration) { if (!\is_array($configuration)) { $config[$name] = [ @@ -174,7 +182,8 @@ private function createListFieldPriorityNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createSessionTimeoutNode(): ArrayNodeDefinition @@ -183,6 +192,7 @@ private function createSessionTimeoutNode(): ArrayNodeDefinition ->canBeEnabled() ->children() ->integerNode('delay')->defaultValue(3600)->end() - ->end(); + ->end() + ; } } diff --git a/packages/sonata-extra-bundle/DependencyInjection/DrawSonataExtraExtension.php b/packages/sonata-extra-bundle/DependencyInjection/DrawSonataExtraExtension.php index 87e57df91..e535b8236 100644 --- a/packages/sonata-extra-bundle/DependencyInjection/DrawSonataExtraExtension.php +++ b/packages/sonata-extra-bundle/DependencyInjection/DrawSonataExtraExtension.php @@ -51,7 +51,8 @@ public function load(array $configs, ContainerBuilder $container): void $container ->getDefinition(AutoActionExtension::class) ->setArgument('$ignoreAdmins', $config['auto_action']['ignore_admins']) - ->setArgument('$actions', $config['auto_action']['actions']); + ->setArgument('$actions', $config['auto_action']['actions']) + ; } if (!($config['auto_help']['enabled'] ?? false)) { @@ -71,7 +72,8 @@ public function load(array $configs, ContainerBuilder $container): void } else { $container ->getDefinition(PreventDeleteExtension::class) - ->setArgument('$restrictToRole', $config['prevent_delete_extension']['restrict_to_role']); + ->setArgument('$restrictToRole', $config['prevent_delete_extension']['restrict_to_role']) + ; } if (!($config['notifier']['enabled'] ?? false)) { @@ -105,10 +107,12 @@ public function load(array $configs, ContainerBuilder $container): void ->setArgument( '$preventDeleteFromAllRelations', $config['can_security_handler']['prevent_delete_voter']['prevent_delete_from_all_relations'] - ); + ) + ; if (!$config['can_security_handler']['prevent_delete_voter']['use_cache']) { $container->getDefinition(PreventDeleteRelationLoader::class) - ->setArgument('$cacheDirectory', null); + ->setArgument('$cacheDirectory', null) + ; } } } @@ -127,7 +131,8 @@ public function load(array $configs, ContainerBuilder $container): void ->setArguments([ '$defaultMaxField' => $config['list_field_priority']['default_max_field'], '$defaultFieldPriorities' => $defaultFieldPriorities, - ]); + ]) + ; } if (!($config['session_timeout']['enabled'] ?? false)) { @@ -135,7 +140,8 @@ public function load(array $configs, ContainerBuilder $container): void } else { $container ->getDefinition(SessionTimeoutRequestListener::class) - ->setArgument('$delay', $config['session_timeout']['delay']); + ->setArgument('$delay', $config['session_timeout']['delay']) + ; } $container->removeDefinition(FinalizeContextEvent::class); @@ -161,7 +167,7 @@ private function loadActionableAdmin(array $config, ContainerBuilder $container) $this->registerClasses( $loader, - 'Draw\\Bundle\\SonataExtraBundle\\ActionableAdmin\\', + 'Draw\Bundle\SonataExtraBundle\ActionableAdmin\\', \dirname((new \ReflectionClass(AdminAction::class))->getFileName()), ); } diff --git a/packages/sonata-extra-bundle/EventListener/PreObjectDeleteBatchEventEventListener.php b/packages/sonata-extra-bundle/EventListener/PreObjectDeleteBatchEventEventListener.php index 3b7be2cb0..73356e80a 100644 --- a/packages/sonata-extra-bundle/EventListener/PreObjectDeleteBatchEventEventListener.php +++ b/packages/sonata-extra-bundle/EventListener/PreObjectDeleteBatchEventEventListener.php @@ -17,7 +17,8 @@ public function handlePreObjectDeleteBatchEvent(PreObjectDeleteBatchEvent $event { $canDelete = $this->pool ->getAdminByClass($event->getClassName()) - ->hasAccess('delete', $event->getObject()); + ->hasAccess('delete', $event->getObject()) + ; if (!$canDelete) { $event->preventDelete(); diff --git a/packages/sonata-extra-bundle/Extension/BatchActionExtension.php b/packages/sonata-extra-bundle/Extension/BatchActionExtension.php index 72a54e2af..8d1de6601 100644 --- a/packages/sonata-extra-bundle/Extension/BatchActionExtension.php +++ b/packages/sonata-extra-bundle/Extension/BatchActionExtension.php @@ -18,7 +18,8 @@ public function configureRoutes(AdminInterface $admin, RouteCollectionInterface $collection ->get('batch') - ->setDefault('_controller', BatchAdminController::class.'::batchAction'); + ->setDefault('_controller', BatchAdminController::class.'::batchAction') + ; } public function configureBatchActions(AdminInterface $admin, array $actions): array diff --git a/packages/sonata-extra-bundle/Extension/DoctrineInheritanceExtension.php b/packages/sonata-extra-bundle/Extension/DoctrineInheritanceExtension.php index 2dd8c1c31..3ab91193d 100644 --- a/packages/sonata-extra-bundle/Extension/DoctrineInheritanceExtension.php +++ b/packages/sonata-extra-bundle/Extension/DoctrineInheritanceExtension.php @@ -51,7 +51,7 @@ private function getFilteredClass(AdminInterface $admin): ?string continue; } - if (!\in_array($data['value'], $subClasses)) { + if (!\in_array($data['value'], $subClasses, true)) { continue; } @@ -86,7 +86,7 @@ private function filterOut(ListMapper|DatagridMapper $mapper): void $forClasses = [$forClasses]; } - if (!\in_array($subClass, $forClasses)) { + if (!\in_array($subClass, $forClasses, true)) { $mapper->remove($key); } } diff --git a/packages/sonata-extra-bundle/Extension/GridExtension.php b/packages/sonata-extra-bundle/Extension/GridExtension.php index 78364ce78..7e886a0d1 100644 --- a/packages/sonata-extra-bundle/Extension/GridExtension.php +++ b/packages/sonata-extra-bundle/Extension/GridExtension.php @@ -66,7 +66,7 @@ private function configureGrid(FieldDescriptionInterface $field, AdminInterface ); } - if (\in_array($fields[$key]->getType(), static::VIRTUAL_FIELD_TYPES)) { + if (\in_array($fields[$key]->getType(), static::VIRTUAL_FIELD_TYPES, true)) { $fields[$key]->setOption('virtual_field', true); } } diff --git a/packages/sonata-extra-bundle/Extension/ListFieldPriorityExtension.php b/packages/sonata-extra-bundle/Extension/ListFieldPriorityExtension.php index 0a563955e..0e9c3a5e5 100644 --- a/packages/sonata-extra-bundle/Extension/ListFieldPriorityExtension.php +++ b/packages/sonata-extra-bundle/Extension/ListFieldPriorityExtension.php @@ -26,7 +26,8 @@ private function getOptions(AdminInterface $admin): array 'defaultMaxField' => $this->defaultMaxField, 'defaultFieldPriorities' => [], ]) - ->resolve($options); + ->resolve($options) + ; } public function configureListFields(ListMapper $list): void diff --git a/packages/sonata-extra-bundle/FieldDescriptionFactory/SubClassFieldDescriptionFactory.php b/packages/sonata-extra-bundle/FieldDescriptionFactory/SubClassFieldDescriptionFactory.php index 99345a452..861730b63 100644 --- a/packages/sonata-extra-bundle/FieldDescriptionFactory/SubClassFieldDescriptionFactory.php +++ b/packages/sonata-extra-bundle/FieldDescriptionFactory/SubClassFieldDescriptionFactory.php @@ -30,7 +30,8 @@ public function create(string $class, string $name, array $options = []): FieldD } return $this->decorated - ->create($options['forClasses'][0] ?? $class, $name, $options); + ->create($options['forClasses'][0] ?? $class, $name, $options) + ; } private function getForClasses(ClassMetadataInfo $classMetadata, string $fieldName): ?array @@ -45,7 +46,8 @@ private function getForClasses(ClassMetadataInfo $classMetadata, string $fieldNa foreach ($classMetadata->subClasses as $subClass) { $subClassMetadata = $this->managerRegistry ->getManagerForClass($subClass) - ->getClassMetadata($subClass); + ->getClassMetadata($subClass) + ; \assert($subClassMetadata instanceof ClassMetadataInfo); diff --git a/packages/sonata-extra-bundle/PreventDelete/Extension/PreventDeleteExtension.php b/packages/sonata-extra-bundle/PreventDelete/Extension/PreventDeleteExtension.php index 46b98d385..9677f6d66 100644 --- a/packages/sonata-extra-bundle/PreventDelete/Extension/PreventDeleteExtension.php +++ b/packages/sonata-extra-bundle/PreventDelete/Extension/PreventDeleteExtension.php @@ -59,7 +59,8 @@ public function configureShowFields(ShowMapper $show): void } $show - ->tab('prevent_deletions'); + ->tab('prevent_deletions') + ; $configurationPool = $admin->getConfigurationPool(); @@ -118,11 +119,13 @@ public function configureShowFields(ShowMapper $show): void 'has_more' => $hasMore, ] ) - ->end(); + ->end() + ; } $show - ->end(); + ->end() + ; } private function getFilterParameters( diff --git a/packages/sonata-extra-bundle/PreventDelete/PreventDelete.php b/packages/sonata-extra-bundle/PreventDelete/PreventDelete.php index a9ce1ad5c..8b237eb8e 100644 --- a/packages/sonata-extra-bundle/PreventDelete/PreventDelete.php +++ b/packages/sonata-extra-bundle/PreventDelete/PreventDelete.php @@ -77,7 +77,8 @@ public function exists(ManagerRegistry $managerRegistry, object $subject): bool $query = $this->createQueryBuilder($managerRegistry, $subject) ->select('1') ->setMaxResults(1) - ->getQuery(); + ->getQuery() + ; if (class_exists(CommentSqlWalker::class)) { CommentSqlWalker::addComment( @@ -100,7 +101,8 @@ public function getEntities(ManagerRegistry $managerRegistry, object $subject, i ->select('DISTINCT(root)') ->setMaxResults($limit) ->getQuery() - ->execute(); + ->execute() + ; if (!$ids) { return $ids; @@ -112,7 +114,8 @@ public function getEntities(ManagerRegistry $managerRegistry, object $subject, i $idField = $entityManager ->getClassMetadata($this->getRelatedClass()) - ->getIdentifierFieldNames()[0]; + ->getIdentifierFieldNames()[0] + ; return $entityManager ->createQueryBuilder() @@ -121,7 +124,8 @@ public function getEntities(ManagerRegistry $managerRegistry, object $subject, i ->andWhere('root.'.$idField.' IN (:ids)') ->setParameter('ids', $ids) ->getQuery() - ->execute(); + ->execute() + ; } private function createQueryBuilder(ManagerRegistry $managerRegistry, object $subject): QueryBuilder @@ -133,7 +137,8 @@ private function createQueryBuilder(ManagerRegistry $managerRegistry, object $su $paths = explode('.', $this->getPath()); $queryBuilder = $entityManager->createQueryBuilder() - ->from($this->getRelatedClass(), 'root'); + ->from($this->getRelatedClass(), 'root') + ; $nextAlias = 'root'; foreach ($paths as $index => $path) { @@ -143,7 +148,8 @@ private function createQueryBuilder(ManagerRegistry $managerRegistry, object $su $queryBuilder ->andWhere('path_'.(\count($paths) - 1).' = :subject') - ->setParameter('subject', $subject); + ->setParameter('subject', $subject) + ; return $queryBuilder; } diff --git a/packages/sonata-extra-bundle/PreventDelete/PreventDeleteRelationLoader.php b/packages/sonata-extra-bundle/PreventDelete/PreventDeleteRelationLoader.php index 26b629039..d0bd171e1 100644 --- a/packages/sonata-extra-bundle/PreventDelete/PreventDeleteRelationLoader.php +++ b/packages/sonata-extra-bundle/PreventDelete/PreventDeleteRelationLoader.php @@ -195,7 +195,8 @@ private function preventDeleteFromPropertyAttribute(array $associationMapping): $associationMapping['sourceEntity'], $associationMapping['fieldName'] )) - ->getAttributes(PreventDelete::class, \ReflectionAttribute::IS_INSTANCEOF); + ->getAttributes(PreventDelete::class, \ReflectionAttribute::IS_INSTANCEOF) + ; if (\count($attributes) > 1) { throw new \LogicException('Only one PreventDelete attribute is allowed per property. Repeatable is only allowed on class.'); diff --git a/packages/sonata-extra-bundle/PreventDelete/Security/Voter/PreventDeleteVoter.php b/packages/sonata-extra-bundle/PreventDelete/Security/Voter/PreventDeleteVoter.php index cf373c078..58d2f4c17 100644 --- a/packages/sonata-extra-bundle/PreventDelete/Security/Voter/PreventDeleteVoter.php +++ b/packages/sonata-extra-bundle/PreventDelete/Security/Voter/PreventDeleteVoter.php @@ -21,7 +21,7 @@ public function vote(TokenInterface $token, $subject, array $attributes): int return VoterInterface::ACCESS_ABSTAIN; } - if (!\in_array('SONATA_CAN_DELETE', $attributes)) { + if (!\in_array('SONATA_CAN_DELETE', $attributes, true)) { return VoterInterface::ACCESS_ABSTAIN; } diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/Compiler/DecorateCompilerPassTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/Compiler/DecorateCompilerPassTest.php index 028392336..2fb0ac2b5 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/Compiler/DecorateCompilerPassTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/Compiler/DecorateCompilerPassTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; +/** + * @internal + */ class DecorateCompilerPassTest extends TestCase { private DecoratesCompilerPass $compilerPass; diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php index 85402f3bd..70992e87e 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/ConfigurationTest.php @@ -7,6 +7,9 @@ use Draw\Component\Tester\Test\DependencyInjection\ConfigurationTestCase; use Symfony\Component\Config\Definition\ConfigurationInterface; +/** + * @internal + */ class ConfigurationTest extends ConfigurationTestCase { public function createConfiguration(): ConfigurationInterface diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoActionEnabledTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoActionEnabledTest.php index ccbbc5b04..e70abbe76 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoActionEnabledTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoActionEnabledTest.php @@ -6,6 +6,9 @@ use Draw\Bundle\SonataExtraBundle\Extension\AutoActionExtension; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawSonataExtraExtensionAutoActionEnabledTest extends DrawSonataExtraExtensionTest { public function createExtension(): Extension diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoHelpEnabledTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoHelpEnabledTest.php index 775679e83..9cfca96ff 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoHelpEnabledTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionAutoHelpEnabledTest.php @@ -6,6 +6,9 @@ use Draw\Bundle\SonataExtraBundle\EventListener\AutoHelpListener; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawSonataExtraExtensionAutoHelpEnabledTest extends DrawSonataExtraExtensionTest { public function createExtension(): Extension diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionBatchDeleteCheckEnabledTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionBatchDeleteCheckEnabledTest.php index dce9ad9ef..a9f38a181 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionBatchDeleteCheckEnabledTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionBatchDeleteCheckEnabledTest.php @@ -7,6 +7,9 @@ use Draw\Bundle\SonataExtraBundle\Tests\DependencyInjection\DrawSonataExtraExtensionTest; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawSonataExtraExtensionBatchDeleteCheckEnabledTest extends DrawSonataExtraExtensionTest { public function createExtension(): Extension diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionCanSecurityHandlerEnabledTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionCanSecurityHandlerEnabledTest.php index 324536559..6e7deb675 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionCanSecurityHandlerEnabledTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionCanSecurityHandlerEnabledTest.php @@ -9,6 +9,9 @@ use Draw\Bundle\SonataExtraBundle\Security\Voter\DefaultCanVoter; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawSonataExtraExtensionCanSecurityHandlerEnabledTest extends DrawSonataExtraExtensionTest { public function createExtension(): Extension diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionFixMenuDeptEnabledTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionFixMenuDeptEnabledTest.php index 1a4cc5ecd..d7b82f841 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionFixMenuDeptEnabledTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionFixMenuDeptEnabledTest.php @@ -6,6 +6,9 @@ use Draw\Bundle\SonataExtraBundle\EventListener\FixDepthMenuBuilderListener; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawSonataExtraExtensionFixMenuDeptEnabledTest extends DrawSonataExtraExtensionTest { public function createExtension(): Extension diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionNotifierEnabledTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionNotifierEnabledTest.php index b3586848d..4d712ee11 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionNotifierEnabledTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionNotifierEnabledTest.php @@ -7,6 +7,9 @@ use Draw\Bundle\SonataExtraBundle\Tests\DependencyInjection\DrawSonataExtraExtensionTest; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawSonataExtraExtensionNotifierEnabledTest extends DrawSonataExtraExtensionTest { public function createExtension(): Extension diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionSessionTimeoutEnabledTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionSessionTimeoutEnabledTest.php index 8b6ebed59..a6b1f6632 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionSessionTimeoutEnabledTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionSessionTimeoutEnabledTest.php @@ -6,6 +6,9 @@ use Draw\Bundle\SonataExtraBundle\EventListener\SessionTimeoutRequestListener; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawSonataExtraExtensionSessionTimeoutEnabledTest extends DrawSonataExtraExtensionTest { public function createExtension(): Extension diff --git a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionTest.php b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionTest.php index e7bc7cbf9..82cf11a65 100644 --- a/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionTest.php +++ b/packages/sonata-extra-bundle/Tests/DependencyInjection/DrawSonataExtraExtensionTest.php @@ -25,6 +25,8 @@ /** * @method DrawSonataExtraExtension getExtension() + * + * @internal */ class DrawSonataExtraExtensionTest extends ExtensionTestCase { @@ -70,7 +72,8 @@ public function testPrepend(): void $this->getExtension()->prepend($containerBuilder); $result = $containerBuilder - ->getExtensionConfig('twig'); + ->getExtensionConfig('twig') + ; static::assertSame( [ @@ -84,7 +87,8 @@ public function testPrepend(): void ); $result = $containerBuilder - ->getExtensionConfig('sonata_doctrine_orm_admin'); + ->getExtensionConfig('sonata_doctrine_orm_admin') + ; static::assertSame( [ @@ -109,7 +113,8 @@ public function testPrepend(): void ); $result = $containerBuilder - ->getExtensionConfig('sonata_admin'); + ->getExtensionConfig('sonata_admin') + ; static::assertSame( [ diff --git a/packages/sonata-extra-bundle/Tests/EventListener/SessionTimeoutRequestListenerTest.php b/packages/sonata-extra-bundle/Tests/EventListener/SessionTimeoutRequestListenerTest.php index b9836a672..f1a49d7ef 100644 --- a/packages/sonata-extra-bundle/Tests/EventListener/SessionTimeoutRequestListenerTest.php +++ b/packages/sonata-extra-bundle/Tests/EventListener/SessionTimeoutRequestListenerTest.php @@ -23,6 +23,9 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\User\UserInterface; +/** + * @internal + */ #[CoversClass(SessionTimeoutRequestListener::class)] class SessionTimeoutRequestListenerTest extends TestCase { @@ -79,10 +82,12 @@ public function testOnKernelRequestInvalidate(): void $session->expects(static::once()) ->method('get') ->with('draw_sonata_integration_last_used') - ->willReturn(time() - 3601); + ->willReturn(time() - 3601) + ; $session->expects(static::once()) - ->method('invalidate'); + ->method('invalidate') + ; $this->object->onKernelRequestInvalidate($requestEvent); } @@ -255,7 +260,8 @@ public function testOnKernelResponseAddDialog(): void $this->security->expects(static::once()) ->method('getUser') - ->willReturn($this->createMock(UserInterface::class)); + ->willReturn($this->createMock(UserInterface::class)) + ; $this->urlGenerator->expects(static::exactly(2)) ->method('generate') @@ -268,7 +274,8 @@ public function testOnKernelResponseAddDialog(): void ->willReturnOnConsecutiveCalls( '/admin/keep-alive', '/admin/login' - ); + ) + ; $this->object->onKernelResponseAddDialog($event); @@ -367,10 +374,12 @@ public function testOnKernelResponseAddDialogNoInjection( ): void { $this->security->expects(static::once()) ->method('getUser') - ->willReturn($user); + ->willReturn($user) + ; $this->urlGenerator->expects(static::never()) - ->method('generate'); + ->method('generate') + ; $previousContent = $response->getContent(); diff --git a/packages/sonata-extra-bundle/Tests/PreventDeletion/Extension/PreventDeleteExtensionTest.php b/packages/sonata-extra-bundle/Tests/PreventDeletion/Extension/PreventDeleteExtensionTest.php index 322ca7e32..4c4bef32e 100644 --- a/packages/sonata-extra-bundle/Tests/PreventDeletion/Extension/PreventDeleteExtensionTest.php +++ b/packages/sonata-extra-bundle/Tests/PreventDeletion/Extension/PreventDeleteExtensionTest.php @@ -14,6 +14,9 @@ use Sonata\AdminBundle\FieldDescription\FieldDescriptionCollection; use Sonata\AdminBundle\Show\ShowMapper; +/** + * @internal + */ class PreventDeleteExtensionTest extends TestCase { private PreventDeleteExtension $object; @@ -43,11 +46,13 @@ public function testConfigureShowFieldsNoAccess(): void ->expects(static::once()) ->method('isGranted') ->with('ROLE_ADMIN') - ->willReturn(false); + ->willReturn(false) + ; $this->preventDeleteRelationLoader ->expects(static::never()) - ->method('getRelationsForObject'); + ->method('getRelationsForObject') + ; $showMapper = new ShowMapper( $this->createMock(ShowBuilderInterface::class), diff --git a/packages/sonata-import-bundle/Admin/ColumnAdmin.php b/packages/sonata-import-bundle/Admin/ColumnAdmin.php index 261be5c11..a7e06a3a8 100644 --- a/packages/sonata-import-bundle/Admin/ColumnAdmin.php +++ b/packages/sonata-import-bundle/Admin/ColumnAdmin.php @@ -59,7 +59,8 @@ protected function configureFormFields(FormMapper $form): void ) ->add('isIdentifier') ->add('isDate') - ->add('isIgnored'); + ->add('isIgnored') + ; } private function loadMappedToOptions(Column $column): array diff --git a/packages/sonata-import-bundle/Admin/ImportAdmin.php b/packages/sonata-import-bundle/Admin/ImportAdmin.php index 4cb3066d7..22ec32ea3 100644 --- a/packages/sonata-import-bundle/Admin/ImportAdmin.php +++ b/packages/sonata-import-bundle/Admin/ImportAdmin.php @@ -78,7 +78,8 @@ private function processFileUpload(Import $import, ?UploadedFile $file = null): } $this->importer - ->buildFromFile($import, $file); + ->buildFromFile($import, $file) + ; } public function configureListFields(ListMapper $list): void @@ -95,7 +96,8 @@ public function configureListFields(ListMapper $list): void ) ->add('insertWhenNotFound') ->add('state') - ->add('createdAt'); + ->add('createdAt') + ; } public function configureFormFields(FormMapper $form): void @@ -166,7 +168,8 @@ public function configureFormFields(FormMapper $form): void 'attr' => ['disabled' => true], ] ) - ->ifEnd(); + ->ifEnd() + ; } private function getEntityClassChoices(): array diff --git a/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractor.php b/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractor.php index 9eac072a9..dd47a6ece 100644 --- a/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractor.php +++ b/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractor.php @@ -33,7 +33,8 @@ public function getOptions(Column $column, array $options): array $targetClassMetadata = $this->managerRegistry ->getManagerForClass($associationMapping['targetEntity']) - ->getClassMetadata($associationMapping['targetEntity']); + ->getClassMetadata($associationMapping['targetEntity']) + ; if (!$targetClassMetadata instanceof ClassMetadata) { continue; @@ -54,7 +55,7 @@ public function getOptions(Column $column, array $options): array #[\Override] public function assign(object $object, Column $column, mixed $value): bool { - if (!\in_array($column->getMappedTo(), $this->getOptions($column, []))) { + if (!\in_array($column->getMappedTo(), $this->getOptions($column, []), true)) { return false; } @@ -62,7 +63,8 @@ public function assign(object $object, Column $column, mixed $value): bool $classMetadata = $this->managerRegistry ->getManagerForClass($class) - ->getClassMetadata($class); + ->getClassMetadata($class) + ; \assert($classMetadata instanceof ClassMetadata); @@ -72,7 +74,8 @@ public function assign(object $object, Column $column, mixed $value): bool $targetEntity = $this->managerRegistry ->getRepository($targetEntityClass) - ->findOneBy([$field => $value]); + ->findOneBy([$field => $value]) + ; if (null === $targetEntity) { return false; diff --git a/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractor.php b/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractor.php index 241f70903..bf1d43d53 100644 --- a/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractor.php +++ b/packages/sonata-import-bundle/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractor.php @@ -34,7 +34,7 @@ public function getOptions(Column $column, array $options): array #[\Override] public function extractDefaultValue(Column $column, array $samples): ?Column { - if (!\in_array($column->getHeaderName(), $this->getOptions($column, []))) { + if (!\in_array($column->getHeaderName(), $this->getOptions($column, []), true)) { return null; } @@ -43,7 +43,8 @@ public function extractDefaultValue(Column $column, array $samples): ?Column $classMetadata = $this->managerRegistry ->getManagerForClass($class) - ->getClassMetadata($class); + ->getClassMetadata($class) + ; \assert($classMetadata instanceof ClassMetadata); @@ -51,7 +52,8 @@ public function extractDefaultValue(Column $column, array $samples): ?Column $columnInfo = (new Column()) ->setMappedTo($headerName) - ->setIsDate(str_starts_with($fieldMapping['type'], 'date')); + ->setIsDate(str_starts_with($fieldMapping['type'], 'date')) + ; if ($fieldMapping['id'] ?? false) { $columnInfo->setIsIdentifier(true); diff --git a/packages/sonata-import-bundle/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractor.php b/packages/sonata-import-bundle/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractor.php index 8ecf7a705..dbe54f48e 100644 --- a/packages/sonata-import-bundle/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractor.php +++ b/packages/sonata-import-bundle/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractor.php @@ -37,7 +37,8 @@ public function getOptions(Column $column, array $options): array $metadata = $this->managerRegistry ->getManagerForClass($translationClass) - ->getClassMetadata($translationClass); + ->getClassMetadata($translationClass) + ; if (!$metadata instanceof ClassMetadata) { return $options; @@ -63,7 +64,7 @@ public function getOptions(Column $column, array $options): array #[\Override] public function assign(object $object, Column $column, mixed $value): bool { - if (!\in_array($column->getMappedTo(), $this->getOptions($column, []))) { + if (!\in_array($column->getMappedTo(), $this->getOptions($column, []), true)) { return false; } diff --git a/packages/sonata-import-bundle/Column/ColumnFactory.php b/packages/sonata-import-bundle/Column/ColumnFactory.php index da29f1df9..eeb27f351 100644 --- a/packages/sonata-import-bundle/Column/ColumnFactory.php +++ b/packages/sonata-import-bundle/Column/ColumnFactory.php @@ -24,7 +24,8 @@ public function buildColumns(Import $import, array $headers, array $samples): vo $column = (new Column()) ->setImport($import) ->setIsDate(false) - ->setHeaderName($headerName); + ->setHeaderName($headerName) + ; $columnSamples = []; diff --git a/packages/sonata-import-bundle/Column/Extractor/ExactMatchColumnExtractor.php b/packages/sonata-import-bundle/Column/Extractor/ExactMatchColumnExtractor.php index 15f4190fb..4306a8927 100644 --- a/packages/sonata-import-bundle/Column/Extractor/ExactMatchColumnExtractor.php +++ b/packages/sonata-import-bundle/Column/Extractor/ExactMatchColumnExtractor.php @@ -26,9 +26,10 @@ public function extractDefaultValue(Column $column, array $samples): ?Column return null; } - if (\in_array($column->getHeaderName(), $this->importer->getOptions($column))) { + if (\in_array($column->getHeaderName(), $this->importer->getOptions($column), true)) { return (new Column()) - ->setMappedTo($column->getHeaderName()); + ->setMappedTo($column->getHeaderName()) + ; } return null; diff --git a/packages/sonata-import-bundle/Column/Extractor/SetterMethodReflectionColumnExtractor.php b/packages/sonata-import-bundle/Column/Extractor/SetterMethodReflectionColumnExtractor.php index c4277e911..f429da6a6 100644 --- a/packages/sonata-import-bundle/Column/Extractor/SetterMethodReflectionColumnExtractor.php +++ b/packages/sonata-import-bundle/Column/Extractor/SetterMethodReflectionColumnExtractor.php @@ -53,7 +53,8 @@ public function extractDefaultValue(Column $column, array $samples): ?Column $parameter = array_shift($parameters); $columnInfo = (new Column()) - ->setMappedTo($headerName); + ->setMappedTo($headerName) + ; if ($this->isDate($parameter)) { $columnInfo->setIsDate(true); @@ -90,7 +91,7 @@ private function isValidMethod(\ReflectionMethod $reflectionMethod): bool $name = $type->getName(); - if (!\in_array($name, ['int', 'float', 'string', 'bool', 'mixed']) && !$this->isDate($parameter)) { + if (!\in_array($name, ['int', 'float', 'string', 'bool', 'mixed'], true) && !$this->isDate($parameter)) { return false; } diff --git a/packages/sonata-import-bundle/Controller/ImportController.php b/packages/sonata-import-bundle/Controller/ImportController.php index 4fd97075f..ff65ee308 100644 --- a/packages/sonata-import-bundle/Controller/ImportController.php +++ b/packages/sonata-import-bundle/Controller/ImportController.php @@ -19,7 +19,8 @@ public function downloadAction(Import $import): Response ->makeDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'import_'.$import->getId().'.csv' - ); + ) + ; $response->headers->set('Content-Disposition', $disposition); diff --git a/packages/sonata-import-bundle/DependencyInjection/Compiler/CompilerPass.php b/packages/sonata-import-bundle/DependencyInjection/Compiler/CompilerPass.php index 7ef4fd7b7..b813181e6 100644 --- a/packages/sonata-import-bundle/DependencyInjection/Compiler/CompilerPass.php +++ b/packages/sonata-import-bundle/DependencyInjection/Compiler/CompilerPass.php @@ -24,7 +24,8 @@ public function process(ContainerBuilder $container): void } $container->getDefinition($serviceId) - ->addMethodCall('addExtension', [new Reference(ImportExtension::class)]); + ->addMethodCall('addExtension', [new Reference(ImportExtension::class)]) + ; break; } diff --git a/packages/sonata-import-bundle/DependencyInjection/Configuration.php b/packages/sonata-import-bundle/DependencyInjection/Configuration.php index 935bcf96a..48d1a3ae0 100755 --- a/packages/sonata-import-bundle/DependencyInjection/Configuration.php +++ b/packages/sonata-import-bundle/DependencyInjection/Configuration.php @@ -23,7 +23,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->children() ->arrayNode('classes') ->beforeNormalization() - ->always(function ($classes) { + ->always(static function ($classes) { $result = []; foreach ($classes as $class => $configuration) { if (\is_string($configuration)) { @@ -52,7 +52,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayNode('handlers') ->append($this->createDoctrineTranslationNode()) ->end() - ->end(); + ->end() + ; return $treeBuilder; } @@ -75,6 +76,7 @@ private function createDoctrineTranslationNode(): ArrayNodeDefinition ->defaultValue([]) ->scalarPrototype()->end() ->end() - ->end(); + ->end() + ; } } diff --git a/packages/sonata-import-bundle/DependencyInjection/DrawSonataImportExtension.php b/packages/sonata-import-bundle/DependencyInjection/DrawSonataImportExtension.php index b6cdbac01..445d3e8f4 100644 --- a/packages/sonata-import-bundle/DependencyInjection/DrawSonataImportExtension.php +++ b/packages/sonata-import-bundle/DependencyInjection/DrawSonataImportExtension.php @@ -17,7 +17,8 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container $loader->load('services.yaml'); $container ->registerForAutoconfiguration(ColumnExtractorInterface::class) - ->addTag('draw.sonata_import.extractor'); + ->addTag('draw.sonata_import.extractor') + ; $container->setParameter('draw.sonata_import.classes', $mergedConfig['classes']); @@ -34,6 +35,7 @@ protected function loadDoctrineTranslationHandler(array $config, ContainerBuilde $container ->getDefinition(DoctrineTranslationColumnExtractor::class) - ->setArgument('$supportedLocales', $config['supported_locales']); + ->setArgument('$supportedLocales', $config['supported_locales']) + ; } } diff --git a/packages/sonata-import-bundle/Entity/Import.php b/packages/sonata-import-bundle/Entity/Import.php index 9b25a2392..55a75b389 100644 --- a/packages/sonata-import-bundle/Entity/Import.php +++ b/packages/sonata-import-bundle/Entity/Import.php @@ -210,7 +210,8 @@ public function validateForProcessing(ExecutionContextInterface $context): void ->buildViolation('Identifier column "{{ name }}" cannot be ignored.') ->atPath('columns['.$key.']') ->setParameter('{{ name }}', $column->getHeaderName()) - ->addViolation(); + ->addViolation() + ; } } @@ -221,7 +222,8 @@ public function validateForProcessing(ExecutionContextInterface $context): void $context ->buildViolation('You need a identifier column.') ->atPath('columns') - ->addViolation(); + ->addViolation() + ; } } @@ -251,7 +253,8 @@ public function getColumnMapping(): array { $criteria = Criteria::create() ->andWhere(Criteria::expr()->neq('isIdentifier', true)) - ->andWhere(Criteria::expr()->neq('isIgnored', true)); + ->andWhere(Criteria::expr()->neq('isIgnored', true)) + ; $mapping = []; foreach ($this->columns->matching($criteria) as $column) { @@ -271,7 +274,8 @@ public function getIdentifierColumns(): array Criteria::create() ->andWhere(Criteria::expr()->eq('isIdentifier', true)) ) - ->toArray(); + ->toArray() + ; if (\count($columns) > 0) { return $columns; diff --git a/packages/sonata-import-bundle/Import/Importer.php b/packages/sonata-import-bundle/Import/Importer.php index f87159725..d757ce127 100644 --- a/packages/sonata-import-bundle/Import/Importer.php +++ b/packages/sonata-import-bundle/Import/Importer.php @@ -33,7 +33,6 @@ public function getOptions(Column $column): array $options = []; foreach ($this->columnsExtractors as $mappedToOptionBuilder) { - $options = $mappedToOptionBuilder->getOptions( $column, $options @@ -109,7 +108,8 @@ public function processImport(Import $import): bool $line ) ) - ); + ) + ; continue; } @@ -133,7 +133,8 @@ public function processImport(Import $import): bool $exception->getMessage() ) ) - ); + ) + ; continue; } @@ -151,7 +152,8 @@ public function processImport(Import $import): bool $saved ) ) - ); + ) + ; return true; } catch (\Throwable $error) { @@ -163,7 +165,8 @@ public function processImport(Import $import): bool $error->getMessage() ) ) - ); + ) + ; return false; } @@ -214,7 +217,8 @@ private function findOne(string $class, array $criteria, bool $create): ?object $relatedObject = $this->managerRegistry ->getRepository($objectClass) - ->findOneBy($objectCriteria); + ->findOneBy($objectCriteria) + ; if (!$relatedObject) { return null; diff --git a/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractorTest.php b/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractorTest.php index b9879cd2a..7565bbd17 100644 --- a/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractorTest.php +++ b/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineAssociationColumnExtractorTest.php @@ -10,6 +10,9 @@ use Draw\Component\Tester\DoctrineOrmTrait; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class DoctrineAssociationColumnExtractorTest extends TestCase { use DoctrineOrmTrait; @@ -73,13 +76,15 @@ public function testExtractDefaultValue(): void public function testAssign(): void { $import = (new Import()) - ->setEntityClass(\stdClass::class); + ->setEntityClass(\stdClass::class) + ; $this->entityManager->persist($import); $this->entityManager->flush(); $column = $this->createColumn() - ->setMappedTo('import.id'); + ->setMappedTo('import.id') + ; $object = new Column(); @@ -103,6 +108,7 @@ private function createColumn(): Column ->setImport( (new Import()) ->setEntityClass(Column::class) - ); + ) + ; } } diff --git a/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractorTest.php b/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractorTest.php index 36d5e180f..9d81505c1 100644 --- a/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractorTest.php +++ b/packages/sonata-import-bundle/Tests/Column/Bridge/Doctrine/Extractor/DoctrineFieldColumnExtractorTest.php @@ -9,6 +9,9 @@ use Draw\Component\Tester\DoctrineOrmTrait; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class DoctrineFieldColumnExtractorTest extends TestCase { use DoctrineOrmTrait; @@ -142,6 +145,7 @@ private function createColumn(): Column ->setImport( (new Import()) ->setEntityClass(Column::class) - ); + ) + ; } } diff --git a/packages/sonata-import-bundle/Tests/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractorTest.php b/packages/sonata-import-bundle/Tests/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractorTest.php index 3b7e6abab..e36116ac5 100644 --- a/packages/sonata-import-bundle/Tests/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractorTest.php +++ b/packages/sonata-import-bundle/Tests/Column/Bridge/KnpDoctrineBehaviors/Extractor/DoctrineTranslationColumnExtractorTest.php @@ -10,6 +10,9 @@ use Draw\Component\Tester\DoctrineOrmTrait; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class DoctrineTranslationColumnExtractorTest extends TestCase { use DoctrineOrmTrait; @@ -89,6 +92,7 @@ private function createColumn(): Column ->setImport( (new Import()) ->setEntityClass(TranslatableEntity::class) - ); + ) + ; } } diff --git a/packages/sonata-import-bundle/Tests/Column/Extractor/ExactMatchColumnExtractorTest.php b/packages/sonata-import-bundle/Tests/Column/Extractor/ExactMatchColumnExtractorTest.php index 017307e53..ac67632d7 100644 --- a/packages/sonata-import-bundle/Tests/Column/Extractor/ExactMatchColumnExtractorTest.php +++ b/packages/sonata-import-bundle/Tests/Column/Extractor/ExactMatchColumnExtractorTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(ExactMatchColumnExtractor::class)] class ExactMatchColumnExtractorTest extends TestCase { @@ -55,7 +58,8 @@ public function testExtractDefaultValueAlreadySet(): void { $this->importer ->expects(static::never()) - ->method('getOptions'); + ->method('getOptions') + ; static::assertNull( $this->object->extractDefaultValue( @@ -72,7 +76,8 @@ public function testExtractDefaultValueNotInOptions(): void $this->importer ->expects(static::once()) ->method('getOptions') - ->willReturn(['headerName1', 'headerName2']); + ->willReturn(['headerName1', 'headerName2']) + ; static::assertNull( $this->object->extractDefaultValue( @@ -88,10 +93,12 @@ public function testExtractDefaultValueInOptions(): void $this->importer ->expects(static::once()) ->method('getOptions') - ->willReturn(['headerName']); + ->willReturn(['headerName']) + ; $column = (new Column()) - ->setHeaderName('headerName'); + ->setHeaderName('headerName') + ; $column = $this->object->extractDefaultValue( $column, diff --git a/packages/sonata-import-bundle/Tests/Column/Extractor/PropertyPathColumnExtractorTest.php b/packages/sonata-import-bundle/Tests/Column/Extractor/PropertyPathColumnExtractorTest.php index 370876c81..9731324a6 100644 --- a/packages/sonata-import-bundle/Tests/Column/Extractor/PropertyPathColumnExtractorTest.php +++ b/packages/sonata-import-bundle/Tests/Column/Extractor/PropertyPathColumnExtractorTest.php @@ -7,6 +7,9 @@ use Draw\Bundle\SonataImportBundle\Entity\Column; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class PropertyPathColumnExtractorTest extends TestCase { private PropertyPathColumnExtractor $object; diff --git a/packages/sonata-import-bundle/Tests/Column/Extractor/SetterMethodReflectionColumnExtractorTest.php b/packages/sonata-import-bundle/Tests/Column/Extractor/SetterMethodReflectionColumnExtractorTest.php index 3dab5d4c1..dda54ec8e 100644 --- a/packages/sonata-import-bundle/Tests/Column/Extractor/SetterMethodReflectionColumnExtractorTest.php +++ b/packages/sonata-import-bundle/Tests/Column/Extractor/SetterMethodReflectionColumnExtractorTest.php @@ -9,6 +9,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(SetterMethodReflectionColumnExtractor::class)] class SetterMethodReflectionColumnExtractorTest extends TestCase { @@ -115,7 +118,8 @@ private function createColumn(): Column ->setImport( (new Import()) ->setEntityClass(SetterClassStub::class) - ); + ) + ; } } diff --git a/packages/sonata-import-bundle/Tests/ColumnFactoryTest.php b/packages/sonata-import-bundle/Tests/ColumnFactoryTest.php index b2148fae4..c0f3f247f 100644 --- a/packages/sonata-import-bundle/Tests/ColumnFactoryTest.php +++ b/packages/sonata-import-bundle/Tests/ColumnFactoryTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[ CoversClass(ColumnFactory::class), CoversClass(SetterMethodReflectionColumnExtractor::class), @@ -32,14 +35,16 @@ protected function setUp(): void public function testGenerateColumnsDate(): void { $import = (new Import()) - ->setEntityClass(Import::class); + ->setEntityClass(Import::class) + ; $this->columnFactory ->buildColumns( $import, ['createdAt'], ['2018-10-10'] - ); + ) + ; $columns = $import->getColumns()->toArray(); diff --git a/packages/sonata-import-bundle/Tests/Entity/ImportTest.php b/packages/sonata-import-bundle/Tests/Entity/ImportTest.php index b8d4fb6af..0a0f555af 100644 --- a/packages/sonata-import-bundle/Tests/Entity/ImportTest.php +++ b/packages/sonata-import-bundle/Tests/Entity/ImportTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Validator\GroupSequenceProviderInterface; use Symfony\Component\Validator\Validation; +/** + * @internal + */ class ImportTest extends TestCase { use MockTrait; diff --git a/packages/sonata-integration-bundle/Configuration/Admin/ConfigAdmin.php b/packages/sonata-integration-bundle/Configuration/Admin/ConfigAdmin.php index f27eb7c09..e5c791165 100644 --- a/packages/sonata-integration-bundle/Configuration/Admin/ConfigAdmin.php +++ b/packages/sonata-integration-bundle/Configuration/Admin/ConfigAdmin.php @@ -14,7 +14,8 @@ class ConfigAdmin extends AbstractAdmin protected function configureDatagridFilters(DatagridMapper $filter): void { $filter - ->add('id'); + ->add('id') + ; } public function configureFormFields(FormMapper $form): void @@ -27,17 +28,19 @@ public function configureFormFields(FormMapper $form): void [ 'attr' => ['rows' => 20], ] - ); + ) + ; $form->get('data')->addModelTransformer(new CallbackTransformer( - fn ($data) => null !== $data ? json_encode($data, \JSON_PRETTY_PRINT) : null, - fn ($data) => !empty($data) ? json_decode((string) $data, true, 512, \JSON_THROW_ON_ERROR) : null + static fn ($data) => null !== $data ? json_encode($data, \JSON_PRETTY_PRINT) : null, + static fn ($data) => !empty($data) ? json_decode((string) $data, true, 512, \JSON_THROW_ON_ERROR) : null )); } protected function configureListFields(ListMapper $list): void { $list - ->addIdentifier('id'); + ->addIdentifier('id') + ; } } diff --git a/packages/sonata-integration-bundle/Console/Admin/ExecutionAdmin.php b/packages/sonata-integration-bundle/Console/Admin/ExecutionAdmin.php index 6383426a8..470d61b41 100644 --- a/packages/sonata-integration-bundle/Console/Admin/ExecutionAdmin.php +++ b/packages/sonata-integration-bundle/Console/Admin/ExecutionAdmin.php @@ -87,7 +87,8 @@ protected function configureDatagridFilters(DatagridMapper $filter): void 'choices' => array_combine($autoAcknowledgeReasons, $autoAcknowledgeReasons), ], ], - ); + ) + ; } protected function configureListFields(ListMapper $list): void @@ -98,7 +99,8 @@ protected function configureListFields(ListMapper $list): void ->add('commandName') ->add('state') ->add('autoAcknowledgeReason') - ->add('createdAt'); + ->add('createdAt') + ; } protected function configureShowFields(ShowMapper $show): void @@ -119,14 +121,16 @@ protected function configureShowFields(ShowMapper $show): void ->add('commandLine', 'text') ->add('outputHtml', 'html') ->end() - ->end(); + ->end() + ; } protected function configureFormFields(FormMapper $form): void { $form ->add('command', null, ['attr' => ['readonly' => true]]) - ->add('commandName', null, ['attr' => ['readonly' => true]]); + ->add('commandName', null, ['attr' => ['readonly' => true]]) + ; } protected function configureRoutes(RouteCollectionInterface $collection): void @@ -136,7 +140,8 @@ protected function configureRoutes(RouteCollectionInterface $collection): void } else { $collection ->get('create') - ->setDefault('_controller', $collection->getBaseControllerName().'::myCreateAction'); + ->setDefault('_controller', $collection->getBaseControllerName().'::myCreateAction') + ; } $collection->remove('edit'); @@ -146,7 +151,7 @@ protected function configureRoutes(RouteCollectionInterface $collection): void public function configureActionButtons(array $buttonList, $action, $object = null): array { - if ('show' == $action && Execution::STATE_ERROR == $object->getState()) { + if ('show' === $action && Execution::STATE_ERROR === $object->getState()) { $buttonList['acknowledge']['template'] = '@DrawSonataIntegration/Console/Execution/button_acknowledge.html.twig'; } @@ -209,7 +214,8 @@ private function getAutoAcknowledgeReasons(): array ->andWhere('e.autoAcknowledgeReason IS NOT NULL') ->groupBy('e.autoAcknowledgeReason') ->getQuery() - ->getResult(AbstractQuery::HYDRATE_SCALAR); + ->getResult(AbstractQuery::HYDRATE_SCALAR) + ; $result = array_column($result, 'autoAcknowledgeReason'); diff --git a/packages/sonata-integration-bundle/Console/Controller/ExecutionController.php b/packages/sonata-integration-bundle/Console/Controller/ExecutionController.php index f2461dc20..4cbfd9757 100644 --- a/packages/sonata-integration-bundle/Console/Controller/ExecutionController.php +++ b/packages/sonata-integration-bundle/Console/Controller/ExecutionController.php @@ -60,7 +60,8 @@ public function reportAction(EntityManagerInterface $entityManager): Response ->setParameter('state', Execution::STATE_AUTO_ACKNOWLEDGE) ->groupBy('execution.autoAcknowledgeReason') ->getQuery() - ->getResult(); + ->getResult() + ; return $this->renderWithExtraParams( '@DrawSonataIntegration/Console/Execution/report.html.twig', diff --git a/packages/sonata-integration-bundle/CronJob/Admin/CronJobAdmin.php b/packages/sonata-integration-bundle/CronJob/Admin/CronJobAdmin.php index 12a944378..08cefb0c7 100644 --- a/packages/sonata-integration-bundle/CronJob/Admin/CronJobAdmin.php +++ b/packages/sonata-integration-bundle/CronJob/Admin/CronJobAdmin.php @@ -23,7 +23,8 @@ protected function configureDatagridFilters(DatagridMapper $filter): void ->add('id') ->add('name') ->add('command') - ->add('active'); + ->add('active') + ; } protected function configureListFields(ListMapper $list): void @@ -49,7 +50,8 @@ protected function configureListFields(ListMapper $list): void 'delete' => [], ], ] - ); + ) + ; } protected function configureFormFields(FormMapper $form): void @@ -72,7 +74,8 @@ protected function configureFormFields(FormMapper $form): void ->with('Queue Configuration', ['class' => 'col-md-4']) ->add('timeToLive') ->add('priority') - ->end(); + ->end() + ; } protected function configureShowFields(ShowMapper $show): void @@ -100,7 +103,8 @@ protected function configureShowFields(ShowMapper $show): void 'fields' => $executionAdmin->configureGridFields([]), ] ) - ->ifEnd(); + ->ifEnd() + ; } protected function configureRoutes(RouteCollectionInterface $collection): void diff --git a/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php b/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php index fa697c581..a76d55643 100644 --- a/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php +++ b/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php @@ -62,8 +62,8 @@ protected function configureDatagridFilters(DatagridMapper $filter): void filterOptions: [ 'show_filter' => true, ] - ); - + ) + ; } protected function configureListFields(ListMapper $list): void @@ -95,7 +95,8 @@ protected function configureListFields(ListMapper $list): void 'delete' => [], ], ] - ); + ) + ; } protected function configureShowFields(ShowMapper $show): void @@ -109,7 +110,8 @@ protected function configureShowFields(ShowMapper $show): void ->add('executionEndedAt') ->add('executionDelay') ->add('exitCode') - ->add('error'); + ->add('error') + ; } protected function configureRoutes(RouteCollectionInterface $collection): void diff --git a/packages/sonata-integration-bundle/DependencyInjection/Configuration.php b/packages/sonata-integration-bundle/DependencyInjection/Configuration.php index 15a428621..f7fce9070 100644 --- a/packages/sonata-integration-bundle/DependencyInjection/Configuration.php +++ b/packages/sonata-integration-bundle/DependencyInjection/Configuration.php @@ -36,7 +36,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->append($this->createEntityMigratorNode()) ->append($this->createMessengerNode()) ->append($this->createUserNode()) - ->end(); + ->end() + ; return $treeBuilder; } @@ -49,7 +50,8 @@ private function createConfigurationNode(): ArrayNodeDefinition ->addDefaultsIfNotSet() ->labelDefaultValue('config') ->iconDefaultValue('fa fa-server') - ); + ) + ; } private function createConsoleNode(): ArrayNodeDefinition @@ -66,7 +68,7 @@ private function createConsoleNode(): ArrayNodeDefinition ->children() ->arrayNode('commands') ->beforeNormalization() - ->always(function ($commands) { + ->always(static function ($commands) { foreach ($commands as $name => $configuration) { if (!isset($configuration['name'])) { $commands[$name]['name'] = $name; @@ -86,7 +88,8 @@ private function createConsoleNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createCronJobNode(): ArrayNodeDefinition @@ -115,7 +118,8 @@ private function createCronJobNode(): ArrayNodeDefinition ->translationDomainDefaultValue('DrawCronJobAdmin') ) ->end() - ->end(); + ->end() + ; } private function createEntityMigratorNode(): ArrayNodeDefinition @@ -127,7 +131,8 @@ private function createEntityMigratorNode(): ArrayNodeDefinition ->addDefaultsIfNotSet() ->labelDefaultValue('Migration') ->iconDefaultValue('fa fa-cogs') - ); + ) + ; } private function createMessengerNode(): ArrayNodeDefinition @@ -150,7 +155,8 @@ private function createMessengerNode(): ArrayNodeDefinition ->translationDomainDefaultValue('DrawMessengerAdmin') ->canBeDisabled() ) - ->end(); + ->end() + ; } private function createUserNode(): ArrayNodeDefinition @@ -182,7 +188,8 @@ private function createUserNode(): ArrayNodeDefinition ->end() ->end() ->end() - ->end(); + ->end() + ; } private function createUserLockNode(): ArrayNodeDefinition @@ -202,7 +209,8 @@ private function createUserLockNode(): ArrayNodeDefinition ->iconDefaultValue('fas fa-ba') ->labelDefaultValue('User lock') ) - ->end(); + ->end() + ; } private function canBe(string $class, ArrayNodeDefinition $arrayNodeDefinition): ArrayNodeDefinition diff --git a/packages/sonata-integration-bundle/DependencyInjection/DrawSonataIntegrationExtension.php b/packages/sonata-integration-bundle/DependencyInjection/DrawSonataIntegrationExtension.php index f871a0315..1cfc60320 100644 --- a/packages/sonata-integration-bundle/DependencyInjection/DrawSonataIntegrationExtension.php +++ b/packages/sonata-integration-bundle/DependencyInjection/DrawSonataIntegrationExtension.php @@ -72,7 +72,8 @@ private function configureConfiguration( ->addMethodCall( 'setTranslationDomain', ['DrawConfigurationSonata'] - ); + ) + ; } private function configureConsole(array $config, Loader\FileLoader $loader, ContainerBuilder $container): void @@ -90,7 +91,8 @@ private function configureConsole(array $config, Loader\FileLoader $loader, Cont ) ) ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; $this->setControllerClassDefinition($config['admin'], $container); @@ -100,7 +102,8 @@ private function configureConsole(array $config, Loader\FileLoader $loader, Cont (new Definition(CommandRegistry::class)) ->setAutowired(true) ->setAutoconfigured(true) - ); + ) + ; foreach ($config['commands'] as $configuration) { $definition->addMethodCall( @@ -134,7 +137,8 @@ private function configureCronJob(array $config, Loader\FileLoader $loader, Cont ) ) ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; $this->setControllerClassDefinition($config['admin'][$adminId], $container); } @@ -153,7 +157,8 @@ private function configureMessenger(array $config, Loader\FileLoader $loader, Co (new Definition(FinalizeContextQueueCountEventListener::class)) ->setAutowired(true) ->setAutoconfigured(true) - ); + ) + ; } if ($config['admin']['enabled']) { @@ -173,7 +178,8 @@ private function configureMessenger(array $config, Loader\FileLoader $loader, Co ) ->setBindings([ '$queueNames' => $config['queue_names'], - ]); + ]) + ; $container ->setDefinition( @@ -181,7 +187,8 @@ private function configureMessenger(array $config, Loader\FileLoader $loader, Co (new Definition(CanShowMessageVoter::class)) ->setAutowired(true) ->setAutoconfigured(true) - ); + ) + ; $this->setControllerClassDefinition($config['admin'], $container); } @@ -202,7 +209,8 @@ private function configureEntityMigrator(array $config, Loader\FileLoader $loade ) ) ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; } private function configureUser(array $config, Loader\FileLoader $loader, ContainerBuilder $container): void @@ -220,7 +228,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ) ->setAutoconfigured(true) ->setAutowired(true) - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; $container ->setDefinition( @@ -230,7 +239,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ->setAutoconfigured(true) ->setAutowired(true) ->setArgument('$userAdminCode', new Parameter('draw_user.sonata.user_admin_code')) - ->addTag('sonata.block'); + ->addTag('sonata.block') + ; $container ->setDefinition( @@ -238,7 +248,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain new Definition(UserAdminExtension::class) ) ->setAutoconfigured(true) - ->setAutowired(true); + ->setAutowired(true) + ; $container ->setDefinition( @@ -247,7 +258,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ) ->setAutoconfigured(true) ->setAutowired(true) - ->setArgument('$userAdminCode', new Parameter('draw_user.sonata.user_admin_code')); + ->setArgument('$userAdminCode', new Parameter('draw_user.sonata.user_admin_code')) + ; $container ->setDefinition( @@ -256,7 +268,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ) ->setAutoconfigured(true) ->setAutowired(true) - ->addTag('sonata.admin.extension', ['target' => $config['user_admin_code']]); + ->addTag('sonata.admin.extension', ['target' => $config['user_admin_code']]) + ; $container ->setDefinition( @@ -265,7 +278,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ) ->setAutoconfigured(true) ->setAutowired(true) - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; $this->configureUserLock($config['user_lock'], $loader, $container); @@ -285,7 +299,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ) ->setAutoconfigured(true) ->setAutowired(true) - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; } $reflectionClass = new \ReflectionClass($userEntityClass = $container->getParameter('draw_user.user_entity_class')); @@ -301,7 +316,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ->setAutoconfigured(true) ->setAutowired(true) ->setArgument(0, $config['2fa']['field_positions']) - ->addTag('sonata.admin.extension', ['target' => $config['user_admin_code']]); + ->addTag('sonata.admin.extension', ['target' => $config['user_admin_code']]) + ; $container ->setDefinition( @@ -310,7 +326,8 @@ private function configureUser(array $config, Loader\FileLoader $loader, Contain ) ->setAutoconfigured(true) ->setAutowired(true) - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; } private function configureUserLock(array $config, Loader\FileLoader $loader, ContainerBuilder $container): void @@ -326,7 +343,8 @@ private function configureUserLock(array $config, Loader\FileLoader $loader, Con new Definition(UserLockAdmin::class), $config['admin'] ) - ); + ) + ; if ($config['unlock_user_lock_extension']['enabled']) { $container @@ -339,7 +357,8 @@ private function configureUserLock(array $config, Loader\FileLoader $loader, Con ->addTag( 'sonata.admin.extension', ['target' => $container->getParameter('draw_user.sonata.user_admin_code')] - ); + ) + ; $container ->setDefinition( @@ -348,7 +367,8 @@ private function configureUserLock(array $config, Loader\FileLoader $loader, Con ) ->setAutoconfigured(true) ->setAutowired(true) - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; } if ($config['refresh_user_lock_extension']['enabled']) { @@ -362,7 +382,8 @@ private function configureUserLock(array $config, Loader\FileLoader $loader, Con ->addTag( 'sonata.admin.extension', ['target' => $container->getParameter('draw_user.sonata.user_admin_code')] - ); + ) + ; $container ->setDefinition( @@ -371,7 +392,8 @@ private function configureUserLock(array $config, Loader\FileLoader $loader, Con ) ->setAutoconfigured(true) ->setAutowired(true) - ->addTag('controller.service_arguments'); + ->addTag('controller.service_arguments') + ; } } diff --git a/packages/sonata-integration-bundle/DependencyInjection/Factory/Security/AdminLoginFactory.php b/packages/sonata-integration-bundle/DependencyInjection/Factory/Security/AdminLoginFactory.php index ae4da5767..318195363 100644 --- a/packages/sonata-integration-bundle/DependencyInjection/Factory/Security/AdminLoginFactory.php +++ b/packages/sonata-integration-bundle/DependencyInjection/Factory/Security/AdminLoginFactory.php @@ -38,7 +38,8 @@ public function addConfiguration(NodeDefinition $node): void ->scalarNode('username_parameter')->defaultValue('admin_login_form[email]')->end() ->scalarNode('password_parameter')->defaultValue('admin_login_form[password]')->end() ->scalarNode('required_role')->defaultValue('ROLE_SONATA_ADMIN')->end() - ->end(); + ->end() + ; } public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string diff --git a/packages/sonata-integration-bundle/EntityMigrator/Admin/BaseEntityMigrationAdmin.php b/packages/sonata-integration-bundle/EntityMigrator/Admin/BaseEntityMigrationAdmin.php index eb32cfa12..8942fbc25 100644 --- a/packages/sonata-integration-bundle/EntityMigrator/Admin/BaseEntityMigrationAdmin.php +++ b/packages/sonata-integration-bundle/EntityMigrator/Admin/BaseEntityMigrationAdmin.php @@ -51,7 +51,8 @@ protected function configureDatagridFilters(DatagridMapper $filter): void ], 'show_filter' => true, ] - ); + ) + ; } protected function configureListFields(ListMapper $list): void @@ -60,7 +61,8 @@ protected function configureListFields(ListMapper $list): void ->addIdentifier('id') ->add('entity') ->add('migration') - ->add('state'); + ->add('state') + ; } protected function configureShowFields(ShowMapper $show): void @@ -76,12 +78,14 @@ protected function configureShowFields(ShowMapper $show): void 'template' => '@DrawSonataIntegration/EntityMigrator/BaseEntityMigration/show_transition_logs.html.twig', ] ) - ->add('createdAt'); + ->add('createdAt') + ; } protected function configureRoutes(RouteCollectionInterface $collection): void { $collection - ->clearExcept(['list', 'show']); + ->clearExcept(['list', 'show']) + ; } } diff --git a/packages/sonata-integration-bundle/EntityMigrator/Admin/MigrationAdmin.php b/packages/sonata-integration-bundle/EntityMigrator/Admin/MigrationAdmin.php index 52113e86b..fbd64be87 100644 --- a/packages/sonata-integration-bundle/EntityMigrator/Admin/MigrationAdmin.php +++ b/packages/sonata-integration-bundle/EntityMigrator/Admin/MigrationAdmin.php @@ -14,7 +14,8 @@ protected function configureListFields(ListMapper $list): void $list ->addIdentifier('id') ->add('name') - ->add('state'); + ->add('state') + ; } protected function configureShowFields(ShowMapper $show): void @@ -22,7 +23,8 @@ protected function configureShowFields(ShowMapper $show): void $show ->add('id') ->add('name') - ->add('state'); + ->add('state') + ; } protected function configureRoutes(RouteCollectionInterface $collection): void @@ -30,6 +32,7 @@ protected function configureRoutes(RouteCollectionInterface $collection): void $collection ->remove('edit') ->remove('create') - ->remove('delete'); + ->remove('delete') + ; } } diff --git a/packages/sonata-integration-bundle/Messenger/Admin/MessengerMessageAdmin.php b/packages/sonata-integration-bundle/Messenger/Admin/MessengerMessageAdmin.php index f2522fc0d..291e1f41b 100644 --- a/packages/sonata-integration-bundle/Messenger/Admin/MessengerMessageAdmin.php +++ b/packages/sonata-integration-bundle/Messenger/Admin/MessengerMessageAdmin.php @@ -77,7 +77,8 @@ protected function configureDatagridFilters(DatagridMapper $filter): void ->add( 'expiresAt', RelativeDateTimeFilter::class, - ); + ) + ; } protected function configureListFields(ListMapper $list): void @@ -103,7 +104,8 @@ protected function configureListFields(ListMapper $list): void 'delete' => [], ], ] - ); + ) + ; } public function dumpMessage(DrawMessageInterface $message): string @@ -140,7 +142,8 @@ protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterfa \sprintf('%s.expiresAt IS NULL', $query->getRootAliases()[0]), ) ) - ->setParameter('now', new \DateTimeImmutable()); + ->setParameter('now', new \DateTimeImmutable()) + ; return $query; } diff --git a/packages/sonata-integration-bundle/Messenger/EventListener/FinalizeContextQueueCountEventListener.php b/packages/sonata-integration-bundle/Messenger/EventListener/FinalizeContextQueueCountEventListener.php index d568691b2..6259ba3d4 100644 --- a/packages/sonata-integration-bundle/Messenger/EventListener/FinalizeContextQueueCountEventListener.php +++ b/packages/sonata-integration-bundle/Messenger/EventListener/FinalizeContextQueueCountEventListener.php @@ -18,7 +18,6 @@ public static function getSubscribedEvents(): array public function __construct(private TransportRepositoryInterface $transportRepository) { - } public function finalizeContext(FinalizeContextEvent $event): void diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/ConfigurationTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/ConfigurationTest.php index 3c0d821e4..e8225081b 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/ConfigurationTest.php @@ -20,6 +20,9 @@ use Sonata\AdminBundle\Datagrid\ListMapper; use Symfony\Component\Config\Definition\ConfigurationInterface; +/** + * @internal + */ class ConfigurationTest extends ConfigurationTestCase { public function createConfiguration(): ConfigurationInterface diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConfigurationEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConfigurationEnabledTest.php index c287bc725..e0f95179d 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConfigurationEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConfigurationEnabledTest.php @@ -6,6 +6,9 @@ use Draw\Bundle\SonataIntegrationBundle\DependencyInjection\DrawSonataIntegrationExtension; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionConfigurationEnabledTest extends DrawSonataIntegrationExtensionTest { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConsoleEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConsoleEnabledTest.php index ea5c3f074..d57aeeeda 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConsoleEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionConsoleEnabledTest.php @@ -8,6 +8,9 @@ use Draw\Bundle\SonataIntegrationBundle\DependencyInjection\DrawSonataIntegrationExtension; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionConsoleEnabledTest extends DrawSonataIntegrationExtensionTest { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionCronJobEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionCronJobEnabledTest.php index b41cd170e..c5ce626be 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionCronJobEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionCronJobEnabledTest.php @@ -12,6 +12,9 @@ use Draw\Bundle\SonataIntegrationBundle\Tests\DependencyInjection\DrawSonataIntegrationExtensionTest; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionCronJobEnabledTest extends DrawSonataIntegrationExtensionTest { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionMessengerEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionMessengerEnabledTest.php index 5c25956ef..30cba685a 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionMessengerEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionMessengerEnabledTest.php @@ -9,6 +9,9 @@ use Draw\Bundle\SonataIntegrationBundle\Messenger\Security\CanShowMessageVoter; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionMessengerEnabledTest extends DrawSonataIntegrationExtensionTest { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionTest.php index 2c0c270f7..8fcc0a1d1 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionTest extends ExtensionTestCase { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledEmailEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledEmailEnabledTest.php index c29d0ffba..1b1f3f9ff 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledEmailEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledEmailEnabledTest.php @@ -5,6 +5,9 @@ use Draw\Bundle\SonataIntegrationBundle\DependencyInjection\DrawSonataIntegrationExtension; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionUser2faEnabledEmailEnabledTest extends DrawSonataIntegrationExtensionUser2faEnabledTest { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledTest.php index d5f88a6d4..5d8a22a9a 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUser2faEnabledTest.php @@ -10,6 +10,9 @@ use Scheb\TwoFactorBundle\SchebTwoFactorBundle; use Symfony\Component\DependencyInjection\ContainerBuilder; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionUser2faEnabledTest extends DrawSonataIntegrationExtensionUserEnabledTest { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserEnabledTest.php index 7d87d4e1d..87b7a1b93 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserEnabledTest.php @@ -10,6 +10,9 @@ use Draw\Bundle\SonataIntegrationBundle\User\Twig\UserAdminRuntime; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionUserEnabledTest extends DrawSonataIntegrationExtensionTest { diff --git a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserLockEnabledTest.php b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserLockEnabledTest.php index 598766eaf..ceb14928f 100644 --- a/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserLockEnabledTest.php +++ b/packages/sonata-integration-bundle/Tests/DependencyInjection/DrawSonataIntegrationExtensionUserLockEnabledTest.php @@ -10,6 +10,9 @@ use Draw\Bundle\SonataIntegrationBundle\User\Controller\RefreshUserLockController; use PHPUnit\Framework\Attributes\CoversClass; +/** + * @internal + */ #[CoversClass(DrawSonataIntegrationExtension::class)] class DrawSonataIntegrationExtensionUserLockEnabledTest extends DrawSonataIntegrationExtensionUserEnabledTest { diff --git a/packages/sonata-integration-bundle/Tests/User/Action/TwoFactorAuthenticationResendCodeActionTest.php b/packages/sonata-integration-bundle/Tests/User/Action/TwoFactorAuthenticationResendCodeActionTest.php index 30e84ee0c..acf09bd75 100644 --- a/packages/sonata-integration-bundle/Tests/User/Action/TwoFactorAuthenticationResendCodeActionTest.php +++ b/packages/sonata-integration-bundle/Tests/User/Action/TwoFactorAuthenticationResendCodeActionTest.php @@ -13,6 +13,9 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\User\UserInterface; +/** + * @internal + */ #[CoversClass(TwoFactorAuthenticationResendCodeAction::class)] class TwoFactorAuthenticationResendCodeActionTest extends TestCase { @@ -80,19 +83,22 @@ public function getUserIdentifier(): string $this->codeGenerator ->expects(static::once()) ->method('generateAndSend') - ->with($user); + ->with($user) + ; $this->urlGenerator ->expects(static::once()) ->method('generate') ->with('admin_2fa_login', ['preferProvider' => 'email']) - ->willReturn($url = uniqid('https://')); + ->willReturn($url = uniqid('https://')) + ; $securityMock = $this->createMock(Security::class); $securityMock ->expects(static::once()) ->method('getUser') - ->willReturn($user); + ->willReturn($user) + ; $result = \call_user_func( $this->object, diff --git a/packages/sonata-integration-bundle/User/Action/UnlockUserAction.php b/packages/sonata-integration-bundle/User/Action/UnlockUserAction.php index f9fcbdae2..22012f255 100644 --- a/packages/sonata-integration-bundle/User/Action/UnlockUserAction.php +++ b/packages/sonata-integration-bundle/User/Action/UnlockUserAction.php @@ -33,7 +33,8 @@ public function __invoke(AdminInterface $admin, UserInterface $currentUser) 'draw_user.account_locker.user_lock.unlock_success', [], 'SonataAdminBundle' - ); + ) + ; } catch (\Throwable) { $this->userFeed ->addToFeed( @@ -42,7 +43,8 @@ public function __invoke(AdminInterface $admin, UserInterface $currentUser) 'flash_edit_error', ['%name%' => htmlspecialchars((string) $user)], 'SonataAdminBundle', - ); + ) + ; } return new RedirectResponse($admin->generateObjectUrl('show', $user)); diff --git a/packages/sonata-integration-bundle/User/Admin/Extension/PasswordChangeEnforcerExtension.php b/packages/sonata-integration-bundle/User/Admin/Extension/PasswordChangeEnforcerExtension.php index e3d6229ab..8e9847b8f 100644 --- a/packages/sonata-integration-bundle/User/Admin/Extension/PasswordChangeEnforcerExtension.php +++ b/packages/sonata-integration-bundle/User/Admin/Extension/PasswordChangeEnforcerExtension.php @@ -44,6 +44,7 @@ public function configureRoutes(AdminInterface $admin, RouteCollectionInterface [ '_controller' => 'draw.sonata.user.action.request_password_change_action', ] - ); + ) + ; } } diff --git a/packages/sonata-integration-bundle/User/Admin/Extension/RefreshUserLockExtension.php b/packages/sonata-integration-bundle/User/Admin/Extension/RefreshUserLockExtension.php index 85e4b1a03..79b70c921 100644 --- a/packages/sonata-integration-bundle/User/Admin/Extension/RefreshUserLockExtension.php +++ b/packages/sonata-integration-bundle/User/Admin/Extension/RefreshUserLockExtension.php @@ -33,7 +33,7 @@ public function configureActionButtons( ): array { switch (true) { case !$admin->isGranted('refresh-user-locks', $object): - case !\in_array($action, ['edit', 'show']): + case !\in_array($action, ['edit', 'show'], true): break; default: $list['refresh-user-lock'] = [ diff --git a/packages/sonata-integration-bundle/User/Admin/Extension/UnlockUserLockExtension.php b/packages/sonata-integration-bundle/User/Admin/Extension/UnlockUserLockExtension.php index 29ce99d2a..395121a85 100644 --- a/packages/sonata-integration-bundle/User/Admin/Extension/UnlockUserLockExtension.php +++ b/packages/sonata-integration-bundle/User/Admin/Extension/UnlockUserLockExtension.php @@ -35,7 +35,7 @@ public function configureActionButtons( case !$object instanceof LockableUserInterface: case !$object->isLocked(): case !$admin->isGranted('unlock', $object): - case !\in_array($action, ['edit', 'show']): + case !\in_array($action, ['edit', 'show'], true): break; default: $list['unlock'] = [ diff --git a/packages/sonata-integration-bundle/User/Admin/UserLockAdmin.php b/packages/sonata-integration-bundle/User/Admin/UserLockAdmin.php index bd75b38f3..1b68a9e04 100644 --- a/packages/sonata-integration-bundle/User/Admin/UserLockAdmin.php +++ b/packages/sonata-integration-bundle/User/Admin/UserLockAdmin.php @@ -49,7 +49,8 @@ public function configureListFields(ListMapper $list): void 'edit' => [], ], ] - ); + ) + ; } public function configureFormFields(FormMapper $form): void @@ -87,7 +88,8 @@ public function configureFormFields(FormMapper $form): void [ 'required' => false, ] - ); + ) + ; } public function configureShowFields(ShowMapper $show): void @@ -107,7 +109,8 @@ public function configureShowFields(ShowMapper $show): void 'virtual_field' => true, 'template' => '@DrawSonataIntegration/UserLock/CRUD/show_reason_details.html.twig', ] - ); + ) + ; } public function configureGridFields(array $fields): array diff --git a/packages/sonata-integration-bundle/User/Block/UserCountBlock.php b/packages/sonata-integration-bundle/User/Block/UserCountBlock.php index dc06a721f..18572065f 100644 --- a/packages/sonata-integration-bundle/User/Block/UserCountBlock.php +++ b/packages/sonata-integration-bundle/User/Block/UserCountBlock.php @@ -48,7 +48,8 @@ public function execute(BlockContextInterface $blockContext, ?Response $response $response ) ->setTtl(0) - ->setPrivate(); + ->setPrivate() + ; } public function getName(): string diff --git a/packages/sonata-integration-bundle/User/Extension/TwoFactorAuthenticationExtension.php b/packages/sonata-integration-bundle/User/Extension/TwoFactorAuthenticationExtension.php index bb6781dc7..761bbc545 100644 --- a/packages/sonata-integration-bundle/User/Extension/TwoFactorAuthenticationExtension.php +++ b/packages/sonata-integration-bundle/User/Extension/TwoFactorAuthenticationExtension.php @@ -81,7 +81,8 @@ public function configureFormFields(FormMapper $form): void [ 'translation_domain' => 'DrawUserBundle', ] - ); + ) + ; if (false !== $index = array_search($before, $keys, true)) { array_splice($keys, $index, 0, 'totpAuthenticationEnabled'); @@ -106,7 +107,7 @@ public function configureRoutes(AdminInterface $admin, RouteCollectionInterface public function configureActionButtons(AdminInterface $admin, $list, $action, ?object $object = null): array { - if (!\in_array($action, ['edit', 'show'])) { + if (!\in_array($action, ['edit', 'show'], true)) { return $list; } diff --git a/packages/sonata-integration-bundle/User/Form/AdminLoginForm.php b/packages/sonata-integration-bundle/User/Form/AdminLoginForm.php index 27a3a709e..187fe8e0e 100644 --- a/packages/sonata-integration-bundle/User/Form/AdminLoginForm.php +++ b/packages/sonata-integration-bundle/User/Form/AdminLoginForm.php @@ -47,7 +47,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'form.authenticate.field.submit', 'attr' => ['class' => 'btn-primary'], ] - ); + ) + ; } public function configureOptions(OptionsResolver $resolver): void @@ -55,6 +56,7 @@ public function configureOptions(OptionsResolver $resolver): void $resolver ->setDefaults([ 'translation_domain' => 'DrawUserBundle', - ]); + ]) + ; } } diff --git a/packages/sonata-integration-bundle/User/Form/ChangePasswordForm.php b/packages/sonata-integration-bundle/User/Form/ChangePasswordForm.php index 0bd3d999e..9a94df721 100644 --- a/packages/sonata-integration-bundle/User/Form/ChangePasswordForm.php +++ b/packages/sonata-integration-bundle/User/Form/ChangePasswordForm.php @@ -42,7 +42,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'form.change_password.field.submit', 'attr' => ['class' => 'btn-primary'], ] - ); + ) + ; } public function configureOptions(OptionsResolver $resolver): void diff --git a/packages/sonata-integration-bundle/User/Form/Enable2faForm.php b/packages/sonata-integration-bundle/User/Form/Enable2faForm.php index 5b9bbfa09..ee3907fc6 100644 --- a/packages/sonata-integration-bundle/User/Form/Enable2faForm.php +++ b/packages/sonata-integration-bundle/User/Form/Enable2faForm.php @@ -36,7 +36,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'form.enable_2fa.field.submit', 'attr' => ['class' => 'btn-primary', 'style' => 'float: left;'], ] - ); + ) + ; $user = $options['user'] ?? null; @@ -53,7 +54,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ], 'validation_groups' => false, ] - ); + ) + ; } } @@ -67,6 +69,7 @@ public function configureOptions(OptionsResolver $resolver): void 'attr' => [ 'novalidate' => 'novalidate', ], - ]); + ]) + ; } } diff --git a/packages/sonata-integration-bundle/User/Form/ForgotPasswordForm.php b/packages/sonata-integration-bundle/User/Form/ForgotPasswordForm.php index fa8962c93..918324397 100644 --- a/packages/sonata-integration-bundle/User/Form/ForgotPasswordForm.php +++ b/packages/sonata-integration-bundle/User/Form/ForgotPasswordForm.php @@ -36,7 +36,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'form.forgot_password.field.submit', 'attr' => ['class' => 'btn-primary'], ] - ); + ) + ; } public function configureOptions(OptionsResolver $resolver): void @@ -44,6 +45,7 @@ public function configureOptions(OptionsResolver $resolver): void $resolver ->setDefaults([ 'translation_domain' => 'DrawUserBundle', - ]); + ]) + ; } } diff --git a/packages/tester-bundle/DependencyInjection/CompilerPass.php b/packages/tester-bundle/DependencyInjection/CompilerPass.php index 39f9c6a3b..77d08a0b7 100644 --- a/packages/tester-bundle/DependencyInjection/CompilerPass.php +++ b/packages/tester-bundle/DependencyInjection/CompilerPass.php @@ -26,13 +26,15 @@ public function process(ContainerBuilder $container): void ->setArgument( '$serviceProvider', ServiceLocatorTagPass::register($container, $expressionEvaluators) - ); + ) + ; foreach ($container->findTaggedServiceIds('messenger.receiver') as $receiverId => $tags) { $transportTester = (new Definition(TransportTester::class)) ->setArgument('$transport', new Reference($receiverId)) ->setArgument('$evaluator', new Reference('draw.tester.expression_filter')) - ->setPublic(true); + ->setPublic(true) + ; $container->setDefinition($receiverId.'.draw.tester', $transportTester); } diff --git a/packages/tester-bundle/DependencyInjection/Configuration.php b/packages/tester-bundle/DependencyInjection/Configuration.php index b98e49c2d..80cdd48e2 100755 --- a/packages/tester-bundle/DependencyInjection/Configuration.php +++ b/packages/tester-bundle/DependencyInjection/Configuration.php @@ -18,7 +18,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayNode('profiling') ->{class_exists(ProfilerCoordinator::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->end() - ->end(); + ->end() + ; return $treeBuilder; } diff --git a/packages/tester-bundle/DependencyInjection/DrawTesterExtension.php b/packages/tester-bundle/DependencyInjection/DrawTesterExtension.php index 69ea2b3a0..d5f16e6c6 100644 --- a/packages/tester-bundle/DependencyInjection/DrawTesterExtension.php +++ b/packages/tester-bundle/DependencyInjection/DrawTesterExtension.php @@ -18,11 +18,13 @@ public function load(array $configs, ContainerBuilder $container): void $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); $container ->registerForAutoconfiguration(ProfilerInterface::class) - ->addTag(ProfilerInterface::class); + ->addTag(ProfilerInterface::class) + ; $container ->registerForAutoconfiguration(ExpressionEvaluator::class) - ->addTag(ExpressionEvaluator::class); + ->addTag(ExpressionEvaluator::class) + ; $fileLocator = new FileLocator(__DIR__.'/../Resources/config'); $fileLoader = new Loader\XmlFileLoader($container, $fileLocator); diff --git a/packages/tester-bundle/JsonResponseAssertionsTrait.php b/packages/tester-bundle/JsonResponseAssertionsTrait.php index fe77ce023..710d4d847 100644 --- a/packages/tester-bundle/JsonResponseAssertionsTrait.php +++ b/packages/tester-bundle/JsonResponseAssertionsTrait.php @@ -37,12 +37,14 @@ public static function assertResponseJsonAgainstFile(string $file, array $proper $file, $propertyPathsCheck ) - ); + ) + ; } public static function getJsonResponseDataTester(): DataTester { return (new DataTester(static::getResponseContent())) - ->transform('json_decode'); + ->transform('json_decode') + ; } } diff --git a/packages/tester-bundle/Messenger/TransportTester.php b/packages/tester-bundle/Messenger/TransportTester.php index 1e2b990f7..067b960c8 100644 --- a/packages/tester-bundle/Messenger/TransportTester.php +++ b/packages/tester-bundle/Messenger/TransportTester.php @@ -30,6 +30,7 @@ public function getTransport(): InMemoryTransport /** * @template T of object + * * @param class-string $messageClass the name of the class * * @return array @@ -46,7 +47,8 @@ public function assertMessageMatch( } $query = (new Query()) - ->where(new ConstraintExpression(null, new Type($messageClass))); + ->where(new ConstraintExpression(null, new Type($messageClass))) + ; if ($expression) { $query = $query->andWhere($expression); diff --git a/packages/tester-bundle/PHPUnit/Extension/DeleteTemporaryEntity/DeleteTemporaryEntityExtension.php b/packages/tester-bundle/PHPUnit/Extension/DeleteTemporaryEntity/DeleteTemporaryEntityExtension.php index db4e9e9eb..ffe7d2745 100644 --- a/packages/tester-bundle/PHPUnit/Extension/DeleteTemporaryEntity/DeleteTemporaryEntityExtension.php +++ b/packages/tester-bundle/PHPUnit/Extension/DeleteTemporaryEntity/DeleteTemporaryEntityExtension.php @@ -54,12 +54,8 @@ public function notify(TestSuiteFinished $event): void \assert($temporaryEntityFactory instanceof TemporaryEntityCleanerInterface); $temporaryEntityFactory->deleteTemporaryEntities(); - } catch (\Throwable $error) { - throw new \RuntimeException( - 'Failed to delete temporary entities in '.$class.'. '.$error->getMessage(), - previous: $error - ); + throw new \RuntimeException('Failed to delete temporary entities in '.$class.'. '.$error->getMessage(), previous: $error); } } } diff --git a/packages/tester-bundle/PHPUnit/Extension/DoctrineTransaction/DoctrineTransactionExtension.php b/packages/tester-bundle/PHPUnit/Extension/DoctrineTransaction/DoctrineTransactionExtension.php index 688002c44..bafc57d79 100644 --- a/packages/tester-bundle/PHPUnit/Extension/DoctrineTransaction/DoctrineTransactionExtension.php +++ b/packages/tester-bundle/PHPUnit/Extension/DoctrineTransaction/DoctrineTransactionExtension.php @@ -75,6 +75,6 @@ public static function startTransactionIfNeeded(string $class): void StaticDriver::setKeepStaticConnections(true); - static::begin(); + self::begin(); } } diff --git a/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireClient.php b/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireClient.php index 14e904457..e902a4cc7 100644 --- a/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireClient.php +++ b/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireClient.php @@ -37,13 +37,7 @@ public function getServer(): array public function autowire(TestCase $testCase, \ReflectionProperty $reflectionProperty): void { if (!$testCase instanceof SymfonyWebTestCase && !$testCase instanceof DrawWebTestCase) { - throw new \RuntimeException( - \sprintf( - 'AutowireClient attribute can only be used in %s or %s.', - SymfonyWebTestCase::class, - DrawWebTestCase::class - ) - ); + throw new \RuntimeException(\sprintf('AutowireClient attribute can only be used in %s or %s.', SymfonyWebTestCase::class, DrawWebTestCase::class)); } // This is to ensure the kernel is not booted before calling createClient diff --git a/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireEntity.php b/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireEntity.php index ce04496a5..9b5517d38 100644 --- a/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireEntity.php +++ b/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowireEntity.php @@ -43,7 +43,8 @@ public function autowire(TestCase $testCase, \ReflectionProperty $reflectionProp ->get(ManagerRegistry::class) ->getManager() ->getRepository($class) - ->findOneBy($this->criteria); + ->findOneBy($this->criteria) + ; $reflectionProperty->setValue( $testCase, diff --git a/packages/tester-bundle/Tests/DependencyInjection/Compiler/MessengerPassTest.php b/packages/tester-bundle/Tests/DependencyInjection/Compiler/MessengerPassTest.php index 43dce1145..e29b1f9df 100644 --- a/packages/tester-bundle/Tests/DependencyInjection/Compiler/MessengerPassTest.php +++ b/packages/tester-bundle/Tests/DependencyInjection/Compiler/MessengerPassTest.php @@ -9,6 +9,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +/** + * @internal + */ #[CoversClass(MessengerPass::class)] class MessengerPassTest extends TestCase { diff --git a/packages/tester-bundle/Tests/DependencyInjection/ConfigurationTest.php b/packages/tester-bundle/Tests/DependencyInjection/ConfigurationTest.php index 1d033dcbd..aefeae3d8 100644 --- a/packages/tester-bundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/packages/tester-bundle/Tests/DependencyInjection/ConfigurationTest.php @@ -6,6 +6,9 @@ use Draw\Component\Tester\Test\DependencyInjection\ConfigurationTestCase; use Symfony\Component\Config\Definition\ConfigurationInterface; +/** + * @internal + */ class ConfigurationTest extends ConfigurationTestCase { public function createConfiguration(): ConfigurationInterface diff --git a/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionTest.php b/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionTest.php index b40a141bf..2b40f1f03 100644 --- a/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionTest.php +++ b/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionTest.php @@ -12,6 +12,9 @@ use Draw\Component\Tester\Test\DependencyInjection\ExtensionTestCase; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawTesterExtensionTest extends ExtensionTestCase { public function createExtension(): Extension diff --git a/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionWithoutProfilingTest.php b/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionWithoutProfilingTest.php index 269c1f4cb..53e67e496 100644 --- a/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionWithoutProfilingTest.php +++ b/packages/tester-bundle/Tests/DependencyInjection/DrawTesterExtensionWithoutProfilingTest.php @@ -5,6 +5,9 @@ use Draw\Bundle\TesterBundle\Profiling\SqlProfiler; use Draw\Component\Profiling\ProfilerCoordinator; +/** + * @internal + */ class DrawTesterExtensionWithoutProfilingTest extends DrawTesterExtensionTest { public function getConfiguration(): array diff --git a/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php b/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php index f46de3d72..b8fc96f2a 100644 --- a/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php +++ b/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\ExpectationFailedException; use Symfony\Component\Messenger\Envelope; +/** + * @internal + */ class TransportTesterTest extends TestCase implements AutowiredInterface { #[AutowireTransportTester('memory')] diff --git a/packages/tester-bundle/Tests/TestCase.php b/packages/tester-bundle/Tests/TestCase.php index 6a6a761c3..72f2fbbef 100644 --- a/packages/tester-bundle/Tests/TestCase.php +++ b/packages/tester-bundle/Tests/TestCase.php @@ -4,6 +4,9 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +/** + * @internal + */ class TestCase extends KernelTestCase { protected static function getKernelClass(): string diff --git a/packages/tester/Application/CommandDataTester.php b/packages/tester/Application/CommandDataTester.php index ce817759b..36f79d8d2 100644 --- a/packages/tester/Application/CommandDataTester.php +++ b/packages/tester/Application/CommandDataTester.php @@ -23,7 +23,8 @@ public static function create( ): self { return (new self())->setExpectedStatusCode($expectedStatusCode) ->setExpectedDisplay($expectedDisplay) - ->setExpectedErrorOutput($expectedErrorOutput); + ->setExpectedErrorOutput($expectedErrorOutput) + ; } public function getExpectedDisplay(): array|string|null diff --git a/packages/tester/AssertTrait.php b/packages/tester/AssertTrait.php index c17c9fcfc..99f948c78 100644 --- a/packages/tester/AssertTrait.php +++ b/packages/tester/AssertTrait.php @@ -5,9 +5,6 @@ use PHPUnit\Framework\Assert; use Symfony\Component\PropertyAccess\PropertyPathInterface; -/** - * @internal - */ trait AssertTrait { /** @@ -20,8 +17,6 @@ abstract public function getData($path = null); // example-start: assertContains /** * Asserts that a haystack contains a needle. - * - * @param mixed $needle */ public function assertContains($needle, string $message = ''): self { @@ -34,8 +29,6 @@ public function assertContains($needle, string $message = ''): self // example-start: assertNotContains /** * Asserts that a haystack does not contain a needle. - * - * @param mixed $needle */ public function assertNotContains($needle, string $message = ''): self { @@ -108,8 +101,6 @@ public function assertNotCount(int $expectedCount, string $message = ''): self // example-start: assertEquals /** * Asserts that two variables are equal. - * - * @param mixed $expected */ public function assertEquals($expected, string $message = ''): self { @@ -122,8 +113,6 @@ public function assertEquals($expected, string $message = ''): self // example-start: assertNotEquals /** * Asserts that two variables are not equal. - * - * @param mixed $expected */ public function assertNotEquals($expected, string $message = ''): self { @@ -160,8 +149,6 @@ public function assertNotEmpty(string $message = ''): self // example-start: assertGreaterThan /** * Asserts that a value is greater than another value. - * - * @param mixed $expected */ public function assertGreaterThan($expected, string $message = ''): self { @@ -174,8 +161,6 @@ public function assertGreaterThan($expected, string $message = ''): self // example-start: assertGreaterThanOrEqual /** * Asserts that a value is greater than or equal to another value. - * - * @param mixed $expected */ public function assertGreaterThanOrEqual($expected, string $message = ''): self { @@ -188,8 +173,6 @@ public function assertGreaterThanOrEqual($expected, string $message = ''): self // example-start: assertLessThan /** * Asserts that a value is smaller than another value. - * - * @param mixed $expected */ public function assertLessThan($expected, string $message = ''): self { @@ -202,8 +185,6 @@ public function assertLessThan($expected, string $message = ''): self // example-start: assertLessThanOrEqual /** * Asserts that a value is smaller than or equal to another value. - * - * @param mixed $expected */ public function assertLessThanOrEqual($expected, string $message = ''): self { @@ -326,8 +307,6 @@ public function assertNan(string $message = ''): self * Asserts that two variables have the same type and value. * Used on objects, it asserts that two variables reference * the same object. - * - * @param mixed $expected */ public function assertSame($expected, string $message = ''): self { @@ -342,8 +321,6 @@ public function assertSame($expected, string $message = ''): self * Asserts that two variables do not have the same type and value. * Used on objects, it asserts that two variables do not reference * the same object. - * - * @param mixed $expected */ public function assertNotSame($expected, string $message = ''): self { @@ -542,8 +519,6 @@ public function assertNotContainsEquals($needle, string $message = ''): self // example-start: assertEqualsCanonicalizing /** * Asserts that two variables are equal (canonicalizing). - * - * @param mixed $expected */ public function assertEqualsCanonicalizing($expected, string $message = ''): self { @@ -556,8 +531,6 @@ public function assertEqualsCanonicalizing($expected, string $message = ''): sel // example-start: assertEqualsIgnoringCase /** * Asserts that two variables are equal (ignoring case). - * - * @param mixed $expected */ public function assertEqualsIgnoringCase($expected, string $message = ''): self { @@ -570,8 +543,6 @@ public function assertEqualsIgnoringCase($expected, string $message = ''): self // example-start: assertEqualsWithDelta /** * Asserts that two variables are equal (with delta). - * - * @param mixed $expected */ public function assertEqualsWithDelta($expected, float $delta, string $message = ''): self { @@ -584,8 +555,6 @@ public function assertEqualsWithDelta($expected, float $delta, string $message = // example-start: assertNotEqualsCanonicalizing /** * Asserts that two variables are not equal (canonicalizing). - * - * @param mixed $expected */ public function assertNotEqualsCanonicalizing($expected, string $message = ''): self { @@ -598,8 +567,6 @@ public function assertNotEqualsCanonicalizing($expected, string $message = ''): // example-start: assertNotEqualsIgnoringCase /** * Asserts that two variables are not equal (ignoring case). - * - * @param mixed $expected */ public function assertNotEqualsIgnoringCase($expected, string $message = ''): self { @@ -612,8 +579,6 @@ public function assertNotEqualsIgnoringCase($expected, string $message = ''): se // example-start: assertNotEqualsWithDelta /** * Asserts that two variables are not equal (with delta). - * - * @param mixed $expected */ public function assertNotEqualsWithDelta($expected, float $delta, string $message = ''): self { diff --git a/packages/tester/Command/DumpAssertMethodsCommand.php b/packages/tester/Command/DumpAssertMethodsCommand.php index 0a32e0a0e..8c55eaf6c 100644 --- a/packages/tester/Command/DumpAssertMethodsCommand.php +++ b/packages/tester/Command/DumpAssertMethodsCommand.php @@ -15,7 +15,8 @@ protected function configure(): void $this ->setName('draw:tester:dump-assert-methods') ->setDescription('Dump all PHPUnit Assert Methods in a json file to use for generation ') - ->addArgument('filePath', InputArgument::REQUIRED, 'The file path where to dump.'); + ->addArgument('filePath', InputArgument::REQUIRED, 'The file path where to dump.') + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -43,28 +44,28 @@ protected function execute(InputInterface $input, OutputInterface $output): int $guessParameter = null; switch (true) { - case \in_array('actual', $parameters): + case \in_array('actual', $parameters, true): $guessParameter = 'actual'; break; - case \in_array('array', $parameters): + case \in_array('array', $parameters, true): $guessParameter = 'array'; break; - case \in_array('haystack', $parameters): + case \in_array('haystack', $parameters, true): $guessParameter = 'haystack'; break; - case \in_array('condition', $parameters): + case \in_array('condition', $parameters, true): $guessParameter = 'condition'; break; - case \in_array('className', $parameters): + case \in_array('className', $parameters, true): $guessParameter = 'className'; break; - case \in_array('object', $parameters): + case \in_array('object', $parameters, true): $guessParameter = 'object'; break; - case \in_array('string', $parameters): + case \in_array('string', $parameters, true): $guessParameter = 'string'; break; - case 2 == \count($parameters): + case 2 === \count($parameters): $guessParameter = $parameters[0]; break; default: diff --git a/packages/tester/Command/GenerateAssertsDocumentationPageCommand.php b/packages/tester/Command/GenerateAssertsDocumentationPageCommand.php index 3cd6ed598..828cd9764 100644 --- a/packages/tester/Command/GenerateAssertsDocumentationPageCommand.php +++ b/packages/tester/Command/GenerateAssertsDocumentationPageCommand.php @@ -19,7 +19,8 @@ protected function configure(): void InputArgument::OPTIONAL, 'The file path where the methods configuration are.', __DIR__.'/../Resources/config/assert_methods.json' - ); + ) + ; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -48,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $file .= " -$methodName +{$methodName} ".str_pad('', \strlen($methodName), '^').' .. literalinclude:: ../AssertTrait.php diff --git a/packages/tester/Command/GenerateTraitCommand.php b/packages/tester/Command/GenerateTraitCommand.php index 35bea3a09..55be5a622 100644 --- a/packages/tester/Command/GenerateTraitCommand.php +++ b/packages/tester/Command/GenerateTraitCommand.php @@ -20,7 +20,8 @@ protected function configure(): void InputArgument::OPTIONAL, 'The file path where the methods configuration are.', __DIR__.'/../Resources/config/assert_methods.json' - ); + ) + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/packages/tester/Command/TestsCoverageCheckCommand.php b/packages/tester/Command/TestsCoverageCheckCommand.php index 86a8712fe..f5e71f22b 100644 --- a/packages/tester/Command/TestsCoverageCheckCommand.php +++ b/packages/tester/Command/TestsCoverageCheckCommand.php @@ -16,7 +16,8 @@ protected function configure(): void ->setName('draw:tester:coverage-check') ->setDescription('Check the code coverage by the tests') ->addArgument('clover-xlm-file-path', InputArgument::REQUIRED, 'Clover report file path') - ->addArgument('coverage', InputArgument::REQUIRED, 'Required coverage in percentage'); + ->addArgument('coverage', InputArgument::REQUIRED, 'Required coverage in percentage') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/packages/tester/Data/AgainstJsonFileTester.php b/packages/tester/Data/AgainstJsonFileTester.php index 57074bc5f..4fa6bbe3a 100644 --- a/packages/tester/Data/AgainstJsonFileTester.php +++ b/packages/tester/Data/AgainstJsonFileTester.php @@ -30,14 +30,14 @@ public function __invoke(DataTester $tester): void foreach ($this->propertyPathsCheck as $path => $callable) { if ($callable instanceof Constraint) { $constraint = $callable; - $callable = function (DataTester $dataTester) use ($constraint, $path): void { + $callable = static function (DataTester $dataTester) use ($constraint, $path): void { TestCase::assertThat($dataTester->getData(), $constraint, 'Path: '.$path); }; } if (!\is_callable($callable)) { $value = $callable; - $callable = function (DataTester $tester) use ($value, $path): void { + $callable = static function (DataTester $tester) use ($value, $path): void { $tester->assertEquals($value, 'Path: '.$path); }; } diff --git a/packages/tester/Data/ViolationListTester.php b/packages/tester/Data/ViolationListTester.php index 356908e58..d9cdcdffe 100644 --- a/packages/tester/Data/ViolationListTester.php +++ b/packages/tester/Data/ViolationListTester.php @@ -17,7 +17,7 @@ public function __invoke(DataTester $tester): void foreach ($this->violations as $index => $violation) { foreach ($violation as $property => $value) { - $tester->path("[$index].$property")->assertSame($value); + $tester->path("[{$index}].{$property}")->assertSame($value); } } } diff --git a/packages/tester/DependencyInjection/TesterIntegration.php b/packages/tester/DependencyInjection/TesterIntegration.php index fc0b90032..5cd0002d9 100644 --- a/packages/tester/DependencyInjection/TesterIntegration.php +++ b/packages/tester/DependencyInjection/TesterIntegration.php @@ -26,7 +26,8 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con new Definition(TestsCoverageCheckCommand::class) ) ->setAutoconfigured(true) - ->setAutowired(true); + ->setAutowired(true) + ; $container->setAlias(TestsCoverageCheckCommand::class, 'draw.tester.command.tests_coverage_check_command'); } diff --git a/packages/tester/DoctrineOrmTrait.php b/packages/tester/DoctrineOrmTrait.php index 13e514ba3..316baa155 100644 --- a/packages/tester/DoctrineOrmTrait.php +++ b/packages/tester/DoctrineOrmTrait.php @@ -118,6 +118,5 @@ public function getManagerForClass($class) return $this->entityManager; } }; - } } diff --git a/packages/tester/Test/DependencyInjection/ConfigurationTestCase.php b/packages/tester/Test/DependencyInjection/ConfigurationTestCase.php index 209810dd1..6f0754a97 100644 --- a/packages/tester/Test/DependencyInjection/ConfigurationTestCase.php +++ b/packages/tester/Test/DependencyInjection/ConfigurationTestCase.php @@ -49,7 +49,7 @@ public function testDefault(): void { $config = $this->processConfiguration([[]]); - static::assertEquals( + static::assertEqualsCanonicalizing( $this->getDefaultConfiguration(), $config ); diff --git a/packages/tester/Test/DependencyInjection/ExtensionTestCase.php b/packages/tester/Test/DependencyInjection/ExtensionTestCase.php index ceef04de5..6bbaa4887 100644 --- a/packages/tester/Test/DependencyInjection/ExtensionTestCase.php +++ b/packages/tester/Test/DependencyInjection/ExtensionTestCase.php @@ -28,7 +28,7 @@ abstract public static function provideTestHasServiceDefinition(): iterable; protected static function removeProvidedService(array $idsToRemove, iterable $providedServices): iterable { foreach ($providedServices as $providedService) { - if (!\in_array($providedService[0], $idsToRemove)) { + if (!\in_array($providedService[0], $idsToRemove, true)) { yield $providedService; } } @@ -79,7 +79,7 @@ private function assertServiceDefinition(string $id, ?string $aliasOf = null): v ); if ($aliasOf) { - static::assertEquals($aliasOf, self::$containerBuilder->getAlias($id)); + static::assertSame($aliasOf, (string) self::$containerBuilder->getAlias($id)); } } diff --git a/packages/tester/Tests/Command/TestsCoverageCheckCommandTest.php b/packages/tester/Tests/Command/TestsCoverageCheckCommandTest.php index ab9eb7786..0e5d531d5 100644 --- a/packages/tester/Tests/Command/TestsCoverageCheckCommandTest.php +++ b/packages/tester/Tests/Command/TestsCoverageCheckCommandTest.php @@ -10,6 +10,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Tester\CommandTester; +/** + * @internal + */ #[CoversClass(TestsCoverageCheckCommand::class)] class TestsCoverageCheckCommandTest extends TestCase { diff --git a/packages/tester/Tests/Data/AgainstJsonFileTesterTest.php b/packages/tester/Tests/Data/AgainstJsonFileTesterTest.php index 122519836..1d1e8df40 100644 --- a/packages/tester/Tests/Data/AgainstJsonFileTesterTest.php +++ b/packages/tester/Tests/Data/AgainstJsonFileTesterTest.php @@ -9,6 +9,9 @@ use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class AgainstJsonFileTesterTest extends TestCase { private static \stdClass $data; @@ -21,7 +24,8 @@ public static function setUpBeforeClass(): void public function testInvoke(): void { (new DataTester(self::$data)) - ->test(new AgainstJsonFileTester(__DIR__.'/fixtures/AgainstJsonFileTesterTest.json')); + ->test(new AgainstJsonFileTester(__DIR__.'/fixtures/AgainstJsonFileTesterTest.json')) + ; } public function testInvokeDoesNotMatch(): void @@ -30,7 +34,8 @@ public function testInvokeDoesNotMatch(): void $this->expectExceptionMessage('Failed asserting that two objects are equal.'); (new DataTester((object) ['url' => 'toto'])) - ->test(new AgainstJsonFileTester(__DIR__.'/fixtures/AgainstJsonFileTesterTest.json')); + ->test(new AgainstJsonFileTester(__DIR__.'/fixtures/AgainstJsonFileTesterTest.json')) + ; } public function testInvokePropertyPathChecksValue(): void @@ -43,7 +48,8 @@ public function testInvokePropertyPathChecksValue(): void 'url' => 'http://google.com', ] ) - ); + ) + ; } public function testInvokePropertyPathChecksViaConstraint(): void @@ -56,7 +62,8 @@ public function testInvokePropertyPathChecksViaConstraint(): void 'url' => new IsType(IsType::TYPE_STRING), ] ) - ); + ) + ; } public function testInvokePropertyPathChecksValueFail(): void @@ -73,7 +80,8 @@ public function testInvokePropertyPathChecksValueFail(): void 'url' => 'wrong-value', ] ) - ); + ) + ; } public function testInvokePropertyPathChecksCallable(): void @@ -84,7 +92,7 @@ public function testInvokePropertyPathChecksCallable(): void new AgainstJsonFileTester( __DIR__.'/fixtures/AgainstJsonFileTesterTest.json', [ - 'url' => function (DataTester $dataTester) use (&$called): void { + 'url' => static function (DataTester $dataTester) use (&$called): void { // Make sure the DataTester have the value of the path $dataTester->assertEquals('http://google.com'); @@ -92,7 +100,8 @@ public function testInvokePropertyPathChecksCallable(): void }, ] ) - ); + ) + ; static::assertTrue($called); } @@ -105,13 +114,14 @@ public function testInvokePropertyPathChecksCallableFail(): void new AgainstJsonFileTester( __DIR__.'/fixtures/AgainstJsonFileTesterTest.json', [ - 'url' => function (DataTester $dataTester): void { + 'url' => static function (DataTester $dataTester): void { // Make sure the DataTester have the value of the path $dataTester->assertEquals('wrong-value'); }, ] ) - ); + ) + ; } public function testInvokeFileNotFoundException(): void @@ -131,6 +141,7 @@ public function testInvokeFileNotFoundException(): void ); (new DataTester(self::$data)) - ->test(new AgainstJsonFileTester($filePath)); + ->test(new AgainstJsonFileTester($filePath)) + ; } } diff --git a/packages/tester/Tests/DataTesterTest.php b/packages/tester/Tests/DataTesterTest.php index 3620ac0bc..22aa64c6c 100644 --- a/packages/tester/Tests/DataTesterTest.php +++ b/packages/tester/Tests/DataTesterTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Constraint\IsIdentical; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class DataTesterTest extends TestCase { public function testAssertPathIsNotReadable(): void @@ -56,7 +59,8 @@ public function testChain(): void $tester->path('key1')->assertSame('value1'); $tester ->path('key2')->assertCount(2) - ->path('[0]')->assertSame('arrayValue0'); + ->path('[0]')->assertSame('arrayValue0') + ; $tester->path('key2[1]')->assertSame('arrayValue1'); } @@ -71,7 +75,7 @@ public function testIfPathIsReadable(): void $tester, $tester->ifPathIsReadable( 'toto', - function (DataTester $tester) use (&$hasBeenCalled): void { + static function (DataTester $tester) use (&$hasBeenCalled): void { // To remove the warning of the ide we use the variable // assigning true would have been enough $hasBeenCalled = null !== $tester; @@ -100,7 +104,7 @@ public function testEach(): void static::assertSame( $tester, $tester->each( - function (DataTester $tester) use (&$callbackCount): void { + static function (DataTester $tester) use (&$callbackCount): void { ++$callbackCount; } ) diff --git a/packages/tester/Tests/DependencyInjection/TesterIntegrationTest.php b/packages/tester/Tests/DependencyInjection/TesterIntegrationTest.php index 18aa87eae..03ac7257c 100644 --- a/packages/tester/Tests/DependencyInjection/TesterIntegrationTest.php +++ b/packages/tester/Tests/DependencyInjection/TesterIntegrationTest.php @@ -11,6 +11,8 @@ /** * @property TesterIntegration $integration + * + * @internal */ #[CoversClass(TesterIntegration::class)] class TesterIntegrationTest extends IntegrationTestCase diff --git a/packages/tester/Tests/ExampleTest.php b/packages/tester/Tests/ExampleTest.php index dbc758a13..76842b094 100644 --- a/packages/tester/Tests/ExampleTest.php +++ b/packages/tester/Tests/ExampleTest.php @@ -5,6 +5,9 @@ use Draw\Component\Tester\DataTester; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class ExampleTest extends TestCase { public function test(): void @@ -13,7 +16,8 @@ public function test(): void $tester = new DataTester($dataToTest); $tester - ->assertSame('A string value'); + ->assertSame('A string value') + ; } // example-end: TestClass @@ -22,7 +26,8 @@ public function testConciseNew(): void { // example-start: ConciseNew (new DataTester('A string value')) - ->assertSame('A string value'); + ->assertSame('A string value') + ; // example-end: ConciseNew } @@ -31,7 +36,8 @@ public function testPath(): void // example-start: TestPath (new DataTester((object) ['key' => 'value'])) ->path('key') - ->assertSame('value'); + ->assertSame('value') + ; // example-end: TestPath } @@ -49,7 +55,8 @@ public function testDeeperPath(): void // example-start: DeeperPathTest (new DataTester((object) ['level1' => (object) ['level2' => 'value']])) ->path('level1') - ->path('level2')->assertSame('value'); + ->path('level2')->assertSame('value') + ; // example-end: DeeperPathTest } @@ -58,10 +65,11 @@ public function testEach(): void // example-start: EachTest (new DataTester(['value1', 'value2'])) ->each( - function (DataTester $tester): void { + static function (DataTester $tester): void { $tester->assertIsString(); } - ); + ) + ; // example-end: EachTest } @@ -70,7 +78,8 @@ public function testTransform(): void // example-start: Transform (new DataTester('{"key":"value"}')) ->transform('json_decode') - ->path('key')->assertSame('value'); + ->path('key')->assertSame('value') + ; // example-end: Transform } @@ -80,7 +89,8 @@ public function testTransformAssert(): void (new DataTester('{"key":"value"}')) ->assertJson() ->transform('json_decode') - ->path('key')->assertSame('value'); + ->path('key')->assertSame('value') + ; // example-end: AssertTransform } @@ -89,8 +99,9 @@ public function testTransformAssertCustom(): void // example-start: AssertTransformCustom (new DataTester('{"key":"value"}')) ->assertJson() - ->transform(fn ($data) => json_decode((string) $data, true, 512, \JSON_THROW_ON_ERROR)) - ->path('[key]')->assertSame('value'); + ->transform(static fn ($data) => json_decode((string) $data, true, 512, \JSON_THROW_ON_ERROR)) + ->path('[key]')->assertSame('value') + ; // example-end: AssertTransformCustom } @@ -100,10 +111,11 @@ public function testIfPathIsReadable(): void (new DataTester(null)) ->ifPathIsReadable( 'notExistingPath', - function (DataTester $tester): void { + static function (DataTester $tester): void { // Will not be call with current data to test } - ); + ) + ; // example-end: IfPathIsReadable static::assertTrue(true); // This is to prevent PHPUnit to flag test as risky } @@ -124,17 +136,18 @@ public function testIfPathIsReadableAndEach(): void ]; (new DataTester($users)) ->each( - function (DataTester $tester): void { + static function (DataTester $tester): void { $tester->path('firstName')->assertIsString(); $tester->path('active')->assertIsBool(); $tester->ifPathIsReadable( 'referral', - function (DataTester $tester): void { + static function (DataTester $tester): void { $tester->assertIsString(); } ); } - ); + ) + ; // example-end: IfPathIsReadableAndEach } @@ -148,7 +161,8 @@ public function testUser(): void ]; (new DataTester($user)) - ->test(new UserDataTester()); + ->test(new UserDataTester()) + ; // example-end: TestWithClassCallable } @@ -168,7 +182,8 @@ public function testUsers(): void ]; (new DataTester($users)) - ->each(new UserDataTester()); + ->each(new UserDataTester()) + ; // example-end: EachWithClassCallableEach } } @@ -182,7 +197,7 @@ public function __invoke(DataTester $tester): void $tester->path('active')->assertIsBool(); $tester->ifPathIsReadable( 'referral', - function (DataTester $tester): void { + static function (DataTester $tester): void { $tester->assertIsString(); } ); diff --git a/packages/user-bundle/AccountLocker.php b/packages/user-bundle/AccountLocker.php index af280e83d..48f80321c 100644 --- a/packages/user-bundle/AccountLocker.php +++ b/packages/user-bundle/AccountLocker.php @@ -46,7 +46,7 @@ public function getActiveLocks(LockableUserInterface $user): array { return array_filter( $this->refreshUserLocks($user), - fn (UserLock $userLock) => $userLock->isActive() + static fn (UserLock $userLock) => $userLock->isActive() ); } } diff --git a/packages/user-bundle/Command/RefreshUserLocksCommand.php b/packages/user-bundle/Command/RefreshUserLocksCommand.php index 4f7c6270f..676ae2891 100644 --- a/packages/user-bundle/Command/RefreshUserLocksCommand.php +++ b/packages/user-bundle/Command/RefreshUserLocksCommand.php @@ -26,7 +26,8 @@ protected function configure(): void ->setDescription( 'Send a [RefreshUserLockMessage] for all user.'.\PHP_EOL. 'Configure you messenger routing properly otherwise it will be sync' - ); + ) + ; } public function execute(InputInterface $input, OutputInterface $output): int @@ -40,7 +41,8 @@ public function execute(InputInterface $input, OutputInterface $output): int $rows = $this->drawUserEntityRepository->createQueryBuilder('user') ->select('user.id') ->getQuery() - ->execute(); + ->execute() + ; foreach ($rows as $row) { $this->messageBus->dispatch(new RefreshUserLockMessage($row['id'])); diff --git a/packages/user-bundle/DependencyInjection/Compiler/ExcludeDoctrineEntitiesCompilerPass.php b/packages/user-bundle/DependencyInjection/Compiler/ExcludeDoctrineEntitiesCompilerPass.php index 391378293..bb8ec6dc7 100644 --- a/packages/user-bundle/DependencyInjection/Compiler/ExcludeDoctrineEntitiesCompilerPass.php +++ b/packages/user-bundle/DependencyInjection/Compiler/ExcludeDoctrineEntitiesCompilerPass.php @@ -17,6 +17,7 @@ public function process(ContainerBuilder $container): void ->addMethodCall( 'addExcludePaths', [$container->getParameter('draw.user.orm.metadata_driver.exclude_paths')] - ); + ) + ; } } diff --git a/packages/user-bundle/DependencyInjection/Configuration.php b/packages/user-bundle/DependencyInjection/Configuration.php index 715541e9b..0b2af4d52 100755 --- a/packages/user-bundle/DependencyInjection/Configuration.php +++ b/packages/user-bundle/DependencyInjection/Configuration.php @@ -44,7 +44,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->append($this->createEmailWritersNodes()) ->scalarNode('user_entity_class') ->validate() - ->ifTrue(fn ($value) => !class_exists($value)) + ->ifTrue(static fn ($value) => !class_exists($value)) ->thenInvalid('The class [%s] for the user entity must exists.') ->end() ->defaultValue(User::class) @@ -55,7 +55,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('invite_create_account_route') ->defaultValue('home') ->end() - ->end(); + ->end() + ; return $treeBuilder; } @@ -80,7 +81,8 @@ private function createEmailWritersNodes(): ArrayNodeDefinition ->arrayNode('to_user') ->canBeDisabled() ->end() - ->end(); + ->end() + ; } private function createAccountLockerNode(): ArrayNodeDefinition @@ -92,7 +94,8 @@ private function createAccountLockerNode(): ArrayNodeDefinition ->arrayNode('entity') ->canBeEnabled() ->end() - ->end(); + ->end() + ; } private function createNeedPasswordChangeEnforcerNode(): ArrayNodeDefinition @@ -101,12 +104,14 @@ private function createNeedPasswordChangeEnforcerNode(): ArrayNodeDefinition ->canBeEnabled() ->children() ->scalarNode('change_password_route')->defaultValue('admin_change_password')->end() - ->end(); + ->end() + ; } private function createOnboardingNode(): ArrayNodeDefinition { return (new ArrayNodeDefinition('onboarding')) - ->canBeEnabled(); + ->canBeEnabled() + ; } } diff --git a/packages/user-bundle/DependencyInjection/DrawUserExtension.php b/packages/user-bundle/DependencyInjection/DrawUserExtension.php index da051046c..f3d4a8c04 100644 --- a/packages/user-bundle/DependencyInjection/DrawUserExtension.php +++ b/packages/user-bundle/DependencyInjection/DrawUserExtension.php @@ -57,7 +57,8 @@ public function load(array $configs, ContainerBuilder $container): void new Definition(EntityRepository::class) ) ->setFactory([new Reference('doctrine'), 'getRepository']) - ->setArgument(0, new Parameter('draw_user.user_entity_class')); + ->setArgument(0, new Parameter('draw_user.user_entity_class')) + ; $container->registerAliasForArgument( 'draw_user.user_repository', @@ -67,7 +68,8 @@ public function load(array $configs, ContainerBuilder $container): void $definition = (new Definition()) ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; $bundleDirectory = realpath(__DIR__.'/..'); @@ -90,26 +92,28 @@ public function load(array $configs, ContainerBuilder $container): void $loader->registerClasses( $definition, - 'Draw\\Bundle\\UserBundle\\', + 'Draw\Bundle\UserBundle\\', $bundleDirectory, $exclude ); $loader->registerClasses( $definition->addTag('controller.service_arguments'), - 'Draw\\Bundle\\UserBundle\\Controller\\', + 'Draw\Bundle\UserBundle\Controller\\', $bundleDirectory.'/Controller/' ); $container - ->setAlias(UserFeedInterface::class, FlashUserFeed::class); + ->setAlias(UserFeedInterface::class, FlashUserFeed::class) + ; $container ->getDefinition(UserRequestInterceptorListener::class) ->setArgument( '$firewallMap', new Reference('security.firewall.map', ContainerInterface::NULL_ON_INVALID_REFERENCE) - ); + ) + ; $this->assignParameters($config, $container); @@ -131,7 +135,8 @@ public function load(array $configs, ContainerBuilder $container): void ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'preUpdate']) ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'prePersist']) ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'postPersist']) - ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'postUpdate']); + ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'postUpdate']) + ; } else { $container->removeDefinition(EncryptPasswordUserEntityListener::class); } @@ -177,11 +182,12 @@ private function configureEmailWriters( $definition = new Definition(); $definition ->setAutowired(true) - ->setAutoconfigured(true); + ->setAutoconfigured(true) + ; $loader->registerClasses( $definition, - 'Draw\\Bundle\\UserBundle\\EmailWriter\\', + 'Draw\Bundle\UserBundle\EmailWriter\\', realpath(__DIR__.'/../EmailWriter'), ); @@ -190,7 +196,8 @@ private function configureEmailWriters( } else { $container->getDefinition(ForgotPasswordEmailWriter::class) ->setArgument('$resetPasswordRoute', new Parameter('draw_user.reset_password_route')) - ->setArgument('$inviteCreateAccountRoute', new Parameter('draw_user.invite_create_account_route')); + ->setArgument('$inviteCreateAccountRoute', new Parameter('draw_user.invite_create_account_route')) + ; } if (!$config['onboarding']['enabled']) { @@ -198,7 +205,8 @@ private function configureEmailWriters( } else { $container ->getDefinition(UserOnboardingEmailWriter::class) - ->setArgument('$messageExpirationDelay', $config['onboarding']['expiration_delay']); + ->setArgument('$messageExpirationDelay', $config['onboarding']['expiration_delay']) + ; } if (!$config['password_change_requested']['enabled']) { @@ -228,7 +236,8 @@ private function configureAccountLocker( $containerBuilder ->getDefinition(AccountLockerListener::class) - ->setArgument('$accountLockedRoute', $config['account_locked_route']); + ->setArgument('$accountLockedRoute', $config['account_locked_route']) + ; } private function configureNeedPasswordChangeEnforcer( @@ -245,7 +254,8 @@ private function configureNeedPasswordChangeEnforcer( $containerBuilder ->getDefinition(PasswordChangeEnforcerListener::class) - ->setArgument('$changePasswordRoute', $config['change_password_route']); + ->setArgument('$changePasswordRoute', $config['change_password_route']) + ; } private function configureOnBoarding( @@ -279,12 +289,14 @@ private function configureEnforce2fa( $containerBuilder ->getDefinition(TwoFactorAuthenticationEntityListener::class) ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'preUpdate']) - ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'prePersist']); + ->addTag('doctrine.orm.entity_listener', ['entity' => $userClass, 'event' => 'prePersist']) + ; $containerBuilder ->getDefinition(TwoFactorAuthenticationListener::class) ->setArgument('$enableRoute', $config['enable_route']) - ->setArgument('$allowedRoutes', $config['allowed_routes']); + ->setArgument('$allowedRoutes', $config['allowed_routes']) + ; if ($config['email']['enabled']) { $containerBuilder->setDefinition( @@ -294,7 +306,8 @@ private function configureEnforce2fa( ->setAutoconfigured(true) ->setAutowired(true) ->setDecoratedService('scheb_two_factor.security.email.provider', 'draw.user.scheb_two_factor.security.email.provider.inner') - ->setArgument('$decorated', new Reference('draw.user.scheb_two_factor.security.email.provider.inner')); + ->setArgument('$decorated', new Reference('draw.user.scheb_two_factor.security.email.provider.inner')) + ; } else { $containerBuilder->removeDefinition(AuthCodeMailer::class); $containerBuilder->removeDefinition(EmailTwoFactorProvider::class); @@ -303,20 +316,23 @@ private function configureEnforce2fa( if ($config['enforcing_roles']) { $containerBuilder ->getDefinition(RolesTwoFactorAuthenticationEnforcer::class) - ->setArgument('$enforcingRoles', $config['enforcing_roles']); + ->setArgument('$enforcingRoles', $config['enforcing_roles']) + ; $containerBuilder ->setAlias( TwoFactorAuthenticationEnforcerInterface::class, RolesTwoFactorAuthenticationEnforcer::class - ); + ) + ; } else { $containerBuilder->removeDefinition(RolesTwoFactorAuthenticationEnforcer::class); $containerBuilder ->setAlias( TwoFactorAuthenticationEnforcerInterface::class, IndecisiveTwoFactorAuthenticationEnforcer::class - ); + ) + ; } } diff --git a/packages/user-bundle/EmailWriter/ForgotPasswordEmailWriter.php b/packages/user-bundle/EmailWriter/ForgotPasswordEmailWriter.php index 64d27feca..5006487d0 100644 --- a/packages/user-bundle/EmailWriter/ForgotPasswordEmailWriter.php +++ b/packages/user-bundle/EmailWriter/ForgotPasswordEmailWriter.php @@ -42,7 +42,8 @@ public function compose(ForgotPasswordEmail $forgotPasswordEmail): void public function completeEmail(ForgotPasswordEmail $forgotPasswordEmail, ?SecurityUserInterface $user): void { $forgotPasswordEmail - ->to($forgotPasswordEmail->getEmailAddress()); + ->to($forgotPasswordEmail->getEmailAddress()) + ; if (null === $user) { $forgotPasswordEmail @@ -53,7 +54,8 @@ public function completeEmail(ForgotPasswordEmail $forgotPasswordEmail, ?Securit [], UrlGeneratorInterface::ABSOLUTE_URL ) - ); + ) + ; return; } @@ -70,6 +72,7 @@ public function completeEmail(ForgotPasswordEmail $forgotPasswordEmail, ?Securit new \DateTimeImmutable('+ 1 day'), 'reset_password', ) - ); + ) + ; } } diff --git a/packages/user-bundle/Message/PasswordChangeRequestedMessage.php b/packages/user-bundle/Message/PasswordChangeRequestedMessage.php index c1e3328df..53f06c16c 100644 --- a/packages/user-bundle/Message/PasswordChangeRequestedMessage.php +++ b/packages/user-bundle/Message/PasswordChangeRequestedMessage.php @@ -20,9 +20,6 @@ public function preSend(MessageHolderInterface $messageHolder): void $this->userId = $messageHolder->getId(); } - /** - * @return mixed - */ public function getUserId() { return $this->userId; diff --git a/packages/user-bundle/Message/RedirectToSecuredRouteMessage.php b/packages/user-bundle/Message/RedirectToSecuredRouteMessage.php index 801f42ab1..6497f6c18 100644 --- a/packages/user-bundle/Message/RedirectToSecuredRouteMessage.php +++ b/packages/user-bundle/Message/RedirectToSecuredRouteMessage.php @@ -10,7 +10,6 @@ class RedirectToSecuredRouteMessage extends AutoConnect implements RedirectToRou use RedirectToRouteMessageTrait; /** - * @param mixed $userId * @param array $urlParameters */ public function __construct($userId, string $route, array $urlParameters = []) diff --git a/packages/user-bundle/Message/RefreshUserLockMessage.php b/packages/user-bundle/Message/RefreshUserLockMessage.php index 9a0e9325e..c2a15d74e 100644 --- a/packages/user-bundle/Message/RefreshUserLockMessage.php +++ b/packages/user-bundle/Message/RefreshUserLockMessage.php @@ -8,9 +8,6 @@ public function __construct(private mixed $userId) { } - /** - * @return mixed - */ public function getUserId() { return $this->userId; diff --git a/packages/user-bundle/Message/ResetPassword.php b/packages/user-bundle/Message/ResetPassword.php index 78f663de1..173c98d62 100644 --- a/packages/user-bundle/Message/ResetPassword.php +++ b/packages/user-bundle/Message/ResetPassword.php @@ -4,9 +4,6 @@ class ResetPassword extends RedirectToSecuredRouteMessage { - /** - * @param mixed $userId - */ public function __construct($userId, string $route = 'admin_change_password') { parent::__construct($userId, $route); diff --git a/packages/user-bundle/MessageHandler/RefreshUserLockMessageHandler.php b/packages/user-bundle/MessageHandler/RefreshUserLockMessageHandler.php index 7474b4e8e..9a9d15896 100644 --- a/packages/user-bundle/MessageHandler/RefreshUserLockMessageHandler.php +++ b/packages/user-bundle/MessageHandler/RefreshUserLockMessageHandler.php @@ -30,11 +30,7 @@ public function handleRefreshUserLockMessage(RefreshUserLockMessage $message): v } if (!$user instanceof LockableUserInterface) { - throw new \UnexpectedValueException(\sprintf( - 'Expected instance of [%s], instance of [%s] returned.', - LockableUserInterface::class, - $user::class - )); + throw new \UnexpectedValueException(\sprintf('Expected instance of [%s], instance of [%s] returned.', LockableUserInterface::class, $user::class)); } $this->accountLocker->refreshUserLocks($user); diff --git a/packages/user-bundle/Security/TwoFactorAuthentication/Enforcer/RolesTwoFactorAuthenticationEnforcer.php b/packages/user-bundle/Security/TwoFactorAuthentication/Enforcer/RolesTwoFactorAuthenticationEnforcer.php index 2bab277e0..b4454e5e3 100644 --- a/packages/user-bundle/Security/TwoFactorAuthentication/Enforcer/RolesTwoFactorAuthenticationEnforcer.php +++ b/packages/user-bundle/Security/TwoFactorAuthentication/Enforcer/RolesTwoFactorAuthenticationEnforcer.php @@ -29,7 +29,7 @@ public function shouldEnforceTwoFactorAuthentication(TwoFactorAuthenticationUser $roles = $this->roleHierarchy->getReachableRoleNames($user->getRoles()); foreach ($roles as $role) { - if (\in_array($role, $this->enforcingRoles)) { + if (\in_array($role, $this->enforcingRoles, true)) { return true; } } diff --git a/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByEmailTrait.php b/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByEmailTrait.php index 041052880..d2a350d4b 100644 --- a/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByEmailTrait.php +++ b/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByEmailTrait.php @@ -16,7 +16,7 @@ trait ByEmailTrait public function isEmailAuthEnabled(): bool { - return \in_array('email', $this->getTwoFactorAuthenticationEnabledProviders()) && $this->getEmailAuthRecipient(); + return \in_array('email', $this->getTwoFactorAuthenticationEnabledProviders(), true) && $this->getEmailAuthRecipient(); } public function getEmailAuthRecipient(): string diff --git a/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByTimeBaseOneTimePasswordTrait.php b/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByTimeBaseOneTimePasswordTrait.php index 6fa8d0b5d..a7a04129c 100644 --- a/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByTimeBaseOneTimePasswordTrait.php +++ b/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ByTimeBaseOneTimePasswordTrait.php @@ -27,12 +27,12 @@ abstract public function getUserIdentifier(): string; public function isTotpAuthenticationEnabled(): bool { - return \in_array('totp', $this->getTwoFactorAuthenticationEnabledProviders()) && $this->totpSecret; + return \in_array('totp', $this->getTwoFactorAuthenticationEnabledProviders(), true) && $this->totpSecret; } public function needToEnableTotpAuthenticationEnabled(): bool { - return \in_array('totp', $this->getTwoFactorAuthenticationEnabledProviders()) && !$this->totpSecret; + return \in_array('totp', $this->getTwoFactorAuthenticationEnabledProviders(), true) && !$this->totpSecret; } public function getTotpAuthenticationUsername(): string diff --git a/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ConfigurationTrait.php b/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ConfigurationTrait.php index cd6590d77..7590169db 100644 --- a/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ConfigurationTrait.php +++ b/packages/user-bundle/Security/TwoFactorAuthentication/Entity/ConfigurationTrait.php @@ -24,7 +24,7 @@ public function setTwoFactorAuthenticationEnabledProviders(array $providers): vo { $this->twoFactorAuthenticationEnabledProviders = array_values(array_unique($providers)); - if (!\in_array('totp', $this->twoFactorAuthenticationEnabledProviders) && $this instanceof ByTimeBaseOneTimePasswordInterface) { + if (!\in_array('totp', $this->twoFactorAuthenticationEnabledProviders, true) && $this instanceof ByTimeBaseOneTimePasswordInterface) { $this->setTotpSecret(null); } } @@ -33,7 +33,7 @@ public function enableTwoFActorAuthenticationProvider(string $provider): void { $enabledProviders = $this->getTwoFactorAuthenticationEnabledProviders(); - if (!\in_array($enabledProviders, $this->twoFactorAuthenticationEnabledProviders)) { + if (!\in_array($enabledProviders, $this->twoFactorAuthenticationEnabledProviders, true)) { $enabledProviders[] = $provider; $this->setTwoFactorAuthenticationEnabledProviders($enabledProviders); diff --git a/packages/user-bundle/Security/TwoFactorAuthentication/QrCodeGenerator.php b/packages/user-bundle/Security/TwoFactorAuthentication/QrCodeGenerator.php index d6d87a458..510b3d13f 100644 --- a/packages/user-bundle/Security/TwoFactorAuthentication/QrCodeGenerator.php +++ b/packages/user-bundle/Security/TwoFactorAuthentication/QrCodeGenerator.php @@ -22,6 +22,7 @@ public function getTotpQrCode(string $qrCodeContent): ResultInterface ->size(200) ->margin(0) ->roundBlockSizeMode(RoundBlockSizeMode::Margin) - ->build(); + ->build() + ; } } diff --git a/packages/user-bundle/Tests/AccountLocker/Entity/LockableUserTraitTest.php b/packages/user-bundle/Tests/AccountLocker/Entity/LockableUserTraitTest.php index cdc558caa..4b1857a15 100644 --- a/packages/user-bundle/Tests/AccountLocker/Entity/LockableUserTraitTest.php +++ b/packages/user-bundle/Tests/AccountLocker/Entity/LockableUserTraitTest.php @@ -12,6 +12,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(MessageHolderTrait::class)] class LockableUserTraitTest extends TestCase { diff --git a/packages/user-bundle/Tests/AccountLocker/Entity/UserLockTest.php b/packages/user-bundle/Tests/AccountLocker/Entity/UserLockTest.php index d46a9098f..60852e605 100644 --- a/packages/user-bundle/Tests/AccountLocker/Entity/UserLockTest.php +++ b/packages/user-bundle/Tests/AccountLocker/Entity/UserLockTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(UserLock::class)] class UserLockTest extends TestCase { diff --git a/packages/user-bundle/Tests/DependencyInjection/ConfigurationTest.php b/packages/user-bundle/Tests/DependencyInjection/ConfigurationTest.php index 5f18765d2..16f2077ad 100644 --- a/packages/user-bundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/ConfigurationTest.php @@ -7,6 +7,9 @@ use Draw\Component\Tester\Test\DependencyInjection\ConfigurationTestCase; use Symfony\Component\Config\Definition\ConfigurationInterface; +/** + * @internal + */ class ConfigurationTest extends ConfigurationTestCase { public function createConfiguration(): ConfigurationInterface diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionTest.php index e176ada7d..1172ffa7b 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionTest.php @@ -16,6 +16,9 @@ use Draw\Component\Tester\Test\DependencyInjection\ExtensionTestCase; use Symfony\Component\DependencyInjection\Extension\Extension; +/** + * @internal + */ class DrawUserExtensionTest extends ExtensionTestCase { public function createExtension(): Extension diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithAccountLockerEnabledTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithAccountLockerEnabledTest.php index 2943e21f4..c7d316ec5 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithAccountLockerEnabledTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithAccountLockerEnabledTest.php @@ -9,6 +9,9 @@ use Draw\Bundle\UserBundle\MessageHandler\UserLockLifeCycleMessageHandler; use Draw\Bundle\UserBundle\Tests\Fixtures\Entity\User; +/** + * @internal + */ class DrawUserExtensionWithAccountLockerEnabledTest extends DrawUserExtensionTest { public function getConfiguration(): array diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEmailWritersEnabledTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEmailWritersEnabledTest.php index bb809ce0d..02ab346d2 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEmailWritersEnabledTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEmailWritersEnabledTest.php @@ -7,6 +7,9 @@ use Draw\Bundle\UserBundle\EmailWriter\ToUserEmailWriter; use Draw\Bundle\UserBundle\EmailWriter\UserOnboardingEmailWriter; +/** + * @internal + */ class DrawUserExtensionWithEmailWritersEnabledTest extends DrawUserExtensionTest { public function getConfiguration(): array diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faTest.php index 57f7a7db2..4c1a14bec 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faTest.php @@ -7,6 +7,9 @@ use Draw\Bundle\UserBundle\Security\TwoFactorAuthentication\Enforcer\IndecisiveTwoFactorAuthenticationEnforcer; use Draw\Bundle\UserBundle\Security\TwoFactorAuthentication\Enforcer\TwoFactorAuthenticationEnforcerInterface; +/** + * @internal + */ class DrawUserExtensionWithEnforce2faTest extends DrawUserExtensionTest { public function getConfiguration(): array diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faWithEnforcingRolesTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faWithEnforcingRolesTest.php index bbc81c8c5..bd23d32dc 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faWithEnforcingRolesTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithEnforce2faWithEnforcingRolesTest.php @@ -5,6 +5,9 @@ use Draw\Bundle\UserBundle\Security\TwoFactorAuthentication\Enforcer\RolesTwoFactorAuthenticationEnforcer; use Draw\Bundle\UserBundle\Security\TwoFactorAuthentication\Enforcer\TwoFactorAuthenticationEnforcerInterface; +/** + * @internal + */ class DrawUserExtensionWithEnforce2faWithEnforcingRolesTest extends DrawUserExtensionWithEnforce2faTest { public function getConfiguration(): array diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithOnboardingEnabledTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithOnboardingEnabledTest.php index b1b82db0a..20077d74f 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithOnboardingEnabledTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithOnboardingEnabledTest.php @@ -4,6 +4,9 @@ use Draw\Bundle\UserBundle\MessageHandler\NewUserSendEmailMessageHandler; +/** + * @internal + */ class DrawUserExtensionWithOnboardingEnabledTest extends DrawUserExtensionTest { public function getConfiguration(): array diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithPasswordChangeEnforcerEnabledTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithPasswordChangeEnforcerEnabledTest.php index d5710bee3..8be1741ee 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithPasswordChangeEnforcerEnabledTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithPasswordChangeEnforcerEnabledTest.php @@ -5,6 +5,9 @@ use Draw\Bundle\UserBundle\EventListener\PasswordChangeEnforcerListener; use Draw\Bundle\UserBundle\MessageHandler\PasswordChangeRequestedSendEmailMessageHandler; +/** + * @internal + */ class DrawUserExtensionWithPasswordChangeEnforcerEnabledTest extends DrawUserExtensionTest { public function getConfiguration(): array diff --git a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithoutEncryptPasswordListenerTest.php b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithoutEncryptPasswordListenerTest.php index 5979ac747..d32b97575 100644 --- a/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithoutEncryptPasswordListenerTest.php +++ b/packages/user-bundle/Tests/DependencyInjection/DrawUserExtensionWithoutEncryptPasswordListenerTest.php @@ -5,6 +5,9 @@ use Draw\Bundle\UserBundle\EventListener\EncryptPasswordUserEntityListener; use Draw\Bundle\UserBundle\Tests\Fixtures\Entity\User; +/** + * @internal + */ class DrawUserExtensionWithoutEncryptPasswordListenerTest extends DrawUserExtensionTest { public function getConfiguration(): array diff --git a/packages/user-bundle/Tests/Entity/ConfigurationTraitTest.php b/packages/user-bundle/Tests/Entity/ConfigurationTraitTest.php index 83dd7440a..69c17ac74 100644 --- a/packages/user-bundle/Tests/Entity/ConfigurationTraitTest.php +++ b/packages/user-bundle/Tests/Entity/ConfigurationTraitTest.php @@ -5,6 +5,9 @@ use Draw\Bundle\UserBundle\Security\TwoFactorAuthentication\Entity\ConfigurationTrait; use PHPUnit\Framework\TestCase; +/** + * @internal + */ class ConfigurationTraitTest extends TestCase { use ConfigurationTrait; diff --git a/packages/user-bundle/Tests/EventListener/TwoFactorAuthenticationListenerTest.php b/packages/user-bundle/Tests/EventListener/TwoFactorAuthenticationListenerTest.php index d15d9f474..58fd32ff0 100644 --- a/packages/user-bundle/Tests/EventListener/TwoFactorAuthenticationListenerTest.php +++ b/packages/user-bundle/Tests/EventListener/TwoFactorAuthenticationListenerTest.php @@ -20,6 +20,9 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\User\UserInterface; +/** + * @internal + */ class TwoFactorAuthenticationListenerTest extends TestCase { private const ENABLE_ROUTE = 'route'; @@ -106,8 +109,7 @@ public function eraseCredentials(): void yield 'not-two-factor-authentication-user' => [ new UserRequestInterceptionEvent( - new class implements SecurityUserInterface, - TwoFactorAuthenticationUserInterface { + new class implements SecurityUserInterface, TwoFactorAuthenticationUserInterface { use ConfigurationTrait { asOneTwoFActorAuthenticationProviderEnabled as originalAsOneProviderEnabled; } @@ -132,8 +134,7 @@ public function asOneTwoFActorAuthenticationProviderEnabled(): bool yield 'not-as-one-provider-enable' => [ new UserRequestInterceptionEvent( - new class implements SecurityUserInterface, - TwoFactorAuthenticationUserInterface { + new class implements SecurityUserInterface, TwoFactorAuthenticationUserInterface { use ConfigurationTrait { asOneTwoFActorAuthenticationProviderEnabled as originalAsOneProviderEnabled; } @@ -158,8 +159,7 @@ public function asOneTwoFActorAuthenticationProviderEnabled(): bool yield 'not-force-enabling-two-factor-authentication' => [ new UserRequestInterceptionEvent( - new class implements SecurityUserInterface, - TwoFactorAuthenticationUserInterface { + new class implements SecurityUserInterface, TwoFactorAuthenticationUserInterface { use ConfigurationTrait; use SecurityUserTrait; @@ -176,8 +176,7 @@ public function getId(): mixed yield 'not-by-time-base-one-time-password' => [ new UserRequestInterceptionEvent( - new class implements SecurityUserInterface, - TwoFactorAuthenticationUserInterface { + new class implements SecurityUserInterface, TwoFactorAuthenticationUserInterface { use ConfigurationTrait { isForceEnablingTwoFactorAuthentication as originalIsForceEnablingTwoFactorAuthentication; } @@ -202,9 +201,7 @@ public function isForceEnablingTwoFactorAuthentication(): bool yield 'enabled-route' => [ new UserRequestInterceptionEvent( - new class implements SecurityUserInterface, - TwoFactorAuthenticationUserInterface, - ByTimeBaseOneTimePasswordInterface { + new class implements SecurityUserInterface, TwoFactorAuthenticationUserInterface, ByTimeBaseOneTimePasswordInterface { use ByTimeBaseOneTimePasswordTrait { isForceEnablingTwoFactorAuthentication as originalIsForceEnablingTwoFactorAuthentication; } @@ -229,9 +226,7 @@ public function isForceEnablingTwoFactorAuthentication(): bool yield 'not-enabled-route' => [ new UserRequestInterceptionEvent( - new class implements SecurityUserInterface, - TwoFactorAuthenticationUserInterface, - ByTimeBaseOneTimePasswordInterface { + new class implements SecurityUserInterface, TwoFactorAuthenticationUserInterface, ByTimeBaseOneTimePasswordInterface { use ByTimeBaseOneTimePasswordTrait { isForceEnablingTwoFactorAuthentication as originalIsForceEnablingTwoFactorAuthentication; } @@ -273,7 +268,8 @@ public function testCheckNeedToEnableTwoFactorAuthentication( self::ENABLE_ROUTE, ['id' => $user->getId()] ) - ->willReturn($url = uniqid('url')); + ->willReturn($url = uniqid('url')) + ; } $this->object->checkNeedToEnableTwoFactorAuthentication($event); @@ -299,7 +295,8 @@ public function testAllowHandlingRequestWhenTwoFactorAuthenticationInProgressTru ->expects(static::once()) ->method('isGranted') ->with('IS_AUTHENTICATED_2FA_IN_PROGRESS') - ->willReturn(true); + ->willReturn(true) + ; $this->object->allowHandlingRequestWhenTwoFactorAuthenticationInProgress( $event = new UserRequestInterceptionEvent( @@ -317,7 +314,8 @@ public function testAllowHandlingRequestWhenTwoFactorAuthenticationInProgressFal ->expects(static::once()) ->method('isGranted') ->with('IS_AUTHENTICATED_2FA_IN_PROGRESS') - ->willReturn(false); + ->willReturn(false) + ; $this->object->allowHandlingRequestWhenTwoFactorAuthenticationInProgress( $event = new UserRequestInterceptionEvent( diff --git a/packages/user-bundle/Tests/Message/TemporaryUnlockedMessageTest.php b/packages/user-bundle/Tests/Message/TemporaryUnlockedMessageTest.php index 3100dd4ef..c0951124a 100644 --- a/packages/user-bundle/Tests/Message/TemporaryUnlockedMessageTest.php +++ b/packages/user-bundle/Tests/Message/TemporaryUnlockedMessageTest.php @@ -11,6 +11,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @internal + */ #[CoversClass(TemporaryUnlockedMessage::class)] class TemporaryUnlockedMessageTest extends TestCase { @@ -46,8 +49,7 @@ public function testGetUserIdentifier(): void static::assertNull($this->object->getUserIdentifier()); $this->object->preSend( - new class implements MessageHolderInterface, - LockableUserInterface { + new class implements MessageHolderInterface, LockableUserInterface { use LockableUserTrait; use MessageHolderTrait; use SecurityUserTrait; diff --git a/packages/validator/Constraints/PhpCallableValidator.php b/packages/validator/Constraints/PhpCallableValidator.php index 667db4113..1fa760776 100644 --- a/packages/validator/Constraints/PhpCallableValidator.php +++ b/packages/validator/Constraints/PhpCallableValidator.php @@ -33,6 +33,7 @@ public function validate($value, Constraint $constraint): void $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) - ->addViolation(); + ->addViolation() + ; } } diff --git a/packages/validator/Constraints/RemoteFileExistsValidator.php b/packages/validator/Constraints/RemoteFileExistsValidator.php index 8ed23d726..f9414ecd2 100644 --- a/packages/validator/Constraints/RemoteFileExistsValidator.php +++ b/packages/validator/Constraints/RemoteFileExistsValidator.php @@ -17,7 +17,8 @@ public function validate($value, Constraint $constraint): void if (!$this->remoteFileExists($value)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $value) - ->addViolation(); + ->addViolation() + ; } } diff --git a/packages/validator/Constraints/ValueIsNotUsedValidator.php b/packages/validator/Constraints/ValueIsNotUsedValidator.php index 85ed243c8..b8eed0b50 100644 --- a/packages/validator/Constraints/ValueIsNotUsedValidator.php +++ b/packages/validator/Constraints/ValueIsNotUsedValidator.php @@ -30,7 +30,8 @@ public function validate($value, Constraint $constraint): void $queryBuilder = $manager->createQueryBuilder() ->from($constraint->entityClass, 'root') ->andWhere('root.'.$constraint->field.' = :value') - ->setParameter('value', $value); + ->setParameter('value', $value) + ; $identifiers = $manager->getClassMetadata($constraint->entityClass)->getIdentifier(); @@ -41,7 +42,8 @@ public function validate($value, Constraint $constraint): void $result = $queryBuilder ->setMaxResults(1) ->getQuery() - ->getResult(); + ->getResult() + ; if (0 === \count($result)) { return; @@ -51,6 +53,7 @@ public function validate($value, Constraint $constraint): void ->buildViolation($constraint->message) ->setParameter('{{ value }}', $value) ->setCode(ValueIsNotUsed::CODE) - ->addViolation(); + ->addViolation() + ; } } diff --git a/packages/validator/DependencyInjection/ValidatorIntegration.php b/packages/validator/DependencyInjection/ValidatorIntegration.php index 70ef78723..9365a40ed 100644 --- a/packages/validator/DependencyInjection/ValidatorIntegration.php +++ b/packages/validator/DependencyInjection/ValidatorIntegration.php @@ -27,7 +27,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Validator\\Constraints\\', + $namespace = 'Draw\Component\Validator\Constraints\\', \dirname((new \ReflectionClass(ValueIsNotUsedValidator::class))->getFileName()).'/*Validator.php' ); diff --git a/packages/validator/Tests/Constraints/PhpCallableTest.php b/packages/validator/Tests/Constraints/PhpCallableTest.php index db182aeca..288962799 100644 --- a/packages/validator/Tests/Constraints/PhpCallableTest.php +++ b/packages/validator/Tests/Constraints/PhpCallableTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraint; +/** + * @internal + */ #[CoversClass(PhpCallable::class)] class PhpCallableTest extends TestCase { diff --git a/packages/validator/Tests/Constraints/PhpCallableValidatorTest.php b/packages/validator/Tests/Constraints/PhpCallableValidatorTest.php index 81957b829..b393c46af 100644 --- a/packages/validator/Tests/Constraints/PhpCallableValidatorTest.php +++ b/packages/validator/Tests/Constraints/PhpCallableValidatorTest.php @@ -14,6 +14,9 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Validation; +/** + * @internal + */ #[CoversClass(PhpCallableValidator::class)] class PhpCallableValidatorTest extends TestCase { @@ -69,7 +72,7 @@ public function testValidate(mixed $value, ?Constraint $returnValueConstraint, i $value, [ new PhpCallable([ - 'callable' => function ($value) { + 'callable' => static function ($value) { if ($value instanceof \Exception) { throw $value; } @@ -81,6 +84,6 @@ public function testValidate(mixed $value, ?Constraint $returnValueConstraint, i ] ); - static::assertEquals($violationsCount, $violations->count()); + static::assertCount($violationsCount, $violations); } } diff --git a/packages/validator/Tests/Constraints/RemoteFileExistsTest.php b/packages/validator/Tests/Constraints/RemoteFileExistsTest.php index 4bff8d3b3..b7e0cfc45 100644 --- a/packages/validator/Tests/Constraints/RemoteFileExistsTest.php +++ b/packages/validator/Tests/Constraints/RemoteFileExistsTest.php @@ -7,6 +7,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraint; +/** + * @internal + */ #[CoversClass(RemoteFileExists::class)] class RemoteFileExistsTest extends TestCase { diff --git a/packages/validator/Tests/Constraints/RemoteFileExistsValidatorTest.php b/packages/validator/Tests/Constraints/RemoteFileExistsValidatorTest.php index 1ad24c98f..dc161e6ee 100644 --- a/packages/validator/Tests/Constraints/RemoteFileExistsValidatorTest.php +++ b/packages/validator/Tests/Constraints/RemoteFileExistsValidatorTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Validation; +/** + * @internal + */ #[CoversClass(RemoteFileExistsValidator::class)] class RemoteFileExistsValidatorTest extends TestCase { @@ -63,6 +66,6 @@ public function testValidate(string $file, int $violationsCount): void $validator = Validation::createValidator(); $violations = $validator->validate($file, [new RemoteFileExists()]); - static::assertEquals($violationsCount, $violations->count()); + static::assertCount($violationsCount, $violations); } } diff --git a/packages/validator/Tests/Constraints/StrtotimeTest.php b/packages/validator/Tests/Constraints/StrtotimeTest.php index b0159ec45..b877c3eaf 100644 --- a/packages/validator/Tests/Constraints/StrtotimeTest.php +++ b/packages/validator/Tests/Constraints/StrtotimeTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\Type; +/** + * @internal + */ #[CoversClass(Strtotime::class)] class StrtotimeTest extends TestCase { diff --git a/packages/validator/Tests/DependencyInjection/ValidatorIntegrationTest.php b/packages/validator/Tests/DependencyInjection/ValidatorIntegrationTest.php index 7e7b04784..ef13a9522 100644 --- a/packages/validator/Tests/DependencyInjection/ValidatorIntegrationTest.php +++ b/packages/validator/Tests/DependencyInjection/ValidatorIntegrationTest.php @@ -13,6 +13,8 @@ /** * @property ValidatorIntegration $integration + * + * @internal */ #[CoversClass(ValidatorIntegration::class)] class ValidatorIntegrationTest extends IntegrationTestCase diff --git a/packages/workflow/DependencyInjection/WorkflowIntegration.php b/packages/workflow/DependencyInjection/WorkflowIntegration.php index 46588aeaa..59222848f 100644 --- a/packages/workflow/DependencyInjection/WorkflowIntegration.php +++ b/packages/workflow/DependencyInjection/WorkflowIntegration.php @@ -24,7 +24,7 @@ public function load(array $config, PhpFileLoader $loader, ContainerBuilder $con { $this->registerClasses( $loader, - $namespace = 'Draw\\Component\\Workflow\\', + $namespace = 'Draw\Component\Workflow\\', \dirname( (new \ReflectionClass(AddTransitionNameToContextListener::class))->getFileName(), 2 diff --git a/packages/workflow/Tests/DependencyInjection/WorkflowIntegrationTest.php b/packages/workflow/Tests/DependencyInjection/WorkflowIntegrationTest.php index 0a74c16f6..3b76f29d8 100644 --- a/packages/workflow/Tests/DependencyInjection/WorkflowIntegrationTest.php +++ b/packages/workflow/Tests/DependencyInjection/WorkflowIntegrationTest.php @@ -12,6 +12,8 @@ /** * @property WorkflowIntegration $integration + * + * @internal */ #[CoversClass(WorkflowIntegration::class)] class WorkflowIntegrationTest extends IntegrationTestCase diff --git a/packages/workflow/Tests/EventListener/AddTransitionNameToContextListenerTest.php b/packages/workflow/Tests/EventListener/AddTransitionNameToContextListenerTest.php index de73ff105..0a56ae0d1 100644 --- a/packages/workflow/Tests/EventListener/AddTransitionNameToContextListenerTest.php +++ b/packages/workflow/Tests/EventListener/AddTransitionNameToContextListenerTest.php @@ -9,6 +9,9 @@ use Symfony\Component\Workflow\Marking; use Symfony\Component\Workflow\Transition; +/** + * @internal + */ class AddTransitionNameToContextListenerTest extends TestCase { private AddTransitionNameToContextListener $object; diff --git a/packages/workflow/Tests/EventListener/AddUserToContextListenerTest.php b/packages/workflow/Tests/EventListener/AddUserToContextListenerTest.php index 71736162e..fdc3d113e 100644 --- a/packages/workflow/Tests/EventListener/AddUserToContextListenerTest.php +++ b/packages/workflow/Tests/EventListener/AddUserToContextListenerTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Workflow\Event\TransitionEvent; use Symfony\Component\Workflow\Marking; +/** + * @internal + */ class AddUserToContextListenerTest extends TestCase { private AddUserToContextListener $object; @@ -73,7 +76,8 @@ public function testAddUserToContextProperUser(): void $this->security ->expects(static::once()) ->method('getUser') - ->willReturn($user = $this->createMock(UserInterface::class)); + ->willReturn($user = $this->createMock(UserInterface::class)) + ; $this->object->addUserToContext($transitionEvent); diff --git a/public/index.php b/public/index.php index b6ec432a1..751fe55dd 100644 --- a/public/index.php +++ b/public/index.php @@ -4,4 +4,4 @@ require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; -return fn (array $context) => new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); +return static fn (array $context) => new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); diff --git a/tests/AppKernelTest.php b/tests/AppKernelTest.php index 0ab59510b..f397366df 100644 --- a/tests/AppKernelTest.php +++ b/tests/AppKernelTest.php @@ -5,6 +5,9 @@ use Draw\Bundle\TesterBundle\EventDispatcher\EventDispatcherTesterTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +/** + * @internal + */ class AppKernelTest extends KernelTestCase { use EventDispatcherTesterTrait; diff --git a/tests/Command/NullCommandTest.php b/tests/Command/NullCommandTest.php index 5588e6654..529999174 100644 --- a/tests/Command/NullCommandTest.php +++ b/tests/Command/NullCommandTest.php @@ -11,6 +11,9 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputOption; +/** + * @internal + */ class NullCommandTest extends TestCase implements AutowiredInterface { use CommandTestTrait; @@ -69,6 +72,7 @@ public function testExecute(): void ->test( CommandDataTester::create() ->setExpectedDisplay('This does nothing.') - ); + ) + ; } } diff --git a/tests/Console/Command/GenerateDocumentationCommandTest.php b/tests/Console/Command/GenerateDocumentationCommandTest.php index 202e350d8..e8c7d3a39 100644 --- a/tests/Console/Command/GenerateDocumentationCommandTest.php +++ b/tests/Console/Command/GenerateDocumentationCommandTest.php @@ -13,6 +13,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +/** + * @internal + */ #[CoversClass(GenerateDocumentationCommand::class)] class GenerateDocumentationCommandTest extends TestCase implements AutowiredInterface { @@ -51,7 +54,7 @@ public function testExecute(): void $filePath = tempnam(sys_get_temp_dir(), 'testExecute'); register_shutdown_function( - function () use ($filePath): void { + static function () use ($filePath): void { if (file_exists($filePath)) { unlink($filePath); } @@ -66,7 +69,8 @@ function () use ($filePath): void { 'Export completed', ]) ->setExpectedErrorOutput(null) - ); + ) + ; if ($this->writeFile) { file_put_contents( diff --git a/tests/Controller/Api/ConnectionTokensControllerTest.php b/tests/Controller/Api/ConnectionTokensControllerTest.php index 6c4263737..95c1da95c 100644 --- a/tests/Controller/Api/ConnectionTokensControllerTest.php +++ b/tests/Controller/Api/ConnectionTokensControllerTest.php @@ -9,6 +9,9 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; +/** + * @internal + */ class ConnectionTokensControllerTest extends WebTestCase implements AutowiredInterface { #[AutowireClient] @@ -31,7 +34,8 @@ public function testRefresh(): void '/api/connection-tokens/refresh', [], ['Authorization' => 'Bearer '.$token] - ); + ) + ; static::assertResponseStatusCodeSame(Response::HTTP_FORBIDDEN); } diff --git a/tests/Controller/Api/TestDocumentControllerTest.php b/tests/Controller/Api/TestDocumentControllerTest.php index 48f04374d..8312c3ed3 100644 --- a/tests/Controller/Api/TestDocumentControllerTest.php +++ b/tests/Controller/Api/TestDocumentControllerTest.php @@ -9,6 +9,9 @@ use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; +/** + * @internal + */ class TestDocumentControllerTest extends WebTestCase implements AutowiredInterface { use MessengerTesterTrait; @@ -22,15 +25,18 @@ public function testCreate(): void ->jsonRequest( 'POST', '/api/test-documents', - ); + ) + ; static::assertResponseIsSuccessful(); static::getJsonResponseDataTester() ->path('id') - ->assertIsString(); + ->assertIsString() + ; static::getTransportTester('sync') - ->assertMessageMatch(NewTestDocumentMessage::class); + ->assertMessageMatch(NewTestDocumentMessage::class) + ; } } diff --git a/tests/Controller/Api/UsersControllerTest.php b/tests/Controller/Api/UsersControllerTest.php index 1f5920f67..c10b3308f 100644 --- a/tests/Controller/Api/UsersControllerTest.php +++ b/tests/Controller/Api/UsersControllerTest.php @@ -19,6 +19,9 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; +/** + * @internal + */ class UsersControllerTest extends WebTestCase implements AutowiredInterface { use TemplatedMailerAssertionsTrait; @@ -45,13 +48,15 @@ public static function cleanUp(): void ->andWhere('user.email = :email') ->setParameter('email', 'test@example.com') ->getQuery() - ->execute(); + ->execute() + ; } public function testUsersAction(): void { $this->client - ->request('GET', '/api/users'); + ->request('GET', '/api/users') + ; static::assertResponseIsSuccessful(); } @@ -71,7 +76,8 @@ public function testUsersCreateAction(): object ['id' => 1], ], ] - ); + ) + ; static::assertResponseIsSuccessful(); @@ -94,13 +100,15 @@ public function testUsersEditAction(object $user): void [ 'tags' => [], ] - ); + ) + ; static::assertResponseIsSuccessful(); static::getJsonResponseDataTester() ->path('tags') - ->assertSame([]); + ->assertSame([]) + ; } #[Depends('testUsersCreateAction')] @@ -115,13 +123,15 @@ public function testSetTagsAction(object $user): void [ ['id' => 1], ] - ); + ) + ; static::assertResponseIsSuccessful(); static::getJsonResponseDataTester() ->path('[0].id') - ->assertSame(1); + ->assertSame(1) + ; } #[Depends('testUsersCreateAction')] @@ -132,7 +142,8 @@ public function testSendResetPasswordEmail(object $user): void ->jsonRequest( 'POST', '/api/users/'.$user->id.'/reset-password-email', - ); + ) + ; static::assertResponseIsSuccessful(); @@ -157,7 +168,8 @@ public function testUsersDeleteAction(object $user): void $this->client->loginUser($this->user); $this->client - ->jsonRequest('DELETE', '/api/users/'.$user->id); + ->jsonRequest('DELETE', '/api/users/'.$user->id) + ; static::assertResponseStatusCodeSame(Response::HTTP_NO_CONTENT); } @@ -172,7 +184,8 @@ public function testCreateUnsupportedContentType(): void '/api/users', server: ['CONTENT_TYPE' => 'application/xml'], content: '' - ); + ) + ; static::assertResponseStatusCodeSame(Response::HTTP_UNSUPPORTED_MEDIA_TYPE); } diff --git a/tests/Controller/OpenApiControllerTest.php b/tests/Controller/OpenApiControllerTest.php index 4bd0bf4bc..1aed7e081 100644 --- a/tests/Controller/OpenApiControllerTest.php +++ b/tests/Controller/OpenApiControllerTest.php @@ -7,6 +7,9 @@ use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; +/** + * @internal + */ class OpenApiControllerTest extends WebTestCase implements AutowiredInterface { #[AutowireClient] diff --git a/tests/Controller/PingActionTest.php b/tests/Controller/PingActionTest.php index 08c47f948..b0f9dc0c6 100644 --- a/tests/Controller/PingActionTest.php +++ b/tests/Controller/PingActionTest.php @@ -9,6 +9,9 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; +/** + * @internal + */ class PingActionTest extends WebTestCase implements AutowiredInterface { #[AutowireClient] diff --git a/tests/Controller/Security/TwoFactorAuthorizationTest.php b/tests/Controller/Security/TwoFactorAuthorizationTest.php index 4c4df6635..4d20c85f2 100644 --- a/tests/Controller/Security/TwoFactorAuthorizationTest.php +++ b/tests/Controller/Security/TwoFactorAuthorizationTest.php @@ -13,6 +13,9 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\DomCrawler\Crawler; +/** + * @internal + */ class TwoFactorAuthorizationTest extends WebTestCase implements AutowiredInterface { final public const ADMIN_URL = '/admin'; diff --git a/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php b/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php index c24ef448d..d71670c27 100644 --- a/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php +++ b/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php @@ -10,6 +10,9 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; +/** + * @internal + */ class UserRequestInterceptedSubscriberTest extends WebTestCase implements AutowiredInterface { #[AutowireClient( @@ -33,6 +36,7 @@ public function testRedirectedErrorMessage(): void static::getJsonResponseDataTester() ->path('message') - ->assertSame('User request intercepted: 2fa_need_enabling'); + ->assertSame('User request intercepted: 2fa_need_enabling') + ; } } diff --git a/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php b/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php index f94a1dc8e..2aad92a68 100644 --- a/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php +++ b/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; +/** + * @internal + */ class PostExecutionQueueCronJobListenerTest extends KernelTestCase implements AutowiredCompletionAwareInterface { #[AutowireService] @@ -41,7 +44,8 @@ public function testTriggerCronJob(): void '--draw-post-execution-queue-cron-job' => ['test', 'test'], ]), new NullOutput() - ); + ) + ; static::assertSame( Command::SUCCESS, @@ -55,7 +59,8 @@ public function testTriggerCronJob(): void 'execution.cronJob.name' => 'test', ]), 2 - ); + ) + ; } public function testTriggerCronJobError(): void @@ -68,7 +73,8 @@ public function testTriggerCronJobError(): void '--draw-post-execution-queue-cron-job' => ['test', 'test'], ]), new NullOutput() - ); + ) + ; static::assertSame( Command::FAILURE, @@ -79,6 +85,7 @@ public function testTriggerCronJobError(): void ->assertMessageMatch( ExecuteCronJobMessage::class, count: 0 - ); + ) + ; } } diff --git a/tests/Entity/UserTest.php b/tests/Entity/UserTest.php index eaf54a339..49bb77d6f 100644 --- a/tests/Entity/UserTest.php +++ b/tests/Entity/UserTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\Stamp\ReceivedStamp; +/** + * @internal + */ class UserTest extends TestCase implements AutowiredInterface { #[AutowireService] @@ -37,7 +40,8 @@ public function cleanUp(): void ->where('user.email = :email') ->setParameter('email', 'test-lock@example.com') ->getQuery() - ->execute(); + ->execute() + ; } public function testLock(): void diff --git a/tests/Feature/DemoFeatureTest.php b/tests/Feature/DemoFeatureTest.php index ce5f0cf00..d786eae81 100644 --- a/tests/Feature/DemoFeatureTest.php +++ b/tests/Feature/DemoFeatureTest.php @@ -5,6 +5,9 @@ use App\Feature\DemoFeature; use App\Tests\TestCase; +/** + * @internal + */ class DemoFeatureTest extends TestCase { private DemoFeature $object; diff --git a/tests/MessageHandler/NullMessageHandlerTest.php b/tests/MessageHandler/NullMessageHandlerTest.php index e280d7769..dd75978a2 100644 --- a/tests/MessageHandler/NullMessageHandlerTest.php +++ b/tests/MessageHandler/NullMessageHandlerTest.php @@ -8,6 +8,9 @@ use Draw\Bundle\TesterBundle\Messenger\MessageHandlerAssertionTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +/** + * @internal + */ class NullMessageHandlerTest extends KernelTestCase { use MessageHandlerAssertionTrait; diff --git a/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php b/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php index 42744635b..e1ea9b399 100644 --- a/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php +++ b/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php @@ -17,6 +17,9 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @internal + */ class PropertyReferenceEncodingListenerTest extends KernelTestCase implements AutowiredInterface { #[AutowireService] diff --git a/tests/Messenger/Retry/EventDrivenRetryStrategyTest.php b/tests/Messenger/Retry/EventDrivenRetryStrategyTest.php index b391d0dfe..5d381512b 100644 --- a/tests/Messenger/Retry/EventDrivenRetryStrategyTest.php +++ b/tests/Messenger/Retry/EventDrivenRetryStrategyTest.php @@ -7,13 +7,17 @@ use Draw\Component\Messenger\Retry\EventDrivenRetryStrategy; use Symfony\Component\Messenger\Retry\MultiplierRetryStrategy; +/** + * @internal + */ class EventDrivenRetryStrategyTest extends TestCase { public function testRetry(): void { $service = static::getContainer() ->get('messenger.retry_strategy_locator') - ->get('async'); + ->get('async') + ; static::assertInstanceOf( EventDrivenRetryStrategy::class, diff --git a/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php b/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php index fe5507aaa..1f2a269bf 100644 --- a/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php +++ b/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php @@ -9,6 +9,9 @@ use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +/** + * @internal + */ class ResponseApiExceptionListenerTest extends KernelTestCase implements AutowiredInterface { use EventListenerTestTrait; diff --git a/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php b/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php index 7f72cab4b..96c6ca392 100644 --- a/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php +++ b/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php @@ -13,6 +13,9 @@ use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +/** + * @internal + */ class PreObjectDeleteBatchEventEventListenerTest extends KernelTestCase implements AutowiredInterface { #[AutowireService] @@ -28,7 +31,8 @@ public function testHandlePreObjectDeleteBatchEventCannotDelete(): void { $user = $this->entityManager ->getRepository(User::class) - ->findOneBy(['email' => 'admin@example.com']); + ->findOneBy(['email' => 'admin@example.com']) + ; $this->connectUser($user); @@ -49,7 +53,8 @@ public function testHandlePreObjectDeleteBatchEventCanDelete(): void { $user = $this->entityManager ->getRepository(User::class) - ->findOneBy(['email' => 'admin@example.com']); + ->findOneBy(['email' => 'admin@example.com']) + ; $this->connectUser($user); @@ -82,6 +87,7 @@ public function getCredentials() return null; } } - ); + ) + ; } } diff --git a/tests/SonataExtraBundle/Security/Voter/RelationPreventDeleteCanVoterTest.php b/tests/SonataExtraBundle/Security/Voter/RelationPreventDeleteCanVoterTest.php index 934d51f34..1c3600b9f 100644 --- a/tests/SonataExtraBundle/Security/Voter/RelationPreventDeleteCanVoterTest.php +++ b/tests/SonataExtraBundle/Security/Voter/RelationPreventDeleteCanVoterTest.php @@ -10,6 +10,9 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; +/** + * @internal + */ class RelationPreventDeleteCanVoterTest extends KernelTestCase { private PreventDeleteVoter $object; diff --git a/tests/SonataImportBundle/ImporterTest.php b/tests/SonataImportBundle/ImporterTest.php index 23e2e7a80..7d9692bb9 100644 --- a/tests/SonataImportBundle/ImporterTest.php +++ b/tests/SonataImportBundle/ImporterTest.php @@ -11,6 +11,9 @@ use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +/** + * @internal + */ class ImporterTest extends KernelTestCase implements AutowiredInterface { #[AutowireService] @@ -33,7 +36,8 @@ public function testImport(): void $import = (new Import()) ->setEntityClass(Tag::class) - ->setInsertWhenNotFound(false); + ->setInsertWhenNotFound(false) + ; $this->importer->buildFromFile( $import, @@ -41,7 +45,8 @@ public function testImport(): void ); $this->importer - ->processImport($import); + ->processImport($import) + ; $tag = $this->entityManager->getRepository(Tag::class)->findOneBy(['name' => $name]); @@ -53,7 +58,8 @@ public function testImport(): void $import->setInsertWhenNotFound(true); $this->importer - ->processImport($import); + ->processImport($import) + ; $tag = $this->entityManager->getRepository(Tag::class)->findOneBy(['name' => $name]); diff --git a/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php b/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php index a556d8dc0..8ce996eea 100644 --- a/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php +++ b/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php @@ -20,6 +20,9 @@ use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\Stamp\TransportNamesStamp; +/** + * @internal + */ class RetryFailedMessageActionTest extends WebTestCase implements AutowiredInterface { use MessengerTesterTrait; @@ -63,7 +66,8 @@ public function testRetry(): void static::assertResponseStatusCodeSame(Response::HTTP_FOUND); static::getTransportTester('async') - ->assertMessageMatch(RetryFailedMessageMessage::class); + ->assertMessageMatch(RetryFailedMessageMessage::class) + ; $this->client->followRedirect(); diff --git a/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php b/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php index 7dd21f760..0eef2b42a 100644 --- a/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php +++ b/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php @@ -15,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Response; +/** + * @internal + */ class UnlockUserActionTest extends WebTestCase implements AutowiredInterface { #[AutowireClient] diff --git a/tests/TestCase.php b/tests/TestCase.php index 7612a6a2a..fd8df3f91 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,7 +7,7 @@ use Draw\Bundle\TesterBundle\Profiling\MetricTesterTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -class TestCase extends KernelTestCase +abstract class TestCase extends KernelTestCase { use MessengerTesterTrait; use MetricTesterTrait; diff --git a/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php b/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php index 5f6806724..d32a5b7e6 100644 --- a/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php +++ b/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php @@ -16,6 +16,9 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +/** + * @internal + */ class SetUpAutowireExtensionTest extends WebTestCase implements AutowiredInterface { #[ diff --git a/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php b/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php index 89e85c850..c08d7e307 100644 --- a/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php +++ b/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php @@ -11,6 +11,9 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Validator\Validator\ValidatorInterface; +/** + * @internal + */ class ValueIsNotUsedValidatorTest extends KernelTestCase implements AutowiredInterface { #[AutowireService] @@ -20,7 +23,8 @@ class ValueIsNotUsedValidatorTest extends KernelTestCase implements AutowiredInt public function testValidate(mixed $value, string $entityClass, string $field, bool $expectError): void { $violations = $this->validator - ->validate($value, new ValueIsNotUsed(entityClass: $entityClass, field: $field)); + ->validate($value, new ValueIsNotUsed(entityClass: $entityClass, field: $field)) + ; if (!$expectError) { static::assertCount(0, $violations);