From 848b201005cbcd4c07db1b83ef82d9e681dfbf04 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 30 Nov 2020 15:21:42 +0100 Subject: [PATCH 1/9] Escape / in release version (#371) --- src/DependencyInjection/Configuration.php | 17 ++++++++++++++--- test/DependencyInjection/ConfigurationTest.php | 7 +++++++ 2 files changed, 21 insertions(+), 3 deletions(-) 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/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 */ From 2ad43f7148dc1e251411630eabf1d156af29b36f Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Mon, 30 Nov 2020 15:23:21 +0100 Subject: [PATCH 2/9] Update the changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a7ba85..4b667a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ 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 + - 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) From f2a14e5639303922b2b7282433d5c4a0f4a157bd Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Thu, 25 Mar 2021 17:47:44 +0100 Subject: [PATCH 3/9] Allow jean85/pretty-package-versions v2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 51198c99..de2349d7 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", From 8ed5f31462e8659dd072224ddf27038c2dec94a1 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Wed, 31 Mar 2021 15:55:34 +0200 Subject: [PATCH 4/9] Require latest symfony/phpunit-bridge to avoid CI failures --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index de2349d7..283a6972 100644 --- a/composer.json +++ b/composer.json @@ -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": { From 909dbcb5fa413036f4bb3db0c89faf321e5f743b Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Wed, 31 Mar 2021 16:05:41 +0200 Subject: [PATCH 5/9] Prepare release 3.5.4 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b667a3f..7a1b420a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ 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 + - ... + +## 3.5.4 - CLI commands registration policy changed to lazy load (#373, thanks to @kefzce) - Escape release option if it contains a `/` (#371, thanks to @VincentLanglet) From 187ccb47b54ec538477873f11162ae211113c6af Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Wed, 31 Mar 2021 16:07:30 +0200 Subject: [PATCH 6/9] Copy release workflow from master branch --- .github/workflows/publish-release.yaml | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/publish-release.yaml 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 }} From 3ba18c5733794290b3cea9956ad9d8a115bef3a7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 26 Apr 2021 14:05:47 +0200 Subject: [PATCH 7/9] Fix deprecations triggered by Symfony 5.3 (#490) --- CHANGELOG.md | 2 +- phpstan-baseline.neon | 126 +++++++++--------- .../KernelEventForwardCompatibilityTrait.php | 21 +++ src/EventListener/RequestListener.php | 8 +- src/EventListener/SubRequestListener.php | 6 +- test/EventListener/RequestListenerTest.php | 7 +- 6 files changed, 100 insertions(+), 70 deletions(-) create mode 100644 src/EventListener/KernelEventForwardCompatibilityTrait.php 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; } From 45a42502578ea1969232d82d16181143aa9448c9 Mon Sep 17 00:00:00 2001 From: Stefano Arlandini Date: Wed, 12 May 2021 22:04:13 +0200 Subject: [PATCH 8/9] Prepare release 3.5.4 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cdef43f..d2da7205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,9 @@ 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 +## 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) From b3f9b7f0fff3725f0b7811aa4e070e4658b8722b Mon Sep 17 00:00:00 2001 From: Stefano Arlandini Date: Thu, 13 May 2021 10:38:28 +0200 Subject: [PATCH 9/9] Update PHPStan baseline to fix broken build --- phpstan-baseline.neon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index de5a60da..b2504cb4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -226,7 +226,7 @@ parameters: path: test/DependencyInjection/SentryExtensionTest.php - - message: "#^Comparison operation \"\\>\\=\" between 50206 and 40300 is always true\\.$#" + message: "#^Comparison operation \"\\>\\=\" between 50208 and 40300 is always true\\.$#" count: 1 path: test/End2End/App/Kernel.php @@ -241,7 +241,7 @@ parameters: path: test/End2End/End2EndTest.php - - message: "#^Comparison operation \"\\<\" between 50206 and 40300 is always false\\.$#" + message: "#^Comparison operation \"\\<\" between 50208 and 40300 is always false\\.$#" count: 1 path: test/End2End/End2EndTest.php