Skip to content

Commit

Permalink
fix: phpstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Nov 12, 2023
1 parent c7c41ad commit cd8c777
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Performance/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public function measure($event)
));

static::$measure->setDescription($event->extension->name);
} elseif (static::$measure) {
} elseif (static::$measure !== null) {
static::$measure->finish();
}
}

public function __destruct()
{
if (static::$parent) {
if (static::$parent !== null) {
static::$parent->finish();
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/Performance/Middleware/MeasurePerformanceMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
use Psr\Http\Server\RequestHandlerInterface;
use Sentry\Tracing\Span;
use Sentry\Tracing\SpanContext;
use Sentry\Tracing\Transaction;

class MeasurePerformanceMiddleware implements Middleware
{
/**
* @var Transaction
* @var Span
*/
protected $transaction;

/**
* @var string
*/
protected $frontend;

public function __construct(string $frontend, Span $transaction)
Expand Down
8 changes: 1 addition & 7 deletions src/Reporters/SentryReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@ public function report(Throwable $error)
/** @var HubInterface $hub */
$hub = $this->container->make('sentry');

if ($hub === null) {
$this->logger->warning('[fof/sentry] sentry dsn not set');

return;
}

if ($this->container->bound('sentry.request')) {
$hub->configureScope(function (Scope $scope) {
$request = $this->container->make('sentry.request');
$user = RequestUtil::getActor($request);

if ($user && $user->id !== 0) {
if (!$user->isGuest() && $user->id !== 0) {
$data = $user->only('id', 'username');

// Only send email if enabled in settings
Expand Down
6 changes: 3 additions & 3 deletions src/SentryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function register()
$this->container->singleton(HubInterface::class, function ($container) {
/** @var SettingsRepositoryInterface $settings */
$settings = $container->make(SettingsRepositoryInterface::class);
/** @var UrlGenerator $urlGenerator */
/** @var UrlGenerator $url */
$url = $container->make(UrlGenerator::class);
$dsn = $settings->get('fof-sentry.dsn_backend');
$environment = empty($settings->get('fof-sentry.environment')) ? str_replace(['https://', 'http://'], '', $url->to('forum')->base()) : $settings->get('fof-sentry.environment');
Expand Down Expand Up @@ -94,8 +94,8 @@ public function register()
$hub = $this->container->make(HubInterface::class);

$hub->configureScope(function (Scope $scope) use ($config) {
$scope->setTag('offline', (int) Arr::get($config, 'offline', false));
$scope->setTag('debug', (int) Arr::get($config, 'debug', true));
$scope->setTag('offline', Arr::get($config, 'offline', false));
$scope->setTag('debug', Arr::get($config, 'debug', true));
$scope->setTag('flarum', Application::VERSION);

if ($this->container->bound('sentry.stack')) {
Expand Down

0 comments on commit cd8c777

Please sign in to comment.