From d6a3d9faa7e42ce9ea877916e37a095d13fd36c2 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 15 Jul 2019 14:59:42 +0200 Subject: [PATCH] phpcs fix --- examples/simple.php | 10 +++++----- lib/NativeDecoder.php | 15 +++++++-------- lib/NativeDecoderFactory.php | 7 ------- lib/NativeEncoder.php | 9 ++++----- lib/NativeEncoderFactory.php | 2 +- test/NativeDecoderTest.php | 18 +++++++++--------- test/NativeEncoderTest.php | 2 +- 7 files changed, 27 insertions(+), 36 deletions(-) diff --git a/examples/simple.php b/examples/simple.php index 58f545c..7dfca6b 100644 --- a/examples/simple.php +++ b/examples/simple.php @@ -1,10 +1,10 @@ add($question); $encoder = (new NativeEncoderFactory)->create(); $question = $encoder->encode($message); -$result = dns_get_record(...$question); +$result = \dns_get_record(...$question); $decoder = (new NativeDecoderFactory)->create(); $result = $decoder->decode($result, ...$question); -var_dump($result); +\var_dump($result); diff --git a/lib/NativeDecoder.php b/lib/NativeDecoder.php index 0a5b65d..5c6c26b 100644 --- a/lib/NativeDecoder.php +++ b/lib/NativeDecoder.php @@ -2,7 +2,6 @@ namespace danog\LibDNSNative; -use LibDNS\Decoder\Decoder; use LibDNS\Decoder\DecoderFactory; use LibDNS\Encoder\EncodingContext; use LibDNS\Encoder\EncodingContextFactory; @@ -50,7 +49,7 @@ class NativeDecoder private $decoderFactory; /** - * Map class names to IDs + * Map class names to IDs. * * @var array */ @@ -110,7 +109,7 @@ class NativeDecoder } /** - * Encode a question record + * Encode a question record. * * @param \LibDNS\Encoder\EncodingContext $encodingContext * @param \LibDNS\Records\Question $record @@ -132,7 +131,7 @@ class NativeDecoder } } /** - * Encode a DomainName field + * Encode a DomainName field. * * @param \LibDNS\Records\Types\DomainName $domainName * @param \LibDNS\Encoder\EncodingContext $encodingContext @@ -180,7 +179,7 @@ class NativeDecoder } /** - * Encode a resource record + * Encode a resource record. * * @param \LibDNS\Encoder\EncodingContext $encodingContext * @param array $record @@ -243,17 +242,17 @@ class NativeDecoder $this->encodeQuestionRecord($encodingContext, $domain, $type); - $expectedAnswers = count($result); + $expectedAnswers = \count($result); for ($i = 0; $i < $expectedAnswers; $i++) { $this->encodeResourceRecord($encodingContext, $result[$i]); } - $expectedAuth = count($authoritative); + $expectedAuth = \count($authoritative); for ($i = 0; $i < $expectedAuth; $i++) { $this->encodeResourceRecord($encodingContext, $authoritative[$i]); } - $expectedAdditional = count($additional); + $expectedAdditional = \count($additional); for ($i = 0; $i < $expectedAdditional; $i++) { $this->encodeResourceRecord($encodingContext, $additional[$i]); } diff --git a/lib/NativeDecoderFactory.php b/lib/NativeDecoderFactory.php index f50a2b8..4817b2c 100644 --- a/lib/NativeDecoderFactory.php +++ b/lib/NativeDecoderFactory.php @@ -9,17 +9,10 @@ namespace danog\LibDNSNative; -use LibDNS\Decoder\DecodingContextFactory; use \LibDNS\Messages\MessageFactory; use \LibDNS\Packets\PacketFactory; use \LibDNS\Records\QuestionFactory; -use \LibDNS\Records\RDataBuilder; -use \LibDNS\Records\RDataFactory; use \LibDNS\Records\RecordCollectionFactory; -use \LibDNS\Records\ResourceBuilder; -use \LibDNS\Records\ResourceFactory; -use \LibDNS\Records\TypeDefinitions\FieldDefinitionFactory; -use \LibDNS\Records\TypeDefinitions\TypeDefinitionFactory; use \LibDNS\Records\TypeDefinitions\TypeDefinitionManager; use \LibDNS\Records\Types\TypeBuilder; use \LibDNS\Records\Types\TypeFactory; diff --git a/lib/NativeEncoder.php b/lib/NativeEncoder.php index c4d0606..34f611b 100644 --- a/lib/NativeEncoder.php +++ b/lib/NativeEncoder.php @@ -1,4 +1,4 @@ -count() !== 1) { throw new \InvalidArgumentException('Invalid question: only one question record can be provided at a time'); } - + $question = $questions->getRecordByIndex(0); - + return [ \implode('.', $question->getName()->getLabels()), // Name $question->getType(), // Type diff --git a/lib/NativeEncoderFactory.php b/lib/NativeEncoderFactory.php index 47f2183..e2ad41b 100644 --- a/lib/NativeEncoderFactory.php +++ b/lib/NativeEncoderFactory.php @@ -1,4 +1,4 @@ - 'IN', 'ttl' => 3600, 'type' => 48, - 'data' => base64_decode('AQADDaCTEREs+ROIGM0v6ulw671NajD2CIwlsyWjmrvFzRGXqgmCg+Wq9CEXfCql1xSZKplX0bzBj5jNcfHxgGtl4Ug='), + 'data' => \base64_decode('AQADDaCTEREs+ROIGM0v6ulw671NajD2CIwlsyWjmrvFzRGXqgmCg+Wq9CEXfCql1xSZKplX0bzBj5jNcfHxgGtl4Ug='), ], [ @@ -46,7 +46,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 3600, 'type' => 48, - 'data' => base64_decode('AQEDDZnbLMFMq9wz1td9pjovFfcRElhPI06NHcQo456KSpfhqicaVV3JBwHhfipMS28SC3wy1E9KwCvYlM8tS+d3ihk='), + 'data' => \base64_decode('AQEDDZnbLMFMq9wz1td9pjovFfcRElhPI06NHcQo456KSpfhqicaVV3JBwHhfipMS28SC3wy1E9KwCvYlM8tS+d3ihk='), ], ], 'daniil.it', @@ -65,7 +65,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 2898, 'type' => 1, - 'data' => base64_decode('EazgLw=='), + 'data' => \base64_decode('EazgLw=='), ], [ @@ -73,7 +73,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 2898, 'type' => 1, - 'data' => base64_decode('EY6gOw=='), + 'data' => \base64_decode('EY6gOw=='), ], [ @@ -81,7 +81,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 2898, 'type' => 1, - 'data' => base64_decode('EbJgOw=='), + 'data' => \base64_decode('EbJgOw=='), ], ], 'apple.com', @@ -100,7 +100,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 166, 'type' => 1, - 'data' => base64_decode('aBgUIg=='), + 'data' => \base64_decode('aBgUIg=='), ], [ @@ -108,7 +108,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 166, 'type' => 1, - 'data' => base64_decode('aBgVIg=='), + 'data' => \base64_decode('aBgVIg=='), ], ], 'amphp.org', @@ -126,7 +126,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 282, 'type' => 5, - 'data' => base64_decode('A2docwxnb29nbGVob3N0ZWQDY29tAA=='), + 'data' => \base64_decode('A2docwxnb29nbGVob3N0ZWQDY29tAA=='), ], ], 'tssthacks.daniil.it', @@ -141,7 +141,7 @@ class NativeDecoderTest extends TestCase 'class' => 'IN', 'ttl' => 289, 'type' => 15, - 'data' => base64_decode('AAoCbXgGeWFuZGV4A25ldAA='), + 'data' => \base64_decode('AAoCbXgGeWFuZGV4A25ldAA='), ], ], 'daniil.it', diff --git a/test/NativeEncoderTest.php b/test/NativeEncoderTest.php index b35ead2..9f3de8c 100644 --- a/test/NativeEncoderTest.php +++ b/test/NativeEncoderTest.php @@ -5,8 +5,8 @@ namespace danog\LibDNSNative\Test; use danog\LibDNSNative\NativeDecoderFactory; use danog\LibDNSNative\NativeEncoderFactory; use LibDNS\Messages\MessageTypes; -use PHPUnit\Framework\TestCase; use LibDNS\Records\ResourceQTypes; +use PHPUnit\Framework\TestCase; class NativeEncoderTest extends TestCase {