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
25 changes: 23 additions & 2 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 404 Rules Overview
# 405 Rules Overview

<br>

Expand Down Expand Up @@ -64,7 +64,7 @@

- [Transform](#transform) (34)

- [TypeDeclaration](#typedeclaration) (32)
- [TypeDeclaration](#typedeclaration) (33)

- [Visibility](#visibility) (3)

Expand Down Expand Up @@ -8869,6 +8869,27 @@ return static function (RectorConfig $rectorConfig): void {

<br>

### AddParamTypeFromPropertyTypeRector

Adds param type declaration based on property type the value is assigned to PHPUnit provider return type declaration

- class: [`Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector`](../rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php)

```diff
final class SomeClass
{
private string $name;

- public function setName($name)
+ public function setName(string $name)
{
$this->name = $name;
}
}
```

<br>

### AddParamTypeSplFixedArrayRector

Add exact fixed array type in known cases
Expand Down
2 changes: 2 additions & 0 deletions config/set/type-declaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeBasedOnPHPUnitDataProviderRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector;
Expand Down Expand Up @@ -64,5 +65,6 @@
ParamTypeByParentCallTypeRector::class,
AddParamTypeSplFixedArrayRector::class,
AddParamTypeBasedOnPHPUnitDataProviderRector::class,
AddParamTypeFromPropertyTypeRector::class,
]);
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;

use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class PropertyTypeParamTypeDeclarationRectorTest extends AbstractRectorTestCase
final class AddParamTypeFromPropertyTypeRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
Expand All @@ -17,13 +17,16 @@ public function test(string $filePath): void
$this->doTestFile($filePath);
}

/**
* @return Iterator<array<string>>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/FixturePropertyType');
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/typed_properties.php';
return __DIR__ . '/config/configured_rule.php';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector\Fixture;

final class SomeClass
{
private int $number;

public function setValue($number)
{
$this->number = $number;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector\Fixture;

final class SomeClass
{
private int $number;

public function setValue(int $number)
{
$this->number = $number;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector\Fixture;

final class NullableProperty
{
/**
* @var int[]|null
*/
public ?array $bar;

public function setBar($bar): void
{
$this->bar = $bar;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector\Fixture;

final class NullableProperty
{
/**
* @var int[]|null
*/
public ?array $bar;

public function setBar(?array $bar): void
{
$this->bar = $bar;
}
}

?>
Loading