diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..f2a39827d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +; top-most EditorConfig file +root = true + +; Unix-style newlines +[*] +charset = utf-8 +end_of_line = LF +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[*.md] +max_line_length = 80 + +[COMMIT_EDITMSG] +max_line_length = 0 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29bb..000000000 diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 6620f0be4..ac4e2eeee 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,6 +1,6 @@ tools: external_code_coverage: - runs: 1 + timeout: 600 build: nodes: diff --git a/.travis.yml b/.travis.yml index e183017f9..b521de777 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,70 +1,56 @@ language: php php: - - 7.1 - - 7.2 - -matrix: - fast_finish: true - allow_failures: - - php: nightly + - 7.1 + - 7.2 + - 7.3 + - nightly env: - - REMOVE_XDEBUG="0" - - REMOVE_XDEBUG="1" - -cache: - directories: - - $HOME/.composer/cache + - dependencies=lowest + - dependencies=highest -before_install: - - if [ "$REMOVE_XDEBUG" = "1" ]; then phpenv config-rm xdebug.ini; fi +matrix: + fast_finish: true + allow_failures: + - php: nightly -install: travis_retry composer install --no-interaction +cache: + directories: + - $HOME/.composer/cache -script: - - composer tests +stages: + - Code style & static analysis + - Test + - Code coverage jobs: - include: - - stage: Test - php: 7.2 - env: - REMOVE_XDEBUG: "0" - COVERAGE: true - script: - - vendor/bin/phpunit --verbose --configuration phpunit.xml.dist --coverage-clover tests/clover.xml - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover tests/clover.xml --revision=$TRAVIS_COMMIT - - php: 7.1 - env: - COMPOSER_OPTIONS: "--prefer-lowest" - REMOVE_XDEBUG: "1" - install: travis_retry composer update --no-interaction --prefer-lowest - - php: nightly - allow_failure: true - before_install: - - composer remove --dev friendsofphp/php-cs-fixer - env: - REMOVE_XDEBUG: "0" - - stage: Code style & static analysis - env: - CS-FIXER: true - REMOVE_XDEBUG: "1" - script: - - composer phpcs - - env: - PHPSTAN: true - REMOVE_XDEBUG: "1" - script: - - composer phpstan + include: + - stage: Code style & static analysis + name: PHP CS Fixer + script: composer phpcs + - script: composer phpstan + name: PHPStan + - stage: Code coverage + php: 7.3 + env: dependencies=highest + script: + - vendor/bin/phpunit --verbose --coverage-clover=build/logs/clover.xml + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml --revision=$TRAVIS_COMMIT + after_success: + - travis_retry php vendor/bin/php-coveralls --verbose + +install: + - if [ "$dependencies" = "lowest" ]; then composer update --no-interaction --prefer-lowest --prefer-dist; fi; + - if [ "$dependencies" = "highest" ]; then composer update --no-interaction --prefer-dist; fi; notifications: - webhooks: - urls: - - https://zeus.ci/hooks/cf8597c4-ffba-11e7-89c9-0a580a281308/public/provider/travis/webhook - on_success: always - on_failure: always - on_start: always - on_cancel: always - on_error: always + webhooks: + urls: + - https://zeus.ci/hooks/cf8597c4-ffba-11e7-89c9-0a580a281308/public/provider/travis/webhook + on_success: always + on_failure: always + on_start: always + on_cancel: always + on_error: always diff --git a/src/ClientBuilder.php b/src/ClientBuilder.php index c7e9a08e5..1ef1ab09f 100644 --- a/src/ClientBuilder.php +++ b/src/ClientBuilder.php @@ -19,7 +19,7 @@ use Http\Message\MessageFactory; use Http\Message\UriFactory; use Jean85\PrettyVersions; -use Sentry\HttpClient\Authentication\SentryAuth; +use Sentry\HttpClient\Authentication\SentryAuthentication; use Sentry\Integration\ErrorHandlerIntegration; use Sentry\Integration\RequestIntegration; use Sentry\Serializer\RepresentationSerializer; @@ -287,7 +287,7 @@ private function createHttpClientInstance(): PluginClient } $this->addHttpClientPlugin(new HeaderSetPlugin(['User-Agent' => $this->sdkIdentifier . '/' . $this->getSdkVersion()])); - $this->addHttpClientPlugin(new AuthenticationPlugin(new SentryAuth($this->options, $this->sdkIdentifier, $this->getSdkVersion()))); + $this->addHttpClientPlugin(new AuthenticationPlugin(new SentryAuthentication($this->options, $this->sdkIdentifier, $this->getSdkVersion()))); $this->addHttpClientPlugin(new RetryPlugin(['retries' => $this->options->getSendAttempts()])); $this->addHttpClientPlugin(new ErrorPlugin()); diff --git a/src/HttpClient/Authentication/SentryAuth.php b/src/HttpClient/Authentication/SentryAuthentication.php similarity index 88% rename from src/HttpClient/Authentication/SentryAuth.php rename to src/HttpClient/Authentication/SentryAuthentication.php index ec7fc6607..5956ab18b 100644 --- a/src/HttpClient/Authentication/SentryAuth.php +++ b/src/HttpClient/Authentication/SentryAuthentication.php @@ -15,7 +15,7 @@ * * @author Stefano Arlandini */ -final class SentryAuth implements Authentication +final class SentryAuthentication implements Authentication { /** * @var Options The Sentry client configuration @@ -68,6 +68,9 @@ public function authenticate(RequestInterface $request): RequestInterface $headers[] = $headerKey . '=' . $headerValue; } - return $request->withHeader('X-Sentry-Auth', 'Sentry ' . implode(', ', $headers)); + /** @var RequestInterface $request */ + $request = $request->withHeader('X-Sentry-Auth', 'Sentry ' . implode(', ', $headers)); + + return $request; } } diff --git a/tests/HttpClient/Authentication/SentryAuthTest.php b/tests/HttpClient/Authentication/SentryAuthenticationTest.php similarity index 87% rename from tests/HttpClient/Authentication/SentryAuthTest.php rename to tests/HttpClient/Authentication/SentryAuthenticationTest.php index 901a0b847..620d27c47 100644 --- a/tests/HttpClient/Authentication/SentryAuthTest.php +++ b/tests/HttpClient/Authentication/SentryAuthenticationTest.php @@ -8,18 +8,18 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Sentry\Client; -use Sentry\HttpClient\Authentication\SentryAuth; +use Sentry\HttpClient\Authentication\SentryAuthentication; use Sentry\Options; /** * @group time-sensitive */ -final class SentryAuthTest extends TestCase +final class SentryAuthenticationTest extends TestCase { public function testAuthenticate(): void { $configuration = new Options(['dsn' => 'http://public:secret@example.com/']); - $authentication = new SentryAuth($configuration, 'sentry.php.test', '1.2.3'); + $authentication = new SentryAuthentication($configuration, 'sentry.php.test', '1.2.3'); /** @var RequestInterface|MockObject $request */ $request = $this->getMockBuilder(RequestInterface::class) @@ -47,7 +47,7 @@ public function testAuthenticate(): void public function testAuthenticateWithNoSecretKey(): void { $configuration = new Options(['dsn' => 'http://public@example.com/']); - $authentication = new SentryAuth($configuration, 'sentry.php.test', '2.0.0'); + $authentication = new SentryAuthentication($configuration, 'sentry.php.test', '2.0.0'); /** @var RequestInterface|MockObject $request */ $request = $this->getMockBuilder(RequestInterface::class) diff --git a/tests/SdkTest.php b/tests/SdkTest.php index 9f9b0b013..4271282c4 100644 --- a/tests/SdkTest.php +++ b/tests/SdkTest.php @@ -6,16 +6,16 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use function Sentry\addBreadcrumb; use Sentry\Breadcrumb; +use Sentry\ClientInterface; +use Sentry\State\Hub; +use function Sentry\addBreadcrumb; use function Sentry\captureEvent; use function Sentry\captureException; use function Sentry\captureLastError; use function Sentry\captureMessage; -use Sentry\ClientInterface; use function Sentry\configureScope; use function Sentry\init; -use Sentry\State\Hub; use function Sentry\withScope; class SdkTest extends TestCase diff --git a/tests/Serializer/AbstractSerializerTest.php b/tests/Serializer/AbstractSerializerTest.php index 76f057b02..01bf87123 100644 --- a/tests/Serializer/AbstractSerializerTest.php +++ b/tests/Serializer/AbstractSerializerTest.php @@ -346,7 +346,7 @@ public function testSerializeValueResource(bool $serializeAllObjects): void $this->assertNotFalse($filename, 'Temp file creation failed'); - $resource = fopen($filename, 'w'); + $resource = fopen($filename, 'wb'); $result = $this->invokeSerialization($serializer, $resource); diff --git a/tests/Util/JSONTest.php b/tests/Util/JSONTest.php index e9857fe83..7f1d24289 100644 --- a/tests/Util/JSONTest.php +++ b/tests/Util/JSONTest.php @@ -63,7 +63,7 @@ public function encodeDataProvider(): array */ public function testEncodeThrowsIfValueIsResource(): void { - $resource = fopen('php://memory', 'r'); + $resource = fopen('php://memory', 'rb'); $this->assertNotFalse($resource);