diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4413b88..26006ce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,7 @@ name: Tests on: [ push, pull_request ] jobs: - build: + unit: runs-on: ubuntu-latest strategy: @@ -30,3 +30,25 @@ jobs: - name: Execute tests run: composer test + + type: + runs-on: ubuntu-latest + + name: Type Coverage + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv + coverage: xdebug + + - name: Install dependencies + run: composer update + + - name: Execute tests + run: composer lint:type diff --git a/composer.json b/composer.json index b1444c8..a26f7de 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "orchestra/testbench": "^9.0 || ^10.0", "pestphp/pest": "^3.0 || ^4.0", "pestphp/pest-plugin-laravel": "^3.0 || ^4.0", + "pestphp/pest-plugin-type-coverage": "^3.0 || ^4.0", "symfony/var-dumper": "^7.3" }, "minimum-stability": "stable", @@ -69,6 +70,7 @@ ], "build": "@php vendor/bin/testbench workbench:build --ansi", "clear": "@php vendor/bin/testbench package:purge-skeleton --ansi", + "lint:type": "@php vendor/bin/pest --type-coverage --compact --min=95", "migrate": "@php vendor/bin/testbench migrate:fresh --seed --ansi", "prepare": "@php vendor/bin/testbench package:discover --ansi", "style": "vendor/bin/pint --parallel --ansi", diff --git a/src/Console/Commands/FeedInfoMakeCommand.php b/src/Console/Commands/FeedInfoMakeCommand.php index 213bddd..eb17614 100644 --- a/src/Console/Commands/FeedInfoMakeCommand.php +++ b/src/Console/Commands/FeedInfoMakeCommand.php @@ -21,7 +21,7 @@ protected function getStub(): string return __DIR__ . '/../../../stubs/feed_info.stub'; } - protected function getDefaultNamespace($rootNamespace): string + protected function getDefaultNamespace($rootNamespace): string // @pest-ignore-type { return $rootNamespace . '\Feeds\Info'; } diff --git a/src/Console/Commands/FeedItemMakeCommand.php b/src/Console/Commands/FeedItemMakeCommand.php index d15746b..1b6549f 100644 --- a/src/Console/Commands/FeedItemMakeCommand.php +++ b/src/Console/Commands/FeedItemMakeCommand.php @@ -21,7 +21,7 @@ protected function getStub(): string return __DIR__ . '/../../../stubs/feed_item.stub'; } - protected function getDefaultNamespace($rootNamespace): string + protected function getDefaultNamespace($rootNamespace): string // @pest-ignore-type { return $rootNamespace . '\Feeds\Items'; } diff --git a/src/Console/Commands/FeedMakeCommand.php b/src/Console/Commands/FeedMakeCommand.php index cce1bd7..55174c5 100644 --- a/src/Console/Commands/FeedMakeCommand.php +++ b/src/Console/Commands/FeedMakeCommand.php @@ -80,7 +80,7 @@ protected function getStub(): string return __DIR__ . '/../../../stubs/feed.stub'; } - protected function getDefaultNamespace($rootNamespace): string + protected function getDefaultNamespace($rootNamespace): string // @pest-ignore-type { return $rootNamespace . '\Feeds'; } diff --git a/src/Converters/ConvertToXml.php b/src/Converters/ConvertToXml.php index ed6bc74..4a557eb 100644 --- a/src/Converters/ConvertToXml.php +++ b/src/Converters/ConvertToXml.php @@ -128,7 +128,7 @@ protected function setMixed(DOMNode $element, string $value): void $element->appendChild($fragment); } - protected function setItemsArray(DOMNode $parent, $value, string $key): void + protected function setItemsArray(DOMNode $parent, array $value, string $key): void { $key = Str::substr($key, 1); diff --git a/src/Services/Filesystem.php b/src/Services/Filesystem.php index f7bcb4d..46314e9 100644 --- a/src/Services/Filesystem.php +++ b/src/Services/Filesystem.php @@ -24,7 +24,7 @@ public function __construct( /** * @return resource */ - public function open(string $path) + public function open(string $path) // @pest-ignore-type { $path = $this->draft($path); @@ -43,7 +43,7 @@ public function open(string $path) /** * @param resource $resource */ - public function append($resource, string $content, string $path): void + public function append($resource, string $content, string $path): void // @pest-ignore-type { if (blank($content)) { return; @@ -57,7 +57,7 @@ public function append($resource, string $content, string $path): void /** * @param resource $resource */ - public function release($resource, string $path): void + public function release($resource, string $path): void // @pest-ignore-type { $this->close($resource); @@ -74,7 +74,7 @@ public function release($resource, string $path): void /** * @param resource $resource */ - public function close($resource): void + public function close($resource): void // @pest-ignore-type { if (! is_resource($resource)) { return; diff --git a/src/Services/Generator.php b/src/Services/Generator.php index 25ebea6..2cb2fd5 100644 --- a/src/Services/Generator.php +++ b/src/Services/Generator.php @@ -41,7 +41,7 @@ public function feed(Feed $feed): void $this->setLastActivity($feed); } - protected function performItem($file, Feed $feed): void + protected function performItem($file, Feed $feed): void // @pest-ignore-type { $feed->builder()->chunkById($feed->chunkSize(), function (Collection $models) use ($file, $feed) { $content = []; @@ -56,12 +56,12 @@ protected function performItem($file, Feed $feed): void }); } - protected function performHeader($file, Feed $feed): void + protected function performHeader($file, Feed $feed): void // @pest-ignore-type { $this->append($file, $feed->header(), $feed->path()); } - protected function performInfo($file, Feed $feed): void + protected function performInfo($file, Feed $feed): void // @pest-ignore-type { if (blank($info = $feed->info()->toArray())) { return; @@ -72,7 +72,7 @@ protected function performInfo($file, Feed $feed): void $this->append($file, PHP_EOL . $value, $feed->path()); } - protected function performRoot($file, Feed $feed): void + protected function performRoot($file, Feed $feed): void // @pest-ignore-type { if (! $name = $feed->root()->name) { return; @@ -85,7 +85,7 @@ protected function performRoot($file, Feed $feed): void $this->append($file, $value, $feed->path()); } - protected function performFooter($file, Feed $feed): void + protected function performFooter($file, Feed $feed): void // @pest-ignore-type { $value = ''; @@ -105,17 +105,17 @@ protected function makeRootAttributes(ElementData $item): string ->implode(' '); } - protected function append($file, string $content, string $path): void + protected function append($file, string $content, string $path): void // @pest-ignore-type { $this->filesystem->append($file, $content, $path); } - protected function release($file, string $path): void + protected function release($file, string $path): void // @pest-ignore-type { $this->filesystem->release($file, $path); } - protected function openFile(string $path) + protected function openFile(string $path) // @pest-ignore-type { return $this->filesystem->open($path); }