diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a1b420a..0cdef43f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased - - ... + - Fix deprecations triggered by Symfony 5.3 (#490) ## 3.5.4 - CLI commands registration policy changed to lazy load (#373, thanks to @kefzce) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dbaf9034..de5a60da 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6,72 +6,77 @@ parameters: path: src/DependencyInjection/Configuration.php - - message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:configureErrorListener\\(\\) has parameter \\$processedConfiguration with no value type specified in iterable type array\\.$#" count: 1 path: src/DependencyInjection/SentryExtension.php - - message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:passConfigurationToOptions\\(\\) has parameter \\$processedConfiguration with no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:configureMessengerListener\\(\\) has parameter \\$processedConfiguration with no value type specified in iterable type array\\.$#" count: 1 path: src/DependencyInjection/SentryExtension.php - - message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:configureErrorListener\\(\\) has parameter \\$processedConfiguration with no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:configureMonologHandler\\(\\) has parameter \\$monologConfiguration with no value type specified in iterable type array\\.$#" count: 1 path: src/DependencyInjection/SentryExtension.php - - message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:configureMessengerListener\\(\\) has parameter \\$processedConfiguration with no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#" count: 1 path: src/DependencyInjection/SentryExtension.php - - message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:configureMonologHandler\\(\\) has parameter \\$monologConfiguration with no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:passConfigurationToOptions\\(\\) has parameter \\$processedConfiguration with no value type specified in iterable type array\\.$#" count: 1 path: src/DependencyInjection/SentryExtension.php - - message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\ErrorListener\\:\\:onKernelException\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#" + message: "#^Call to method getException\\(\\) on an unknown class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#" count: 1 path: src/EventListener/ErrorListener.php - - message: "#^Call to method getException\\(\\) on an unknown class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#" + message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\ErrorListener\\:\\:onKernelException\\(\\) has invalid typehint type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#" count: 1 path: src/EventListener/ErrorListener.php - - message: "#^Comparison operation \"\\>\\=\" between 5 and 5 is always true\\.$#" + message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#" + count: 2 + path: src/EventListener/RequestListener.php + + - + message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#" count: 1 path: src/EventListener/RequestListener.php - - message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent not found\\.$#" + message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent not found\\.$#" count: 2 path: src/EventListener/RequestListener.php - - message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent not found\\.$#" + message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent not found\\.$#" count: 2 path: src/EventListener/RequestListener.php - - message: "#^Else branch is unreachable because previous condition is always true\\.$#" + message: "#^Comparison operation \"\\>\\=\" between 5 and 5 is always true\\.$#" count: 1 path: src/EventListener/RequestListener.php - - message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:onKernelRequest\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#" - count: 2 + message: "#^Else branch is unreachable because previous condition is always true\\.$#" + count: 1 path: src/EventListener/RequestListener.php - - message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#" + message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:isMainRequest\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent, Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent given\\.$#" count: 1 path: src/EventListener/RequestListener.php - - message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#" + message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:isMainRequest\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent, Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent given\\.$#" count: 1 path: src/EventListener/RequestListener.php @@ -81,14 +86,14 @@ parameters: path: src/EventListener/RequestListener.php - - message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#" - count: 1 + message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:onKernelRequest\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#" + count: 2 path: src/EventListener/RequestListener.php - - message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#" + message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent not found\\.$#" count: 2 - path: src/EventListener/RequestListener.php + path: src/EventListener/SubRequestListener.php - message: "#^Comparison operation \"\\>\\=\" between 5 and 5 is always true\\.$#" @@ -96,12 +101,12 @@ parameters: path: src/EventListener/SubRequestListener.php - - message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent not found\\.$#" - count: 2 + message: "#^Else branch is unreachable because previous condition is always true\\.$#" + count: 1 path: src/EventListener/SubRequestListener.php - - message: "#^Else branch is unreachable because previous condition is always true\\.$#" + message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListener\\:\\:isMainRequest\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent, Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent given\\.$#" count: 1 path: src/EventListener/SubRequestListener.php @@ -110,18 +115,13 @@ parameters: count: 2 path: src/EventListener/SubRequestListener.php - - - message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent\\.$#" - count: 1 - path: src/EventListener/SubRequestListener.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\BaseTestCase\\:\\:createRequestEvent\\(\\) has no return typehint specified\\.$#" count: 1 path: test/BaseTestCase.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:testOptionValuesProcessing\\(\\) has parameter \\$value with no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:invalidValuesProvider\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/DependencyInjection/ConfigurationTest.php @@ -131,52 +131,52 @@ parameters: path: test/DependencyInjection/ConfigurationTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:testInvalidValues\\(\\) has parameter \\$value with no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:processConfiguration\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#" count: 1 path: test/DependencyInjection/ConfigurationTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:invalidValuesProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:processConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/DependencyInjection/ConfigurationTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:processConfiguration\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:testInvalidValues\\(\\) has parameter \\$value with no typehint specified\\.$#" count: 1 path: test/DependencyInjection/ConfigurationTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:processConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:testOptionValuesProcessing\\(\\) has parameter \\$value with no typehint specified\\.$#" count: 1 path: test/DependencyInjection/ConfigurationTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:optionsValueProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockBeforeBreadcrumb\\(\\) never returns Sentry\\\\Breadcrumb so it can be removed from the return typehint\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:test_that_it_ignores_empty_dsn_value\\(\\) has parameter \\$emptyDsn with no typehint specified\\.$#" + message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockBeforeSend\\(\\) never returns Sentry\\\\Event so it can be removed from the return typehint\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:emptyDsnValueProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockClassSerializer\\(\\) has no return typehint specified\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:testBeforeSendUsingScalarCallable\\(\\) has parameter \\$scalarCallable with no typehint specified\\.$#" + message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockClassSerializer\\(\\) has parameter \\$object with no typehint specified\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:testBeforeBreadcrumbUsingScalarCallable\\(\\) has parameter \\$scalarCallable with no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\CallbackMock\\:\\:callback\\(\\) has no return typehint specified\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:scalarCallableDataProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:emptyDsnValueProvider\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php @@ -186,7 +186,7 @@ parameters: path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:testMonologHandlerIsConfiguredProperly\\(\\) has parameter \\$level with no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:getContainer\\(\\) has parameter \\$configuration with no value type specified in iterable type array\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php @@ -196,37 +196,37 @@ parameters: path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:getContainer\\(\\) has parameter \\$configuration with no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:optionsValueProvider\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockBeforeSend\\(\\) never returns Sentry\\\\Event so it can be removed from the return typehint\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:scalarCallableDataProvider\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockBeforeBreadcrumb\\(\\) never returns Sentry\\\\Breadcrumb so it can be removed from the return typehint\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:testBeforeBreadcrumbUsingScalarCallable\\(\\) has parameter \\$scalarCallable with no typehint specified\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockClassSerializer\\(\\) has no return typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:testBeforeSendUsingScalarCallable\\(\\) has parameter \\$scalarCallable with no typehint specified\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Function Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\mockClassSerializer\\(\\) has parameter \\$object with no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:testMonologHandlerIsConfiguredProperly\\(\\) has parameter \\$level with no typehint specified\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\CallbackMock\\:\\:callback\\(\\) has no return typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\SentryExtensionTest\\:\\:test_that_it_ignores_empty_dsn_value\\(\\) has parameter \\$emptyDsn with no typehint specified\\.$#" count: 1 path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Comparison operation \"\\>\\=\" between \\d+ and 40300 is always true\\.$#" + message: "#^Comparison operation \"\\>\\=\" between 50206 and 40300 is always true\\.$#" count: 1 path: test/End2End/App/Kernel.php @@ -241,57 +241,57 @@ parameters: path: test/End2End/End2EndTest.php - - message: "#^Comparison operation \"\\<\" between \\d+ and 40300 is always false\\.$#" + message: "#^Comparison operation \"\\<\" between 50206 and 40300 is always false\\.$#" count: 1 path: test/End2End/End2EndTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\ErrorTypesParserTest\\:\\:testParse\\(\\) has parameter \\$value with no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\ErrorTypesParserTest\\:\\:parsableValueProvider\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/ErrorTypesParserTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\ErrorTypesParserTest\\:\\:parsableValueProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\ErrorTypesParserTest\\:\\:testParse\\(\\) has parameter \\$value with no typehint specified\\.$#" count: 1 path: test/ErrorTypesParserTest.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ConsoleListenerTest\\:\\:\\$currentHub has no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ConsoleListenerTest\\:\\:getTagsContext\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/EventListener/ConsoleListenerTest.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ConsoleListenerTest\\:\\:\\$currentScope has no typehint specified\\.$#" + message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ConsoleListenerTest\\:\\:\\$currentHub has no typehint specified\\.$#" count: 1 path: test/EventListener/ConsoleListenerTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ConsoleListenerTest\\:\\:getTagsContext\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ConsoleListenerTest\\:\\:\\$currentScope has no typehint specified\\.$#" count: 1 path: test/EventListener/ConsoleListenerTest.php - - message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Event\\\\WorkerMessageHandledEvent constructor invoked with 3 parameters, 2 required\\.$#" + message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Event\\\\WorkerMessageFailedEvent constructor invoked with 4 parameters, 3 required\\.$#" count: 1 path: test/EventListener/MessengerListenerTest.php - - message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Event\\\\WorkerMessageFailedEvent constructor invoked with 4 parameters, 3 required\\.$#" + message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Event\\\\WorkerMessageHandledEvent constructor invoked with 3 parameters, 2 required\\.$#" count: 1 path: test/EventListener/MessengerListenerTest.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:\\$currentScope has no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:createControllerEvent\\(\\) has no return typehint specified\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:\\$currentHub has no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:getTagsContext\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:\\$options has no typehint specified\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:getUserContext\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php @@ -306,32 +306,32 @@ parameters: path: test/EventListener/RequestListenerTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:getUserContext\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\UserWithInterface\\:\\:eraseCredentials\\(\\) has no return typehint specified\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:getTagsContext\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:\\$currentHub has no typehint specified\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:createControllerEvent\\(\\) has no return typehint specified\\.$#" + message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:\\$currentScope has no typehint specified\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\UserWithInterface\\:\\:\\$username has no typehint specified\\.$#" + message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\RequestListenerTest\\:\\:\\$options has no typehint specified\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\UserWithInterface\\:\\:eraseCredentials\\(\\) has no return typehint specified\\.$#" + message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ToStringUser\\:\\:\\$username has no typehint specified\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\ToStringUser\\:\\:\\$username has no typehint specified\\.$#" + message: "#^Property Sentry\\\\SentryBundle\\\\Test\\\\EventListener\\\\UserWithInterface\\:\\:\\$username has no typehint specified\\.$#" count: 1 path: test/EventListener/RequestListenerTest.php diff --git a/src/EventListener/KernelEventForwardCompatibilityTrait.php b/src/EventListener/KernelEventForwardCompatibilityTrait.php new file mode 100644 index 00000000..f2ae42d5 --- /dev/null +++ b/src/EventListener/KernelEventForwardCompatibilityTrait.php @@ -0,0 +1,21 @@ +isMainRequest() + : $event->isMasterRequest() + ; + } +} diff --git a/src/EventListener/RequestListener.php b/src/EventListener/RequestListener.php index f9bc0c71..756c63ff 100644 --- a/src/EventListener/RequestListener.php +++ b/src/EventListener/RequestListener.php @@ -35,6 +35,8 @@ class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class) */ final class RequestListener { + use KernelEventForwardCompatibilityTrait; + /** @var HubInterface */ private $hub; @@ -61,7 +63,7 @@ public function __construct( */ public function onKernelRequest(RequestListenerRequestEvent $event): void { - if (! $event->isMasterRequest()) { + if (! $this->isMainRequest($event)) { return; } @@ -96,7 +98,7 @@ public function onKernelRequest(RequestListenerRequestEvent $event): void public function onKernelController(RequestListenerControllerEvent $event): void { - if (! $event->isMasterRequest()) { + if (! $this->isMainRequest($event)) { return; } @@ -120,7 +122,7 @@ private function getUserData($user): array { if ($user instanceof UserInterface) { return [ - 'username' => $user->getUsername(), + 'username' => method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), ]; } diff --git a/src/EventListener/SubRequestListener.php b/src/EventListener/SubRequestListener.php index 55496954..40b37bab 100644 --- a/src/EventListener/SubRequestListener.php +++ b/src/EventListener/SubRequestListener.php @@ -20,6 +20,8 @@ class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class); final class SubRequestListener { + use KernelEventForwardCompatibilityTrait; + /** * Pushes a new {@see Scope} for each SubRequest * @@ -27,7 +29,7 @@ final class SubRequestListener */ public function onKernelRequest(SubRequestListenerRequestEvent $event): void { - if ($event->isMasterRequest()) { + if ($this->isMainRequest($event)) { return; } @@ -41,7 +43,7 @@ public function onKernelRequest(SubRequestListenerRequestEvent $event): void */ public function onKernelFinishRequest(FinishRequestEvent $event): void { - if ($event->isMasterRequest()) { + if ($this->isMainRequest($event)) { return; } diff --git a/test/EventListener/RequestListenerTest.php b/test/EventListener/RequestListenerTest.php index e6577c55..c62aaf4f 100644 --- a/test/EventListener/RequestListenerTest.php +++ b/test/EventListener/RequestListenerTest.php @@ -353,7 +353,12 @@ public function getSalt() return null; } - public function getUsername() + public function getUsername(): string + { + return $this->getUserIdentifier(); + } + + public function getUserIdentifier(): string { return $this->username; }