Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[default.extend-words]
Symplify = "Symplify"

# plurals
Identicals = "Identicals"
24 changes: 24 additions & 0 deletions .github/workflows/typos.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]"
with:
config: .github/typos.toml
files: "README.md src rules tests"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rules/CodingStyle/ValueObject/ObjectMagicMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class ObjectMagicMethods
MethodName::CLONE,
MethodName::CONSTRUCT,
'__debugInfo',
MethodName::DESCTRUCT,
MethodName::DESTRUCT,
'__get',
MethodName::INVOKE,
'__isset',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions rules/Privatization/TypeManipulator/TypeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/RenamedClassesDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should be safe, as we use them only internally while running rule tests.

{
/**
* @var array<string, string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rector\Contract\DependencyInjection;

interface ResetableInterface
interface ResettableInterface
{
public function reset(): void;
}
8 changes: 4 additions & 4 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -451,9 +451,9 @@ static function (Container $container): DynamicSourceLocatorProvider {
}
);

// resetables
$rectorConfig->tag(DynamicSourceLocatorProvider::class, ResetableInterface::class);
$rectorConfig->tag(RenamedClassesDataCollector::class, ResetableInterface::class);
// resettable
$rectorConfig->tag(DynamicSourceLocatorProvider::class, ResettableInterface::class);
$rectorConfig->tag(RenamedClassesDataCollector::class, ResettableInterface::class);

// caching
$rectorConfig->singleton(Cache::class, static function (Container $container): Cache {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
4 changes: 2 additions & 2 deletions src/PostRector/Application/PostFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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[]
Expand Down
12 changes: 6 additions & 6 deletions src/Testing/PHPUnit/AbstractRectorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,12 +77,12 @@ protected function setUp(): void

if (! isset(self::$cacheByRuleAndConfig[$cacheKey])) {
// reset
/** @var RewindableGenerator<int, ResetableInterface> $resetables */
$resetables = $rectorConfig->tagged(ResetableInterface::class);
/** @var RewindableGenerator<int, ResettableInterface> $resettables */
$resettables = $rectorConfig->tagged(ResettableInterface::class);

foreach ($resetables as $resetable) {
/** @var ResetableInterface $resetable */
$resetable->reset();
foreach ($resettables as $resettable) {
/** @var ResettableInterface $resettable */
$resettable->reset();
}

$this->forgetRectorsRules();
Expand Down
2 changes: 1 addition & 1 deletion src/ValueObject/MethodName.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class MethodName
/**
* @var string
*/
public const DESCTRUCT = '__destruct';
public const DESTRUCT = '__destruct';

/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/**
* @foor a,
* @foo a,
*/
4 changes: 2 additions & 2 deletions tests/Issues/PropertyPromoNeverReturn/Fixture/fixture.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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';
},
];
}
Expand All @@ -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';
},
];
}
Expand Down