diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index be7174a9..4313a41a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -70,6 +70,11 @@ parameters: count: 2 path: src/DependencyInjection/SentryExtension.php + - + message: "#^Cannot access offset 'logger' on mixed\\.$#" + count: 1 + path: src/DependencyInjection/SentryExtension.php + - message: "#^Cannot access offset 'traces_sampler' on mixed\\.$#" count: 1 @@ -92,7 +97,7 @@ parameters: - message: "#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, mixed given\\.$#" - count: 9 + count: 10 path: src/DependencyInjection/SentryExtension.php - @@ -165,6 +170,21 @@ parameters: count: 1 path: src/EventListener/LoginListener.php + - + message: "#^Instanceof between Throwable and Symfony\\\\Component\\\\Messenger\\\\Exception\\\\DelayedMessageHandlingException will always evaluate to false\\.$#" + count: 1 + path: src/EventListener/MessengerListener.php + + - + message: "#^Instanceof between Throwable and Symfony\\\\Component\\\\Messenger\\\\Exception\\\\HandlerFailedException will always evaluate to false\\.$#" + count: 1 + path: src/EventListener/MessengerListener.php + + - + message: "#^Result of && is always false\\.$#" + count: 2 + path: src/EventListener/MessengerListener.php + - message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#" count: 1 diff --git a/src/DependencyInjection/SentryExtension.php b/src/DependencyInjection/SentryExtension.php index 78f1faa4..52675ded 100644 --- a/src/DependencyInjection/SentryExtension.php +++ b/src/DependencyInjection/SentryExtension.php @@ -94,6 +94,10 @@ private function registerConfiguration(ContainerBuilder $container, array $confi }); } + if (isset($options['logger'])) { + $options['logger'] = new Reference($options['logger']); + } + if (isset($options['traces_sampler'])) { $options['traces_sampler'] = new Reference($options['traces_sampler']); } diff --git a/tests/DependencyInjection/Fixtures/php/full.php b/tests/DependencyInjection/Fixtures/php/full.php index 0f30c967..aa11c22f 100644 --- a/tests/DependencyInjection/Fixtures/php/full.php +++ b/tests/DependencyInjection/Fixtures/php/full.php @@ -21,7 +21,7 @@ 'attach_metric_code_locations' => true, 'context_lines' => 0, 'environment' => 'development', - 'logger' => 'php', + 'logger' => Sentry\Logger\DebugStdOutLogger::class, 'spotlight' => true, 'spotlight_url' => 'http://localhost:8969', 'release' => '4.0.x-dev', diff --git a/tests/DependencyInjection/Fixtures/xml/full.xml b/tests/DependencyInjection/Fixtures/xml/full.xml index 88d01372..df951eb4 100644 --- a/tests/DependencyInjection/Fixtures/xml/full.xml +++ b/tests/DependencyInjection/Fixtures/xml/full.xml @@ -20,7 +20,7 @@ attach-metric-code-locations="true" context-lines="0" environment="development" - logger="php" + logger="Sentry\Logger\DebugStdOutLogger" spotlight="true" spotlight-url="http://localhost:8969" release="4.0.x-dev" diff --git a/tests/DependencyInjection/Fixtures/yml/full.yml b/tests/DependencyInjection/Fixtures/yml/full.yml index 8da66d50..8a42e682 100644 --- a/tests/DependencyInjection/Fixtures/yml/full.yml +++ b/tests/DependencyInjection/Fixtures/yml/full.yml @@ -16,7 +16,7 @@ sentry: attach_metric_code_locations: true context_lines: 0 environment: development - logger: php + logger: Sentry\Logger\DebugStdOutLogger spotlight: true spotlight_url: http://localhost:8969 release: 4.0.x-dev diff --git a/tests/DependencyInjection/SentryExtensionTest.php b/tests/DependencyInjection/SentryExtensionTest.php index ae8921c8..232f0887 100644 --- a/tests/DependencyInjection/SentryExtensionTest.php +++ b/tests/DependencyInjection/SentryExtensionTest.php @@ -9,6 +9,7 @@ use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Sentry\ClientInterface; +use Sentry\Logger\DebugStdOutLogger; use Sentry\Options; use Sentry\SentryBundle\DependencyInjection\SentryExtension; use Sentry\SentryBundle\EventListener\ConsoleListener; @@ -211,7 +212,7 @@ public function testClientIsCreatedFromOptions(): void 'attach_metric_code_locations' => true, 'context_lines' => 0, 'environment' => 'development', - 'logger' => 'php', + 'logger' => new Reference(DebugStdOutLogger::class), 'spotlight' => true, 'spotlight_url' => 'http://localhost:8969', 'release' => '4.0.x-dev', diff --git a/tests/EventListener/Fixtures/UserWithIdentifierStub.php b/tests/EventListener/Fixtures/UserWithIdentifierStub.php index 9b82b8ea..97eccde9 100644 --- a/tests/EventListener/Fixtures/UserWithIdentifierStub.php +++ b/tests/EventListener/Fixtures/UserWithIdentifierStub.php @@ -9,20 +9,29 @@ final class UserWithIdentifierStub implements UserInterface { /** - * @var string + * @var non-empty-string */ private $username; + /** + * @param non-empty-string $username + */ public function __construct(string $username = 'foo_user') { $this->username = $username; } + /** + * @return non-empty-string + */ public function getUserIdentifier(): string { return $this->getUsername(); } + /** + * @return non-empty-string + */ public function getUsername(): string { return $this->username;