diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index f797866..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms -github: tomasvotruba -custom: https://www.paypal.me/rectorphp diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml deleted file mode 100644 index 75afe49..0000000 --- a/.github/workflows/code_analysis.yaml +++ /dev/null @@ -1,45 +0,0 @@ -name: Code Analysis - -on: - pull_request: null - push: - branches: - - main - -jobs: - code_analysis: - strategy: - fail-fast: false - matrix: - actions: - - - name: 'PHPStan' - run: composer phpstan --ansi - - - - name: 'Composer Validate' - run: composer validate --ansi - - - - name: 'Coding Standard' - run: composer fix-cs --ansi - - - - name: 'Tests' - run: vendor/bin/phpunit - - name: ${{ matrix.actions.name }} - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - # see https://github.com/shivammathur/setup-php - - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - coverage: none - - # composer install cache - https://github.com/ramsey/composer-install - - uses: "ramsey/composer-install@v2" - - - run: ${{ matrix.actions.run }} diff --git a/.github/workflows/downgraded_release.yaml b/.github/workflows/downgraded_release.yaml deleted file mode 100644 index 816abeb..0000000 --- a/.github/workflows/downgraded_release.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: Downgraded Release - -on: - push: - tags: - - '*' - -jobs: - downgrade_release: - runs-on: ubuntu-latest - - steps: - - uses: "actions/checkout@v2" - - - - uses: "shivammathur/setup-php@v2" - with: - php-version: 8.2 - coverage: none - - - uses: "ramsey/composer-install@v2" - - # downgrade /src to PHP 7.2 - - run: vendor/bin/rector process src --config build/rector-downgrade-php-72.php --ansi - - run: vendor/bin/ecs check src --fix --ansi - - # copy PHP 7.2 composer - - run: cp build/composer-php-72.json composer.json - - # clear the dev files - - run: rm -rf build .github tests stubs ecs.php phpstan.neon phpunit.xml - - # setup git user - - - run: | - git config user.email "action@github.com" - git config user.name "GitHub Action" - - # publish to the same repository with a new tag - - - name: "Tag Downgraded Code" - run: | - # separate a "git add" to add untracked (new) files too - git add --all - git commit -m "release PHP 7.2 downgraded" - - # force push tag, so there is only 1 version - git tag "${GITHUB_REF#refs/tags/}" --force - git push origin "${GITHUB_REF#refs/tags/}" --force diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml deleted file mode 100644 index 419fb7f..0000000 --- a/.github/workflows/rector.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# github action that checks code with Rector -name: Rector - -on: - pull_request: null - -jobs: - rector: - runs-on: ubuntu-latest - if: github.event.pull_request.head.repo.full_name == 'TomasVotruba/type-coverage' - steps: - - - if: github.event.pull_request.head.repo.full_name == github.repository - uses: actions/checkout@v3 - with: - # Must be used to trigger workflow after push - token: ${{ secrets.ACCESS_TOKEN }} - - - - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - coverage: none - - - uses: "ramsey/composer-install@v2" - - - run: vendor/bin/rector --ansi - - - - # commit only to core contributors who have repository access - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: '[rector] Rector fixes' - commit_author: 'GitHub Action ' - commit_user_email: 'action@github.com' diff --git a/.github/workflows/various_php_install.yaml b/.github/workflows/various_php_install.yaml deleted file mode 100644 index 5c669e6..0000000 --- a/.github/workflows/various_php_install.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Various PHP Install - -on: - push: - branches: - - main - -jobs: - various_php_install: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php: - - 7.2 - - 8.0 - - 8.1 - - name: "Install on PHP ${{ matrix.php }}" - - steps: - - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - - run: composer require tomasvotruba/type-coverage --dev --ansi diff --git a/build/composer-php-72.json b/build/composer-php-72.json deleted file mode 100644 index cb512c5..0000000 --- a/build/composer-php-72.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "tomasvotruba/type-coverage", - "type": "phpstan-extension", - "description": "Measure type coverage of your project", - "license": "MIT", - "keywords": ["static analysis", "phpstan-extension"], - "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.9.3", - "nette/utils": "^3.2 || ^4.0" - }, - "autoload": { - "psr-4": { - "TomasVotruba\\TypeCoverage\\": "src" - } - }, - "extra": { - "phpstan": { - "includes": [ - "config/extension.neon" - ] - } - } -} diff --git a/build/rector-downgrade-php-72.php b/build/rector-downgrade-php-72.php deleted file mode 100644 index 5550cff..0000000 --- a/build/rector-downgrade-php-72.php +++ /dev/null @@ -1,10 +0,0 @@ -sets([DowngradeLevelSetList::DOWN_TO_PHP_72]); -}; diff --git a/composer.json b/composer.json index b526bc4..cb512c5 100644 --- a/composer.json +++ b/composer.json @@ -5,39 +5,15 @@ "license": "MIT", "keywords": ["static analysis", "phpstan-extension"], "require": { - "php": "^8.2", - "phpstan/phpstan": "^1.10.67" - }, - "require-dev": { - "phpstan/extension-installer": "^1.3", - "phpunit/phpunit": "^10.5", - "symplify/easy-coding-standard": "^12.1", - "rector/rector": "^1.0.4", - "tracy/tracy": "^2.10", - "tomasvotruba/unused-public": "^0.2" + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.3", + "nette/utils": "^3.2 || ^4.0" }, "autoload": { "psr-4": { "TomasVotruba\\TypeCoverage\\": "src" } }, - "autoload-dev": { - "psr-4": { - "TomasVotruba\\TypeCoverage\\Tests\\": "tests" - } - }, - "scripts": { - "check-cs": "vendor/bin/ecs check --ansi", - "fix-cs": "vendor/bin/ecs check --fix --ansi", - "phpstan": "vendor/bin/phpstan --ansi", - "rector": "vendor/bin/rector --dry-run --ansi", - "release": "vendor/bin/monorepo-builder release patch --ansi" - }, - "config": { - "allow-plugins": { - "phpstan/extension-installer": true - } - }, "extra": { "phpstan": { "includes": [ diff --git a/ecs.php b/ecs.php deleted file mode 100644 index 0fc134c..0000000 --- a/ecs.php +++ /dev/null @@ -1,14 +0,0 @@ -withPaths([__DIR__ . '/src', __DIR__ . '/tests']) - ->withSkip([ - // these fixtures use PHP 8.3 features, we cannot check them wit lower versions - __DIR__ . '/tests/Rules/ConstantTypeCoverageRule/Fixture/SkipKnownConstantType.php', - __DIR__ . '/tests/Rules/ConstantTypeCoverageRule/Fixture/UnknownConstantType.php', - ]) - ->withPreparedSets(common: true, psr12: true, cleanCode: true, symplify: true); diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index d123cd1..0000000 --- a/phpstan.neon +++ /dev/null @@ -1,29 +0,0 @@ -includes: - - config/extension.neon - -parameters: - level: 8 - - paths: - - src - - tests - - type_coverage: - # coverage - declare: 100 - - # type declarations - return_type: 99.9 - param_type: 100 - property_type: 100 - constant_type: 0 # requires PHP 8.3 - - # only show final data, no error report - # measure: true - - ignoreErrors: - - identifier: missingType.generics - - excludePaths: - - "*/Fixture/*" - - "*/Source/*" diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index b109cf5..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - tests - - diff --git a/src/Collectors/ParamTypeDeclarationCollector.php b/src/Collectors/ParamTypeDeclarationCollector.php index 4761534..a9d4a49 100644 --- a/src/Collectors/ParamTypeDeclarationCollector.php +++ b/src/Collectors/ParamTypeDeclarationCollector.php @@ -67,6 +67,6 @@ private function hasFunctionLikeCallableParam(FunctionLike $functionLike): bool } $docCommentText = $docComment->getText(); - return str_contains($docCommentText, '@param callable'); + return strpos($docCommentText, '@param callable') !== false; } } diff --git a/src/Collectors/PropertyTypeDeclarationCollector.php b/src/Collectors/PropertyTypeDeclarationCollector.php index 3226448..893a60b 100644 --- a/src/Collectors/PropertyTypeDeclarationCollector.php +++ b/src/Collectors/PropertyTypeDeclarationCollector.php @@ -70,7 +70,7 @@ private function isPropertyDocTyped(Property $property): bool $docCommentText = $docComment->getText(); // skip as unable to type - return str_contains($docCommentText, 'callable') || str_contains($docCommentText, 'resource'); + return strpos($docCommentText, 'callable') !== false || strpos($docCommentText, 'resource') !== false; } private function isGuardedByParentClassProperty(Scope $scope, Property $property): bool diff --git a/src/Configuration.php b/src/Configuration.php index 77174e2..2751e55 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -4,17 +4,26 @@ namespace TomasVotruba\TypeCoverage; -final readonly class Configuration +final class Configuration { + /** + * @var array + * @readonly + */ + private $parameters; + /** * @param array $parameters */ - public function __construct( - private array $parameters - ) { + public function __construct(array $parameters) + { + $this->parameters = $parameters; } - public function getRequiredPropertyTypeLevel(): float|int + /** + * @return float|int + */ + public function getRequiredPropertyTypeLevel() { return $this->parameters['property'] ?? $this->parameters['property_type']; } @@ -28,22 +37,34 @@ public function isConstantTypeCoverageEnabled(): bool return $this->getRequiredConstantTypeLevel() > 0; } - public function getRequiredConstantTypeLevel(): float|int + /** + * @return float|int + */ + public function getRequiredConstantTypeLevel() { return $this->parameters['constant'] ?? $this->parameters['constant_type']; } - public function getRequiredParamTypeLevel(): float|int + /** + * @return float|int + */ + public function getRequiredParamTypeLevel() { return $this->parameters['param'] ?? $this->parameters['param_type']; } - public function getRequiredReturnTypeLevel(): float|int + /** + * @return float|int + */ + public function getRequiredReturnTypeLevel() { return $this->parameters['return'] ?? $this->parameters['return_type']; } - public function getRequiredDeclareLevel(): float|int + /** + * @return float|int + */ + public function getRequiredDeclareLevel() { return $this->parameters['declare']; } diff --git a/src/Formatter/TypeCoverageFormatter.php b/src/Formatter/TypeCoverageFormatter.php index 592a2d6..3086919 100644 --- a/src/Formatter/TypeCoverageFormatter.php +++ b/src/Formatter/TypeCoverageFormatter.php @@ -12,10 +12,11 @@ final class TypeCoverageFormatter { /** * @return RuleError[] + * @param float|int $minimalLevel */ public function formatErrors( string $message, - float|int $minimalLevel, + $minimalLevel, TypeCountAndMissingTypes $typeCountAndMissingTypes ): array { if ($typeCountAndMissingTypes->getTotalCount() === 0) { diff --git a/src/Rules/ConstantTypeCoverageRule.php b/src/Rules/ConstantTypeCoverageRule.php index d5aae5c..300dec3 100644 --- a/src/Rules/ConstantTypeCoverageRule.php +++ b/src/Rules/ConstantTypeCoverageRule.php @@ -18,18 +18,36 @@ * * @implements Rule */ -final readonly class ConstantTypeCoverageRule implements Rule +final class ConstantTypeCoverageRule implements Rule { /** * @var string */ public const ERROR_MESSAGE = 'Out of %d possible constant types, only %d - %.1f %% actually have it. Add more constant types to get over %s %%'; - public function __construct( - private TypeCoverageFormatter $typeCoverageFormatter, - private Configuration $configuration, - private CollectorDataNormalizer $collectorDataNormalizer, - ) { + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Formatter\TypeCoverageFormatter + */ + private $typeCoverageFormatter; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Configuration + */ + private $configuration; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\CollectorDataNormalizer + */ + private $collectorDataNormalizer; + + public function __construct(TypeCoverageFormatter $typeCoverageFormatter, Configuration $configuration, CollectorDataNormalizer $collectorDataNormalizer) + { + $this->typeCoverageFormatter = $typeCoverageFormatter; + $this->configuration = $configuration; + $this->collectorDataNormalizer = $collectorDataNormalizer; } /** diff --git a/src/Rules/DeclareCoverageRule.php b/src/Rules/DeclareCoverageRule.php index f96d4cc..4ed0af1 100644 --- a/src/Rules/DeclareCoverageRule.php +++ b/src/Rules/DeclareCoverageRule.php @@ -17,16 +17,22 @@ * * @implements Rule */ -final readonly class DeclareCoverageRule implements Rule +final class DeclareCoverageRule implements Rule { /** * @var string */ public const ERROR_MESSAGE = 'Out of %d possible declare(strict_types=1), only %d - %.1f %% actually have it. Add more declares to get over %s %%'; - public function __construct( - private Configuration $configuration, - ) { + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Configuration + */ + private $configuration; + + public function __construct(Configuration $configuration) + { + $this->configuration = $configuration; } /** @@ -94,7 +100,7 @@ public function processNode(Node $node, Scope $scope): array $totalPossibleDeclares, $coveredDeclares, $declareCoverage, - $requiredDeclareLevel, + $requiredDeclareLevel ); $ruleErrors[] = RuleErrorBuilder::message($errorMessage)->file($notCoveredDeclareFilePath)->build(); diff --git a/src/Rules/ParamTypeCoverageRule.php b/src/Rules/ParamTypeCoverageRule.php index 3223bd9..8aeba98 100644 --- a/src/Rules/ParamTypeCoverageRule.php +++ b/src/Rules/ParamTypeCoverageRule.php @@ -18,18 +18,36 @@ * * @implements Rule */ -final readonly class ParamTypeCoverageRule implements Rule +final class ParamTypeCoverageRule implements Rule { /** * @var string */ public const ERROR_MESSAGE = 'Out of %d possible param types, only %d - %.1f %% actually have it. Add more param types to get over %s %%'; - public function __construct( - private TypeCoverageFormatter $typeCoverageFormatter, - private Configuration $configuration, - private CollectorDataNormalizer $collectorDataNormalizer, - ) { + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Formatter\TypeCoverageFormatter + */ + private $typeCoverageFormatter; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Configuration + */ + private $configuration; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\CollectorDataNormalizer + */ + private $collectorDataNormalizer; + + public function __construct(TypeCoverageFormatter $typeCoverageFormatter, Configuration $configuration, CollectorDataNormalizer $collectorDataNormalizer) + { + $this->typeCoverageFormatter = $typeCoverageFormatter; + $this->configuration = $configuration; + $this->collectorDataNormalizer = $collectorDataNormalizer; } /** diff --git a/src/Rules/PropertyTypeCoverageRule.php b/src/Rules/PropertyTypeCoverageRule.php index 8c9c70c..e03a711 100644 --- a/src/Rules/PropertyTypeCoverageRule.php +++ b/src/Rules/PropertyTypeCoverageRule.php @@ -18,18 +18,36 @@ * * @implements Rule */ -final readonly class PropertyTypeCoverageRule implements Rule +final class PropertyTypeCoverageRule implements Rule { /** * @var string */ public const ERROR_MESSAGE = 'Out of %d possible property types, only %d - %.1f %% actually have it. Add more property types to get over %s %%'; - public function __construct( - private TypeCoverageFormatter $typeCoverageFormatter, - private Configuration $configuration, - private CollectorDataNormalizer $collectorDataNormalizer, - ) { + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Formatter\TypeCoverageFormatter + */ + private $typeCoverageFormatter; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Configuration + */ + private $configuration; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\CollectorDataNormalizer + */ + private $collectorDataNormalizer; + + public function __construct(TypeCoverageFormatter $typeCoverageFormatter, Configuration $configuration, CollectorDataNormalizer $collectorDataNormalizer) + { + $this->typeCoverageFormatter = $typeCoverageFormatter; + $this->configuration = $configuration; + $this->collectorDataNormalizer = $collectorDataNormalizer; } /** diff --git a/src/Rules/ReturnTypeCoverageRule.php b/src/Rules/ReturnTypeCoverageRule.php index 6cea6ec..1dee473 100644 --- a/src/Rules/ReturnTypeCoverageRule.php +++ b/src/Rules/ReturnTypeCoverageRule.php @@ -18,18 +18,36 @@ * * @implements Rule */ -final readonly class ReturnTypeCoverageRule implements Rule +final class ReturnTypeCoverageRule implements Rule { /** * @var string */ public const ERROR_MESSAGE = 'Out of %d possible return types, only %d - %.1f %% actually have it. Add more return types to get over %s %%'; - public function __construct( - private TypeCoverageFormatter $typeCoverageFormatter, - private Configuration $configuration, - private CollectorDataNormalizer $collectorDataNormalizer, - ) { + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Formatter\TypeCoverageFormatter + */ + private $typeCoverageFormatter; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\Configuration + */ + private $configuration; + + /** + * @readonly + * @var \TomasVotruba\TypeCoverage\CollectorDataNormalizer + */ + private $collectorDataNormalizer; + + public function __construct(TypeCoverageFormatter $typeCoverageFormatter, Configuration $configuration, CollectorDataNormalizer $collectorDataNormalizer) + { + $this->typeCoverageFormatter = $typeCoverageFormatter; + $this->configuration = $configuration; + $this->collectorDataNormalizer = $collectorDataNormalizer; } /** diff --git a/src/ValueObject/TypeCountAndMissingTypes.php b/src/ValueObject/TypeCountAndMissingTypes.php index 146294f..e279e61 100644 --- a/src/ValueObject/TypeCountAndMissingTypes.php +++ b/src/ValueObject/TypeCountAndMissingTypes.php @@ -4,16 +4,34 @@ namespace TomasVotruba\TypeCoverage\ValueObject; -final readonly class TypeCountAndMissingTypes +final class TypeCountAndMissingTypes { + /** + * @readonly + * @var int + */ + private $totalCount; + + /** + * @readonly + * @var int + */ + private $missingCount; + + /** + * @var array + * @readonly + */ + private $missingTypeLinesByFilePath; + /** * @param array $missingTypeLinesByFilePath */ - public function __construct( - private int $totalCount, - private int $missingCount, - private array $missingTypeLinesByFilePath - ) { + public function __construct(int $totalCount, int $missingCount, array $missingTypeLinesByFilePath) + { + $this->totalCount = $totalCount; + $this->missingCount = $missingCount; + $this->missingTypeLinesByFilePath = $missingTypeLinesByFilePath; } public function getTotalCount(): int diff --git a/tests/Rules/ConstantTypeCoverageRule/ConstantTypeCoverageRuleTest.php b/tests/Rules/ConstantTypeCoverageRule/ConstantTypeCoverageRuleTest.php deleted file mode 100644 index 721d23c..0000000 --- a/tests/Rules/ConstantTypeCoverageRule/ConstantTypeCoverageRuleTest.php +++ /dev/null @@ -1,64 +0,0 @@ -analyse($filePaths, $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - echo __METHOD__; - yield [[__DIR__ . '/Fixture/SkipKnownConstantType.php'], []]; - yield [[__DIR__ . '/Fixture/SkipParentBlockingConstant.php'], []]; - - $errorMessage = sprintf(ConstantTypeCoverageRule::ERROR_MESSAGE, 2, 1, 50.0, 80); - yield [[__DIR__ . '/Fixture/UnknownConstantType.php'], [[$errorMessage, 9]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ConstantTypeCoverageRule::class); - } - - /** - * @return Collector[] - */ - protected function getCollectors(): array - { - return [self::getContainer()->getByType(ConstantTypeDeclarationCollector::class)]; - } -} diff --git a/tests/Rules/ConstantTypeCoverageRule/Fixture/SkipKnownConstantType.php b/tests/Rules/ConstantTypeCoverageRule/Fixture/SkipKnownConstantType.php deleted file mode 100644 index 245cacb..0000000 --- a/tests/Rules/ConstantTypeCoverageRule/Fixture/SkipKnownConstantType.php +++ /dev/null @@ -1,10 +0,0 @@ -analyse($filePaths, $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - $expectedErrorMessage = sprintf(DeclareCoverageRule::ERROR_MESSAGE, 1, 0, 0.0, 50); - yield [[__DIR__ . '/Fixture/SomeFileWithoutDeclares.php'], [[$expectedErrorMessage, -1]]]; - yield [[__DIR__ . '/Fixture/SkipDeclareTicks.php'], [[$expectedErrorMessage, -1]]]; - yield [[__DIR__ . '/Fixture/SkipDeclareStrictTypesZero.php'], [[$expectedErrorMessage, -1]]]; - - yield [[__DIR__ . '/Fixture/DeclareCovered.php', __DIR__ . '/Fixture/SomeFileWithoutDeclares.php'], []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(DeclareCoverageRule::class); - } - - /** - * @return Collector[] - */ - protected function getCollectors(): array - { - return [self::getContainer()->getByType(DeclareCollector::class)]; - } -} diff --git a/tests/Rules/DeclareCoverageRule/Fixture/DeclareCovered.php b/tests/Rules/DeclareCoverageRule/Fixture/DeclareCovered.php deleted file mode 100644 index 774c223..0000000 --- a/tests/Rules/DeclareCoverageRule/Fixture/DeclareCovered.php +++ /dev/null @@ -1,9 +0,0 @@ -analyse($filePaths, $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [[__DIR__ . '/Fixture/SkipKnownParamType.php', __DIR__ . '/Fixture/SkipAgainKnownParamType.php'], []]; - yield [[__DIR__ . '/Fixture/SkipVariadic.php'], []]; - yield [[__DIR__ . '/Fixture/SkipCallableParam.php'], []]; - - $firstErrorMessage = sprintf(ParamTypeCoverageRule::ERROR_MESSAGE, 3, 1, 33.3, 80); - $thirdErrorMessage = sprintf(ParamTypeCoverageRule::ERROR_MESSAGE, 3, 1, 33.3, 80); - - yield [[__DIR__ . '/Fixture/UnknownParamType.php'], [[$firstErrorMessage, 9], [$thirdErrorMessage, 13]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ParamTypeCoverageRule::class); - } - - /** - * @return Collector[] - */ - protected function getCollectors(): array - { - return [self::getContainer()->getByType(ParamTypeDeclarationCollector::class)]; - } -} diff --git a/tests/Rules/ParamTypeCoverageRule/config/configured_rule.neon b/tests/Rules/ParamTypeCoverageRule/config/configured_rule.neon deleted file mode 100644 index cb6f27b..0000000 --- a/tests/Rules/ParamTypeCoverageRule/config/configured_rule.neon +++ /dev/null @@ -1,7 +0,0 @@ -includes: - - ../../../../config/extension.neon - -parameters: - type_coverage: - param_type: 80 - print_suggestions: false diff --git a/tests/Rules/PropertyTypeCoverageRule/Fixture/SkipCallableProperty.php b/tests/Rules/PropertyTypeCoverageRule/Fixture/SkipCallableProperty.php deleted file mode 100644 index 4699c5c..0000000 --- a/tests/Rules/PropertyTypeCoverageRule/Fixture/SkipCallableProperty.php +++ /dev/null @@ -1,13 +0,0 @@ -analyse($filePaths, $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [[__DIR__ . '/Fixture/SkipKnownPropertyType.php'], []]; - yield [[__DIR__ . '/Fixture/SkipCallableProperty.php'], []]; - yield [[__DIR__ . '/Fixture/SkipResource.php'], []]; - yield [[__DIR__ . '/Fixture/SkipParentBlockingProperty.php'], []]; - - $errorMessage = sprintf(PropertyTypeCoverageRule::ERROR_MESSAGE, 2, 1, 50.0, 80); - yield [[__DIR__ . '/Fixture/UnknownPropertyType.php'], [[$errorMessage, 9]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(PropertyTypeCoverageRule::class); - } - - /** - * @return Collector[] - */ - protected function getCollectors(): array - { - return [self::getContainer()->getByType(PropertyTypeDeclarationCollector::class)]; - } -} diff --git a/tests/Rules/PropertyTypeCoverageRule/Source/ParentBlockingClass.php b/tests/Rules/PropertyTypeCoverageRule/Source/ParentBlockingClass.php deleted file mode 100644 index d03161a..0000000 --- a/tests/Rules/PropertyTypeCoverageRule/Source/ParentBlockingClass.php +++ /dev/null @@ -1,10 +0,0 @@ -traitConstruct(); - } -} - -trait TraitWithConstructor -{ - public function __construct() - { - } -} diff --git a/tests/Rules/ReturnTypeCoverageRule/Fixture/UnknownReturnType.php b/tests/Rules/ReturnTypeCoverageRule/Fixture/UnknownReturnType.php deleted file mode 100644 index b004cf1..0000000 --- a/tests/Rules/ReturnTypeCoverageRule/Fixture/UnknownReturnType.php +++ /dev/null @@ -1,16 +0,0 @@ -analyse($filePaths, $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [[__DIR__ . '/Fixture/SkipKnownReturnType.php', __DIR__ . '/Fixture/SkipAgainKnownReturnType.php'], []]; - yield [[__DIR__ . '/Fixture/SkipConstructor.php'], []]; - yield [[__DIR__ . '/Fixture/SkipTraitConstructor.php'], []]; - - $errorMessage = sprintf(ReturnTypeCoverageRule::ERROR_MESSAGE, 2, 0, 0, 80); - yield [[__DIR__ . '/Fixture/UnknownReturnType.php'], [[$errorMessage, 9], [$errorMessage, 13]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/config/configured_rule.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ReturnTypeCoverageRule::class); - } - - /** - * @return Collector[] - */ - protected function getCollectors(): array - { - return [self::getContainer()->getByType(ReturnTypeDeclarationCollector::class)]; - } -} diff --git a/tests/Rules/ReturnTypeCoverageRule/config/configured_rule.neon b/tests/Rules/ReturnTypeCoverageRule/config/configured_rule.neon deleted file mode 100644 index 227735b..0000000 --- a/tests/Rules/ReturnTypeCoverageRule/config/configured_rule.neon +++ /dev/null @@ -1,6 +0,0 @@ -includes: - - ../../../../config/extension.neon - -parameters: - type_coverage: - return_type: 80