Skip to content

Commit

Permalink
Add compatibility to monolog 2 (handcraftedinthealps#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Jun 30, 2020
1 parent c2cf4b1 commit eea1a34
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ before_script:
script:
- wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200
- vendor/bin/simple-phpunit --coverage-clover=coverage.clover
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/,var/ ./
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/,var/,Profiler/Handler/BackwardCompatibilityWriteTrait.php ./

after_script:
- travis_retry php vendor/bin/coveralls
21 changes: 21 additions & 0 deletions Profiler/Handler/BackwardCompatibilityWriteTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace ONGR\ElasticsearchBundle\Profiler\Handler;

if (PHP_VERSION_ID >= 70200) {
/**
* @internal
*/
trait BackwardCompatibilityWriteTrait
{
use BackwardCompatibilityWriteTrait72;
}
} else {
/**
* @internal
*/
trait BackwardCompatibilityWriteTrait
{
use BackwardCompatibilityWriteTrait71;
}
}
14 changes: 14 additions & 0 deletions Profiler/Handler/BackwardCompatibilityWriteTrait71.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace ONGR\ElasticsearchBundle\Profiler\Handler;

/**
* @internal
*/
trait BackwardCompatibilityWriteTrait71
{
protected function write(array $record)
{
$this->doWrite($record);
}
}
14 changes: 14 additions & 0 deletions Profiler/Handler/BackwardCompatibilityWriteTrait72.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace ONGR\ElasticsearchBundle\Profiler\Handler;

/**
* @internal
*/
trait BackwardCompatibilityWriteTrait72
{
protected function write(array $record): void
{
$this->doWrite($record);
}
}
4 changes: 3 additions & 1 deletion Profiler/Handler/CollectionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class CollectionHandler extends AbstractProcessingHandler
{
use BackwardCompatibilityWriteTrait;

/**
* @var array
*/
Expand All @@ -26,7 +28,7 @@ class CollectionHandler extends AbstractProcessingHandler
/**
* {@inheritdoc}
*/
protected function write(array $record)
protected function doWrite(array $record)
{
$this->records[] = $record;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"doctrine/inflector": "~1.0",
"doctrine/cache": "~1.4",
"doctrine/collections": "~1.4",
"monolog/monolog": "~1.10",
"monolog/monolog": "^1.10 || ^2.0",
"handcraftedinthealps/elasticsearch-dsl": "^5.0.7.1|^6.2.0.1|^7.2.0.1"
},
"require-dev": {
Expand Down

0 comments on commit eea1a34

Please sign in to comment.