From 4cd21c1993e5f36826609c40ab7de7c31b2deedf Mon Sep 17 00:00:00 2001 From: chthomas Date: Tue, 21 Dec 2021 20:53:46 -0500 Subject: [PATCH 1/2] style fix --- src/Entities/EntityAbstract.php | 1 - src/Entities/PTRData.php | 2 +- src/Exceptions/InvalidArgumentException.php | 1 - src/Resolvers/Exceptions/QueryFailure.php | 1 - src/Resolvers/Exceptions/ReverseLookupFailure.php | 1 - src/Resolvers/Interfaces/ObservableResolver.php | 1 - tests/Unit/Entities/CAADataTest.php | 1 - 7 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Entities/EntityAbstract.php b/src/Entities/EntityAbstract.php index 86a5b21..1064b3f 100644 --- a/src/Entities/EntityAbstract.php +++ b/src/Entities/EntityAbstract.php @@ -4,5 +4,4 @@ abstract class EntityAbstract { - } diff --git a/src/Entities/PTRData.php b/src/Entities/PTRData.php index 2f86e9e..9873ec1 100644 --- a/src/Entities/PTRData.php +++ b/src/Entities/PTRData.php @@ -44,4 +44,4 @@ public function unserialize($serialized): void $unserialized = unserialize($serialized); $this->hostname = new Hostname($unserialized['hostname']); } -} \ No newline at end of file +} diff --git a/src/Exceptions/InvalidArgumentException.php b/src/Exceptions/InvalidArgumentException.php index 9f17737..973b7ec 100644 --- a/src/Exceptions/InvalidArgumentException.php +++ b/src/Exceptions/InvalidArgumentException.php @@ -4,5 +4,4 @@ final class InvalidArgumentException extends Exception { - } diff --git a/src/Resolvers/Exceptions/QueryFailure.php b/src/Resolvers/Exceptions/QueryFailure.php index a377df5..67fcdb0 100644 --- a/src/Resolvers/Exceptions/QueryFailure.php +++ b/src/Resolvers/Exceptions/QueryFailure.php @@ -6,5 +6,4 @@ class QueryFailure extends Exception { - } diff --git a/src/Resolvers/Exceptions/ReverseLookupFailure.php b/src/Resolvers/Exceptions/ReverseLookupFailure.php index 4f939c6..0b79f40 100644 --- a/src/Resolvers/Exceptions/ReverseLookupFailure.php +++ b/src/Resolvers/Exceptions/ReverseLookupFailure.php @@ -4,5 +4,4 @@ final class ReverseLookupFailure extends QueryFailure { - } diff --git a/src/Resolvers/Interfaces/ObservableResolver.php b/src/Resolvers/Interfaces/ObservableResolver.php index f899ea8..abaf224 100644 --- a/src/Resolvers/Interfaces/ObservableResolver.php +++ b/src/Resolvers/Interfaces/ObservableResolver.php @@ -7,5 +7,4 @@ interface ObservableResolver extends Resolver, Observable, LoggerAwareInterface { - } diff --git a/tests/Unit/Entities/CAADataTest.php b/tests/Unit/Entities/CAADataTest.php index 7a52a18..5202133 100644 --- a/tests/Unit/Entities/CAADataTest.php +++ b/tests/Unit/Entities/CAADataTest.php @@ -11,7 +11,6 @@ class CAADataTest extends BaseTestAbstract { - private $flags = 0; private $tag = 'issue'; From ee54ba7ccc190805ae1c7211947dd256c7664b11 Mon Sep 17 00:00:00 2001 From: chthomas Date: Tue, 21 Dec 2021 21:44:11 -0500 Subject: [PATCH 2/2] get ci happy --- .github/workflows/php-ci.yml | 2 +- Makefile | 2 +- composer.json | 2 +- phpstan.neon | 29 ---------------------------- rector.php | 8 ++++---- src/Entities/CNAMEData.php | 1 + src/Entities/DNSRecordCollection.php | 14 +++++++++++++- 7 files changed, 21 insertions(+), 37 deletions(-) diff --git a/.github/workflows/php-ci.yml b/.github/workflows/php-ci.yml index 384607d..d8910f1 100755 --- a/.github/workflows/php-ci.yml +++ b/.github/workflows/php-ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.4', '8.1'] + php-versions: ['7.4', '8.0'] name: PHP ${{ matrix.php-versions }} Test on Ubuntu steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 7cc0160..ac31e43 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ churn-report: @vendor/bin/churn run static-analysis: - @vendor/bin/phpstan analyze --level=max ./src && ./vendor/bin/psalm --show-info=false + @vendor/bin/phpstan analyze --level=8 ./src && ./vendor/bin/psalm --show-info=false style-fix: @vendor/bin/phpcbf --standard=PSR12 ./src ./tests diff --git a/composer.json b/composer.json index fa18eb7..2d8849e 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "php-coveralls/php-coveralls": "^2.1", "symfony/cache": "^4.3", "vimeo/psalm": "^4.10", - "rector/rector": "^0.11.58", + "rector/rector": "^0.12.8", "bmitch/churn-php": "^1.5" }, "autoload": { diff --git a/phpstan.neon b/phpstan.neon index 65d83d4..d572bb4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,32 +2,3 @@ parameters: checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false ignoreErrors: - - - message: "#^Method RemotelyLiving\\\\PHPDNS\\\\Entities\\\\DNSRecordCollection\\:\\:offsetExists\\(\\) has parameter \\$offset with no typehint specified\\.$#" - count: 1 - path: src/Entities/DNSRecordCollection.php - - - - message: "#^Method RemotelyLiving\\\\PHPDNS\\\\Entities\\\\DNSRecordCollection\\:\\:offsetGet\\(\\) has parameter \\$offset with no typehint specified\\.$#" - count: 1 - path: src/Entities/DNSRecordCollection.php - - - - message: "#^Method RemotelyLiving\\\\PHPDNS\\\\Entities\\\\DNSRecordCollection\\:\\:offsetSet\\(\\) has parameter \\$offset with no typehint specified\\.$#" - count: 1 - path: src/Entities/DNSRecordCollection.php - - - - message: "#^Method RemotelyLiving\\\\PHPDNS\\\\Entities\\\\DNSRecordCollection\\:\\:offsetSet\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/Entities/DNSRecordCollection.php - - - - message: "#^Method RemotelyLiving\\\\PHPDNS\\\\Entities\\\\DNSRecordCollection\\:\\:offsetUnset\\(\\) has parameter \\$offset with no typehint specified\\.$#" - count: 1 - path: src/Entities/DNSRecordCollection.php - - - - message: "#^Variable \\$record in PHPDoc tag @var does not exist\\.$#" - count: 1 - path: src/Entities/DNSRecordCollection.php diff --git a/rector.php b/rector.php index 75d4d52..77893c7 100644 --- a/rector.php +++ b/rector.php @@ -4,7 +4,7 @@ use Rector\Core\Configuration\Option; use Rector\Php74\Rector\Property\TypedPropertyRector; -use Rector\Set\ValueObject\SetList; +use Rector\Set\ValueObject\LevelSetList; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { @@ -15,11 +15,11 @@ ]); // Define what rule sets will be applied - $containerConfigurator->import(SetList::DEAD_CODE); + $containerConfigurator->import(LevelSetList::UP_TO_PHP_81); // get services (needed for register a single rule) - // $services = $containerConfigurator->services(); + $services = $containerConfigurator->services(); // register a single rule - // $services->set(TypedPropertyRector::class); + $services->set(TypedPropertyRector::class); }; diff --git a/src/Entities/CNAMEData.php b/src/Entities/CNAMEData.php index ac978ae..6918b7f 100644 --- a/src/Entities/CNAMEData.php +++ b/src/Entities/CNAMEData.php @@ -41,6 +41,7 @@ public function serialize(): string */ public function unserialize($serialized): void { + /** @var array{'hostname': string} $unserialized */ $unserialized = unserialize($serialized); $this->hostname = new Hostname($unserialized['hostname']); } diff --git a/src/Entities/DNSRecordCollection.php b/src/Entities/DNSRecordCollection.php index c01b402..25f5a93 100644 --- a/src/Entities/DNSRecordCollection.php +++ b/src/Entities/DNSRecordCollection.php @@ -87,17 +87,27 @@ public function rewind(): void $this->records->rewind(); } + /** + * @param mixed $offset + * @return bool + */ public function offsetExists($offset): bool { return $this->records->offsetExists($offset); } + /** + * @param mixed $offset + * @return \RemotelyLiving\PHPDNS\Entities\Interfaces\DNSRecordInterface + */ public function offsetGet($offset): DNSRecordInterface { return $this->records->offsetGet($offset); } /** + * @param mixed $offset + * @param mixed $value * @throws \RemotelyLiving\PHPDNS\Exceptions\InvalidArgumentException */ public function offsetSet($offset, $value): void @@ -109,6 +119,9 @@ public function offsetSet($offset, $value): void $this->records->offsetSet($offset, /** @scrutinizer ignore-type */ $value); } + /** + * @param mixed $offset + */ public function offsetUnset($offset): void { $this->records->offsetUnset($offset); @@ -165,7 +178,6 @@ private function filterValues(callable $eval): self $filtered = new self(); $records = $this->records->getArrayCopy(); - /** @var \RemotelyLiving\PHPDNS\Entities\Interfaces\DNSRecordInterface $record */ while ($record = array_shift($records)) { if ($eval($record, new self(...$records))) { $filtered[] = $record;