-
-
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.
[Doctrine] Handle Partial removal annotation has annotation below on …
…RemoveRedundantDefaultPropertyAnnotationValuesRector (#2914) * [Doctrine] Handle Partial removal annotation has annotation below on RemoveRedundantDefaultPropertyAnnotationValuesRector * Fixed 🎉 * clean up
- Loading branch information
1 parent
a638a67
commit e5d9275
Showing
6 changed files
with
175 additions
and
29 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
32 changes: 32 additions & 0 deletions
32
tests/Issues/PartialValueDocblockRemoval/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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\PartialValueDocblockRemoval; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class AutoImportTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<array<string>> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/auto_import.php'; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...rtialValueDocblockRemoval/Fixture/partial_removal_annotation_has_annotation_below.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,75 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\PartialValueDocblockRemoval\Fixture; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use JMS\Serializer\Annotation\Expose; | ||
use JMS\Serializer\Annotation\Groups as JmsGroups; | ||
|
||
/** | ||
* @ORM\Entity() | ||
*/ | ||
class PartialRemovalAnnotationHasAnnotationBelow | ||
{ | ||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="name", type="string", length=255, nullable=false) | ||
* | ||
* @Expose | ||
* @JmsGroups({"list", "details"}) | ||
*/ | ||
private $name; | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name): self | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\PartialValueDocblockRemoval\Fixture; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use JMS\Serializer\Annotation\Expose; | ||
use JMS\Serializer\Annotation\Groups as JmsGroups; | ||
|
||
/** | ||
* @ORM\Entity() | ||
*/ | ||
class PartialRemovalAnnotationHasAnnotationBelow | ||
{ | ||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="name", type="string", length=255) | ||
* | ||
* @Expose | ||
* @JmsGroups({"list", "details"}) | ||
*/ | ||
private $name; | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name): self | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
} | ||
|
||
?> |
32 changes: 32 additions & 0 deletions
32
tests/Issues/PartialValueDocblockRemoval/PartialValueDocblockRemovalTest.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\PartialValueDocblockRemoval; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class PartialValueDocblockRemovalTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<array<string>> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/Issues/PartialValueDocblockRemoval/config/auto_import.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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Doctrine\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->importNames(); | ||
$rectorConfig->rule(RemoveRedundantDefaultPropertyAnnotationValuesRector::class); | ||
}; |
10 changes: 10 additions & 0 deletions
10
tests/Issues/PartialValueDocblockRemoval/config/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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Doctrine\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(RemoveRedundantDefaultPropertyAnnotationValuesRector::class); | ||
}; |