Skip to content

Commit

Permalink
Merge pull request #97 from samuelwilliams/master
Browse files Browse the repository at this point in the history
Update PHP-CS-Fixer configuration
  • Loading branch information
samuelwilliams authored Mar 5, 2020
2 parents 50de52e + 88aa273 commit 7b65b03
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 38 deletions.
20 changes: 15 additions & 5 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of PHP DNS Server.
*
* (c) Yif Swery <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$header = <<<'EOF'
This file is part of PHP DNS Server.
Expand All @@ -17,12 +26,13 @@ $finder = PhpCsFixer\Finder::create()

$config = PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(array(
->setRules([
'@Symfony' => true,
'header_comment' => array('header' => $header),
'array_syntax' => array('syntax' => 'short'),
))
'header_comment' => ['header' => $header],
'array_syntax' => ['syntax' => 'short'],
'no_superfluous_phpdoc_tags' => false,
])
->setFinder($finder)
;

return $config;
return $config;
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"phpunit/phpunit": "~7.3",
"php-coveralls/php-coveralls": "~2.1",
"bamarni/composer-bin-plugin": "^1.3",
"humbug/box": ">=3.6"
"humbug/box": ">=3.6",
"friendsofphp/php-cs-fixer": "^2.16"
},
"license": "MIT",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion src/Event/QueryReceiveEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace yswery\DNS\Event;

use yswery\DNS\Message;
use Symfony\Component\EventDispatcher\Event;
use yswery\DNS\Message;

class QueryReceiveEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/Subscriber/EchoLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Psr\Log\LogLevel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use yswery\DNS\Event\Events;
use yswery\DNS\Event\ServerExceptionEvent;
use yswery\DNS\Event\QueryReceiveEvent;
use yswery\DNS\Event\QueryResponseEvent;
use yswery\DNS\Event\ServerExceptionEvent;
use yswery\DNS\Event\ServerStartEvent;

class EchoLogger extends AbstractLogger implements EventSubscriberInterface
Expand Down
4 changes: 1 addition & 3 deletions src/RdataDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class RdataDecoder
public static function decodeRdata(int $type, string $rdata)
{
if (!array_key_exists($type, self::$methodMap)) {
throw new UnsupportedTypeException(
sprintf('Record type "%s" is not a supported type.', RecordTypeEnum::getName($type))
);
throw new UnsupportedTypeException(sprintf('Record type "%s" is not a supported type.', RecordTypeEnum::getName($type)));
}

return call_user_func(['self', self::$methodMap[$type]], $rdata);
Expand Down
4 changes: 1 addition & 3 deletions src/RdataEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class RdataEncoder
public static function encodeRdata(int $type, $rdata): string
{
if (!array_key_exists($type, self::$methodMap)) {
throw new UnsupportedTypeException(
sprintf('Record type "%s" is not a supported type.', RecordTypeEnum::getName($type))
);
throw new UnsupportedTypeException(sprintf('Record type "%s" is not a supported type.', RecordTypeEnum::getName($type)));
}

return call_user_func(['self', self::$methodMap[$type]], $rdata);
Expand Down
6 changes: 2 additions & 4 deletions src/Resolver/AbstractResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace yswery\DNS\Resolver;

use yswery\DNS\ResourceRecord;
use yswery\DNS\RecordTypeEnum;
use yswery\DNS\ResourceRecord;
use yswery\DNS\UnsupportedTypeException;

abstract class AbstractResolver implements ResolverInterface
Expand Down Expand Up @@ -245,9 +245,7 @@ protected function extractRdata(array $resourceRecord, int $type, string $parent
case RecordTypeEnum::TYPE_ANY:
return '';
default:
throw new UnsupportedTypeException(
sprintf('Resource Record type "%s" is not a supported type.', RecordTypeEnum::getName($type))
);
throw new UnsupportedTypeException(sprintf('Resource Record type "%s" is not a supported type.', RecordTypeEnum::getName($type)));
}
}
}
8 changes: 3 additions & 5 deletions src/Resolver/SystemResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace yswery\DNS\Resolver;

use yswery\DNS\UnsupportedTypeException;
use yswery\DNS\ResourceRecord;
use yswery\DNS\RecordTypeEnum;
use yswery\DNS\ResourceRecord;
use yswery\DNS\UnsupportedTypeException;

/**
* Use the host system's configured DNS.
Expand Down Expand Up @@ -120,9 +120,7 @@ protected function extractPhpRdata(array $resourceRecord)
'target' => $resourceRecord['target'],
];
default:
throw new UnsupportedTypeException(
sprintf('Record type "%s" is not a supported type.', RecordTypeEnum::getName($type))
);
throw new UnsupportedTypeException(sprintf('Record type "%s" is not a supported type.', RecordTypeEnum::getName($type)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/XmlResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace yswery\DNS\Resolver;

use yswery\DNS\ClassEnum;
use yswery\DNS\ResourceRecord;
use yswery\DNS\RecordTypeEnum;
use yswery\DNS\ResourceRecord;
use yswery\DNS\UnsupportedTypeException;

class XmlResolver extends AbstractResolver
Expand Down
8 changes: 4 additions & 4 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
use React\Datagram\Socket;
use React\Datagram\SocketInterface;
use React\EventLoop\LoopInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use yswery\DNS\Config\FileConfig;
use yswery\DNS\Event\ServerExceptionEvent;
use yswery\DNS\Event\Events;
use yswery\DNS\Event\MessageEvent;
use yswery\DNS\Event\QueryReceiveEvent;
use yswery\DNS\Event\QueryResponseEvent;
use yswery\DNS\Event\ServerExceptionEvent;
use yswery\DNS\Event\ServerStartEvent;
use yswery\DNS\Filesystem\FilesystemManager;
use yswery\DNS\Resolver\JsonFileSystemResolver;
use yswery\DNS\Resolver\ResolverInterface;
use yswery\DNS\Event\Events;
use yswery\DNS\Filesystem\FilesystemManager;

class Server
{
Expand Down
4 changes: 2 additions & 2 deletions tests/DecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace yswery\DNS\Tests;

use PHPUnit\Framework\TestCase;
use yswery\DNS\Decoder;
use yswery\DNS\Encoder;
use yswery\DNS\RdataDecoder;
use yswery\DNS\RdataEncoder;
use yswery\DNS\RecordTypeEnum;
use yswery\DNS\ResourceRecord;
use PHPUnit\Framework\TestCase;
use yswery\DNS\RdataDecoder;

class DecoderTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/DummyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace yswery\DNS\Tests;

use yswery\DNS\RecordTypeEnum;
use yswery\DNS\ResourceRecord;
use yswery\DNS\Resolver\ResolverInterface;
use yswery\DNS\ResourceRecord;

class DummyResolver implements ResolverInterface
{
Expand Down
4 changes: 2 additions & 2 deletions tests/EncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace yswery\DNS\Tests;

use PHPUnit\Framework\TestCase;
use yswery\DNS\ClassEnum;
use yswery\DNS\Encoder;
use yswery\DNS\Header;
use yswery\DNS\RdataEncoder;
use yswery\DNS\RecordTypeEnum;
use yswery\DNS\ResourceRecord;
use yswery\DNS\RdataEncoder;
use PHPUnit\Framework\TestCase;

class EncoderTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Resolver/JsonResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace yswery\DNS\Tests\Resolver;

use yswery\DNS\RecordTypeEnum;
use yswery\DNS\Resolver\JsonResolver;
use yswery\DNS\ResourceRecord;
use yswery\DNS\RecordTypeEnum;

class JsonResolverTest extends AbstractResolverTest
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Resolver/YamlResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
namespace yswery\DNS\Tests\Resolver;

use Symfony\Component\Yaml\Exception\ParseException;
use yswery\DNS\RecordTypeEnum;
use yswery\DNS\Resolver\YamlResolver;
use yswery\DNS\ResourceRecord;
use yswery\DNS\RecordTypeEnum;

class YamlResolverTest extends AbstractResolverTest
{
Expand Down
6 changes: 3 additions & 3 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

namespace yswery\DNS\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use yswery\DNS\ClassEnum;
use yswery\DNS\Decoder;
use yswery\DNS\Encoder;
use yswery\DNS\Header;
use yswery\DNS\Message;
use yswery\DNS\RecordTypeEnum;
use yswery\DNS\Encoder;
use yswery\DNS\Resolver\JsonResolver;
use yswery\DNS\Resolver\StackableResolver;
use yswery\DNS\Resolver\XmlResolver;
use yswery\DNS\ResourceRecord;
use yswery\DNS\Server;
use yswery\DNS\Resolver\JsonResolver;
use PHPUnit\Framework\TestCase;

class ServerTest extends TestCase
{
Expand Down

0 comments on commit 7b65b03

Please sign in to comment.