Skip to content

Commit

Permalink
Merge pull request #604 from alcaeus/fix-wrong-data-collector-signature
Browse files Browse the repository at this point in the history
Fix wrong data collector signature
  • Loading branch information
alcaeus authored Nov 28, 2019
2 parents 594d6cb + 086ba13 commit c27fefe
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:

before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
- composer global require --no-update --no-progress --no-scripts --no-plugins symfony/flex dev-master
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master

install:
- composer self-update
Expand All @@ -37,10 +37,6 @@ jobs:
- php: 7.2
env: LOWEST DRIVER_VERSION="1.5.0" SYMFONY_DEPRECATIONS_HELPER=weak COMPOSER_FLAGS=" -n --prefer-lowest --prefer-stable --prefer-dist"

# Test against latest Symfony 3.4 stable
- php: 7.3
env: SYMFONY_REQUIRE="3.4.*"

# Test against latest Symfony 4.3 stable
- php: 7.3
env: SYMFONY_REQUIRE="4.3.*"
Expand Down
5 changes: 2 additions & 3 deletions DataCollector/CommandDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use Doctrine\ODM\MongoDB\APM\Command;
use Doctrine\ODM\MongoDB\APM\CommandLogger;
use Exception;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Throwable;
use function array_map;
use function count;
use function json_encode;
Expand All @@ -24,8 +24,7 @@ public function __construct(CommandLogger $commandLogger)
$this->commandLogger = $commandLogger;
}

// phpcs:ignore SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly
public function collect(Request $request, Response $response, ?Exception $exception = null) : void
public function collect(Request $request, Response $response, ?Throwable $exception = null) : void
{
$this->data = [
'num_commands' => count($this->commandLogger),
Expand Down
3 changes: 1 addition & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use function is_array;
use function is_string;
use function json_decode;
use function method_exists;
use function preg_match;
use function sprintf;

Expand All @@ -35,7 +34,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('doctrine_mongodb');
$rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('doctrine_mongodb');
$rootNode = $treeBuilder->getRootNode();

$this->addDocumentManagersSection($rootNode);
$this->addConnectionsSection($rootNode);
Expand Down
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Compatibility
The current version of this bundle has the following requirements:
* PHP 7.2 or newer is required
* `ext-mongodb` 1.5 or newer
* Symfony 3.4 or newer is required
* Symfony 4.3 or newer is required

Support for older Symfony, PHP and MongoDB versions is provided via the `3.0.x`
releases (tracked in the `3.0` branch). This version sees bug and security fixes
Expand Down
21 changes: 21 additions & 0 deletions Tests/DataCollector/CommandDataCollectorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests\DataCollector;

use Doctrine\Bundle\MongoDBBundle\DataCollector\CommandDataCollector;
use Doctrine\Bundle\MongoDBBundle\Tests\TestCase;
use Doctrine\ODM\MongoDB\APM\CommandLogger;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class CommandDataCollectorTest extends TestCase
{
public function testCollector()
{
$collector = new CommandDataCollector(new CommandLogger());

$collector->collect($request = new Request(['group' => '0']), $response = new Response());
}
}
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
"doctrine/annotations": "^1.2",
"doctrine/mongodb-odm": "^2.0.0",
"psr/log": "^1.0",
"symfony/console": "^3.4 || ^4.0 || ^5.0",
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0",
"symfony/doctrine-bridge": "^3.4 || ^4.0 || ^5.0",
"symfony/config": "^3.4 || ^4.0 || ^5.0",
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0",
"symfony/options-resolver": "^3.4 || ^4.0 || ^5.0"
"symfony/console": "^4.3.3|^5.0",
"symfony/dependency-injection": "^4.3.3|^5.0",
"symfony/doctrine-bridge": "^4.3.3|^5.0",
"symfony/config": "^4.3.3|^5.0",
"symfony/framework-bundle": "^4.3.3|^5.0",
"symfony/http-kernel": "^4.3.7|^5.0",
"symfony/options-resolver": "^4.3.3|^5.0"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"doctrine/data-fixtures": "^1.2.2",
"phpunit/phpunit": "^7.3",
"squizlabs/php_codesniffer": "^3.5",
"symfony/form": "^3.4 || ^4.0 || ^5.0",
"symfony/phpunit-bridge": "^3.4 || ^4.0 || ^5.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0"
"symfony/form": "^4.3.3|^5.0",
"symfony/phpunit-bridge": "^4.3.3|^5.0",
"symfony/yaml": "^4.3.3|^5.0"
},
"suggest": {
"doctrine/data-fixtures": "Load data fixtures"
Expand Down

0 comments on commit c27fefe

Please sign in to comment.