Skip to content

Commit

Permalink
Symfony 5 support (#5)
Browse files Browse the repository at this point in the history
Symfony 5 support
  • Loading branch information
RomulusED69 authored Jan 16, 2020
2 parents 24bd3b9 + e068abe commit d5da3ac
Show file tree
Hide file tree
Showing 45 changed files with 172 additions and 86 deletions.
14 changes: 0 additions & 14 deletions .coke

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
composer.lock
bin/*
.php_cs.cache
28 changes: 28 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('var')
;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'align_double_arrow' => true,
'align_equals' => true
],
'no_unreachable_default_argument_value' => false,
'braces' => [
'allow_single_line_closure' => true,
],
'heredoc_to_nowdoc' => false,
'phpdoc_summary' => false,
'declare_strict_types' => true,
])
->setFinder($finder)
;
56 changes: 45 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@
dist: bionic

language: php
sudo: false

cache:
directories:
- vendor
- ~/.composer/cache/files

env:
global:
- COMPOSER_MEMORY_LIMIT=-1

matrix:
fast_finish: true
include:
- php: 7.0
- php: 7.1
- php: 7.2
# Minimum supported dependencies with the latest and oldest PHP version
- php: 7.3
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
- php: 7.4
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="max[self]=0"

# Test the latest stable release
- php: 7.3
- php: 7.4

# Test specific Symfony versions
- php: 7.4
env: SYMFONY_VERSION="4.3.5" # LTS
- php: 7.4
env: SYMFONY_VERSION="4.*" # Last 4.x version
- php: 7.4
env: SYMFONY_VERSION="5.*" # Last 5.x version

# Latest commit to master
- php: 7.4
env: STABILITY="dev"

allow_failures:
# Dev-master is allowed to fail.
- env: STABILITY="dev"
- env: SYMFONY_VERSION="5.*"

before_install:
- echo "" > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- phpenv config-rm xdebug.ini
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
- composer require --no-update symfony/flex ${DEPENDENCIES}
- if ! [ -z "$SYMFONY_VERSION" ]; then composer config extra.symfony.require "${SYMFONY_VERSION}"; fi;

before_script:
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
- composer install --no-interaction --prefer-dist

cache:
directories:
- bin
- vendor
- ~/.composer/cache/files
install:
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction

script:
- bin/coke
- bin/php-cs-fixer fix --verbose --diff --dry-run src/
- bin/phpspec run -f dot -n
15 changes: 4 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
"keywords": ["influx", "db", "influxdb", "statistics", "metrics"],
"type": "symfony-bundle",
"license": "MIT",
"repositories": [
{
"type": "vcs",
"url": "git@github.com:Yproximite/Symfony2-coding-standard"
}
],
"require": {
"php": "^7.0",
"symfony/framework-bundle": "^3.0|^4.0",
"php": "^7.3",
"symfony/framework-bundle": "^4.0||^5.0",
"algatux/influxdb-bundle": "~2.1"
},
"autoload": {
Expand All @@ -21,9 +15,8 @@
}
},
"require-dev": {
"phpspec/phpspec": "^3.2",
"m6web/Symfony2-coding-standard": "dev-master",
"m6web/coke": "^2.1"
"phpspec/phpspec": "^6.1",
"friendsofphp/php-cs-fixer": "^2.16.1"
},
"config": {
"bin-dir": "bin"
Expand Down
38 changes: 21 additions & 17 deletions spec/Client/ClientSpec.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
<?php

declare(strict_types=1);

namespace spec\Yproximite\Bundle\InfluxDbPresetBundle\Client;

use InfluxDB\Point;
use Algatux\InfluxDbBundle\Events\DeferredHttpEvent;
use Algatux\InfluxDbBundle\Events\DeferredUdpEvent;
use Algatux\InfluxDbBundle\Events\HttpEvent;
use Algatux\InfluxDbBundle\Events\UdpEvent;
use InfluxDB\Database;
use InfluxDB\Point;
use PhpSpec\ObjectBehavior;
use Algatux\InfluxDbBundle\Events\UdpEvent;
use Algatux\InfluxDbBundle\Events\HttpEvent;
use Algatux\InfluxDbBundle\Events\DeferredUdpEvent;
use Algatux\InfluxDbBundle\Events\DeferredHttpEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

use Yproximite\Bundle\InfluxDbPresetBundle\Events;
use Yproximite\Bundle\InfluxDbPresetBundle\Client\Client;
use Yproximite\Bundle\InfluxDbPresetBundle\Profile\Profile;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPreset;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointBuilder;
use Yproximite\Bundle\InfluxDbPresetBundle\Connection\Connection;
use Yproximite\Bundle\InfluxDbPresetBundle\Event\ClientRequestEvent;
use Yproximite\Bundle\InfluxDbPresetBundle\Profile\ProfilePoolInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Events;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointBuilder;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointBuilderFactoryInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPreset;
use Yproximite\Bundle\InfluxDbPresetBundle\Profile\Profile;
use Yproximite\Bundle\InfluxDbPresetBundle\Profile\ProfilePoolInterface;

class ClientSpec extends ObjectBehavior
{
function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(Client::class);
}

function let(
public function let(
EventDispatcherInterface $eventDispatcher,
ProfilePoolInterface $profilePool,
PointBuilderFactoryInterface $pointBuilderFactory
Expand All @@ -41,7 +42,8 @@ function let(
$this->beConstructedWith($eventDispatcher, $profilePool, $pointBuilderFactory);
}

function it_should_send_point_through_each_of_connection_types(EventDispatcherInterface $eventDispatcher) {
public function it_should_send_point_through_each_of_connection_types(EventDispatcherInterface $eventDispatcher)
{
$dateTime = new \DateTime();

$this->sendPoint('default', 'apple.dropped', 7., $dateTime);
Expand All @@ -62,7 +64,8 @@ function it_should_send_point_through_each_of_connection_types(EventDispatcherIn
}
}

function it_should_dispatch_client_request_event(EventDispatcherInterface $eventDispatcher) {
public function it_should_dispatch_client_request_event(EventDispatcherInterface $eventDispatcher)
{
$dateTime = new \DateTime();

$this->sendPoint('default', 'apple.dropped', 7., $dateTime);
Expand All @@ -72,7 +75,8 @@ function it_should_dispatch_client_request_event(EventDispatcherInterface $event
$eventDispatcher->dispatch(Events::CLIENT_REQUEST, $event)->shouldHaveBeenCalled();
}

function it_should_use_other_profiles_separately(EventDispatcherInterface $eventDispatcher) {
public function it_should_use_other_profiles_separately(EventDispatcherInterface $eventDispatcher)
{
$dateTime = new \DateTime();

$this->sendPoint('custom', 'apple.dropped', 5., $dateTime);
Expand Down Expand Up @@ -105,7 +109,7 @@ private function buildDefaultProfile(): Profile
];

foreach ($connectionConfigs as $connectionConfig) {
list ($connectionName, $connectionProtocol, $connectionDeferred) = $connectionConfig;
list($connectionName, $connectionProtocol, $connectionDeferred) = $connectionConfig;

$connection = new Connection();
$connection
Expand Down
11 changes: 6 additions & 5 deletions spec/Point/PointBuilderSpec.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php

declare(strict_types=1);

namespace spec\Yproximite\Bundle\InfluxDbPresetBundle\Point;

use PhpSpec\ObjectBehavior;

use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPreset;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointBuilder;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPreset;

class PointBuilderSpec extends ObjectBehavior
{
function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(PointBuilder::class);
}

function it_should_build_simple_point()
public function it_should_build_simple_point()
{
$pointPreset = new PointPreset();
$pointPreset->setMeasurement('apples');
Expand All @@ -28,7 +29,7 @@ function it_should_build_simple_point()
$this->build()->__toString()->shouldBeEqualTo(sprintf('apples value=5 %d', $dateTime->getTimestamp()));
}

function it_should_build_advanced_point()
public function it_should_build_advanced_point()
{
$pointPreset = new PointPreset();
$pointPreset
Expand Down
25 changes: 13 additions & 12 deletions src/Client/Client.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?php

declare(strict_types=1);

namespace Yproximite\Bundle\InfluxDbPresetBundle\Client;

use InfluxDB\Point;
use InfluxDB\Database;
use Algatux\InfluxDbBundle\Events\UdpEvent;
use Algatux\InfluxDbBundle\Events\HttpEvent;
use Algatux\InfluxDbBundle\Events\DeferredUdpEvent;
use Algatux\InfluxDbBundle\Events\DeferredHttpEvent;
use Algatux\InfluxDbBundle\Events\DeferredUdpEvent;
use Algatux\InfluxDbBundle\Events\HttpEvent;
use Algatux\InfluxDbBundle\Events\UdpEvent;
use InfluxDB\Database;
use InfluxDB\Point;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Events;
use Yproximite\Bundle\InfluxDbPresetBundle\Connection\ConnectionInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Event\ClientRequestEvent;
use Yproximite\Bundle\InfluxDbPresetBundle\Events;
use Yproximite\Bundle\InfluxDbPresetBundle\Exception\LogicException;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointBuilderFactoryInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPresetInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Profile\ProfilePoolInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Connection\ConnectionInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointBuilderFactoryInterface;

/**
* Class Client
Expand Down Expand Up @@ -94,13 +95,13 @@ private function sendPointUsingConnection(Point $point, ConnectionInterface $con
private function getEventClassName(ConnectionInterface $connection): string
{
switch (true) {
case ($connection->isHttpProtocol() && !$connection->isDeferred()):
case $connection->isHttpProtocol() && !$connection->isDeferred():
return HttpEvent::class;
case ($connection->isHttpProtocol() && $connection->isDeferred()):
case $connection->isHttpProtocol() && $connection->isDeferred():
return DeferredHttpEvent::class;
case ($connection->isUdpProtocol() && !$connection->isDeferred()):
case $connection->isUdpProtocol() && !$connection->isDeferred():
return UdpEvent::class;
case ($connection->isUdpProtocol() && $connection->isDeferred()):
case $connection->isUdpProtocol() && $connection->isDeferred():
return DeferredUdpEvent::class;
default:
throw new LogicException('Could not determine the event class name.');
Expand Down
1 change: 1 addition & 0 deletions src/Client/ClientInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Yproximite\Bundle\InfluxDbPresetBundle\Client;
Expand Down
5 changes: 3 additions & 2 deletions src/Connection/Connection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Yproximite\Bundle\InfluxDbPresetBundle\Connection;
Expand Down Expand Up @@ -49,12 +50,12 @@ public function setProtocol(string $protocol): ConnectionInterface

public function isUdpProtocol(): bool
{
return $this->getProtocol() === self::PROTOCOL_UDP;
return self::PROTOCOL_UDP === $this->getProtocol();
}

public function isHttpProtocol(): bool
{
return $this->getProtocol() === self::PROTOCOL_HTTP;
return self::PROTOCOL_HTTP === $this->getProtocol();
}

public function isDeferred(): bool
Expand Down
1 change: 1 addition & 0 deletions src/Connection/ConnectionFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Yproximite\Bundle\InfluxDbPresetBundle\Connection;
Expand Down
1 change: 1 addition & 0 deletions src/Connection/ConnectionFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Yproximite\Bundle\InfluxDbPresetBundle\Connection;
Expand Down
1 change: 1 addition & 0 deletions src/Connection/ConnectionInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Yproximite\Bundle\InfluxDbPresetBundle\Connection;
Expand Down
2 changes: 1 addition & 1 deletion src/DataCollector/ClientRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Yproximite\Bundle\InfluxDbPresetBundle\Connection\Connection;
use Yproximite\Bundle\InfluxDbPresetBundle\Connection\ConnectionInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPreset;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPresetInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Profile\Profile;
use Yproximite\Bundle\InfluxDbPresetBundle\Profile\ProfileInterface;
use Yproximite\Bundle\InfluxDbPresetBundle\Point\PointPresetInterface;

/**
* Class ClientRequest
Expand Down
1 change: 1 addition & 0 deletions src/DataCollector/InfluxDbPresetDataCollector.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Yproximite\Bundle\InfluxDbPresetBundle\DataCollector;
Expand Down
Loading

0 comments on commit d5da3ac

Please sign in to comment.