From bebbe60fce61db2870235e5c008504c3a0eb2bf4 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 6 Jan 2022 12:03:58 +0100 Subject: [PATCH 01/15] feat: allow symfony6, update tests for installable set --- .gitignore | 1 + .../RollbarExtensionTest.php | 32 +++---------------- Tests/Fixtures/{app => App}/AppKernel.php | 17 +++------- Tests/Fixtures/{app => App}/config/config.yml | 3 +- .../{app => App}/config/config_test.yml | 0 .../{app => App}/config/parameters.yml | 0 Tests/Payload/ErrorItemTest.php | 2 +- Tests/Payload/GeneratorTest.php | 7 ++-- Tests/Payload/TraceItemTest.php | 8 ++--- composer.json | 20 ++++++------ phpunit.xml | 14 ++++---- 11 files changed, 38 insertions(+), 66 deletions(-) rename Tests/Fixtures/{app => App}/AppKernel.php (81%) rename Tests/Fixtures/{app => App}/config/config.yml (80%) rename Tests/Fixtures/{app => App}/config/config_test.yml (100%) rename Tests/Fixtures/{app => App}/config/parameters.yml (100%) diff --git a/.gitignore b/.gitignore index 039c3f1..546b65c 100755 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /vendor/ /var/ !/var/.gitkeep +.phpunit.result.cache composer.lock clover.xml \ No newline at end of file diff --git a/Tests/DependencyInjection/RollbarExtensionTest.php b/Tests/DependencyInjection/RollbarExtensionTest.php index 23bd1df..2725aeb 100755 --- a/Tests/DependencyInjection/RollbarExtensionTest.php +++ b/Tests/DependencyInjection/RollbarExtensionTest.php @@ -27,19 +27,15 @@ protected function getContainerExtensions(): array } /** - * Test config enabled vars. + * Test config vars. * * @dataProvider generatorConfigVars - * - * @param string $var - * @param array $expected */ - public function testConfigEnabledVars(string $var, array $expected): void + public function testConfigVars(string $var, array $expected, array $loadParameters = []): void { - $this->load(); + $this->load($loadParameters); $param = $this->container->getParameter($var); - foreach ($expected as $key => $value) { $this->assertEquals($param[$key], $value); } @@ -54,30 +50,10 @@ public function generatorConfigVars(): array { return [ ['rollbar.config', ['enabled' => true]], + ['rollbar.config', ['enabled' => false], ['enabled' => false]], ]; } - /** - * Test config disabled vars. - * - * @dataProvider generatorConfigVars - * - * @expectedException \PHPUnit_Framework_ExpectationFailedException - * - * @param string $var - * @param array $expected - */ - public function testConfigDisabledVars(string $var, array $expected): void - { - $this->load(['enabled' => false]); - - $param = $this->container->getParameter($var); - - foreach ($expected as $key => $value) { - $this->assertEquals($param[$key], $value); - } - } - /** * Test alias. */ diff --git a/Tests/Fixtures/app/AppKernel.php b/Tests/Fixtures/App/AppKernel.php similarity index 81% rename from Tests/Fixtures/app/AppKernel.php rename to Tests/Fixtures/App/AppKernel.php index 9e755f8..364814c 100755 --- a/Tests/Fixtures/app/AppKernel.php +++ b/Tests/Fixtures/App/AppKernel.php @@ -1,5 +1,7 @@ load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); } - /** - * @return string - */ public function getCacheDir(): string { return realpath(__DIR__ . '/../../../') . '/var/' . $this->environment . '/cache'; diff --git a/Tests/Fixtures/app/config/config.yml b/Tests/Fixtures/App/config/config.yml similarity index 80% rename from Tests/Fixtures/app/config/config.yml rename to Tests/Fixtures/App/config/config.yml index ab5c14d..4fbf716 100755 --- a/Tests/Fixtures/app/config/config.yml +++ b/Tests/Fixtures/App/config/config.yml @@ -4,7 +4,8 @@ parameters: locale: ~ framework: + test: true secret: "%secret%" router: - resource: "%kernel.root_dir%/config/routing.yml" + resource: "%kernel.project_dir%/config/routing.yml" strict_requirements: ~ diff --git a/Tests/Fixtures/app/config/config_test.yml b/Tests/Fixtures/App/config/config_test.yml similarity index 100% rename from Tests/Fixtures/app/config/config_test.yml rename to Tests/Fixtures/App/config/config_test.yml diff --git a/Tests/Fixtures/app/config/parameters.yml b/Tests/Fixtures/App/config/parameters.yml similarity index 100% rename from Tests/Fixtures/app/config/parameters.yml rename to Tests/Fixtures/App/config/parameters.yml diff --git a/Tests/Payload/ErrorItemTest.php b/Tests/Payload/ErrorItemTest.php index 663256e..919d1e6 100755 --- a/Tests/Payload/ErrorItemTest.php +++ b/Tests/Payload/ErrorItemTest.php @@ -33,7 +33,7 @@ public function testInvoke(int $code, string $message, string $file, int $line, $exception = $data['exception']; $this->assertEquals($mapped, $exception['class']); - $this->assertContains($message, $exception['message']); + $this->assertStringContainsString($message, $exception['message']); $this->assertCount(1, $data['frames']); diff --git a/Tests/Payload/GeneratorTest.php b/Tests/Payload/GeneratorTest.php index d059e14..7c41aa4 100755 --- a/Tests/Payload/GeneratorTest.php +++ b/Tests/Payload/GeneratorTest.php @@ -32,12 +32,11 @@ public function setUp(): void */ public function testGetContainer(): void { - $container = $this->getContainer(); $generator = $this->getGenerator(); $result = $generator->getContainer(); - $this->assertEquals($container, $result); + $this->assertInstanceOf(ContainerInterface::class, $result); } /** @@ -185,7 +184,7 @@ public function testGetExceptionPayload(): void list($message, $payload) = $generator->getExceptionPayload($exception); - $this->assertContains($msg, $message); + $this->assertStringContainsString($msg, $message); $this->assertArrayHasKey('body', $payload); $this->assertArrayHasKey('request', $payload); @@ -244,7 +243,7 @@ public function generatorStrangeData(): array * * @return ContainerInterface */ - private function getContainer(): ContainerInterface + protected static function getContainer(): ContainerInterface { return static::$container ?? static::$kernel->getContainer(); } diff --git a/Tests/Payload/TraceItemTest.php b/Tests/Payload/TraceItemTest.php index 628d566..49817eb 100755 --- a/Tests/Payload/TraceItemTest.php +++ b/Tests/Payload/TraceItemTest.php @@ -28,13 +28,13 @@ public function testInvoke(): void $exception = $data['exception']; $this->assertEquals(get_class($ex), $exception['class']); - $this->assertContains($msg, $exception['message']); + $this->assertStringContainsString($msg, $exception['message']); $this->assertGreaterThan(1, count($data['frames'])); $frame = $data['frames'][0]; - $this->assertTrue(array_key_exists('filename', $frame)); - $this->assertTrue(array_key_exists('lineno', $frame)); - $this->assertTrue(array_key_exists('class_name', $frame)); + $this->assertArrayHasKey('filename', $frame); + $this->assertArrayHasKey('lineno', $frame); + $this->assertArrayHasKey('class_name', $frame); } } diff --git a/composer.json b/composer.json index 8ce5ef3..db09586 100755 --- a/composer.json +++ b/composer.json @@ -24,23 +24,23 @@ "Tests/Fixtures/app/AppKernel.php", "Tests/Fixtures/ErrorHandler.php" ], - "psr-4": { "Tests\\": "tests/"} + "psr-4": { "Tests\\": "Tests/"} }, "require": { "php": ">=7.1", "rollbar/rollbar": "^2", - "symfony/dependency-injection": "^5.0", - "symfony/config": "^5.0", - "symfony/http-kernel": "^5.0", - "symfony/monolog-bundle": "*", - "symfony/serializer": "*", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/config": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/monolog-bundle": "^3.0", + "symfony/serializer": "^5.4|^6.0", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "^5.7", - "symfony/framework-bundle": "^5.0", - "squizlabs/php_codesniffer": "^2.7", - "matthiasnoback/symfony-dependency-injection-test": "^1.1" + "phpunit/phpunit": "^8.5", + "symfony/framework-bundle": "^5.4|^6.0", + "squizlabs/php_codesniffer": "^3.6", + "matthiasnoback/symfony-dependency-injection-test": "^4.3" }, "scripts": { "test": [ diff --git a/phpunit.xml b/phpunit.xml index d70f03b..f36dfa1 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,7 +2,7 @@ - - + + + + + + @@ -25,7 +29,5 @@ ./ - - - + From 603950a16e87fdf01a2fccbf490124bd531924f0 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 6 Jan 2022 12:20:56 +0100 Subject: [PATCH 02/15] feat: allow symfony6 and rollbar/rollbar 3, update tests for installable set --- Factories/RollbarHandlerFactory.php | 13 +++++++++---- composer.json | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Factories/RollbarHandlerFactory.php b/Factories/RollbarHandlerFactory.php index b9ea050..30fcec6 100755 --- a/Factories/RollbarHandlerFactory.php +++ b/Factories/RollbarHandlerFactory.php @@ -3,7 +3,8 @@ namespace Rollbar\Symfony\RollbarBundle\Factories; use Psr\Log\LogLevel; -use Rollbar\Monolog\Handler\RollbarHandler; +use Rollbar\Monolog\Handler\RollbarHandler as RollbarHandlerLegacy; +use Monolog\Handler\RollbarHandler; use Rollbar\Rollbar; use Rollbar\Symfony\RollbarBundle\DependencyInjection\RollbarExtension; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -52,10 +53,14 @@ public function __construct(ContainerInterface $container) /** * Create RollbarHandler * - * @return RollbarHandler + * @return RollbarHandler|RollbarHandlerLegacy */ - public function createRollbarHandler(): RollbarHandler + public function createRollbarHandler() { - return new RollbarHandler(Rollbar::logger(), LogLevel::ERROR); + if (class_exists(RollbarHandler::class)) { + return new RollbarHandler(Rollbar::logger(), LogLevel::ERROR); + } + + return new RollbarHandlerLegacy(Rollbar::logger(), LogLevel::ERROR); } } diff --git a/composer.json b/composer.json index db09586..c93e72a 100755 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "require": { "php": ">=7.1", - "rollbar/rollbar": "^2", + "rollbar/rollbar": "^2|^3.0", "symfony/dependency-injection": "^5.4|^6.0", "symfony/config": "^5.4|^6.0", "symfony/http-kernel": "^5.4|^6.0", From 051ac90dea0b2ee6802ca0881fc010601c6c8a6e Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 6 Jan 2022 16:11:38 +0100 Subject: [PATCH 03/15] test: add github actions --- .github/workflows/code_checks.yaml | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/code_checks.yaml diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml new file mode 100644 index 0000000..69bbdc6 --- /dev/null +++ b/.github/workflows/code_checks.yaml @@ -0,0 +1,37 @@ +# .github/workflows/code_checks.yaml +name: Code_Checks + +on: ["push", "pull_request"] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + stability: [ prefer-lowest, prefer-stable ] + + name: PHP ${{ matrix.php }} - ${{ matrix.stability }} tests + steps: + # basically git clone + - uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + # use PHP of specific version + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: pcov, dom, curl, libxml, mbstring + coverage: pcov + + - name: Install dependencies + run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/phpunit --verbose From 78838dab013fd737828e774e876608b51ce6c636 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 6 Jan 2022 16:16:06 +0100 Subject: [PATCH 04/15] feat: allow symfony6 and rollbar/rollbar 3, update tests for installable set --- Tests/Fixtures/App/AppKernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Fixtures/App/AppKernel.php b/Tests/Fixtures/App/AppKernel.php index 364814c..de1c415 100755 --- a/Tests/Fixtures/App/AppKernel.php +++ b/Tests/Fixtures/App/AppKernel.php @@ -10,7 +10,7 @@ class AppKernel extends Kernel { - public function registerBundles(): array + public function registerBundles(): iterable { return [ new FrameworkBundle(), From cf41adce35132e75eea26b725d601e1d08c524e8 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 6 Jan 2022 16:18:42 +0100 Subject: [PATCH 05/15] feat: allow symfony6 and rollbar/rollbar 3, update tests for installable set, php for symfony 5 needs to be >=7.2.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c93e72a..da21367 100755 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "psr-4": { "Tests\\": "Tests/"} }, "require": { - "php": ">=7.1", + "php": ">=7.2.5", "rollbar/rollbar": "^2|^3.0", "symfony/dependency-injection": "^5.4|^6.0", "symfony/config": "^5.4|^6.0", From 18b0a49dfcbb807cb86c3313cfd7d81ce7d34599 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 6 Jan 2022 16:30:22 +0100 Subject: [PATCH 06/15] test: add github actions --- .github/workflows/code_checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml index 69bbdc6..edf3495 100644 --- a/.github/workflows/code_checks.yaml +++ b/.github/workflows/code_checks.yaml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1'] stability: [ prefer-lowest, prefer-stable ] name: PHP ${{ matrix.php }} - ${{ matrix.stability }} tests From 743dd45e20eb691b5aab674095f037aedeb8da0e Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Mon, 11 Apr 2022 12:47:30 +0200 Subject: [PATCH 07/15] feat: drop support of php < 8 --- DependencyInjection/Configuration.php | 21 +--- DependencyInjection/RollbarExtension.php | 7 +- Factories/RollbarHandlerFactory.php | 26 +---- Payload/ErrorItem.php | 30 ++---- Payload/Generator.php | 101 ++++-------------- Payload/TraceChain.php | 14 +-- Payload/TraceItem.php | 17 +-- README.md | 6 +- Resources/doc/index.rst | 48 +++------ RollbarBundle.php | 5 - .../DependencyInjection/ConfigurationTest.php | 20 +--- .../RollbarExtensionTest.php | 12 --- Tests/Fixtures/ErrorHandler.php | 26 +---- Tests/Payload/ErrorItemTest.php | 12 --- Tests/Payload/GeneratorTest.php | 73 ++----------- Tests/Payload/TraceChainTest.php | 8 -- Tests/Payload/TraceItemTest.php | 8 -- composer.json | 8 +- phpunit.xml | 50 ++++----- 19 files changed, 99 insertions(+), 393 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 79284f3..a5120fa 100755 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -11,8 +11,6 @@ * Class Configuration * * @link https://rollbar.com/docs/notifier/rollbar-php/#configuration-reference - * - * @package Rollbar\Symfony\RollbarBundle\DependencyInjection */ class Configuration implements ConfigurationInterface { @@ -22,12 +20,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder(RollbarExtension::ALIAS); - - if (method_exists($treeBuilder, 'getRootNode')) { - $rollbarConfigNode = $treeBuilder->getRootNode(); - } else { - $rollbarConfigNode = $treeBuilder->root(RollbarExtension::ALIAS); - } + $rollbarConfigNode = $treeBuilder->getRootNode(); $rollbarConfigNodeChildren = $rollbarConfigNode->children(); @@ -35,14 +28,10 @@ public function getConfigTreeBuilder(): TreeBuilder $rollbarDefaults = Defaults::get(); foreach ($configOptions as $option) { - switch ($option) { - case 'branch': - $method = 'gitBranch'; - break; - default: - $method = $option; - break; - } + $method = match ($option) { + 'branch' => 'gitBranch', + default => $option, + }; try { $default = $rollbarDefaults->fromSnakeCase($method); diff --git a/DependencyInjection/RollbarExtension.php b/DependencyInjection/RollbarExtension.php index 56aeb77..9a63665 100755 --- a/DependencyInjection/RollbarExtension.php +++ b/DependencyInjection/RollbarExtension.php @@ -7,14 +7,9 @@ use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -/** - * Class RollbarExtension - * - * @package Rollbar\Symfony\RollbarBundle\DependencyInjection - */ class RollbarExtension extends Extension { - const ALIAS = 'rollbar'; + public const ALIAS = 'rollbar'; /** * {@inheritdoc} diff --git a/Factories/RollbarHandlerFactory.php b/Factories/RollbarHandlerFactory.php index 30fcec6..53e2b82 100755 --- a/Factories/RollbarHandlerFactory.php +++ b/Factories/RollbarHandlerFactory.php @@ -3,24 +3,13 @@ namespace Rollbar\Symfony\RollbarBundle\Factories; use Psr\Log\LogLevel; -use Rollbar\Monolog\Handler\RollbarHandler as RollbarHandlerLegacy; use Monolog\Handler\RollbarHandler; use Rollbar\Rollbar; use Rollbar\Symfony\RollbarBundle\DependencyInjection\RollbarExtension; use Symfony\Component\DependencyInjection\ContainerInterface; -/** - * Class RollbarHandlerFactory - * - * @package Rollbar\Symfony\RollbarBundle\Factories - */ class RollbarHandlerFactory { - /** - * RollbarHandlerFactory constructor. - * - * @param ContainerInterface $container - */ public function __construct(ContainerInterface $container) { $config = $container->getParameter(RollbarExtension::ALIAS . '.config'); @@ -39,7 +28,7 @@ public function __construct(ContainerInterface $container) if ($token) { $user = $token->getUser(); $serializer = $container->get('serializer'); - return \json_decode($serializer->serialize($user, 'json'), true); + return \json_decode($serializer->serialize($user, 'json'), true, 512, JSON_THROW_ON_ERROR); } } catch (\Exception $exception) { // Ignore @@ -50,17 +39,8 @@ public function __construct(ContainerInterface $container) Rollbar::init($config, false, false, false); } - /** - * Create RollbarHandler - * - * @return RollbarHandler|RollbarHandlerLegacy - */ - public function createRollbarHandler() + public function createRollbarHandler(): RollbarHandler { - if (class_exists(RollbarHandler::class)) { - return new RollbarHandler(Rollbar::logger(), LogLevel::ERROR); - } - - return new RollbarHandlerLegacy(Rollbar::logger(), LogLevel::ERROR); + return new RollbarHandler(Rollbar::logger(), LogLevel::ERROR); } } diff --git a/Payload/ErrorItem.php b/Payload/ErrorItem.php index 3d6bc39..1fe28c1 100755 --- a/Payload/ErrorItem.php +++ b/Payload/ErrorItem.php @@ -2,20 +2,15 @@ namespace Rollbar\Symfony\RollbarBundle\Payload; -/** - * Class ErrorItem - * - * @package Rollbar\Symfony\RollbarBundle\Payload - */ +use JetBrains\PhpStorm\ArrayShape; + class ErrorItem { /** * List of map for human readable constants * @link http://php.net/manual/en/errorfunc.constants.php - * - * @var array */ - public static $map = [ + public static array $map = [ E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', @@ -33,17 +28,8 @@ class ErrorItem E_USER_DEPRECATED => 'E_USER_DEPRECATED', ]; - /** - * Invoke. - * - * @param int $code - * @param string $message - * @param string $file - * @param int $line - * - * @return array - */ - public function __invoke($code, $message, $file, $line) + #[ArrayShape(['exception' => "array", 'frames' => "array[]"])] + public function __invoke(int $code, string $message, string $file, int $line): array { return [ 'exception' => [ @@ -69,12 +55,8 @@ public function __invoke($code, $message, $file, $line) /** * Map error code to human format - * - * @param mixed $code - * - * @return string */ - protected function mapError($code): string + protected function mapError(mixed $code): string { $code = (int) $code; diff --git a/Payload/Generator.php b/Payload/Generator.php index 481208c..ba074a4 100755 --- a/Payload/Generator.php +++ b/Payload/Generator.php @@ -2,46 +2,24 @@ namespace Rollbar\Symfony\RollbarBundle\Payload; +use JetBrains\PhpStorm\ArrayShape; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Kernel; -/** - * Class Generator - * - * @package Rollbar\Symfony\RollbarBundle\Payload - */ class Generator { - /** - * @var ContainerInterface - */ - protected $container; - - /** - * @var Kernel - */ - protected $kernel; + protected ?Kernel $kernel; - /** - * Generator constructor. - * - * @param ContainerInterface $container - */ - public function __construct(ContainerInterface $container) + public function __construct(protected ContainerInterface $container) { - $this->container = $container; - $this->kernel = $container->get('kernel'); + $this->kernel = $container->get('kernel'); } /** * Get payload a log record. - * - * @param \Exception $exception - * - * @return array */ - public function getExceptionPayload($exception): array + public function getExceptionPayload(\Exception $exception): array { /** * Build payload @@ -51,19 +29,11 @@ public function getExceptionPayload($exception): array 'body' => [], 'framework' => Kernel::VERSION, 'server' => $this->getServerInfo(), - 'language_version' => phpversion(), + 'language_version' => PHP_VERSION, 'request' => $this->getRequestInfo(), 'environment' => $this->getKernel()->getEnvironment(), ]; - // @link http://php.net/manual/en/reserved.constants.php - // @link http://php.net/manual/en/language.errors.php7.php - if (!($exception instanceof \Exception) || PHP_MAJOR_VERSION > 7 && !($exception instanceof \Throwable)) { - $payload['body'] = $this->buildGeneratorError($exception, __FILE__, __LINE__); - - return ['Undefined error', $payload]; - } - // handle exception $chain = new TraceChain(); $item = new TraceItem(); @@ -75,33 +45,15 @@ public function getExceptionPayload($exception): array return [$message, $payload]; } - /** - * Build generator error. - * - * @param object $object - * @param string $file - * @param int $line - * - * @return array - */ - protected function buildGeneratorError($object, $file, $line): array + #[ArrayShape(['trace' => "array"])] + protected function buildGeneratorError(object $object, string $file, int $line): array { $item = new ErrorItem(); return ['trace' => $item(0, serialize($object), $file, $line)]; } - /** - * Get error payload. - * - * @param int $code - * @param string $message - * @param string $file - * @param int $line - * - * @return array - */ - public function getErrorPayload($code, $message, $file, $line): array + public function getErrorPayload(int $code, string $message, string $file, int $line): array { $item = new ErrorItem(); @@ -117,15 +69,18 @@ public function getErrorPayload($code, $message, $file, $line): array return [$message, $payload]; } - /** - * Get request info. - * - * @return array - */ + #[ArrayShape(['url' => "string", + 'method' => "string", + 'headers' => "mixed", + 'query_string' => "null|string", + 'body' => "mixed", + 'user_ip' => "null|string"])] protected function getRequestInfo(): array { + /** @var $request Request */ $request = $this->getContainer()->get('request_stack')->getCurrentRequest(); - if (empty($request)) { + + if ($request === null) { $request = new Request(); } @@ -139,11 +94,11 @@ protected function getRequestInfo(): array ]; } - /** - * Get server info. - * - * @return array - */ + #[ArrayShape(['host' => "false|string", + 'root' => "string", + 'user' => "string", + 'file' => "mixed|null", + 'argv' => "string"])] protected function getServerInfo(): array { $args = $_SERVER['argv'] ?? []; @@ -158,21 +113,11 @@ protected function getServerInfo(): array ]; } - /** - * Get container. - * - * @return ContainerInterface - */ public function getContainer(): ContainerInterface { return $this->container; } - /** - * Get kernel. - * - * @return Kernel - */ public function getKernel(): Kernel { return $this->kernel; diff --git a/Payload/TraceChain.php b/Payload/TraceChain.php index 04a6054..ba198fb 100755 --- a/Payload/TraceChain.php +++ b/Payload/TraceChain.php @@ -2,21 +2,9 @@ namespace Rollbar\Symfony\RollbarBundle\Payload; -/** - * Class TraceChain - * - * @package Rollbar\Symfony\RollbarBundle\Payload - */ class TraceChain { - /** - * Invoke. - * - * @param $throwable - * - * @return array - */ - public function __invoke($throwable) + public function __invoke(\Throwable $throwable): array { $chain = []; $item = new TraceItem(); diff --git a/Payload/TraceItem.php b/Payload/TraceItem.php index 33aa39f..7d2f626 100755 --- a/Payload/TraceItem.php +++ b/Payload/TraceItem.php @@ -2,21 +2,12 @@ namespace Rollbar\Symfony\RollbarBundle\Payload; -/** - * Class TraceItem - * - * @package Rollbar\Symfony\RollbarBundle\Payload - */ +use JetBrains\PhpStorm\ArrayShape; + class TraceItem { - /** - * Invoke. - * - * @param $throwable - * - * @return array - */ - public function __invoke($throwable) + #[ArrayShape(['exception' => "array", 'frames' => "array"])] + public function __invoke(\Throwable $throwable): array { $frames = []; diff --git a/README.md b/README.md index b092ff2..ea7ab3c 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Rollbar for Symfony -[![codecov](https://codecov.io/gh/rollbar/rollbar-php-symfony3-bundle/branch/master/graph/badge.svg)](https://codecov.io/gh/rollbar/rollbar-php-symfony-bundle) +[![codecov](https://codecov.io/gh/rollbar/rollbar-php-symfony-bundle/branch/master/graph/badge.svg)](https://codecov.io/gh/rollbar/rollbar-php-symfony-bundle) [![Build Status](https://travis-ci.org/rollbar/rollbar-php-symfony-bundle.svg?branch=master)](https://travis-ci.org/rollbar/rollbar-php-symfony-bundle) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) @@ -23,7 +23,7 @@ For complete configuration reference, see our [PHP SDK docs](https://docs.rollba # Release History & Changelog -See our [Releases](https://github.com/rollbar/rollbar-php-symfony3-bundle/releases) page for a list of all releases, including changes. +See our [Releases](https://github.com/rollbar/rollbar-php-symfony-bundle/releases) page for a list of all releases, including changes. # Related projects @@ -33,7 +33,7 @@ A Wordpress Plugin is available through Wordpress Admin Panel or through Wordpre A Laravel-specific package is available for integrating with Laravel: [Rollbar Laravel](https://github.com/rollbar/rollbar-php-laravel) -A CakePHP-specific package is avaliable for integrating with CakePHP 2.x: +A CakePHP-specific package is available for integrating with CakePHP 2.x: [CakeRollbar](https://github.com/tranfuga25s/CakeRollbar) A Flow-specific package is available for integrating with Neos Flow: [m12/flow-rollbar](https://packagist.org/packages/m12/flow-rollbar) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 7c32fa1..bb052e7 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -1,9 +1,9 @@ -Rollbar for Symfony 3 +Rollbar for Symfony 5+ ===================== |codecov| |Build Status| |Software License| -Rollbar full-stack error tracking for Symfony 3 +Rollbar full-stack error tracking for Symfony 5+ Description ----------- @@ -11,7 +11,7 @@ Description Rollbar collects errors that happen in your application, notifies you, and analyzes them so you can debug and fix them. -This plugin integrates Rollbar into your Symfony 3 installation. +This plugin integrates Rollbar into your Symfony 5+ installation. Find out `how Rollbar can help you decrease development and maintenance costs`_. @@ -28,33 +28,15 @@ Installation ------------ 1. Add ``Rollbar for Symfony`` with composer: - ``composer require rollbar/rollbar-php-symfony3-bundle`` -2. Register ``Rollbar\Symfony\RollbarBundle`` in - ``AppKernel::registerBundles()`` **after** registering the - ``MonologBundle`` - (``new Symfony\Bundle\MonologBundle\MonologBundle()``). - -.. code:: php - + ``composer require rollbar/rollbar-php-symfony-bundle`` - public function registerBundles() - { - $bundles = [ - // ... - new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), - // ... - new Symfony\Bundle\MonologBundle\MonologBundle(), - // ... - new \SymfonyRollbarBundle\SymfonyRollbarBundle(), - // ... - ]; - - return $bundles; - } - +2. Register Bundel: Only if you do NOT use Symfony Flex + Register ``Rollbar\Symfony\RollbarBundle\RollbarBundle::class => ['all' => true],`` in + ``config/bundles.php`` **after** registering the + ``MonologBundle`` + (``Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],``). -3. Configure Rollbar and Monolog in your ``app/config.yml`` or - ``app/config_*.yml``. +3. Configure Rollbar and Monolog in your ``config/packages/[*]/rollbar.yml or monolog.yaml`. .. code:: yaml @@ -76,7 +58,7 @@ Usage Exception reporting ~~~~~~~~~~~~~~~~~~~ -Symfony 3 exceptions will be reported to Rollbar automatically after you +Symfony exceptions will be reported to Rollbar automatically after you install and configure the bundle. Manual reporting @@ -113,9 +95,9 @@ LoggerInterface $logger) { $logger->error(‘Test info with person data’); .. _real companies improving their development workflow thanks to Rollbar: https://rollbar.com/customers/ .. _symfony/monolog-bundle: https://github.com/symfony/monolog-bundle -.. |codecov| image:: https://codecov.io/gh/rollbar/rollbar-php-symfony3-bundle/branch/master/graph/badge.svg - :target: https://codecov.io/gh/rollbar/rollbar-php-symfony3-bundle -.. |Build Status| image:: https://travis-ci.org/rollbar/rollbar-php-symfony3-bundle.svg?branch=master - :target: https://travis-ci.org/rollbar/rollbar-php-symfony3-bundle +.. |codecov| image:: https://codecov.io/gh/rollbar/rollbar-php-symfony-bundle/branch/master/graph/badge.svg + :target: https://codecov.io/gh/rollbar/rollbar-php-symfony-bundle +.. |Build Status| image:: https://travis-ci.org/rollbar/rollbar-php-symfony-bundle.svg?branch=master + :target: https://travis-ci.org/rollbar/rollbar-php-symfony-bundle .. |Software License| image:: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square :target: LICENSE \ No newline at end of file diff --git a/RollbarBundle.php b/RollbarBundle.php index 0805352..76fa4e4 100755 --- a/RollbarBundle.php +++ b/RollbarBundle.php @@ -4,11 +4,6 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; -/** - * Class RollbarBundle - * - * @package Rollbar\Symfony - */ class RollbarBundle extends Bundle { } diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index f9380b9..3766a2e 100755 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -7,16 +7,8 @@ use Rollbar\Symfony\RollbarBundle\DependencyInjection\RollbarExtension; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -/** - * Class ConfigurationTest - * - * @package Rollbar\Symfony\RollbarBundle\Tests\DependencyInjection; - */ class ConfigurationTest extends KernelTestCase { - /** - * Test parameters. - */ public function testParameters(): void { static::bootKernel(); @@ -30,14 +22,10 @@ public function testParameters(): void $defaults = []; foreach ($configOptions as $option) { // Handle the "branch" exception - switch ($option) { - case "branch": - $method = "gitBranch"; - break; - default: - $method = $option; - break; - } + $method = match ($option) { + "branch" => "gitBranch", + default => $option, + }; try { $default = $rollbarDefaults->fromSnakeCase($method); diff --git a/Tests/DependencyInjection/RollbarExtensionTest.php b/Tests/DependencyInjection/RollbarExtensionTest.php index 2725aeb..abe9293 100755 --- a/Tests/DependencyInjection/RollbarExtensionTest.php +++ b/Tests/DependencyInjection/RollbarExtensionTest.php @@ -5,19 +5,12 @@ use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; use Rollbar\Symfony\RollbarBundle\DependencyInjection\RollbarExtension; -/** - * Class RollbarExtensionTest - * - * @package Rollbar\Symfony\RollbarBundle\Tests\DependencyInjection - */ class RollbarExtensionTest extends AbstractExtensionTestCase { /** * Get container extensions. * * @link: https://github.com/matthiasnoback/SymfonyDependencyInjectionTest - * - * @return array */ protected function getContainerExtensions(): array { @@ -43,8 +36,6 @@ public function testConfigVars(string $var, array $expected, array $loadParamete /** * Data provider generatorConfigVars. - * - * @return array */ public function generatorConfigVars(): array { @@ -54,9 +45,6 @@ public function generatorConfigVars(): array ]; } - /** - * Test alias. - */ public function testAlias(): void { $extension = new RollbarExtension(); diff --git a/Tests/Fixtures/ErrorHandler.php b/Tests/Fixtures/ErrorHandler.php index e2c8f4c..c8e4ef3 100755 --- a/Tests/Fixtures/ErrorHandler.php +++ b/Tests/Fixtures/ErrorHandler.php @@ -5,28 +5,15 @@ use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; -/** - * Class ErrorHandler - * - * @package Tests\Fixtures - */ class ErrorHandler extends AbstractProcessingHandler { - /** - * @var ErrorHandler - */ - protected static $instance; + protected static ErrorHandler $instance; /** * @var callable */ protected $assert; - /** - * Get instance. - * - * @return ErrorHandler - */ public static function getInstance(): ErrorHandler { if (empty(static::$instance)) { @@ -36,22 +23,13 @@ public static function getInstance(): ErrorHandler return static::$instance; } - /** - * Set assert. - * - * @param callable $assert - */ - public function setAssert($assert = null): void + public function setAssert(callable $assert = null): void { $this->assert = $assert; } /** * Writes the record down to the log of the implementing handler - * - * @param array $record - * - * @return void */ protected function write(array $record): void { diff --git a/Tests/Payload/ErrorItemTest.php b/Tests/Payload/ErrorItemTest.php index 919d1e6..ba85910 100755 --- a/Tests/Payload/ErrorItemTest.php +++ b/Tests/Payload/ErrorItemTest.php @@ -5,23 +5,12 @@ use Rollbar\Symfony\RollbarBundle\Payload\ErrorItem; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -/** - * Class ErrorItemTest - * - * @package Rollbar\Symfony\RollbarBundle\Tests - */ class ErrorItemTest extends KernelTestCase { /** * Test invoke. * * @dataProvider generateInvoke - * - * @param int $code - * @param string $message - * @param string $file - * @param int $line - * @param string $mapped */ public function testInvoke(int $code, string $message, string $file, int $line, string $mapped): void { @@ -45,7 +34,6 @@ public function testInvoke(int $code, string $message, string $file, int $line, /** * Data provider for testInvoke. * - * @return array * @throws \Exception */ public function generateInvoke(): array diff --git a/Tests/Payload/GeneratorTest.php b/Tests/Payload/GeneratorTest.php index 7c41aa4..b801905 100755 --- a/Tests/Payload/GeneratorTest.php +++ b/Tests/Payload/GeneratorTest.php @@ -10,11 +10,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Kernel; -/** - * Class GeneratorTest - * - * @package Rollbar\Symfony\RollbarBundle\Tests - */ class GeneratorTest extends KernelTestCase { /** @@ -27,9 +22,6 @@ public function setUp(): void static::bootKernel(); } - /** - * Test getContainer. - */ public function testGetContainer(): void { $generator = $this->getGenerator(); @@ -39,9 +31,6 @@ public function testGetContainer(): void $this->assertInstanceOf(ContainerInterface::class, $result); } - /** - * Test getKernel. - */ public function testGetKernel(): void { $generator = $this->getGenerator(); @@ -54,10 +43,6 @@ public function testGetKernel(): void /** * Get class method. * - * @param string $class - * @param string $method - * - * @return \ReflectionMethod * @throws \ReflectionException */ protected static function getClassMethod(string $class, string $method): \ReflectionMethod @@ -71,6 +56,7 @@ protected static function getClassMethod(string $class, string $method): \Reflec /** * Test getServerInfo. + * @throws \ReflectionException */ public function testGetServerInfo(): void { @@ -96,7 +82,7 @@ public function testGetServerInfo(): void */ public function testGetRequestInfo(): void { - $container = $this->getContainer(); + $container = self::getContainer(); $generator = $this->getGenerator(); $request = $container->get('request_stack')->getCurrentRequest(); @@ -182,7 +168,7 @@ public function testGetExceptionPayload(): void $exception = new \Exception($msg, $code); $chain = new TraceChain(); - list($message, $payload) = $generator->getExceptionPayload($exception); + [$message, $payload] = $generator->getExceptionPayload($exception); $this->assertStringContainsString($msg, $message); @@ -199,62 +185,19 @@ public function testGetExceptionPayload(): void $this->assertEquals($requestInfo, $payload['request']); $this->assertEquals(static::$kernel->getEnvironment(), $payload['environment']); $this->assertEquals(Kernel::VERSION, $payload['framework']); - $this->assertEquals(phpversion(), $payload['language_version']); + $this->assertEquals(PHP_VERSION, $payload['language_version']); $this->assertEquals($serverInfo, $payload['server']); } - /** - * Test strange exception. - * - * @dataProvider generatorStrangeData - * - * @param mixed $data - */ - public function testStrangeException($data): void - { - $generator = $this->getGenerator(); - - [$message, $payload] = $generator->getExceptionPayload($data); - - $this->assertEquals('Undefined error', $message); - $this->assertNotEmpty($payload['body']['trace']); - } - - /** - * Data provider for testStrangeException. - * - * @return array - */ - public function generatorStrangeData(): array - { - return [ - ['zxcv'], - [1234], - [0.2345], - [null], - [(object) ['p' => 'a']], - [['s' => 'app', 'd' => 'web']], - [new ErrorItem()], - ]; - } - - /** - * Get container. - * - * @return ContainerInterface - */ protected static function getContainer(): ContainerInterface { return static::$container ?? static::$kernel->getContainer(); } - /** - * Get generator. - * - * @return object - */ - private function getGenerator() + private function getGenerator(): Generator { - return $this->getContainer()->get('test.' . Generator::class); + /** @var $generator Generator */ + $generator = self::getContainer()->get('test.' . Generator::class); + return $generator; } } diff --git a/Tests/Payload/TraceChainTest.php b/Tests/Payload/TraceChainTest.php index d5c4094..14bcdc4 100755 --- a/Tests/Payload/TraceChainTest.php +++ b/Tests/Payload/TraceChainTest.php @@ -5,16 +5,8 @@ use Rollbar\Symfony\RollbarBundle\Payload\TraceChain; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -/** - * Class TraceChainTest - * - * @package Rollbar\Symfony\RollbarBundle\Tests\Payload - */ class TraceChainTest extends KernelTestCase { - /** - * Test invoke. - */ public function testInvoke(): void { $previous = new \Exception('Exception', 1); diff --git a/Tests/Payload/TraceItemTest.php b/Tests/Payload/TraceItemTest.php index 49817eb..9d5af59 100755 --- a/Tests/Payload/TraceItemTest.php +++ b/Tests/Payload/TraceItemTest.php @@ -5,16 +5,8 @@ use Rollbar\Symfony\RollbarBundle\Payload\TraceItem; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -/** - * Class TraceItemTest - * - * @package Rollbar\Symfony\RollbarBundle\Tests\Payload - */ class TraceItemTest extends KernelTestCase { - /** - * Test invoke. - */ public function testInvoke(): void { $msg = 'Text exception - ' . md5(microtime()); diff --git a/composer.json b/composer.json index da21367..cea6ae2 100755 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "rollbar/rollbar-php-symfony-bundle", "description": "Bundle for Symfony that integrates Rollbar tracker", - "type": "library", + "type": "symfony-bundle", "license": "MIT", "authors": [ { @@ -27,8 +27,8 @@ "psr-4": { "Tests\\": "Tests/"} }, "require": { - "php": ">=7.2.5", - "rollbar/rollbar": "^2|^3.0", + "php": ">=8.0.2", + "rollbar/rollbar": "^3.0", "symfony/dependency-injection": "^5.4|^6.0", "symfony/config": "^5.4|^6.0", "symfony/http-kernel": "^5.4|^6.0", @@ -37,7 +37,7 @@ "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "^8.5", + "phpunit/phpunit": "^9.5", "symfony/framework-bundle": "^5.4|^6.0", "squizlabs/php_codesniffer": "^3.6", "matthiasnoback/symfony-dependency-injection-test": "^4.3" diff --git a/phpunit.xml b/phpunit.xml index f36dfa1..9fb371f 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,33 +1,23 @@ - - - - - - - - - - - - - - - Tests/ - - - - - - ./ - - - + + + + ./ + + + + + + + + + + + + + + Tests/ + + From cfd007adc01a4a40dc9f9a041151c9b282af4a8b Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 12 Apr 2022 14:44:27 +0200 Subject: [PATCH 08/15] test: add GitHub actions php > 8 --- .github/workflows/code_checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml index edf3495..b37e54d 100644 --- a/.github/workflows/code_checks.yaml +++ b/.github/workflows/code_checks.yaml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1'] + php: ['8.0', '8.1'] stability: [ prefer-lowest, prefer-stable ] name: PHP ${{ matrix.php }} - ${{ matrix.stability }} tests From 7b3329cda9306b0add848578c343ae8f2d8c8534 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 3 May 2022 10:57:29 +0200 Subject: [PATCH 09/15] feat: remove unused language_version --- Payload/Generator.php | 2 -- Tests/Payload/GeneratorTest.php | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Payload/Generator.php b/Payload/Generator.php index ba074a4..0aad53a 100755 --- a/Payload/Generator.php +++ b/Payload/Generator.php @@ -29,7 +29,6 @@ public function getExceptionPayload(\Exception $exception): array 'body' => [], 'framework' => Kernel::VERSION, 'server' => $this->getServerInfo(), - 'language_version' => PHP_VERSION, 'request' => $this->getRequestInfo(), 'environment' => $this->getKernel()->getEnvironment(), ]; @@ -62,7 +61,6 @@ public function getErrorPayload(int $code, string $message, string $file, int $l 'request' => $this->getRequestInfo(), 'environment' => $this->getKernel()->getEnvironment(), 'framework' => Kernel::VERSION, - 'language_version' => PHP_VERSION, 'server' => $this->getServerInfo(), ]; diff --git a/Tests/Payload/GeneratorTest.php b/Tests/Payload/GeneratorTest.php index b801905..b3f0cb3 100755 --- a/Tests/Payload/GeneratorTest.php +++ b/Tests/Payload/GeneratorTest.php @@ -136,7 +136,6 @@ public function testGetErrorPayload(): void $this->assertArrayHasKey('request', $payload); $this->assertArrayHasKey('environment', $payload); $this->assertArrayHasKey('framework', $payload); - $this->assertArrayHasKey('language_version', $payload); $this->assertArrayHasKey('server', $payload); $body = ['trace' => $item($code, $msg, $file, $line)]; @@ -145,7 +144,6 @@ public function testGetErrorPayload(): void $this->assertEquals($requestInfo, $payload['request']); $this->assertEquals(static::$kernel->getEnvironment(), $payload['environment']); $this->assertEquals(Kernel::VERSION, $payload['framework']); - $this->assertEquals(PHP_VERSION, $payload['language_version']); $this->assertEquals($serverInfo, $payload['server']); } @@ -176,7 +174,6 @@ public function testGetExceptionPayload(): void $this->assertArrayHasKey('request', $payload); $this->assertArrayHasKey('environment', $payload); $this->assertArrayHasKey('framework', $payload); - $this->assertArrayHasKey('language_version', $payload); $this->assertArrayHasKey('server', $payload); $body = ['trace_chain' => $chain($exception)]; @@ -185,7 +182,6 @@ public function testGetExceptionPayload(): void $this->assertEquals($requestInfo, $payload['request']); $this->assertEquals(static::$kernel->getEnvironment(), $payload['environment']); $this->assertEquals(Kernel::VERSION, $payload['framework']); - $this->assertEquals(PHP_VERSION, $payload['language_version']); $this->assertEquals($serverInfo, $payload['server']); } From 302141bc56a861ba4ed43d1e363765a6628a5574 Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Mon, 16 May 2022 15:34:38 -0500 Subject: [PATCH 10/15] Fixed the autoloaded test app file path --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cea6ae2..6503be8 100755 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ }, "autoload-dev": { "files": [ - "Tests/Fixtures/app/AppKernel.php", + "Tests/Fixtures/App/AppKernel.php", "Tests/Fixtures/ErrorHandler.php" ], "psr-4": { "Tests\\": "Tests/"} From aa541bebf97a9ca856714641e3b67041ac0e0068 Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Mon, 16 May 2022 16:15:35 -0500 Subject: [PATCH 11/15] Updated rollbar/rollbar to v3.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6503be8..024e9d7 100755 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "require": { "php": ">=8.0.2", - "rollbar/rollbar": "^3.0", + "rollbar/rollbar": "^3.1", "symfony/dependency-injection": "^5.4|^6.0", "symfony/config": "^5.4|^6.0", "symfony/http-kernel": "^5.4|^6.0", From de7166238e49928cd14121b0569f3bd8269c91df Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Fri, 29 Jul 2022 15:59:20 -0500 Subject: [PATCH 12/15] Fixed #51 Made catch more broad --- Factories/RollbarHandlerFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Factories/RollbarHandlerFactory.php b/Factories/RollbarHandlerFactory.php index 53e2b82..67e417e 100755 --- a/Factories/RollbarHandlerFactory.php +++ b/Factories/RollbarHandlerFactory.php @@ -30,7 +30,7 @@ public function __construct(ContainerInterface $container) $serializer = $container->get('serializer'); return \json_decode($serializer->serialize($user, 'json'), true, 512, JSON_THROW_ON_ERROR); } - } catch (\Exception $exception) { + } catch (\Throwable $exception) { // Ignore } }; From 31c0e29c24ecdaadaa0c4dd903ac3308f4bf2b02 Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Mon, 1 Aug 2022 16:13:12 -0500 Subject: [PATCH 13/15] Added CHANGELOG.md --- CHANGELOG.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..12b3279 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,59 @@ +## [v5.0.0] - 2019-01-02 +* Added Symfony 6 support, and update tests by @art-cg in #73 +* Added GitHub actions by @art-cg in #74 +* Feature/remove unused language version by @Chris53897 in #77 +* Fixed failing CI by @danielmorell in #78 +* Fixed #51 To make catch statement broader by @danielmorell in #80 +* Added CHANGELOG.md by @danielmorell in #81 + +## [v4.0.0] - 2020-02-15 +* Update to symfony5 #61 + +## [v3.1.2] - 2019-01-02 +* #39 Person data not loaded TokenStorage as documented + +## [v3.1.1] - 2018-12-16 +* #38: phpunit exits with a non-zero status +* Update README.md + +## [v3.1.0] - 2018-10-16 +* #34 Change the name of the report to rollbar-php-symfony-bundle +* #24 Point docs from README to Rollbar's site +* #37 Remove exception listeners, rely on Symfony...::logKernelException() to log uncaught exceptions +* readme updates + +## [v3.0.0] - 2018-10-10 +* Update README.md by @jessewgibbs in #30 +* Add Symfony 4 support and ability to configure all Rollbar parameters by @javer in #27 + +## [v2.0.0] - 2018-04-17 +* Major refactoring of the directory structure following Symfony's [best practices](http://symfony.com/doc/3.4/bundles/best_practices.html). +* Updated the `rollbar/rollbar` dependency to use the latest release. +* Added support for manual logging through the `LoggerInterface` injected logger. +* Utilized Symfony's Monolog Bundle to tap into Symfony's common logging mechanism. +* Updated `README.md` and `Resources/doc/index.rst`. +* Added Symfony's logged in user tracking by default. +* Added support for `person_fn` for modifying the user tracking data. +* Refactored the configuration options structure for `app/config/config.yml`. +* Added passing Rollbar's default config values as they are defined in `rollbar/rollbar` dependency instead of redefining them in the bundle. + +## [v1.0.2] - 2018-02-16 +* update: allow to work with php7 + +## [v1.0.1] - 2017-08-09 +* Update ExceptionListener.php fix function access level + +## [v1.0.0] - 2017-05-08 +* coverage + + +[v5.0.0]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v4.0.0...v5.0.0 +[v4.0.0]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v3.1.2...v4.0.0 +[v3.1.2]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v3.1.1...v3.1.2 +[v3.1.1]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v3.1.0...v3.1.1 +[v3.1.0]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v3.0.0...v3.1.0 +[v3.0.0]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v2.0.0...v3.0.0 +[v2.0.0]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v1.0.2...v2.0.0 +[v1.0.2]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v1.0.1...v1.0.2 +[v1.0.1]: https://github.com/rollbar/rollbar-php-symfony-bundle/compare/v1.0.0...v1.0.1 +[v1.0.0]: https://github.com/rollbar/rollbar-php-symfony-bundle/releases/tag/v1.0.0 \ No newline at end of file From b15d624a54b95d1a2ffce54fd9e14b6e63b78fbb Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Mon, 12 Sep 2022 16:09:00 -0500 Subject: [PATCH 14/15] Replaced Exception with Throwable for consistent typing --- Payload/Generator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Payload/Generator.php b/Payload/Generator.php index 0aad53a..6db456c 100755 --- a/Payload/Generator.php +++ b/Payload/Generator.php @@ -19,7 +19,7 @@ public function __construct(protected ContainerInterface $container) /** * Get payload a log record. */ - public function getExceptionPayload(\Exception $exception): array + public function getExceptionPayload(\Throwable $exception): array { /** * Build payload From df7064889922b43885004ea243b92594c4e48a83 Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Mon, 12 Sep 2022 16:10:03 -0500 Subject: [PATCH 15/15] Replaced Kernel::getRootDir() method with Kernel::getProjectDir() --- Payload/Generator.php | 2 +- Tests/Fixtures/App/AppKernel.php | 4 ++-- Tests/Payload/GeneratorTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Payload/Generator.php b/Payload/Generator.php index 6db456c..c99ac3c 100755 --- a/Payload/Generator.php +++ b/Payload/Generator.php @@ -104,7 +104,7 @@ protected function getServerInfo(): array return [ 'host' => gethostname(), - 'root' => $kernel->getRootDir(), + 'root' => $kernel->getProjectDir(), 'user' => get_current_user(), 'file' => array_shift($args), 'argv' => implode(' ', $args), diff --git a/Tests/Fixtures/App/AppKernel.php b/Tests/Fixtures/App/AppKernel.php index de1c415..485936e 100755 --- a/Tests/Fixtures/App/AppKernel.php +++ b/Tests/Fixtures/App/AppKernel.php @@ -19,7 +19,7 @@ public function registerBundles(): iterable ]; } - public function getRootDir(): string + public function getProjectDir(): string { return __DIR__; } @@ -29,7 +29,7 @@ public function getRootDir(): string */ public function registerContainerConfiguration(LoaderInterface $loader): void { - $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); + $loader->load($this->getProjectDir().'/config/config_'.$this->getEnvironment().'.yml'); } public function getCacheDir(): string diff --git a/Tests/Payload/GeneratorTest.php b/Tests/Payload/GeneratorTest.php index b3f0cb3..6010395 100755 --- a/Tests/Payload/GeneratorTest.php +++ b/Tests/Payload/GeneratorTest.php @@ -72,7 +72,7 @@ public function testGetServerInfo(): void $this->assertArrayHasKey('argv', $data); $this->assertEquals($data['host'], gethostname()); - $this->assertEquals($data['root'], static::$kernel->getRootDir()); + $this->assertEquals($data['root'], static::$kernel->getProjectDir()); $this->assertEquals($data['user'], get_current_user()); }