From 70d8d470418506aeda3842ab98253776a5b8bddd Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 27 Nov 2025 12:01:46 +0100 Subject: [PATCH 1/5] [ci] add typos workflow --- .github/typos.toml | 2 ++ .github/workflows/typos.yaml | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .github/typos.toml create mode 100644 .github/workflows/typos.yaml diff --git a/.github/typos.toml b/.github/typos.toml new file mode 100644 index 00000000000..5ad1e587539 --- /dev/null +++ b/.github/typos.toml @@ -0,0 +1,2 @@ +[default.extend-words] +Symplify = "Symplify" diff --git a/.github/workflows/typos.yaml b/.github/workflows/typos.yaml new file mode 100644 index 00000000000..0d3b61e0994 --- /dev/null +++ b/.github/workflows/typos.yaml @@ -0,0 +1,24 @@ +# see https://github.com/crate-ci/typos +name: "Typos" + +on: + pull_request: + push: + branches: + - "main" + +jobs: + typos: + name: "Check for typos" + runs-on: "ubuntu-latest" + + steps: + - uses: actions/checkout@v4 + + + + - name: "Check for typos" + uses: "crate-ci/typos@v1.40.0" + with: + config: .github/typos.toml + files: "README.md src rules tests" From 7b23dd25d071cd91fccea8980ef661a202fb8c0b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 27 Nov 2025 12:13:47 +0100 Subject: [PATCH 2/5] fix resettable typo --- src/Config/RectorConfig.php | 4 ++-- src/Configuration/RenamedClassesDataCollector.php | 4 ++-- .../{ResetableInterface.php => ResettableInterface.php} | 2 +- src/DependencyInjection/LazyContainerFactory.php | 6 +++--- .../DynamicSourceLocatorProvider.php | 4 ++-- src/PostRector/Application/PostFileProcessor.php | 4 ++-- src/Testing/PHPUnit/AbstractRectorTestCase.php | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) rename src/Contract/DependencyInjection/{ResetableInterface.php => ResettableInterface.php} (80%) diff --git a/src/Config/RectorConfig.php b/src/Config/RectorConfig.php index 19b361e6f2c..ccd3d748ee5 100644 --- a/src/Config/RectorConfig.php +++ b/src/Config/RectorConfig.php @@ -10,7 +10,7 @@ use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Configuration\RectorConfigBuilder; use Rector\Contract\DependencyInjection\RelatedConfigInterface; -use Rector\Contract\DependencyInjection\ResetableInterface; +use Rector\Contract\DependencyInjection\ResettableInterface; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Contract\Rector\RectorInterface; use Rector\DependencyInjection\Laravel\ContainerMemento; @@ -38,7 +38,7 @@ final class RectorConfig extends Container /** * @var string[] */ - private array $autotagInterfaces = [Command::class, ResetableInterface::class]; + private array $autotagInterfaces = [Command::class, ResettableInterface::class]; private static ?bool $recreated = null; diff --git a/src/Configuration/RenamedClassesDataCollector.php b/src/Configuration/RenamedClassesDataCollector.php index bb8b79d2e87..93ee93cef56 100644 --- a/src/Configuration/RenamedClassesDataCollector.php +++ b/src/Configuration/RenamedClassesDataCollector.php @@ -5,9 +5,9 @@ namespace Rector\Configuration; use PHPStan\Type\ObjectType; -use Rector\Contract\DependencyInjection\ResetableInterface; +use Rector\Contract\DependencyInjection\ResettableInterface; -final class RenamedClassesDataCollector implements ResetableInterface +final class RenamedClassesDataCollector implements ResettableInterface { /** * @var array diff --git a/src/Contract/DependencyInjection/ResetableInterface.php b/src/Contract/DependencyInjection/ResettableInterface.php similarity index 80% rename from src/Contract/DependencyInjection/ResetableInterface.php rename to src/Contract/DependencyInjection/ResettableInterface.php index d8780cb3bf7..ecf8810a33e 100644 --- a/src/Contract/DependencyInjection/ResetableInterface.php +++ b/src/Contract/DependencyInjection/ResettableInterface.php @@ -4,7 +4,7 @@ namespace Rector\Contract\DependencyInjection; -interface ResetableInterface +interface ResettableInterface { public function reset(): void; } diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 89a743cf712..4b2bccf4330 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -64,7 +64,7 @@ use Rector\Console\Output\OutputFormatterCollector; use Rector\Console\Style\RectorStyle; use Rector\Console\Style\SymfonyStyleFactory; -use Rector\Contract\DependencyInjection\ResetableInterface; +use Rector\Contract\DependencyInjection\ResettableInterface; use Rector\Contract\PhpParser\DecoratingNodeVisitorInterface; use Rector\Contract\Rector\RectorInterface; use Rector\NodeDecorator\CreatedByRuleDecorator; @@ -452,8 +452,8 @@ static function (Container $container): DynamicSourceLocatorProvider { ); // resetables - $rectorConfig->tag(DynamicSourceLocatorProvider::class, ResetableInterface::class); - $rectorConfig->tag(RenamedClassesDataCollector::class, ResetableInterface::class); + $rectorConfig->tag(DynamicSourceLocatorProvider::class, ResettableInterface::class); + $rectorConfig->tag(RenamedClassesDataCollector::class, ResettableInterface::class); // caching $rectorConfig->singleton(Cache::class, static function (Container $container): Cache { diff --git a/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php b/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php index 309fdf820d9..d1e6a4b135b 100644 --- a/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php +++ b/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php @@ -9,13 +9,13 @@ use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher; use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocatorFactory; use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator; -use Rector\Contract\DependencyInjection\ResetableInterface; +use Rector\Contract\DependencyInjection\ResettableInterface; use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment; /** * @api phpstan external */ -final class DynamicSourceLocatorProvider implements ResetableInterface +final class DynamicSourceLocatorProvider implements ResettableInterface { /** * @var string[] diff --git a/src/PostRector/Application/PostFileProcessor.php b/src/PostRector/Application/PostFileProcessor.php index 945c8292f14..52f6733344c 100644 --- a/src/PostRector/Application/PostFileProcessor.php +++ b/src/PostRector/Application/PostFileProcessor.php @@ -9,7 +9,7 @@ use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Configuration\RenamedClassesDataCollector; -use Rector\Contract\DependencyInjection\ResetableInterface; +use Rector\Contract\DependencyInjection\ResettableInterface; use Rector\PostRector\Contract\Rector\PostRectorInterface; use Rector\PostRector\Rector\ClassRenamingPostRector; use Rector\PostRector\Rector\DocblockNameImportingPostRector; @@ -20,7 +20,7 @@ use Rector\Skipper\Skipper\Skipper; use Rector\ValueObject\Application\File; -final class PostFileProcessor implements ResetableInterface +final class PostFileProcessor implements ResettableInterface { /** * @var PostRectorInterface[] diff --git a/src/Testing/PHPUnit/AbstractRectorTestCase.php b/src/Testing/PHPUnit/AbstractRectorTestCase.php index 9bb8f088fd5..b50be2c9ee2 100644 --- a/src/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/src/Testing/PHPUnit/AbstractRectorTestCase.php @@ -15,7 +15,7 @@ use Rector\Configuration\ConfigurationFactory; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; -use Rector\Contract\DependencyInjection\ResetableInterface; +use Rector\Contract\DependencyInjection\ResettableInterface; use Rector\Contract\Rector\RectorInterface; use Rector\DependencyInjection\Laravel\ContainerMemento; use Rector\Exception\ShouldNotHappenException; @@ -77,11 +77,11 @@ protected function setUp(): void if (! isset(self::$cacheByRuleAndConfig[$cacheKey])) { // reset - /** @var RewindableGenerator $resetables */ - $resetables = $rectorConfig->tagged(ResetableInterface::class); + /** @var RewindableGenerator $resetables */ + $resetables = $rectorConfig->tagged(ResettableInterface::class); foreach ($resetables as $resetable) { - /** @var ResetableInterface $resetable */ + /** @var ResettableInterface $resetable */ $resetable->reset(); } From 665a58e579e80a09dd607ce4960104639f8bf02b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 27 Nov 2025 12:14:00 +0100 Subject: [PATCH 3/5] lenght typo --- rules/Privatization/TypeManipulator/TypeNormalizer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/Privatization/TypeManipulator/TypeNormalizer.php b/rules/Privatization/TypeManipulator/TypeNormalizer.php index eaf46f1254f..40de76c4bad 100644 --- a/rules/Privatization/TypeManipulator/TypeNormalizer.php +++ b/rules/Privatization/TypeManipulator/TypeNormalizer.php @@ -31,7 +31,7 @@ /** * @var int */ - private const MAX_PRINTED_UNION_DOC_LENGHT = 77; + private const MAX_PRINTED_UNION_DOC_LENGTH = 77; public function __construct( private TypeFactory $typeFactory, @@ -146,7 +146,7 @@ public function generalizeConstantTypes(Type $type): Type // too long if (strlen( (string) $unionedDocType - ) > self::MAX_PRINTED_UNION_DOC_LENGHT && $this->avoidPrintedDocblockTrimming( + ) > self::MAX_PRINTED_UNION_DOC_LENGTH && $this->avoidPrintedDocblockTrimming( $generalizedUnionType ) === false) { $alwaysKnownArrayType = $this->narrowToAlwaysKnownArrayType($generalizedUnionType); From 340aed5f2b251ead9f48a50dddf44d421902661f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 27 Nov 2025 12:14:18 +0100 Subject: [PATCH 4/5] destruct typo --- rules/CodingStyle/ValueObject/ObjectMagicMethods.php | 2 +- .../AddReturnTypeDeclarationBasedOnParentClassMethodRector.php | 2 +- src/ValueObject/MethodName.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rules/CodingStyle/ValueObject/ObjectMagicMethods.php b/rules/CodingStyle/ValueObject/ObjectMagicMethods.php index 2785a7fe3f9..c12d3686028 100644 --- a/rules/CodingStyle/ValueObject/ObjectMagicMethods.php +++ b/rules/CodingStyle/ValueObject/ObjectMagicMethods.php @@ -17,7 +17,7 @@ final class ObjectMagicMethods MethodName::CLONE, MethodName::CONSTRUCT, '__debugInfo', - MethodName::DESCTRUCT, + MethodName::DESTRUCT, '__get', MethodName::INVOKE, '__isset', diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php index e1f5dc75f35..aa96bd590b5 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php @@ -93,7 +93,7 @@ public function refactor(Node $node): ?Node $hasChanged = false; foreach ($node->getMethods() as $classMethod) { - if ($this->isNames($classMethod, [MethodName::CONSTRUCT, MethodName::DESCTRUCT])) { + if ($this->isNames($classMethod, [MethodName::CONSTRUCT, MethodName::DESTRUCT])) { continue; } diff --git a/src/ValueObject/MethodName.php b/src/ValueObject/MethodName.php index 357507b6508..7bd3daf4faa 100644 --- a/src/ValueObject/MethodName.php +++ b/src/ValueObject/MethodName.php @@ -28,7 +28,7 @@ final class MethodName /** * @var string */ - public const DESCTRUCT = '__destruct'; + public const DESTRUCT = '__destruct'; /** * @var string From 847d20cc47221fa2da52ec21ec42a5da73f258a6 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 27 Nov 2025 12:14:36 +0100 Subject: [PATCH 5/5] fix neeeded typo --- .github/typos.toml | 3 +++ .../Equal/UseIdenticalOverEqualWithSameTypeRector.php | 8 ++++---- .../LogicalAnd/AndAssignsToSeparateLinesRector.php | 2 +- .../LNumber/AddLiteralSeparatorToNumberRector.php | 2 +- src/DependencyInjection/LazyContainerFactory.php | 2 +- src/Testing/PHPUnit/AbstractRectorTestCase.php | 10 +++++----- .../PhpDocInfoPrinter/FixtureBasic/minimal.txt | 2 +- .../PropertyPromoNeverReturn/Fixture/fixture.php.inc | 4 ++-- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/typos.toml b/.github/typos.toml index 5ad1e587539..4ffe548d3fc 100644 --- a/.github/typos.toml +++ b/.github/typos.toml @@ -1,2 +1,5 @@ [default.extend-words] Symplify = "Symplify" + +# plurals +Identicals = "Identicals" diff --git a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php index a257acd8c5e..3a4722e4ced 100644 --- a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php +++ b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php @@ -99,17 +99,17 @@ public function refactor(Node $node): ?Node private function hasObjectType(Type $type): bool { - $hasObjecType = false; - TypeTraverser::map($type, function (Type $type, callable $traverseCallback) use (&$hasObjecType): Type { + $hasObjectType = false; + TypeTraverser::map($type, function (Type $type, callable $traverseCallback) use (&$hasObjectType): Type { // maybe has object type? mark as object type if (! $type->isObject()->no()) { - $hasObjecType = true; + $hasObjectType = true; } return $traverseCallback($type); }); - return $hasObjecType; + return $hasObjectType; } private function normalizeScalarType(Type $type): Type diff --git a/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php b/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php index 45206c58263..99aa7e084d1 100644 --- a/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php +++ b/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php @@ -19,7 +19,7 @@ final class AndAssignsToSeparateLinesRector extends AbstractRector { public function getRuleDefinition(): RuleDefinition { - return new RuleDefinition('Split 2 assigns with ands to separate line', [ + return new RuleDefinition('Split 2 assigns with "and" to separate lines', [ new CodeSample( <<<'CODE_SAMPLE' class SomeClass diff --git a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php index 6a1cf811c53..f4c73e70146 100644 --- a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php +++ b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php @@ -20,7 +20,7 @@ * Taking the most generic use case to the account: https://wiki.php.net/rfc/numeric_literal_separator#should_it_be_the_role_of_an_ide_to_group_digits * The final check should be done manually * - * @deprecated as opinionated and group size depends on context. Cannot be automated. Use manually where neeeded instead. + * @deprecated as opinionated and group size depends on context. Cannot be automated. Use manually where needed instead. */ final class AddLiteralSeparatorToNumberRector extends AbstractRector implements MinPhpVersionInterface, ConfigurableRectorInterface, DeprecatedInterface { diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 4b2bccf4330..7eb88fb8228 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -451,7 +451,7 @@ static function (Container $container): DynamicSourceLocatorProvider { } ); - // resetables + // resettable $rectorConfig->tag(DynamicSourceLocatorProvider::class, ResettableInterface::class); $rectorConfig->tag(RenamedClassesDataCollector::class, ResettableInterface::class); diff --git a/src/Testing/PHPUnit/AbstractRectorTestCase.php b/src/Testing/PHPUnit/AbstractRectorTestCase.php index b50be2c9ee2..490b0401d37 100644 --- a/src/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/src/Testing/PHPUnit/AbstractRectorTestCase.php @@ -77,12 +77,12 @@ protected function setUp(): void if (! isset(self::$cacheByRuleAndConfig[$cacheKey])) { // reset - /** @var RewindableGenerator $resetables */ - $resetables = $rectorConfig->tagged(ResettableInterface::class); + /** @var RewindableGenerator $resettables */ + $resettables = $rectorConfig->tagged(ResettableInterface::class); - foreach ($resetables as $resetable) { - /** @var ResettableInterface $resetable */ - $resetable->reset(); + foreach ($resettables as $resettable) { + /** @var ResettableInterface $resettable */ + $resettable->reset(); } $this->forgetRectorsRules(); diff --git a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/FixtureBasic/minimal.txt b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/FixtureBasic/minimal.txt index 9b0829d0fcd..faf504046d5 100644 --- a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/FixtureBasic/minimal.txt +++ b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/FixtureBasic/minimal.txt @@ -1,3 +1,3 @@ /** - * @foor a, + * @foo a, */ diff --git a/tests/Issues/PropertyPromoNeverReturn/Fixture/fixture.php.inc b/tests/Issues/PropertyPromoNeverReturn/Fixture/fixture.php.inc index 8226a542e09..9aa18fbf0ad 100644 --- a/tests/Issues/PropertyPromoNeverReturn/Fixture/fixture.php.inc +++ b/tests/Issues/PropertyPromoNeverReturn/Fixture/fixture.php.inc @@ -13,7 +13,7 @@ class Fixture $this->rules = [ 'chave' => function ($value) { - return is_string($value) ? true : 'deve ser uma string'; + return is_string($value) ? true : 'not string'; }, ]; } @@ -33,7 +33,7 @@ class Fixture { $this->rules = [ 'chave' => function ($value) { - return is_string($value) ? true : 'deve ser uma string'; + return is_string($value) ? true : 'not string'; }, ]; }