From 9980c3b985f747d694b7a131f1464d6a20f51d07 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 14 Sep 2022 17:17:53 +0300 Subject: [PATCH] Remove framework, add CI, update readme --- .github/workflows/phpunit.yml | 19 +++++++++++++++++++ .github/workflows/static-analysis.yml | 17 +++++++++++++++++ README.md | 19 +++++++++++++++---- composer.json | 2 +- phpunit.xml | 27 +++++++++++++-------------- psalm.xml | 23 +++++++++++++++++++++++ src/SentrySnapshotter.php | 12 ++++++------ tests/Sentry/BootloaderTest.php | 9 +-------- tests/Sentry/ConfigTest.php | 7 ------- tests/Sentry/SnapshotterTest.php | 7 ------- tests/bootstrap.php | 6 ------ 11 files changed, 95 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/phpunit.yml create mode 100644 .github/workflows/static-analysis.yml create mode 100644 psalm.xml diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..05904c3 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,19 @@ +on: + pull_request: + push: + branches: + - master + - 2.0 + +name: phpunit + +jobs: + phpunit: + uses: spiral/gh-actions/.github/workflows/phpunit.yml@master + with: + os: >- + ['ubuntu-latest'] + php: >- + ['8.1', '8.2'] + stability: >- + ['prefer-lowest', 'prefer-stable'] diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..804c49e --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,17 @@ +on: + pull_request: + push: + branches: + - master + - 2.0 + +name: static analysis + +jobs: + psalm: + uses: spiral/gh-actions/.github/workflows/psalm.yml@master + with: + os: >- + ['ubuntu-latest'] + php: >- + ['8.1'] diff --git a/README.md b/README.md index c35417a..3bdcb33 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ -Sentry Exception Handler for Spiral -================================ -[![Latest Stable Version](https://poser.pugx.org/spiral/sentry-bridge/version)](https://packagist.org/packages/spiral/sentry-bridge) -[![Build Status](https://travis-ci.org/spiral/sentry-bridge.svg?branch=master)](https://travis-ci.org/spiral/sentry-bridge) +# Sentry Exception Handler for Spiral + +[![PHP Version Require](https://poser.pugx.org/spiral/sentry-bridge/require/php)](https://packagist.org/packages/spiral/sentry-bridge) +[![Latest Stable Version](https://poser.pugx.org/spiral/sentry-bridge/v/stable)](https://packagist.org/packages/spiral/sentry-bridge) +[![phpunit](https://github.com/spiral/sentry-bridge/actions/workflows/phpunit.yml/badge.svg)](https://github.com/spiral/sentry-bridge/actions) +[![psalm](https://github.com/spiral/sentry-bridge/actions/workflows/psalm.yml/badge.svg)](https://github.com/spiral/sentry-bridge/actions) [![Codecov](https://codecov.io/gh/spiral/sentry-bridge/branch/master/graph/badge.svg)](https://codecov.io/gh/spiral/sentry-bridge/) +[![Total Downloads](https://poser.pugx.org/spiral/sentry-bridge/downloads)](https://packagist.org/packages/spiral/sentry-bridge) +[![type-coverage](https://shepherd.dev/github/spiral/sentry-bridge/coverage.svg)](https://shepherd.dev/github/spiral/sentry-bridge) +[![psalm-level](https://shepherd.dev/github/spiral/sentry-bridge/level.svg)](https://shepherd.dev/github/spiral/sentry-bridge) + +[Documentation](https://spiral.dev/docs/extension-sentry) | [Framework Bundle](https://github.com/spiral/framework) + +## License: + +MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [Spiral Scout](https://spiralscout.com). diff --git a/composer.json b/composer.json index 967d890..1caafed 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require-dev": { "phpunit/phpunit": "^9.5.5", "mockery/mockery": "^1.5", - "spiral/framework": "3.0.x-dev", + "vimeo/psalm": "^4.27", "psr/log": "^3.0" }, "autoload": { diff --git a/phpunit.xml b/phpunit.xml index 9499e46..f204021 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,6 @@ - - - - - ./tests/ - - - - - - src - - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + src + + + + + ./tests/ + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..9dd5b27 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/SentrySnapshotter.php b/src/SentrySnapshotter.php index 8a612bb..506c11b 100644 --- a/src/SentrySnapshotter.php +++ b/src/SentrySnapshotter.php @@ -15,20 +15,20 @@ public function __construct( ) { } - public function register(\Throwable $exception): SnapshotInterface + public function register(\Throwable $e): SnapshotInterface { - $eventId = $this->client->send($exception); + $eventId = $this->client->send($e); $snapshot = new Snapshot( - $eventId ? (string) $eventId : $this->getID($exception), - $exception + $eventId ? (string) $eventId : $this->getID($e), + $e ); return $snapshot; } - protected function getID(\Throwable $exception): string + protected function getID(\Throwable $e): string { - return \md5(\implode('|', [$exception->getMessage(), $exception->getFile(), $exception->getLine()])); + return \md5(\implode('|', [$e->getMessage(), $e->getFile(), $e->getLine()])); } } diff --git a/tests/Sentry/BootloaderTest.php b/tests/Sentry/BootloaderTest.php index a8c6c5d..6f2e650 100644 --- a/tests/Sentry/BootloaderTest.php +++ b/tests/Sentry/BootloaderTest.php @@ -1,12 +1,5 @@ 'test' ]); - (new BootloadManager($c, new Initializer($c)))->bootload([SentryBootloader::class]); + (new BootloadManager($c, $c, $c, new Initializer($c, $c)))->bootload([SentryBootloader::class]); $c->bind(SentryConfig::class, new SentryConfig([ 'dsn' => 'https://key@sentry.demo/2' diff --git a/tests/Sentry/ConfigTest.php b/tests/Sentry/ConfigTest.php index 854f2fc..23693f4 100644 --- a/tests/Sentry/ConfigTest.php +++ b/tests/Sentry/ConfigTest.php @@ -1,12 +1,5 @@