From f8fc4deff895614181a51f039b594b676d48bb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 27 May 2024 20:13:58 +0200 Subject: [PATCH 01/31] fix(tests): deprecate warning in Symfony 5.4 for setAuthenticated --- tests/EventListener/LoginListenerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 8092cc15..4a332efd 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -429,7 +429,7 @@ public function __construct($user) $this->setUser($user); } - if (method_exists($this, 'setAuthenticated')) { + if (version_compare(Kernel::VERSION, '5.4', '<') && method_exists($this, 'setAuthenticated')) { $this->setAuthenticated(true); } } From abc5d8ce00627433342fc8b0ac33a2b83fae2447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 08:49:44 +0200 Subject: [PATCH 02/31] fix: error with phpstan with Parameter #2 of function preg_replace_callback expects callable(array): string, Closure(array): mixed given --- src/ErrorTypesParser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ErrorTypesParser.php b/src/ErrorTypesParser.php index aa31d486..f668d022 100644 --- a/src/ErrorTypesParser.php +++ b/src/ErrorTypesParser.php @@ -54,7 +54,8 @@ private static function convertErrorConstants(string $value): string { $output = preg_replace_callback('/(E_[A-Z_]+)/', static function (array $matches) { if (\defined($matches[1])) { - return \constant($matches[1]); + $constant = \constant($matches[1]); + return is_string($constant) ? $constant : (string) $constant; } return $matches[0]; From ac6b793e3194d29f151c6c887ab93ed745223a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:01:06 +0200 Subject: [PATCH 03/31] fix: since PHPUnit 8 filters config changed by whitelist/blacklist --- phpunit.xml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 72fe2378..e4dadb92 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,17 +20,11 @@ src + + src/aliases.php + - - - src - - src/aliases.php - - - - From 26af81b5c1794eae890153e1e2aec4fada1e1242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:01:39 +0200 Subject: [PATCH 04/31] fix: use global namespace for is_string --- src/ErrorTypesParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ErrorTypesParser.php b/src/ErrorTypesParser.php index f668d022..6817d4f3 100644 --- a/src/ErrorTypesParser.php +++ b/src/ErrorTypesParser.php @@ -55,7 +55,7 @@ private static function convertErrorConstants(string $value): string $output = preg_replace_callback('/(E_[A-Z_]+)/', static function (array $matches) { if (\defined($matches[1])) { $constant = \constant($matches[1]); - return is_string($constant) ? $constant : (string) $constant; + return \is_string($constant) ? $constant : (string) $constant; } return $matches[0]; From 98b1b4ce7edd5efe596565edcd0ace12fbb9a25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:07:11 +0200 Subject: [PATCH 05/31] fix: handle non scalar values --- src/ErrorTypesParser.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ErrorTypesParser.php b/src/ErrorTypesParser.php index 6817d4f3..cae68676 100644 --- a/src/ErrorTypesParser.php +++ b/src/ErrorTypesParser.php @@ -55,7 +55,24 @@ private static function convertErrorConstants(string $value): string $output = preg_replace_callback('/(E_[A-Z_]+)/', static function (array $matches) { if (\defined($matches[1])) { $constant = \constant($matches[1]); - return \is_string($constant) ? $constant : (string) $constant; + + if (\is_string($constant)) { + return $constant; + } + elseif (\is_int($constant)) { + return (string) $constant; + } + elseif (\is_array($constant)) { + return implode(' | ', array_map(static function ($value) { + return \is_string($value) ? $value : (string) $value; + }, $constant)); + } + elseif (\is_object($constant)) { + return get_class($constant); + } + else { // Non-scalar values + return ''; + } } return $matches[0]; From de9b825ed7ac767ad6f0db50aaed462bacd6a889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:25:41 +0200 Subject: [PATCH 06/31] fix: remove warning configuration option is deprecated --- tests/End2End/App/deprecations_for_54.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/End2End/App/deprecations_for_54.yml diff --git a/tests/End2End/App/deprecations_for_54.yml b/tests/End2End/App/deprecations_for_54.yml new file mode 100644 index 00000000..bfba309e --- /dev/null +++ b/tests/End2End/App/deprecations_for_54.yml @@ -0,0 +1,5 @@ +framework: + router: + utf8: true + messenger: + reset_on_message: true From 8be62f034923283a26ce2fe8acf3af7814d100dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:36:20 +0200 Subject: [PATCH 07/31] fix: php-cs-fixer warnings --- src/ErrorTypesParser.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ErrorTypesParser.php b/src/ErrorTypesParser.php index cae68676..ce0d7b90 100644 --- a/src/ErrorTypesParser.php +++ b/src/ErrorTypesParser.php @@ -58,19 +58,15 @@ private static function convertErrorConstants(string $value): string if (\is_string($constant)) { return $constant; - } - elseif (\is_int($constant)) { + } elseif (\is_int($constant)) { return (string) $constant; - } - elseif (\is_array($constant)) { + } elseif (\is_array($constant)) { return implode(' | ', array_map(static function ($value) { return \is_string($value) ? $value : (string) $value; }, $constant)); - } - elseif (\is_object($constant)) { - return get_class($constant); - } - else { // Non-scalar values + } elseif (\is_object($constant)) { + return \get_class($constant); + } else { // Non-scalar values return ''; } } From ef568e588d1e91a1588b1e62aea7da0529fb4766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:45:56 +0200 Subject: [PATCH 08/31] feat: add load of config file for 5.4 deprecations --- tests/End2End/App/Kernel.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/End2End/App/Kernel.php b/tests/End2End/App/Kernel.php index 3f323d7e..c372ef46 100644 --- a/tests/End2End/App/Kernel.php +++ b/tests/End2End/App/Kernel.php @@ -44,6 +44,10 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $loader->load(__DIR__ . '/deprecations_for_5.yml'); } + if (self::VERSION_ID >= 50400) { + $loader->load(__DIR__ . '/deprecations_for_54.yml'); + } + if (self::VERSION_ID >= 60000) { $loader->load(__DIR__ . '/deprecations_for_6.yml'); } From f356da0c5a5c07c5a4128929fef2a84c47df76d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:46:34 +0200 Subject: [PATCH 09/31] fix: allow equals to 5.4 version for authenticated --- tests/EventListener/LoginListenerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 4a332efd..7ba8c944 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -429,7 +429,7 @@ public function __construct($user) $this->setUser($user); } - if (version_compare(Kernel::VERSION, '5.4', '<') && method_exists($this, 'setAuthenticated')) { + if (version_compare(Kernel::VERSION, '5.4', '<=') && method_exists($this, 'setAuthenticated')) { $this->setAuthenticated(true); } } From 2a0b841359a2014846db1fb2034796ae13c9c9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 09:56:17 +0200 Subject: [PATCH 10/31] fix: adjust kernel version to only 5.4 load --- tests/End2End/App/Kernel.php | 2 +- tests/End2End/App/deprecations_for_54.yml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/End2End/App/Kernel.php b/tests/End2End/App/Kernel.php index c372ef46..46329757 100644 --- a/tests/End2End/App/Kernel.php +++ b/tests/End2End/App/Kernel.php @@ -44,7 +44,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $loader->load(__DIR__ . '/deprecations_for_5.yml'); } - if (self::VERSION_ID >= 50400) { + if (self::VERSION_ID == 50400) { $loader->load(__DIR__ . '/deprecations_for_54.yml'); } diff --git a/tests/End2End/App/deprecations_for_54.yml b/tests/End2End/App/deprecations_for_54.yml index bfba309e..abd0417d 100644 --- a/tests/End2End/App/deprecations_for_54.yml +++ b/tests/End2End/App/deprecations_for_54.yml @@ -1,5 +1,3 @@ framework: - router: - utf8: true messenger: reset_on_message: true From 06cca8ce69565563ac0368c9067458fc1a231e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 11:39:40 +0200 Subject: [PATCH 11/31] fix: improve condition check 5.4 to 6.0 --- tests/End2End/App/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/End2End/App/Kernel.php b/tests/End2End/App/Kernel.php index 46329757..7c12c07f 100644 --- a/tests/End2End/App/Kernel.php +++ b/tests/End2End/App/Kernel.php @@ -44,7 +44,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $loader->load(__DIR__ . '/deprecations_for_5.yml'); } - if (self::VERSION_ID == 50400) { + if (self::VERSION_ID >= 50400 && self::VERSION_ID <= 60000) { $loader->load(__DIR__ . '/deprecations_for_54.yml'); } From 7673f2bab0952d27b3c2ad4e36a6e083581ae9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 12:56:51 +0200 Subject: [PATCH 12/31] fix: authenticathed for non guard versions of symfony --- tests/EventListener/LoginListenerTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 7ba8c944..92510623 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -418,6 +418,8 @@ public function getCredentials(): ?string final class AuthenticatedTokenStub extends AbstractToken { + private bool $authenticated = true; + /** * @param UserInterface|\Stringable|string|null $user */ @@ -429,11 +431,18 @@ public function __construct($user) $this->setUser($user); } - if (version_compare(Kernel::VERSION, '5.4', '<=') && method_exists($this, 'setAuthenticated')) { + if (version_compare(Kernel::VERSION, '5.4', '>') && method_exists($this, 'setAuthenticated')) { + $this->authenticated = true; + } else { $this->setAuthenticated(true); } } + public function isAuthenticated(): bool + { + return $this->authenticated; + } + public function getCredentials(): ?string { return null; From 0d9bc2fcd7578a6232e1100271d0c2f4c06fd7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 13:02:07 +0200 Subject: [PATCH 13/31] fix: remove strong typed params for PHP 7.x version --- tests/EventListener/LoginListenerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 92510623..83751237 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -418,7 +418,7 @@ public function getCredentials(): ?string final class AuthenticatedTokenStub extends AbstractToken { - private bool $authenticated = true; + private $authenticated = false; /** * @param UserInterface|\Stringable|string|null $user From 92991808d2ae42b3bc35c9f43ed89054e915ae66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 13:09:58 +0200 Subject: [PATCH 14/31] fix: wrong condition inverse --- tests/EventListener/LoginListenerTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 83751237..59db2cc1 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -431,10 +431,10 @@ public function __construct($user) $this->setUser($user); } - if (version_compare(Kernel::VERSION, '5.4', '>') && method_exists($this, 'setAuthenticated')) { - $this->authenticated = true; - } else { + if (version_compare(Kernel::VERSION, '5.4', '<') && method_exists($this, 'setAuthenticated')) { $this->setAuthenticated(true); + } else { + $this->authenticated = true; } } From f8e50a81007032c2022ce8ff15b7755deb009d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 13:12:25 +0200 Subject: [PATCH 15/31] fix: phpstan warning for authentication --- tests/EventListener/LoginListenerTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 59db2cc1..6a57deb2 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -418,6 +418,9 @@ public function getCredentials(): ?string final class AuthenticatedTokenStub extends AbstractToken { + /** + * @var boolean + */ private $authenticated = false; /** From 7533b6ff0fff358e2516318ef5327024a9613706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 13:55:55 +0200 Subject: [PATCH 16/31] fix: implement a legacy version token stub for Symfony 4.x --- tests/EventListener/LoginListenerTest.php | 215 +++++++++++++++++----- 1 file changed, 166 insertions(+), 49 deletions(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 6a57deb2..eea00a9f 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -183,17 +183,35 @@ public function testHandleAuthenticationSuccessEvent(TokenInterface $token, ?Use public function authenticationTokenDataProvider(): \Generator { - yield 'If the username is already set on the User context, then it is not overridden' => [ - new AuthenticatedTokenStub(new UserWithIdentifierStub()), - new UserDataBag('bar_user'), - new UserDataBag('bar_user'), - ]; + if(version_compare(Kernel::VERSION, '5.4', '<')) { + yield 'If the username is already set on the User context, then it is not overridden' => [ + new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()), + new UserDataBag('bar_user'), + new UserDataBag('bar_user'), + ]; + } + else { + yield 'If the username is already set on the User context, then it is not overridden' => [ + new AuthenticatedTokenStub(new UserWithIdentifierStub()), + new UserDataBag('bar_user'), + new UserDataBag('bar_user'), + ]; + } - yield 'If the username is not set on the User context, then it is retrieved from the token' => [ - new AuthenticatedTokenStub(new UserWithIdentifierStub()), - null, - new UserDataBag('foo_user'), - ]; + if(version_compare(Kernel::VERSION, '5.4', '<')) { + yield 'If the username is not set on the User context, then it is retrieved from the token' => [ + new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()), + null, + new UserDataBag('foo_user'), + ]; + } + else { + yield 'If the username is not set on the User context, then it is retrieved from the token' => [ + new AuthenticatedTokenStub(new UserWithIdentifierStub()), + null, + new UserDataBag('foo_user'), + ]; + } yield 'If the user is being impersonated, then the username of the impersonator is set on the User context' => [ (static function (): SwitchUserToken { @@ -203,7 +221,7 @@ public function authenticationTokenDataProvider(): \Generator null, 'foo_provider', ['ROLE_USER'], - new AuthenticatedTokenStub(new UserWithIdentifierStub('bar_user')) + new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub('bar_user')) ); } @@ -228,28 +246,60 @@ public function authenticationTokenForSymfonyVersionLowerThan54DataProvider(): \ return; } - yield 'If the user is a string, then the value is used as-is' => [ - new AuthenticatedTokenStub('foo_user'), - null, - new UserDataBag('foo_user'), - ]; + if(version_compare(Kernel::VERSION, '5.0', '<')) { + yield 'If the user is a string, then the value is used as-is' => [ + new LegacyAuthenticatedTokenStub('foo_user'), + null, + new UserDataBag('foo_user'), + ]; + } + else { + yield 'If the user is a string, then the value is used as-is' => [ + new AuthenticatedTokenStub('foo_user'), + null, + new UserDataBag('foo_user'), + ]; + } - yield 'If the user is an instance of the UserInterface interface but the getUserIdentifier() method does not exist, then the getUsername() method is invoked' => [ - new AuthenticatedTokenStub(new UserWithoutIdentifierStub()), - null, - new UserDataBag('foo_user'), - ]; + if(version_compare(Kernel::VERSION, '5.0', '<')) { + yield 'If the user is an instance of the UserInterface interface but the getUserIdentifier() method does not exist, then the getUsername() method is invoked' => [ + new LegacyAuthenticatedTokenStub(new UserWithoutIdentifierStub()), + null, + new UserDataBag('foo_user'), + ]; + } + else { + yield 'If the user is an instance of the UserInterface interface but the getUserIdentifier() method does not exist, then the getUsername() method is invoked' => [ + new AuthenticatedTokenStub(new UserWithoutIdentifierStub()), + null, + new UserDataBag('foo_user'), + ]; + } - yield 'If the user is an object implementing the Stringable interface, then the __toString() method is invoked' => [ - new AuthenticatedTokenStub(new class() implements \Stringable { - public function __toString(): string - { - return 'foo_user'; - } - }), - null, - new UserDataBag('foo_user'), - ]; + if(version_compare(Kernel::VERSION, '5.0', '<')) { + yield 'If the user is an object implementing the Stringable interface, then the __toString() method is invoked' => [ + new LegacyAuthenticatedTokenStub(new class() implements \Stringable { + public function __toString(): string + { + return 'foo_user'; + } + }), + null, + new UserDataBag('foo_user'), + ]; + } + else { + yield 'If the user is an object implementing the Stringable interface, then the __toString() method is invoked' => [ + new AuthenticatedTokenStub(new class() implements \Stringable { + public function __toString(): string + { + return 'foo_user'; + } + }), + null, + new UserDataBag('foo_user'), + ]; + } } public function testHandleKernelRequestEventDoesNothingIfRequestIsNotMain(): void @@ -312,14 +362,26 @@ public function testHandleLoginSuccessEventDoesNothingIfClientIsNotSetOnHub(): v $this->hub->expects($this->never()) ->method('configureScope'); - $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( - $this->createMock(AuthenticatorInterface::class), - new SelfValidatingPassport(new UserBadge('foo_passport_user')), - new AuthenticatedTokenStub(new UserWithIdentifierStub()), - new Request(), - null, - 'main' - )); + if(version_compare(Kernel::VERSION, '5.4', '<')) { + $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( + $this->createMock(AuthenticatorInterface::class), + new SelfValidatingPassport(new UserBadge('foo_passport_user')), + new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()), + new Request(), + null, + 'main' + )); + } + else { + $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( + $this->createMock(AuthenticatorInterface::class), + new SelfValidatingPassport(new UserBadge('foo_passport_user')), + new AuthenticatedTokenStub(new UserWithIdentifierStub()), + new Request(), + null, + 'main' + )); + } } public function testHandleLoginSuccessEventDoesNothingIfSendingDefaultPiiIsDisabled(): void @@ -340,14 +402,26 @@ public function testHandleLoginSuccessEventDoesNothingIfSendingDefaultPiiIsDisab $this->hub->expects($this->never()) ->method('configureScope'); - $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( - $this->createMock(AuthenticatorInterface::class), - new SelfValidatingPassport(new UserBadge('foo_passport_user')), - new AuthenticatedTokenStub(new UserWithIdentifierStub()), - new Request(), - null, - 'main' - )); + if(version_compare(Kernel::VERSION, '5.4', '<')) { + $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( + $this->createMock(AuthenticatorInterface::class), + new SelfValidatingPassport(new UserBadge('foo_passport_user')), + new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()), + new Request(), + null, + 'main' + )); + } + else { + $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( + $this->createMock(AuthenticatorInterface::class), + new SelfValidatingPassport(new UserBadge('foo_passport_user')), + new AuthenticatedTokenStub(new UserWithIdentifierStub()), + new Request(), + null, + 'main' + )); + } } public function testHandleAuthenticationSuccessEventDoesNothingIfTokenIsNotAuthenticated(): void @@ -378,7 +452,12 @@ public function testHandleAuthenticationSuccessEventDoesNothingIfClientIsNotSetO $this->hub->expects($this->never()) ->method('configureScope'); - $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new AuthenticatedTokenStub(new UserWithIdentifierStub()))); + if (version_compare(Kernel::VERSION, '5.4', '<')) { + $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()))); + } + else { + $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new AuthenticatedTokenStub(new UserWithIdentifierStub()))); + } } public function testHandleAuthenticationSuccessEventDoesNothingIfSendingDefaultPiiIsDisabled(): void @@ -399,7 +478,12 @@ public function testHandleAuthenticationSuccessEventDoesNothingIfSendingDefaultP $this->hub->expects($this->never()) ->method('configureScope'); - $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new AuthenticatedTokenStub(new UserWithIdentifierStub()))); + if (version_compare(Kernel::VERSION, '5.4', '<')) { + $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()))); + } + else { + $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new AuthenticatedTokenStub(new UserWithIdentifierStub()))); + } } } @@ -416,6 +500,38 @@ public function getCredentials(): ?string } } +class LegacyAuthenticatedTokenStub extends AbstractToken +{ + /** + * @var boolean + */ + private $authenticated = false; + + /** + * @param UserInterface|\Stringable|string|null $user + */ + public function __construct($user) + { + parent::__construct(); + + if (null !== $user) { + $this->setUser($user); + } + + if (version_compare(Kernel::VERSION, '5.4', '<') && method_exists($this, 'setAuthenticated')) { + $this->setAuthenticated(true); + } else { + $this->authenticated = true; + } + } + + public function getCredentials(): ?string + { + return null; + } +} + + final class AuthenticatedTokenStub extends AbstractToken { /** @@ -451,3 +567,4 @@ public function getCredentials(): ?string return null; } } + From f9e70f080f20177e465e720732be8ae26298ed89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 14:00:33 +0200 Subject: [PATCH 17/31] fix: php-cs-fixer warnings --- tests/EventListener/LoginListenerTest.php | 47 +++++++++-------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index eea00a9f..1b4bf3aa 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -183,14 +183,13 @@ public function testHandleAuthenticationSuccessEvent(TokenInterface $token, ?Use public function authenticationTokenDataProvider(): \Generator { - if(version_compare(Kernel::VERSION, '5.4', '<')) { + if (version_compare(Kernel::VERSION, '5.4', '<')) { yield 'If the username is already set on the User context, then it is not overridden' => [ new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()), new UserDataBag('bar_user'), new UserDataBag('bar_user'), ]; - } - else { + } else { yield 'If the username is already set on the User context, then it is not overridden' => [ new AuthenticatedTokenStub(new UserWithIdentifierStub()), new UserDataBag('bar_user'), @@ -198,14 +197,13 @@ public function authenticationTokenDataProvider(): \Generator ]; } - if(version_compare(Kernel::VERSION, '5.4', '<')) { + if (version_compare(Kernel::VERSION, '5.4', '<')) { yield 'If the username is not set on the User context, then it is retrieved from the token' => [ new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()), null, new UserDataBag('foo_user'), ]; - } - else { + } else { yield 'If the username is not set on the User context, then it is retrieved from the token' => [ new AuthenticatedTokenStub(new UserWithIdentifierStub()), null, @@ -246,14 +244,13 @@ public function authenticationTokenForSymfonyVersionLowerThan54DataProvider(): \ return; } - if(version_compare(Kernel::VERSION, '5.0', '<')) { + if (version_compare(Kernel::VERSION, '5.0', '<')) { yield 'If the user is a string, then the value is used as-is' => [ new LegacyAuthenticatedTokenStub('foo_user'), null, new UserDataBag('foo_user'), ]; - } - else { + } else { yield 'If the user is a string, then the value is used as-is' => [ new AuthenticatedTokenStub('foo_user'), null, @@ -261,14 +258,13 @@ public function authenticationTokenForSymfonyVersionLowerThan54DataProvider(): \ ]; } - if(version_compare(Kernel::VERSION, '5.0', '<')) { + if (version_compare(Kernel::VERSION, '5.0', '<')) { yield 'If the user is an instance of the UserInterface interface but the getUserIdentifier() method does not exist, then the getUsername() method is invoked' => [ new LegacyAuthenticatedTokenStub(new UserWithoutIdentifierStub()), null, new UserDataBag('foo_user'), ]; - } - else { + } else { yield 'If the user is an instance of the UserInterface interface but the getUserIdentifier() method does not exist, then the getUsername() method is invoked' => [ new AuthenticatedTokenStub(new UserWithoutIdentifierStub()), null, @@ -276,7 +272,7 @@ public function authenticationTokenForSymfonyVersionLowerThan54DataProvider(): \ ]; } - if(version_compare(Kernel::VERSION, '5.0', '<')) { + if (version_compare(Kernel::VERSION, '5.0', '<')) { yield 'If the user is an object implementing the Stringable interface, then the __toString() method is invoked' => [ new LegacyAuthenticatedTokenStub(new class() implements \Stringable { public function __toString(): string @@ -287,8 +283,7 @@ public function __toString(): string null, new UserDataBag('foo_user'), ]; - } - else { + } else { yield 'If the user is an object implementing the Stringable interface, then the __toString() method is invoked' => [ new AuthenticatedTokenStub(new class() implements \Stringable { public function __toString(): string @@ -362,7 +357,7 @@ public function testHandleLoginSuccessEventDoesNothingIfClientIsNotSetOnHub(): v $this->hub->expects($this->never()) ->method('configureScope'); - if(version_compare(Kernel::VERSION, '5.4', '<')) { + if (version_compare(Kernel::VERSION, '5.4', '<')) { $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( $this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('foo_passport_user')), @@ -371,8 +366,7 @@ public function testHandleLoginSuccessEventDoesNothingIfClientIsNotSetOnHub(): v null, 'main' )); - } - else { + } else { $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( $this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('foo_passport_user')), @@ -402,7 +396,7 @@ public function testHandleLoginSuccessEventDoesNothingIfSendingDefaultPiiIsDisab $this->hub->expects($this->never()) ->method('configureScope'); - if(version_compare(Kernel::VERSION, '5.4', '<')) { + if (version_compare(Kernel::VERSION, '5.4', '<')) { $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( $this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('foo_passport_user')), @@ -411,8 +405,7 @@ public function testHandleLoginSuccessEventDoesNothingIfSendingDefaultPiiIsDisab null, 'main' )); - } - else { + } else { $this->listener->handleLoginSuccessEvent(new LoginSuccessEvent( $this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('foo_passport_user')), @@ -454,8 +447,7 @@ public function testHandleAuthenticationSuccessEventDoesNothingIfClientIsNotSetO if (version_compare(Kernel::VERSION, '5.4', '<')) { $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()))); - } - else { + } else { $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new AuthenticatedTokenStub(new UserWithIdentifierStub()))); } } @@ -480,8 +472,7 @@ public function testHandleAuthenticationSuccessEventDoesNothingIfSendingDefaultP if (version_compare(Kernel::VERSION, '5.4', '<')) { $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub()))); - } - else { + } else { $this->listener->handleAuthenticationSuccessEvent(new AuthenticationSuccessEvent(new AuthenticatedTokenStub(new UserWithIdentifierStub()))); } } @@ -503,7 +494,7 @@ public function getCredentials(): ?string class LegacyAuthenticatedTokenStub extends AbstractToken { /** - * @var boolean + * @var bool */ private $authenticated = false; @@ -531,11 +522,10 @@ public function getCredentials(): ?string } } - final class AuthenticatedTokenStub extends AbstractToken { /** - * @var boolean + * @var bool */ private $authenticated = false; @@ -567,4 +557,3 @@ public function getCredentials(): ?string return null; } } - From 1331c1aeaa697702a110b1fc5ae64a838bb76fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 14:21:11 +0200 Subject: [PATCH 18/31] fix: phpstan ignore lines --- tests/EventListener/LoginListenerTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 1b4bf3aa..ef0f4a52 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -285,6 +285,7 @@ public function __toString(): string ]; } else { yield 'If the user is an object implementing the Stringable interface, then the __toString() method is invoked' => [ + // @phpstan-ignore-next-line new AuthenticatedTokenStub(new class() implements \Stringable { public function __toString(): string { @@ -495,10 +496,12 @@ class LegacyAuthenticatedTokenStub extends AbstractToken { /** * @var bool + * @phpstan-ignore-next-line */ private $authenticated = false; /** + * @phpstan-ignore-next-line * @param UserInterface|\Stringable|string|null $user */ public function __construct($user) @@ -526,10 +529,12 @@ final class AuthenticatedTokenStub extends AbstractToken { /** * @var bool + * @phpstan-ignore-next-line */ private $authenticated = false; /** + * @phpstan-ignore-next-line * @param UserInterface|\Stringable|string|null $user */ public function __construct($user) From 69a7df9eca0a8bbbadff6cea1f85c1838ccd6ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 14:27:21 +0200 Subject: [PATCH 19/31] fix: more phpstan warnings and errors --- tests/EventListener/LoginListenerTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index ef0f4a52..24129796 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -219,6 +219,7 @@ public function authenticationTokenDataProvider(): \Generator null, 'foo_provider', ['ROLE_USER'], + // @phpstan-ignore-next-line new LegacyAuthenticatedTokenStub(new UserWithIdentifierStub('bar_user')) ); } @@ -285,7 +286,6 @@ public function __toString(): string ]; } else { yield 'If the user is an object implementing the Stringable interface, then the __toString() method is invoked' => [ - // @phpstan-ignore-next-line new AuthenticatedTokenStub(new class() implements \Stringable { public function __toString(): string { @@ -501,7 +501,6 @@ class LegacyAuthenticatedTokenStub extends AbstractToken private $authenticated = false; /** - * @phpstan-ignore-next-line * @param UserInterface|\Stringable|string|null $user */ public function __construct($user) @@ -509,6 +508,7 @@ public function __construct($user) parent::__construct(); if (null !== $user) { + // @phpstan-ignore-next-line $this->setUser($user); } @@ -529,12 +529,10 @@ final class AuthenticatedTokenStub extends AbstractToken { /** * @var bool - * @phpstan-ignore-next-line */ private $authenticated = false; /** - * @phpstan-ignore-next-line * @param UserInterface|\Stringable|string|null $user */ public function __construct($user) @@ -542,6 +540,7 @@ public function __construct($user) parent::__construct(); if (null !== $user) { + // @phpstan-ignore-next-line $this->setUser($user); } From 705740612e4a1f3622d9d8f0bcf81bb42a28258e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 20:09:59 +0200 Subject: [PATCH 20/31] fix: typo php-cs-fixer --- tests/EventListener/LoginListenerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/EventListener/LoginListenerTest.php b/tests/EventListener/LoginListenerTest.php index 24129796..cfaf50aa 100644 --- a/tests/EventListener/LoginListenerTest.php +++ b/tests/EventListener/LoginListenerTest.php @@ -496,6 +496,7 @@ class LegacyAuthenticatedTokenStub extends AbstractToken { /** * @var bool + * * @phpstan-ignore-next-line */ private $authenticated = false; From f8e95f25ee0d659456365660f4fb1616c9e0609b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 20:37:23 +0200 Subject: [PATCH 21/31] fix: improve pcov test with invalid values --- tests/ErrorTypesParserTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/ErrorTypesParserTest.php b/tests/ErrorTypesParserTest.php index e30d6c78..9e3cd532 100644 --- a/tests/ErrorTypesParserTest.php +++ b/tests/ErrorTypesParserTest.php @@ -71,5 +71,8 @@ public function parseThrowsExceptionIfArgumentContainsInvalidCharactersDataProvi yield ['(']; yield [')']; yield ['()']; + // Non scalar values (probably misstypes, but still valid PHP code) + yield ['[8, 8192]']; + yield [\stdClass::class]; } } From 8e85a9c59f94777cca850cf2628d4a8afca6c4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 20:55:28 +0200 Subject: [PATCH 22/31] fix: check for symfony/messenger class present for autoload config --- tests/End2End/App/Kernel.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/End2End/App/Kernel.php b/tests/End2End/App/Kernel.php index 7c12c07f..2cd79a6d 100644 --- a/tests/End2End/App/Kernel.php +++ b/tests/End2End/App/Kernel.php @@ -45,7 +45,11 @@ public function registerContainerConfiguration(LoaderInterface $loader): void } if (self::VERSION_ID >= 50400 && self::VERSION_ID <= 60000) { - $loader->load(__DIR__ . '/deprecations_for_54.yml'); + + // Check if class for Messenger is present (component symfony/messenger is not mandatory) + if (interface_exists(MessageBusInterface::class)) { + $loader->load(__DIR__ . '/deprecations_for_54.yml'); + } } if (self::VERSION_ID >= 60000) { From cdc72c9cbc44f6b1af55d135dec82f2c44ea270c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Mon, 3 Jun 2024 20:58:24 +0200 Subject: [PATCH 23/31] fix: typo blank line php-cs-fixer --- tests/End2End/App/Kernel.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/End2End/App/Kernel.php b/tests/End2End/App/Kernel.php index 2cd79a6d..c3467c61 100644 --- a/tests/End2End/App/Kernel.php +++ b/tests/End2End/App/Kernel.php @@ -45,7 +45,6 @@ public function registerContainerConfiguration(LoaderInterface $loader): void } if (self::VERSION_ID >= 50400 && self::VERSION_ID <= 60000) { - // Check if class for Messenger is present (component symfony/messenger is not mandatory) if (interface_exists(MessageBusInterface::class)) { $loader->load(__DIR__ . '/deprecations_for_54.yml'); From 832bfe577d769ba7db067fb8f10983d82950907f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 13:06:53 +0200 Subject: [PATCH 24/31] fix: generate new baseline --- phpstan-baseline.neon | 164 ++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 77 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4c723f1e..094e2c67 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -80,11 +80,6 @@ parameters: count: 1 path: src/DependencyInjection/SentryExtension.php - - - message: "#^Parameter \\#1 \\$array of function array_filter expects array, mixed given\\.$#" - count: 1 - path: src/DependencyInjection/SentryExtension.php - - message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: Symfony\\\\Component\\\\DependencyInjection\\\\Reference given\\.$#" count: 1 @@ -95,6 +90,11 @@ parameters: count: 9 path: src/DependencyInjection/SentryExtension.php + - + message: "#^Parameter \\#1 \\$input of function array_filter expects array, mixed given\\.$#" + count: 1 + path: src/DependencyInjection/SentryExtension.php + - message: "#^Parameter \\#1 \\$integrations of method Sentry\\\\SentryBundle\\\\DependencyInjection\\\\SentryExtension\\:\\:configureIntegrationsOption\\(\\) expects array\\, mixed given\\.$#" count: 1 @@ -171,27 +171,42 @@ parameters: path: src/EventListener/LoginListener.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" + message: "#^Call to method getWrappedExceptions\\(\\) on an unknown class Symfony\\\\Component\\\\Messenger\\\\Exception\\\\WrappedExceptionsInterface\\.$#" count: 1 - path: src/EventListener/RequestListener.php + path: src/EventListener/MessengerListener.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" + message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Exception\\\\WrappedExceptionsInterface not found\\.$#" count: 1 - path: src/EventListener/SubRequestListener.php + path: src/EventListener/MessengerListener.php - message: "#^Parameter \\#1 \\$driver of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverMiddleware\\:\\:wrap\\(\\) expects Doctrine\\\\DBAL\\\\Driver, mixed given\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/ConnectionConfigurator.php + - + message: "#^Class Doctrine\\\\DBAL\\\\Platforms\\\\SQLitePlatform not found\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionFactoryForV4.php + + - + message: "#^Anonymous function never returns string so it can be removed from the return type\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + + - + message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:getServerVersion\\(\\)\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + - message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:errorInfo\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:exec\\(\\) should return int\\|numeric\\-string but returns int\\|string\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:lastInsertId\\(\\) should return int\\|string but returns int\\|string\\|false\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php @@ -205,6 +220,11 @@ parameters: count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + - + message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:quote\\(\\) should return string but returns mixed\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + - message: "#^Parameter \\#1 \\$sql of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:query\\(\\) expects string, string\\|null given\\.$#" count: 1 @@ -215,6 +235,46 @@ parameters: count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + - + message: "#^Return type \\(void\\) of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:beginTransaction\\(\\) should be compatible with return type \\(bool\\) of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:beginTransaction\\(\\)$#" + count: 2 + path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + + - + message: "#^Return type \\(void\\) of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:commit\\(\\) should be compatible with return type \\(bool\\) of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:commit\\(\\)$#" + count: 2 + path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + + - + message: "#^Return type \\(void\\) of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:rollBack\\(\\) should be compatible with return type \\(bool\\) of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:rollBack\\(\\)$#" + count: 2 + path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php + + - + message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:getServerVersion\\(\\)\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingDriverForV4.php + + - + message: "#^Instantiated class Doctrine\\\\DBAL\\\\Connection\\\\StaticServerVersionProvider not found\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingDriverForV4.php + + - + message: "#^Method Doctrine\\\\DBAL\\\\Driver\\\\Middleware\\\\AbstractDriverMiddleware\\:\\:getDatabasePlatform\\(\\) invoked with 1 parameter, 0 required\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingDriverForV4.php + + - + message: "#^Parameter \\#2 \\$callback of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\AbstractTracingStatement\\:\\:traceFunction\\(\\) expects callable\\(mixed \\.\\.\\.\\)\\: Doctrine\\\\DBAL\\\\Driver\\\\Result, array\\{Doctrine\\\\DBAL\\\\Driver\\\\Statement, 'execute'\\} given\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingStatementForV4.php + + - + message: "#^Parameter \\#3 \\$type of method Doctrine\\\\DBAL\\\\Driver\\\\Statement\\:\\:bindValue\\(\\) expects int, Doctrine\\\\DBAL\\\\ParameterType given\\.$#" + count: 1 + path: src/Tracing/Doctrine/DBAL/TracingStatementForV4.php + - message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableHttpClient\\:\\:request\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#" count: 1 @@ -255,16 +315,6 @@ parameters: count: 1 path: tests/DependencyInjection/ConfigurationTest.php - - - message: "#^Function Symfony\\\\Component\\\\DependencyInjection\\\\Loader\\\\Configurator\\\\ref not found\\.$#" - count: 1 - path: tests/DependencyInjection/Fixtures/php/release_option_fallback_to_env_var.php - - - - message: "#^Used function Symfony\\\\Component\\\\DependencyInjection\\\\Loader\\\\Configurator\\\\ref not found\\.$#" - count: 1 - path: tests/DependencyInjection/Fixtures/php/release_option_fallback_to_env_var.php - - message: "#^Cannot access offset 'dsn' on mixed\\.$#" count: 1 @@ -285,70 +335,15 @@ parameters: count: 1 path: tests/End2End/TracingEnd2EndTest.php - - - message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" - count: 1 - path: tests/EventListener/ErrorListenerTest.php - - - - message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" - count: 2 - path: tests/EventListener/LoginListenerTest.php - - - - message: "#^Call to function method_exists\\(\\) with \\$this\\(Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub\\) and 'setAuthenticated' will always evaluate to false\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - - - message: "#^Parameter \\#1 \\$user of method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\AbstractToken\\:\\:setUser\\(\\) expects Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface, string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - - - message: "#^Parameter \\#2 \\$firewallName of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string, null given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - message: "#^Parameter \\#3 \\$roles of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects array\\, string given\\.$#" count: 1 path: tests/EventListener/LoginListenerTest.php - - message: "#^Parameter \\#4 \\$originalToken of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\TokenInterface, array\\ given\\.$#" + message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Exception\\\\DelayedMessageHandlingException constructor invoked with 2 parameters, 1 required\\.$#" count: 1 - path: tests/EventListener/LoginListenerTest.php - - - - message: "#^Parameter \\#5 \\$originatedFromUri of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string\\|null, Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - - - message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" - count: 6 - path: tests/EventListener/RequestListenerTest.php - - - - message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" - count: 2 - path: tests/EventListener/SubRequestListenerTest.php - - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" - count: 1 - path: tests/EventListener/SubRequestListenerTest.php - - - - message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" - count: 3 - path: tests/EventListener/TracingRequestListenerTest.php - - - - message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" - count: 2 - path: tests/EventListener/TracingSubRequestListenerTest.php + path: tests/EventListener/MessengerListenerTest.php - message: "#^Call to an undefined method TCacheAdapter of Symfony\\\\Component\\\\Cache\\\\Adapter\\\\AdapterInterface\\:\\:delete\\(\\)\\.$#" @@ -370,6 +365,11 @@ parameters: count: 1 path: tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php + - + message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{foo\\: Symfony\\\\Component\\\\Cache\\\\CacheItem\\} and Traversable\\ will always evaluate to false\\.$#" + count: 1 + path: tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php + - message: "#^Parameter \\#1 \\$decoratedAdapter of method Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Cache\\\\AbstractTraceableCacheAdapterTest\\\\:\\:createCacheAdapter\\(\\) expects TDecoratedCacheAdapter of Symfony\\\\Component\\\\Cache\\\\Adapter\\\\AdapterInterface, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject&Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Cache\\\\CacheInterface given\\.$#" count: 2 @@ -385,6 +385,11 @@ parameters: count: 1 path: tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php + - + message: "#^Class Doctrine\\\\DBAL\\\\Platforms\\\\SQLitePlatform not found\\.$#" + count: 1 + path: tests/Tracing/Doctrine/DBAL/TracingDriverConnectionFactoryV4Test.php + - message: "#^Property Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionFactoryV4Test\\:\\:\\$databasePlatform is never read, only written\\.$#" count: 1 @@ -405,6 +410,11 @@ parameters: count: 1 path: tests/Tracing/Doctrine/DBAL/TracingDriverMiddlewareTest.php + - + message: "#^Parameter \\#3 \\$type of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingStatementForV4\\:\\:bindValue\\(\\) expects Doctrine\\\\DBAL\\\\ParameterType, int given\\.$#" + count: 1 + path: tests/Tracing/Doctrine/DBAL/TracingStatementForV4Test.php + - message: "#^Parameter \\#1 \\$responses of method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableHttpClient\\:\\:stream\\(\\) expects iterable\\<\\(int\\|string\\), Symfony\\\\Contracts\\\\HttpClient\\\\ResponseInterface\\>\\|Symfony\\\\Contracts\\\\HttpClient\\\\ResponseInterface, stdClass given\\.$#" count: 1 From b5f07ac8b47fbc0fa6d93021a286b69bc977a9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 13:50:50 +0200 Subject: [PATCH 25/31] Revert "fix: generate new baseline" This reverts commit 832bfe577d769ba7db067fb8f10983d82950907f. --- phpstan-baseline.neon | 164 ++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 87 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 094e2c67..4c723f1e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -81,18 +81,18 @@ parameters: path: src/DependencyInjection/SentryExtension.php - - message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: Symfony\\\\Component\\\\DependencyInjection\\\\Reference given\\.$#" + message: "#^Parameter \\#1 \\$array of function array_filter expects array, mixed given\\.$#" count: 1 path: src/DependencyInjection/SentryExtension.php - - message: "#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, mixed given\\.$#" - count: 9 + message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: Symfony\\\\Component\\\\DependencyInjection\\\\Reference given\\.$#" + count: 1 path: src/DependencyInjection/SentryExtension.php - - message: "#^Parameter \\#1 \\$input of function array_filter expects array, mixed given\\.$#" - count: 1 + message: "#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, mixed given\\.$#" + count: 9 path: src/DependencyInjection/SentryExtension.php - @@ -171,42 +171,27 @@ parameters: path: src/EventListener/LoginListener.php - - message: "#^Call to method getWrappedExceptions\\(\\) on an unknown class Symfony\\\\Component\\\\Messenger\\\\Exception\\\\WrappedExceptionsInterface\\.$#" + message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" count: 1 - path: src/EventListener/MessengerListener.php + path: src/EventListener/RequestListener.php - - message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Exception\\\\WrappedExceptionsInterface not found\\.$#" + message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" count: 1 - path: src/EventListener/MessengerListener.php + path: src/EventListener/SubRequestListener.php - message: "#^Parameter \\#1 \\$driver of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverMiddleware\\:\\:wrap\\(\\) expects Doctrine\\\\DBAL\\\\Driver, mixed given\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/ConnectionConfigurator.php - - - message: "#^Class Doctrine\\\\DBAL\\\\Platforms\\\\SQLitePlatform not found\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionFactoryForV4.php - - - - message: "#^Anonymous function never returns string so it can be removed from the return type\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:getServerVersion\\(\\)\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:errorInfo\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:lastInsertId\\(\\) should return int\\|string but returns int\\|string\\|false\\.$#" + message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:exec\\(\\) should return int\\|numeric\\-string but returns int\\|string\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php @@ -220,11 +205,6 @@ parameters: count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - - message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:quote\\(\\) should return string but returns mixed\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - message: "#^Parameter \\#1 \\$sql of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:query\\(\\) expects string, string\\|null given\\.$#" count: 1 @@ -235,46 +215,6 @@ parameters: count: 1 path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - - message: "#^Return type \\(void\\) of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:beginTransaction\\(\\) should be compatible with return type \\(bool\\) of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:beginTransaction\\(\\)$#" - count: 2 - path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - - - message: "#^Return type \\(void\\) of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:commit\\(\\) should be compatible with return type \\(bool\\) of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:commit\\(\\)$#" - count: 2 - path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - - - message: "#^Return type \\(void\\) of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionForV4\\:\\:rollBack\\(\\) should be compatible with return type \\(bool\\) of method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:rollBack\\(\\)$#" - count: 2 - path: src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php - - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Driver\\\\Connection\\:\\:getServerVersion\\(\\)\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingDriverForV4.php - - - - message: "#^Instantiated class Doctrine\\\\DBAL\\\\Connection\\\\StaticServerVersionProvider not found\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingDriverForV4.php - - - - message: "#^Method Doctrine\\\\DBAL\\\\Driver\\\\Middleware\\\\AbstractDriverMiddleware\\:\\:getDatabasePlatform\\(\\) invoked with 1 parameter, 0 required\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingDriverForV4.php - - - - message: "#^Parameter \\#2 \\$callback of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\AbstractTracingStatement\\:\\:traceFunction\\(\\) expects callable\\(mixed \\.\\.\\.\\)\\: Doctrine\\\\DBAL\\\\Driver\\\\Result, array\\{Doctrine\\\\DBAL\\\\Driver\\\\Statement, 'execute'\\} given\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingStatementForV4.php - - - - message: "#^Parameter \\#3 \\$type of method Doctrine\\\\DBAL\\\\Driver\\\\Statement\\:\\:bindValue\\(\\) expects int, Doctrine\\\\DBAL\\\\ParameterType given\\.$#" - count: 1 - path: src/Tracing/Doctrine/DBAL/TracingStatementForV4.php - - message: "#^Method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableHttpClient\\:\\:request\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#" count: 1 @@ -315,6 +255,16 @@ parameters: count: 1 path: tests/DependencyInjection/ConfigurationTest.php + - + message: "#^Function Symfony\\\\Component\\\\DependencyInjection\\\\Loader\\\\Configurator\\\\ref not found\\.$#" + count: 1 + path: tests/DependencyInjection/Fixtures/php/release_option_fallback_to_env_var.php + + - + message: "#^Used function Symfony\\\\Component\\\\DependencyInjection\\\\Loader\\\\Configurator\\\\ref not found\\.$#" + count: 1 + path: tests/DependencyInjection/Fixtures/php/release_option_fallback_to_env_var.php + - message: "#^Cannot access offset 'dsn' on mixed\\.$#" count: 1 @@ -335,15 +285,70 @@ parameters: count: 1 path: tests/End2End/TracingEnd2EndTest.php + - + message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" + count: 1 + path: tests/EventListener/ErrorListenerTest.php + + - + message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" + count: 2 + path: tests/EventListener/LoginListenerTest.php + + - + message: "#^Call to function method_exists\\(\\) with \\$this\\(Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub\\) and 'setAuthenticated' will always evaluate to false\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php + + - + message: "#^Parameter \\#1 \\$user of method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\AbstractToken\\:\\:setUser\\(\\) expects Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface, string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface given\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php + + - + message: "#^Parameter \\#2 \\$firewallName of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string, null given\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php + - message: "#^Parameter \\#3 \\$roles of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects array\\, string given\\.$#" count: 1 path: tests/EventListener/LoginListenerTest.php - - message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Exception\\\\DelayedMessageHandlingException constructor invoked with 2 parameters, 1 required\\.$#" + message: "#^Parameter \\#4 \\$originalToken of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\TokenInterface, array\\ given\\.$#" count: 1 - path: tests/EventListener/MessengerListenerTest.php + path: tests/EventListener/LoginListenerTest.php + + - + message: "#^Parameter \\#5 \\$originatedFromUri of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string\\|null, Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub given\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php + + - + message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" + count: 6 + path: tests/EventListener/RequestListenerTest.php + + - + message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" + count: 2 + path: tests/EventListener/SubRequestListenerTest.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" + count: 1 + path: tests/EventListener/SubRequestListenerTest.php + + - + message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" + count: 3 + path: tests/EventListener/TracingRequestListenerTest.php + + - + message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" + count: 2 + path: tests/EventListener/TracingSubRequestListenerTest.php - message: "#^Call to an undefined method TCacheAdapter of Symfony\\\\Component\\\\Cache\\\\Adapter\\\\AdapterInterface\\:\\:delete\\(\\)\\.$#" @@ -365,11 +370,6 @@ parameters: count: 1 path: tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{foo\\: Symfony\\\\Component\\\\Cache\\\\CacheItem\\} and Traversable\\ will always evaluate to false\\.$#" - count: 1 - path: tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php - - message: "#^Parameter \\#1 \\$decoratedAdapter of method Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Cache\\\\AbstractTraceableCacheAdapterTest\\\\:\\:createCacheAdapter\\(\\) expects TDecoratedCacheAdapter of Symfony\\\\Component\\\\Cache\\\\Adapter\\\\AdapterInterface, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject&Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Cache\\\\CacheInterface given\\.$#" count: 2 @@ -385,11 +385,6 @@ parameters: count: 1 path: tests/Tracing/Cache/AbstractTraceableCacheAdapterTest.php - - - message: "#^Class Doctrine\\\\DBAL\\\\Platforms\\\\SQLitePlatform not found\\.$#" - count: 1 - path: tests/Tracing/Doctrine/DBAL/TracingDriverConnectionFactoryV4Test.php - - message: "#^Property Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingDriverConnectionFactoryV4Test\\:\\:\\$databasePlatform is never read, only written\\.$#" count: 1 @@ -410,11 +405,6 @@ parameters: count: 1 path: tests/Tracing/Doctrine/DBAL/TracingDriverMiddlewareTest.php - - - message: "#^Parameter \\#3 \\$type of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\TracingStatementForV4\\:\\:bindValue\\(\\) expects Doctrine\\\\DBAL\\\\ParameterType, int given\\.$#" - count: 1 - path: tests/Tracing/Doctrine/DBAL/TracingStatementForV4Test.php - - message: "#^Parameter \\#1 \\$responses of method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableHttpClient\\:\\:stream\\(\\) expects iterable\\<\\(int\\|string\\), Symfony\\\\Contracts\\\\HttpClient\\\\ResponseInterface\\>\\|Symfony\\\\Contracts\\\\HttpClient\\\\ResponseInterface, stdClass given\\.$#" count: 1 From 51af755ba5abf110059145364685f53633d201a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 19:13:37 +0200 Subject: [PATCH 26/31] fix: add more ignore error to phpstan --- phpstan-baseline.neon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4c723f1e..d053d332 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -155,6 +155,11 @@ parameters: count: 2 path: src/DependencyInjection/SentryExtension.php + - + message: "#^Method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\TokenInterface\\:\\:isAuthenticated\\(\\) invoked with 1 parameter, 0 required\\.$#" + count: 1 + path: src/EventListener/LoginListener.php + - message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\\\)\\: string, Closure\\(array\\)\\: mixed given\\.$#" count: 1 From 7c72979f6f42d0be4362bbe48d00de72876e4f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 19:18:56 +0200 Subject: [PATCH 27/31] fix: add ignore errors to baseline --- phpstan-baseline.neon | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d053d332..0a65bce5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -419,3 +419,23 @@ parameters: message: "#^Parameter \\#2 \\$responses of static method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableResponse\\:\\:stream\\(\\) expects iterable\\, array\\ given\\.$#" count: 1 path: tests/Tracing/HttpClient/TraceableResponseTest.php + + - + message: "#^Parameter \\#3 \\$roles of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects array\\, string given\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php + + - + message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\)\\: string, Closure\\(array\\)\\: mixed given\\.$#" + count: 1 + path: src/ErrorTypesParser.php + + - + message: "#^Parameter \\#1 \\$user of method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\AbstractToken\\:\\:setUser\\(\\) expects Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface, string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface given\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php + + - + message: "#^Parameter \\#5 \\$originatedFromUri of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string\\|null, Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub given\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php From 338c16a34a4a58cc6f2007a065eb9d4dea7cc59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 19:29:31 +0200 Subject: [PATCH 28/31] fix: get rid of report unmatched ignored errors by default --- phpstan-baseline.neon | 4 ++++ phpstan.neon | 1 + 2 files changed, 5 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0a65bce5..851e9f72 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -439,3 +439,7 @@ parameters: message: "#^Parameter \\#5 \\$originatedFromUri of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string\\|null, Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub given\\.$#" count: 1 path: tests/EventListener/LoginListenerTest.php + - + message: "#^Parameter \\#3 \\$roles of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects array\\, string given\\.$#" + count: 1 + path: tests/EventListener/LoginListenerTest.php diff --git a/phpstan.neon b/phpstan.neon index d5a9c0a4..042d9fd8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,7 @@ includes: - phpstan-baseline.neon parameters: + reportUnmatchedIgnoredErrors: false level: 9 paths: - src From eecd3b2641da4d4897e696ee50c01cbcf3cb5bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 19:36:03 +0200 Subject: [PATCH 29/31] fix: update removing from baseline --- phpstan-baseline.neon | 25 ------------------------- phpstan.neon | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 851e9f72..39b912c9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -155,16 +155,6 @@ parameters: count: 2 path: src/DependencyInjection/SentryExtension.php - - - message: "#^Method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\TokenInterface\\:\\:isAuthenticated\\(\\) invoked with 1 parameter, 0 required\\.$#" - count: 1 - path: src/EventListener/LoginListener.php - - - - message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\\\)\\: string, Closure\\(array\\)\\: mixed given\\.$#" - count: 1 - path: src/ErrorTypesParser.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" count: 1 @@ -305,11 +295,6 @@ parameters: count: 1 path: tests/EventListener/LoginListenerTest.php - - - message: "#^Parameter \\#1 \\$user of method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\AbstractToken\\:\\:setUser\\(\\) expects Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface, string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - message: "#^Parameter \\#2 \\$firewallName of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string, null given\\.$#" count: 1 @@ -325,11 +310,6 @@ parameters: count: 1 path: tests/EventListener/LoginListenerTest.php - - - message: "#^Parameter \\#5 \\$originatedFromUri of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string\\|null, Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#" count: 6 @@ -420,11 +400,6 @@ parameters: count: 1 path: tests/Tracing/HttpClient/TraceableResponseTest.php - - - message: "#^Parameter \\#3 \\$roles of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects array\\, string given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\)\\: string, Closure\\(array\\)\\: mixed given\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index 042d9fd8..3608367b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - reportUnmatchedIgnoredErrors: false + reportUnmatchedIgnoredErrors: true level: 9 paths: - src From 3938fd557c59a129ca026bf08f7965d5c60bf0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 19:38:58 +0200 Subject: [PATCH 30/31] fix: remove more unmatched --- phpstan-baseline.neon | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 39b912c9..e61bc153 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -400,21 +400,7 @@ parameters: count: 1 path: tests/Tracing/HttpClient/TraceableResponseTest.php - - - message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\)\\: string, Closure\\(array\\)\\: mixed given\\.$#" - count: 1 - path: src/ErrorTypesParser.php - - - - message: "#^Parameter \\#1 \\$user of method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\AbstractToken\\:\\:setUser\\(\\) expects Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface, string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php - - message: "#^Parameter \\#5 \\$originatedFromUri of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string\\|null, Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub given\\.$#" count: 1 path: tests/EventListener/LoginListenerTest.php - - - message: "#^Parameter \\#3 \\$roles of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects array\\, string given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php From dbe979293742f92ddff5c757f4b877631ddf1809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= Date: Tue, 4 Jun 2024 19:40:28 +0200 Subject: [PATCH 31/31] fix: remove last one unmatched --- phpstan-baseline.neon | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e61bc153..be7174a9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -399,8 +399,3 @@ parameters: message: "#^Parameter \\#2 \\$responses of static method Sentry\\\\SentryBundle\\\\Tracing\\\\HttpClient\\\\AbstractTraceableResponse\\:\\:stream\\(\\) expects iterable\\, array\\ given\\.$#" count: 1 path: tests/Tracing/HttpClient/TraceableResponseTest.php - - - - message: "#^Parameter \\#5 \\$originatedFromUri of class Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\SwitchUserToken constructor expects string\\|null, Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub given\\.$#" - count: 1 - path: tests/EventListener/LoginListenerTest.php