Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeDeclarations] Add IncreaseDeclareStrictTypesRector to raise level of declare() coverage #5849

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Apr 30, 2024

This rule helps with increasing strict declares in your code, in the amount you define per run.

use Rector\TypeDeclaration\Rector\StmtsAwareInterface\IncreaseDeclareStrictTypesRector;

return RectorConfig::configure()
    ->withConfiguredRule(IncreaseDeclareStrictTypesRector::class, [
        'limit' => 10,
    ]);

This configuration will add declare(strict_types=1) to 10 new files per Rector run. Then CI will report feedback and show, if files need type fixes.

The idea is to improve code coverage in gradual, safe and steady way, as any type change could be very sensistive.
See https://tomasvotruba.com/blog/master-the-change for more


Use only manually with combination of cusotm PHPStan rule 🙂
TomasVotruba/type-coverage#35

@TomasVotruba TomasVotruba marked this pull request as draft April 30, 2024 11:24
@TomasVotruba TomasVotruba force-pushed the tv-add-increase-declares-rule branch 2 times, most recently from 2cc9ca1 to 891d60d Compare April 30, 2024 13:05
@TomasVotruba TomasVotruba marked this pull request as ready for review April 30, 2024 13:06
@TomasVotruba TomasVotruba enabled auto-merge (squash) April 30, 2024 13:21
@TomasVotruba TomasVotruba merged commit 57275ef into main Apr 30, 2024
42 checks passed
@TomasVotruba TomasVotruba deleted the tv-add-increase-declares-rule branch April 30, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants