Skip to content

Commit 3e94025

Browse files
authored
Merge pull request #90 from getsentry/prepare-release-2.0
Prepare release 2.0
2 parents 3947a83 + 3aaa5af commit 3e94025

15 files changed

+290
-239
lines changed

Diff for: .travis.yml

+8-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ sudo: false
33
dist: trusty
44

55
php:
6-
- 5.6
7-
- 7.0
86
- 7.1
97
- 7.2
108

@@ -13,33 +11,29 @@ cache:
1311
- $HOME/.composer/cache/files
1412

1513
before_install:
14+
- phpenv config-rm xdebug.ini
1615
- composer self-update
1716
- composer global require hirak/prestissimo
1817

19-
install: travis_wait travis_retry composer update --no-interaction --prefer-dist --prefer-stable $COMPOSER_OPTIONS
18+
install:
19+
- travis_wait travis_retry composer update --no-interaction --prefer-dist --prefer-stable $COMPOSER_OPTIONS
2020

2121
script:
2222
- vendor/bin/phpunit -v
2323

2424
jobs:
2525
include:
26-
- stage: test
27-
php: 5.6
28-
env: COMPOSER_OPTIONS="--prefer-lowest"
2926
- stage: Test
30-
php: 7.0
31-
env: COMPOSER_OPTIONS="--prefer-lowest"
32-
- stage: codestyle and SCA
3327
php: 7.1
28+
env: COMPOSER_OPTIONS="--prefer-lowest"
29+
- stage: Code style and static analysis
3430
script:
35-
- phpenv config-rm xdebug.ini
36-
- composer require --dev phpstan/phpstan symfony/expression-language --no-interaction --prefer-dist --prefer-stable
37-
- vendor/bin/phpstan analyse src --level 7
31+
- composer phpstan
3832
env: PHPSTAN=true
39-
- script: vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
33+
- script:
34+
- composer cs-check
4035
env: CS-FIXER=true
4136
- stage: coverage
42-
php: 7.1
4337
script:
4438
- phpdbg -qrr vendor/bin/phpunit --coverage-clover clover.xml
4539
after_success:

Diff for: CHANGELOG.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9-
## 1.0.0 - [Unreleased]
9+
## 2.0.0 - [Unreleased]
10+
### Added
11+
- Add support for Symfony 4.x
12+
### Changed
13+
- The `SentryBundle::VERSION` constant has been replaced with the `SentryBundle::getVersion(): string` method, to get a more accurate result
14+
- Due to a deprecation in `symfony/console`, we require it at at least version 3.3, and we added a method to `SentryExceptionListenerInterface`:
15+
```php
16+
public function onConsoleException(ConsoleErrorEvent $event);
17+
```
18+
### Removed
19+
- Drop support for Symfony 2.x
20+
- Drop support for PHP 5 and 7.0
21+
22+
## 1.0.0 - 2017-11-07
1023
### Added
1124
- Add official support to PHP 7.2 (#71)
1225
### Changed

Diff for: composer.json

+23-12
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,24 @@
1919
"sort-packages": true
2020
},
2121
"require": {
22-
"php": "^5.6|^7.0",
22+
"php": "^7.1",
23+
"jean85/pretty-package-versions": "^1.0",
2324
"sentry/sentry": "^1.8",
24-
"symfony/config": "^2.7|^3.0",
25-
"symfony/console": "^2.7|^3.0",
26-
"symfony/dependency-injection": "^2.7|^3.0",
27-
"symfony/event-dispatcher": "^2.7|^3.0",
28-
"symfony/http-kernel": "^2.7|^3.0",
29-
"symfony/security-core": "^2.7|^3.0",
30-
"symfony/yaml": "^2.7|^3.0"
25+
"symfony/config": "^3.0||^4.0",
26+
"symfony/console": "^3.3||^4.0",
27+
"symfony/dependency-injection": "^3.0||^4.0",
28+
"symfony/event-dispatcher": "^3.0||^4.0",
29+
"symfony/http-kernel": "^3.0||^4.0",
30+
"symfony/security-core": "^3.0||^4.0",
31+
"symfony/yaml": "^3.0||^4.0"
3132
},
3233
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "^2.5",
34-
"phpunit/phpunit": "^5.7|^6.0",
35-
"scrutinizer/ocular": "^1.4"
34+
"friendsofphp/php-cs-fixer": "^2.8",
35+
"phpstan/phpstan": "^0.9.1",
36+
"phpstan/phpstan-phpunit": "^0.9.1",
37+
"phpunit/phpunit": "^6.5",
38+
"scrutinizer/ocular": "^1.4",
39+
"symfony/expression-language": "^3.0||^4.0"
3640
},
3741
"autoload": {
3842
"psr-4" : {
@@ -44,9 +48,16 @@
4448
"Sentry\\SentryBundle\\Test\\": "test"
4549
}
4650
},
51+
"scripts": {
52+
"phpstan": "vendor/bin/phpstan analyse src test --level 7 -c phpstan.neon",
53+
"cs-check": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
54+
"cs-fix": "vendor/bin/php-cs-fixer fix --verbose --diff"
55+
},
4756
"extra": {
4857
"branch-alias": {
49-
"dev-master": "1.0.x-dev"
58+
"master": "2.0.x-dev",
59+
"releases/0.8.x": "0.8.x-dev",
60+
"releases/1.x": "1.0.x-dev"
5061
}
5162
}
5263
}

Diff for: phpstan.neon

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::/'
4+
- '/Calling method \w+ on possibly null value of type Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null/'
5+
includes:
6+
- vendor/phpstan/phpstan-phpunit/extension.neon

Diff for: src/DependencyInjection/Configuration.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Sentry\SentryBundle\EventListener\ExceptionListener;
77
use Sentry\SentryBundle\EventListener\SentryExceptionListenerInterface;
88
use Sentry\SentryBundle\SentrySymfonyClient;
9+
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
910
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1011
use Symfony\Component\Config\Definition\ConfigurationInterface;
1112
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
@@ -25,6 +26,7 @@ class Configuration implements ConfigurationInterface
2526
public function getConfigTreeBuilder()
2627
{
2728
$treeBuilder = new TreeBuilder();
29+
/** @var ArrayNodeDefinition $rootNode */
2830
$rootNode = $treeBuilder->root('sentry');
2931

3032
// Basic Sentry configuration
@@ -138,10 +140,7 @@ public function getConfigTreeBuilder()
138140
return $treeBuilder;
139141
}
140142

141-
/**
142-
* @return \Closure
143-
*/
144-
private function getExceptionListenerInvalidationClosure()
143+
private function getExceptionListenerInvalidationClosure(): callable
145144
{
146145
return function ($value) {
147146
$implements = class_implements($value);
@@ -153,10 +152,7 @@ private function getExceptionListenerInvalidationClosure()
153152
};
154153
}
155154

156-
/**
157-
* @return \Closure
158-
*/
159-
private function getTrimClosure()
155+
private function getTrimClosure(): callable
160156
{
161157
return function ($str) {
162158
$value = trim($str);

Diff for: src/ErrorTypesParser.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
*/
88
class ErrorTypesParser
99
{
10-
private $expression = null;
10+
/** @var string */
11+
private $expression;
1112

1213
/**
1314
* Initialize ErrorParser
1415
*
1516
* @param string $expression Error Types e.g. E_ALL & ~E_DEPRECATED & ~E_NOTICE
1617
*/
17-
public function __construct($expression)
18+
public function __construct(string $expression)
1819
{
1920
$this->expression = $expression;
2021
}
@@ -23,8 +24,9 @@ public function __construct($expression)
2324
* Parse and compute the error types expression
2425
*
2526
* @return int the parsed expression
27+
* @throws \InvalidArgumentException
2628
*/
27-
public function parse()
29+
public function parse(): int
2830
{
2931
// convert constants to ints
3032
$this->expression = $this->convertErrorConstants($this->expression);
@@ -43,7 +45,7 @@ public function parse()
4345
* @param string $expression e.g. E_ALL & ~E_DEPRECATED & ~E_NOTICE
4446
* @return string converted expression e.g. 32767 & ~8192 & ~8
4547
*/
46-
private function convertErrorConstants($expression)
48+
private function convertErrorConstants(string $expression): string
4749
{
4850
$output = preg_replace_callback('/(E_[a-zA-Z_]+)/', function ($errorConstant) {
4951
if (defined($errorConstant[1])) {
@@ -61,8 +63,9 @@ private function convertErrorConstants($expression)
6163
*
6264
* @param string $expression prepared expression e.g. 32767&~8192&~8
6365
* @return int computed expression e.g. 24567
66+
* @throws \InvalidArgumentException
6467
*/
65-
private function compute($expression)
68+
private function compute(string $expression): int
6669
{
6770
// catch anything which could be a security issue
6871
if (0 !== preg_match("/[^\d.+*%^|&~<>\/()-]/", $this->expression)) {

Diff for: src/Event/SentryUserContextEvent.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
class SentryUserContextEvent extends Event
99
{
10+
/** @var TokenInterface */
1011
private $authenticationToken;
1112

1213
public function __construct(TokenInterface $authenticationToken)
1314
{
1415
$this->authenticationToken = $authenticationToken;
1516
}
1617

17-
public function getAuthenticationToken()
18+
public function getAuthenticationToken(): TokenInterface
1819
{
1920
return $this->authenticationToken;
2021
}

Diff for: src/EventListener/ExceptionListener.php

+29-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Sentry\SentryBundle\Event\SentryUserContextEvent;
66
use Sentry\SentryBundle\SentrySymfonyEvents;
77
use Symfony\Component\Console\Event\ConsoleCommandEvent;
8+
use Symfony\Component\Console\Event\ConsoleErrorEvent;
9+
use Symfony\Component\Console\Event\ConsoleEvent;
810
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
911
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1012
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -71,7 +73,7 @@ public function setClient(\Raven_Client $client)
7173
*
7274
* @param GetResponseEvent $event
7375
*/
74-
public function onKernelRequest(GetResponseEvent $event)
76+
public function onKernelRequest(GetResponseEvent $event): void
7577
{
7678
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
7779
return;
@@ -94,7 +96,7 @@ public function onKernelRequest(GetResponseEvent $event)
9496
/**
9597
* @param GetResponseForExceptionEvent $event
9698
*/
97-
public function onKernelException(GetResponseForExceptionEvent $event)
99+
public function onKernelException(GetResponseForExceptionEvent $event): void
98100
{
99101
$exception = $event->getException();
100102

@@ -114,18 +116,37 @@ public function onKernelException(GetResponseForExceptionEvent $event)
114116
*
115117
* @return void
116118
*/
117-
public function onConsoleCommand(ConsoleCommandEvent $event)
119+
public function onConsoleCommand(ConsoleCommandEvent $event): void
118120
{
119121
// only triggers loading of client, does not need to do anything.
120122
}
121123

124+
public function onConsoleError(ConsoleErrorEvent $event): void
125+
{
126+
$this->handleConsoleError($event);
127+
}
128+
129+
public function onConsoleException(ConsoleExceptionEvent $event): void
130+
{
131+
$this->handleConsoleError($event);
132+
}
133+
122134
/**
123-
* @param ConsoleExceptionEvent $event
135+
* @param ConsoleExceptionEvent|ConsoleErrorEvent $event
124136
*/
125-
public function onConsoleException(ConsoleExceptionEvent $event)
137+
private function handleConsoleError(ConsoleEvent $event): void
126138
{
127139
$command = $event->getCommand();
128-
$exception = $event->getException();
140+
switch (true) {
141+
case $event instanceof ConsoleErrorEvent:
142+
$exception = $event->getError();
143+
break;
144+
case $event instanceof ConsoleExceptionEvent:
145+
$exception = $event->getException();
146+
break;
147+
default:
148+
throw new \InvalidArgumentException('Event not recognized: ' . \get_class($event));
149+
}
129150

130151
if ($this->shouldExceptionCaptureBeSkipped($exception)) {
131152
return;
@@ -142,7 +163,7 @@ public function onConsoleException(ConsoleExceptionEvent $event)
142163
$this->client->captureException($exception, $data);
143164
}
144165

145-
protected function shouldExceptionCaptureBeSkipped(\Exception $exception)
166+
protected function shouldExceptionCaptureBeSkipped(\Throwable $exception): bool
146167
{
147168
foreach ($this->skipCapture as $className) {
148169
if ($exception instanceof $className) {
@@ -171,7 +192,7 @@ private function setUserValue($user)
171192
}
172193

173194
if (is_object($user) && method_exists($user, '__toString')) {
174-
$this->client->set_user_data($user->__toString());
195+
$this->client->set_user_data((string)$user);
175196
}
176197
}
177198
}

Diff for: src/EventListener/SentryExceptionListenerInterface.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Sentry\SentryBundle\EventListener;
44

5+
use Symfony\Component\Console\Event\ConsoleErrorEvent;
56
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
67
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
78
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
@@ -17,21 +18,30 @@ interface SentryExceptionListenerInterface
1718
*
1819
* @param GetResponseEvent $event
1920
*/
20-
public function onKernelRequest(GetResponseEvent $event);
21+
public function onKernelRequest(GetResponseEvent $event): void;
2122

2223
/**
2324
* When an exception occurs as part of a web request, this method will be
2425
* triggered for capturing the error.
2526
*
2627
* @param GetResponseForExceptionEvent $event
2728
*/
28-
public function onKernelException(GetResponseForExceptionEvent $event);
29+
public function onKernelException(GetResponseForExceptionEvent $event): void;
30+
31+
/**
32+
* When an exception occurs on the command line, this method will be
33+
* triggered for capturing the error.
34+
*
35+
* @param ConsoleErrorEvent $event
36+
*/
37+
public function onConsoleError(ConsoleErrorEvent $event): void;
2938

3039
/**
3140
* When an exception occurs on the command line, this method will be
3241
* triggered for capturing the error.
3342
*
3443
* @param ConsoleExceptionEvent $event
44+
* @deprecated This method exists for BC with Symfony 3.x
3545
*/
36-
public function onConsoleException(ConsoleExceptionEvent $event);
46+
public function onConsoleException(ConsoleExceptionEvent $event): void;
3747
}

0 commit comments

Comments
 (0)