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
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
// typeDeclarationDocblocks: true,
privatization: true,
naming: true,
instanceOf: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function test(string $filePath, array $expectedShortNames): void
$this->assertSame($expectedShortNames, $shortNames);
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideData(): Iterator
{
yield [__DIR__ . '/Fixture/various_imports.php.inc', [
Expand Down
3 changes: 3 additions & 0 deletions rules-tests/Naming/Naming/PropertyNamingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function testPropertyName(string $objectName, string $expectedVariableNam
$this->assertSame($expectedVariableName, $variableName);
}

/**
* @return Iterator<array<int, string>>
*/
public static function provideDataPropertyName(): Iterator
{
yield ['SomeVariable', 'someVariable'];
Expand Down
3 changes: 2 additions & 1 deletion rules/Privatization/TypeManipulator/TypeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\Privatization\TypeManipulator;

use PHPStan\Type\Accessory\AccessoryLiteralStringType;
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
use PHPStan\Type\ArrayType;
use PHPStan\Type\BooleanType;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function generalizeConstantBoolTypes(Type $type): Type
public function generalizeConstantTypes(Type $type): Type
{
return TypeTraverser::map($type, function (Type $type, callable $traverseCallback): Type {
if ($type instanceof AccessoryNonFalsyStringType || $type instanceof AccessoryLiteralStringType) {
if ($type instanceof AccessoryNonFalsyStringType || $type instanceof AccessoryLiteralStringType || $type instanceof AccessoryNonEmptyStringType) {
return new StringType();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public function testClass(string $docFilePath, string $className): void
$this->assertSame($docComment, $printedPhpDocInfo);
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideDataClass(): Iterator
{
yield [__DIR__ . '/Source/Doctrine/index_in_table.txt', IndexInTable::class];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public function test(string $docContent, array $expectedArrayItemNodes): void
$this->assertEquals($expectedArrayItemNodes, $arrayItemNodes);
}

/**
* @return Iterator<array<int, (array<int, ArrayItemNode>|string)>>
*/
public static function provideData(): Iterator
{
yield ['{key: "value"}', [new ArrayItemNode(new StringNode('value'), 'key')]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function test(string $docContent, CurlyListNode | array $expectedValue):
$this->assertEquals($expectedValue, $value);
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideData(): Iterator
{
$curlyListNode = new CurlyListNode([
Expand Down
3 changes: 3 additions & 0 deletions tests/FileSystem/FilePathHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public function test(string $inputPath, string $expectedNormalizedPath): void
$this->assertSame($expectedNormalizedPath, $normalizedPath);
}

/**
* @return Iterator<array<int, string>>
*/
public static function provideData(): Iterator
{
// based on Linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function testResolveForForeach(string $currentName, string $expectedSingu
$this->assertSame($expectedSingularName, $singularValue);
}

/**
* @return Iterator<array<int, string>>
*/
public static function provideData(): Iterator
{
yield ['psr4NamespacesToPaths', 'psr4NamespaceToPath'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function test(string $file, int $nodePosition, string $expectedType): voi
$this->assertSame($resolvedType::class, $expectedType);
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideData(): Iterator
{
yield [__DIR__ . '/Source/MethodParamTypeHint.php', 0, FullyQualifiedObjectType::class];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public function test(string $file, int $nodePosition, Type $expectedType): void
$this->assertSame($expectedTypeAsString, $resolvedTypeAsString);
}

/**
* @return Iterator<array<int, (int|ObjectType|UnionType|string)>>
*/
public static function provideData(): Iterator
{
yield [__DIR__ . '/Source/MethodParamDocBlock.php', 0, new ObjectType(Html::class)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function test(string $file, int $nodePosition, TypeWithClassName $expecte
$this->assertSame($expectedTypeWithClassName->getClassName(), $resolvedType->getClassName());
}

/**
* @return Iterator<array<int, (int|ObjectType|string)>>
*/
public static function provideData(): Iterator
{
$anotherTypeObjectType = new ObjectType(AnotherType::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function testMapPHPStanPhpDocTypeNodeToPHPStanType(TypeNode $typeNode, st
$this->assertInstanceOf($expectedType, $phpStanType);
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideData(): Iterator
{
$genericTypeNode = new GenericTypeNode(new IdentifierTypeNode('Traversable'), []);
Expand Down Expand Up @@ -85,6 +88,9 @@ public function testMapPhpParserNodePHPStanType(Node $node, string $expectedType
$this->assertInstanceOf($expectedType, $phpStanType);
}

/**
* @return Iterator<array<int, (class-string<IterableType>|Identifier)>>
*/
public static function provideDataForMapPhpParserNodePHPStanType(): Iterator
{
yield [new Identifier('iterable'), IterableType::class];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public static function provideDataWithoutKeys(): Iterator
yield [$arrayType, 'string[]'];
}

/**
* @return Iterator<array<int, (ArrayType|string)>>
*/
public static function provideDataUnionedWithoutKeys(): Iterator
{
$stringAndIntegerUnionType = new UnionType([new StringType(), new IntegerType()]);
Expand All @@ -66,6 +69,9 @@ public static function provideDataUnionedWithoutKeys(): Iterator
yield [$evenMoreNestedUnionArrayType, 'string[][][]|int[][][]'];
}

/**
* @return Iterator<array<int, (ArrayType|string)>>
*/
public static function provideDataWithKeys(): Iterator
{
$arrayMixedToStringType = new ArrayType(new MixedType(), new StringType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function test(mixed $input, string $expectedTypeClass): void
}
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideData(): Iterator
{
yield [false, ConstFetch::class];
Expand Down
3 changes: 3 additions & 0 deletions tests/PhpAttribute/UseAliasNameMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public function test(
$this->assertSame($expectedAttributeUseImportName, $useAliasMetadata->getUseImportName());
}

/**
* @return Iterator<array<int, (AnnotationToAttribute|string)>>
*/
public static function provideData(): Iterator
{
yield [
Expand Down
3 changes: 3 additions & 0 deletions tests/PhpParser/Printer/BetterStandardPrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public function testYield(Node $node, string $expectedPrintedNode): void
$this->assertSame($expectedPrintedNode, $printedNode);
}

/**
* @return Iterator<array<int, (Yield_|Expression|string)>>
*/
public static function provideDataForYield(): Iterator
{
$yield = new Yield_(new String_('value'));
Expand Down
3 changes: 3 additions & 0 deletions tests/Set/SetManager/SetManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function testByVersion(string $projectDirectory, array $expectedSets): vo
$this->assertSame($expectedSets, $composerTriggeredSets);
}

/**
* @return Iterator<(array<int, array<bool>>|array<int, array<int, bool>>|array<int, array<int, string>>|array<int, string>)>
*/
public static function provideInstalledTwigData(): Iterator
{
// here we cannot used features coming up in 2.4, as we only have 2.0
Expand Down
3 changes: 3 additions & 0 deletions tests/Skipper/FileSystem/FnMatchPathNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function testPaths(string $path, string $expectedNormalizedPath): void
$this->assertSame($expectedNormalizedPath, $normalizedPath);
}

/**
* @return Iterator<array<int, string>>
*/
public static function providePaths(): Iterator
{
yield ['path/with/no/asterisk', 'path/with/no/asterisk'];
Expand Down
6 changes: 6 additions & 0 deletions tests/Skipper/Skipper/SkipperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public function testSkipElementAndFilePath(string $element, string $filePath, bo
$this->assertSame($expectedSkip, $resolvedSkip);
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideCheckerAndFile(): Iterator
{
yield [FifthElement::class, __DIR__ . '/Fixture', true];
Expand All @@ -97,6 +100,9 @@ public static function provideCheckerAndFile(): Iterator
yield [NotSkippedClass::class, __DIR__ . '/Fixture/someOtherFile', false];
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideDataShouldSkipElement(): Iterator
{
yield [ThreeMan::class, false];
Expand Down
3 changes: 3 additions & 0 deletions tests/Util/Reflection/PrivatesAccessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function test(
$this->assertSame($expectedResult, $result);
}

/**
* @return Iterator<array<array<int, mixed>, mixed>>
*/
public static function provideData(): Iterator
{
yield [SomeClassWithPrivateMethods::class, 'getNumber', [], 5];
Expand Down
3 changes: 3 additions & 0 deletions tests/Validation/RectorAssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public function testInvalidFunctionName(string $functionName): void
RectorAssert::functionName($functionName);
}

/**
* @return Iterator<array<int, string>>
*/
public static function provideDataInvalidFunctionNames(): Iterator
{
yield ['35'];
Expand Down
Loading