Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Resources/doc/symfony7_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ final class ErrbitExceptionSubscriber implements EventSubscriberInterface
- **Autoconfigure**: With `autoconfigure: true`, Symfony automatically detects `#[AsEventListener]` attributes and registers them
- **Priority**: Use priority `0` or lower to let Symfony's error handler run first if you want the normal error page to display
- **Async mode**: The `async => true` option uses UDP for non-blocking error reporting
- **Symfony 7.4+**: Supports union types in event listener method signatures
- **Type declarations**: When running on PHP 8+, you can use union types in event listener method signatures
21 changes: 12 additions & 9 deletions src/Errbit/Errbit.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function instance()
* This is made public for flexibility, though it is not expected you
* should use it.
*
* @param array $config the configuration for the API
* @param array<string, mixed> $config the configuration for the API
*/
public function __construct(private array $config = [])
{
Expand Down Expand Up @@ -102,7 +102,7 @@ public function onNotify($callback): static
* - params_filters
* - backtrace_filters
*
* @param array $config
* @param array<string, mixed> $config
*
* @return static the current instance of the client
* @throws \Errbit\Exception\ConfigurationException
Expand All @@ -116,7 +116,7 @@ public function configure(array $config = []): static
}

/**
* @param array $handlers
* @param array<int, string> $handlers
*
* @return $this
* @throws \Errbit\Exception\Exception
Expand All @@ -133,7 +133,7 @@ public function start(array $handlers = ['exception', 'error', 'fatal']): static
* Notify an individual exception manually.
*
* @param \Throwable $exception
* @param array $options
* @param array<string, mixed> $options
*
* @return static [Errbit] the current instance
* @throws \Errbit\Exception\ConfigurationException
Expand All @@ -142,8 +142,9 @@ public function notify(\Throwable $exception, array $options = []): static
{
$this->checkConfig();
$config = array_merge($this->config, $options);

if ($this->shouldNotify($exception, $config['skipped_exceptions'])) {
/** @var array<int, class-string<\Throwable>> $skippedExceptions */
$skippedExceptions = $config['skipped_exceptions'];
if ($this->shouldNotify($exception, $skippedExceptions)) {
$this->getWriter()->write($exception, $config);
$this->notifyObservers($exception, $config);
}
Expand All @@ -153,7 +154,7 @@ public function notify(\Throwable $exception, array $options = []): static

/**
* @param \Throwable $exception
* @param array $skippedExceptions
* @param array<int, class-string<\Throwable>> $skippedExceptions
*
* @return bool
*/
Expand All @@ -165,7 +166,9 @@ protected function shouldNotify(\Throwable $exception, array $skippedExceptions)
}
}
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
foreach ($this->config['ignore_user_agent'] as $ua) {
/** @var array<int, string> $ignoreUserAgents */
$ignoreUserAgents = $this->config['ignore_user_agent'];
foreach ($ignoreUserAgents as $ua) {
if ($userAgent !== '' && str_contains($userAgent, $ua)) {
return false;
}
Expand All @@ -176,7 +179,7 @@ protected function shouldNotify(\Throwable $exception, array $skippedExceptions)

/**
* @param \Throwable $exception
* @param array $config
* @param array<string, mixed> $config
*
* @return void
*/
Expand Down
Loading
Loading