-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php80] Doc mirror var to param improvement on ClassPropertyAssignToC…
…onstructorPromotionRector (#1775) * [Php80] Doc mirror var to param improvement on ClassPropertyAssignToConstructorPromotionRector * [ci-review] Rector Rectify * move to constant for re-use dead use detection * [ci-review] Rector Rectify * add failing fixture for auto import copy annotation * implemented copy on auto import Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
63425ba
commit 50d1978
Showing
7 changed files
with
155 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ts/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector/AutoImportTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class AutoImportTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImport'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/auto_import_configured_rule.php'; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ss_/ClassPropertyAssignToConstructorPromotionRector/Fixture/copy_array_string_doc.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\Fixture; | ||
|
||
final class CopyArrayStringDoc | ||
{ | ||
/** | ||
* Comment | ||
* @var string[] | ||
*/ | ||
private array $map; | ||
|
||
public function __construct(array $map) | ||
{ | ||
$this->map = $map; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\Fixture; | ||
|
||
final class CopyArrayStringDoc | ||
{ | ||
/** | ||
* @param string[] $map | ||
*/ | ||
public function __construct( | ||
/** | ||
* Comment | ||
*/ | ||
private array $map | ||
) | ||
{ | ||
} | ||
} | ||
|
||
?> |
49 changes: 49 additions & 0 deletions
49
...ConstructorPromotionRector/FixtureAutoImport/copy_annotation_and_array_string_doc.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureAutoImport; | ||
|
||
use Symfony\Component\Serializer\Annotation\SerializedName; | ||
|
||
class CopyAnnotationAndArrayStringDoc | ||
{ | ||
/** | ||
* @var string[] | ||
* @SerializedName("owsy/derived-facts") | ||
*/ | ||
private array $derivedFacts; | ||
|
||
public function __construct( | ||
array $derivedFacts = [], | ||
) { | ||
$this->derivedFacts = $derivedFacts; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureAutoImport; | ||
|
||
use Symfony\Component\Serializer\Annotation\SerializedName; | ||
|
||
class CopyAnnotationAndArrayStringDoc | ||
{ | ||
/** | ||
* @param string[] $derivedFacts | ||
*/ | ||
public function __construct( | ||
/** | ||
* @SerializedName("owsy/derived-facts") | ||
*/ | ||
private array $derivedFacts = [] | ||
) | ||
{ | ||
} | ||
} | ||
|
||
?> |
15 changes: 15 additions & 0 deletions
15
...s_/ClassPropertyAssignToConstructorPromotionRector/config/auto_import_configured_rule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Core\Configuration\Option; | ||
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set(Option::AUTO_IMPORT_NAMES, true); | ||
|
||
$services = $containerConfigurator->services(); | ||
$services->set(ClassPropertyAssignToConstructorPromotionRector::class); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters