From 23b14dee45f622d59668e91dc8bfb6577d19a8ab Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 8 Aug 2022 16:59:32 +0200 Subject: [PATCH] Add support for monolog 3 (#30) * Add support for monolog 3 * Fix compatibility to Monolog 3 * Update Profiler/Handler/CollectionHandler.php Co-authored-by: Luca Rath-Heel Co-authored-by: Luca Rath-Heel --- Profiler/ElasticsearchProfiler.php | 4 ---- .../BackwardCompatibilityWriteTrait.php | 21 ------------------- .../BackwardCompatibilityWriteTrait71.php | 14 ------------- .../BackwardCompatibilityWriteTrait72.php | 14 ------------- Profiler/Handler/CollectionHandler.php | 11 +++++----- composer.json | 2 +- 6 files changed, 6 insertions(+), 60 deletions(-) delete mode 100644 Profiler/Handler/BackwardCompatibilityWriteTrait.php delete mode 100644 Profiler/Handler/BackwardCompatibilityWriteTrait71.php delete mode 100644 Profiler/Handler/BackwardCompatibilityWriteTrait72.php diff --git a/Profiler/ElasticsearchProfiler.php b/Profiler/ElasticsearchProfiler.php index 04e22a5a..59f0503b 100644 --- a/Profiler/ElasticsearchProfiler.php +++ b/Profiler/ElasticsearchProfiler.php @@ -16,13 +16,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; -use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\VarDumper\Caster\CutStub; use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Cloner\Stub; -use Symfony\Component\VarDumper\Cloner\VarCloner; /** * Data collector for profiling elasticsearch bundle. diff --git a/Profiler/Handler/BackwardCompatibilityWriteTrait.php b/Profiler/Handler/BackwardCompatibilityWriteTrait.php deleted file mode 100644 index e7c7b814..00000000 --- a/Profiler/Handler/BackwardCompatibilityWriteTrait.php +++ /dev/null @@ -1,21 +0,0 @@ -= 70200) { - /** - * @internal - */ - trait BackwardCompatibilityWriteTrait - { - use BackwardCompatibilityWriteTrait72; - } -} else { - /** - * @internal - */ - trait BackwardCompatibilityWriteTrait - { - use BackwardCompatibilityWriteTrait71; - } -} diff --git a/Profiler/Handler/BackwardCompatibilityWriteTrait71.php b/Profiler/Handler/BackwardCompatibilityWriteTrait71.php deleted file mode 100644 index 0ae08b12..00000000 --- a/Profiler/Handler/BackwardCompatibilityWriteTrait71.php +++ /dev/null @@ -1,14 +0,0 @@ -doWrite($record); - } -} diff --git a/Profiler/Handler/BackwardCompatibilityWriteTrait72.php b/Profiler/Handler/BackwardCompatibilityWriteTrait72.php deleted file mode 100644 index 6d7bdd22..00000000 --- a/Profiler/Handler/BackwardCompatibilityWriteTrait72.php +++ /dev/null @@ -1,14 +0,0 @@ -doWrite($record); - } -} diff --git a/Profiler/Handler/CollectionHandler.php b/Profiler/Handler/CollectionHandler.php index 7ac3bb57..5efef0c4 100644 --- a/Profiler/Handler/CollectionHandler.php +++ b/Profiler/Handler/CollectionHandler.php @@ -12,23 +12,22 @@ namespace ONGR\ElasticsearchBundle\Profiler\Handler; use Monolog\Handler\AbstractProcessingHandler; +use Monolog\LogRecord; /** * Handler that saves all records to him self. */ class CollectionHandler extends AbstractProcessingHandler { - use BackwardCompatibilityWriteTrait; - /** - * @var array + * @var array[]|LogRecord[] */ private $records = []; /** - * {@inheritdoc} + * @param array|LogRecord $record */ - protected function doWrite(array $record) + protected function write($record): void { $this->records[] = $record; } @@ -36,7 +35,7 @@ protected function doWrite(array $record) /** * Returns recorded data. * - * @return array + * @return array[]|LogRecord[] */ public function getRecords() { diff --git a/composer.json b/composer.json index fa212914..9ab1374a 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "doctrine/inflector": "^1.0 || ^2.0", "doctrine/cache": "~1.4", "doctrine/collections": "~1.4", - "monolog/monolog": "^1.10 || ^2.0", + "monolog/monolog": "^1.10 || ^2.0 || ^3.0", "handcraftedinthealps/elasticsearch-dsl": "^5.0.7.1|^6.2.0.1|^7.2.0.1", "symfony/event-dispatcher": "^2.8|^3.0|^4|^5|^6" },