diff --git a/.github/workflows/publish-release.yaml b/.github/workflows/publish-release.yaml new file mode 100644 index 00000000..ea19fe8d --- /dev/null +++ b/.github/workflows/publish-release.yaml @@ -0,0 +1,29 @@ +name: Prepare Release + +on: + workflow_dispatch: + inputs: + version: + description: Version to release + required: true + force: + description: Force a release even when there are release-blockers (optional) + required: false + +jobs: + release: + runs-on: ubuntu-latest + name: Release version + steps: + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GH_RELEASE_PAT }} + fetch-depth: 0 + + - name: Prepare release + uses: getsentry/action-prepare-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }} + with: + version: ${{ github.event.inputs.version }} + force: ${{ github.event.inputs.force }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a7ba85..d2da7205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ 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 - - CLI commands registration policy changed to lazy load + +## 3.5.4 (2021-05-13) + - Fix deprecations triggered by Symfony 5.3 (#490, thanks to @derrabus) + - CLI commands registration policy changed to lazy load (#373, thanks to @kefzce) + - Escape release option if it contains a `/` (#371, thanks to @VincentLanglet) ## 3.5.3 (2020-10-13) - Refactors and fixes class aliases for more robustness (#315 #359, thanks to @guilliamxavier) diff --git a/composer.json b/composer.json index 51198c99..283a6972 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require": { "php": "^7.1", - "jean85/pretty-package-versions": "^1.5", + "jean85/pretty-package-versions": "^1.5 || ^2.0", "sentry/sdk": "^2.1", "symfony/config": "^3.4||^4.0||^5.0", "symfony/console": "^3.4||^4.0||^5.0", @@ -44,7 +44,7 @@ "symfony/framework-bundle": "^3.4||^4.0||^5.0", "symfony/messenger": "^4.3||^5.0", "symfony/monolog-bundle": "^3.4", - "symfony/phpunit-bridge": "^5.0", + "symfony/phpunit-bridge": "^5.2.6", "symfony/yaml": "^3.4||^4.0||^5.0" }, "suggest": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dbaf9034..b2504cb4 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 50208 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 50208 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/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index e2945b27..b787b646 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -111,10 +111,14 @@ public function getConfigTreeBuilder(): TreeBuilder ->prototype('scalar'); $optionsChildNodes->scalarNode('project_root'); - $releaseNode = $optionsChildNodes->scalarNode('release') + $optionsChildNodes->scalarNode('release') ->info('Release version to be reported to sentry, see https://docs.sentry.io/workflow/releases/?platform=php') - ->example('my/application@ff11bb'); - $releaseNode->defaultValue(PrettyVersions::getRootPackageVersion()->getPrettyVersion()); + ->example('my-application@ff11bb') + ->beforeNormalization() + ->ifString() + ->then($this->escapeInvalidReleaseCharacters()) + ->end() + ->defaultValue(PrettyVersions::getRootPackageVersion()->getPrettyVersion()); $optionsChildNodes->floatNode('sample_rate') ->min(0.0) @@ -177,6 +181,13 @@ public function getConfigTreeBuilder(): TreeBuilder return $treeBuilder; } + private function escapeInvalidReleaseCharacters(): \Closure + { + return static function ($str): string { + return str_replace('/', '-', $str); + }; + } + private function getTrimClosure(): \Closure { return static function ($str): ?string { 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/DependencyInjection/ConfigurationTest.php b/test/DependencyInjection/ConfigurationTest.php index 2f3027ee..e137a292 100644 --- a/test/DependencyInjection/ConfigurationTest.php +++ b/test/DependencyInjection/ConfigurationTest.php @@ -137,6 +137,13 @@ public function optionValuesProvider(): array ]; } + public function testReleaseValueEscaped(): void + { + $processed = $this->processConfiguration(['options' => ['release' => 'abc/123']]); + + $this->assertContains(['options' => ['release' => 'abc-123']], $processed); + } + /** * @dataProvider invalidValuesProvider */ 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; }