-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php54][Php80] Handle no scope on LongArrayToShortArrayRector+Annotat…
…ionToAttributeRector (#2749) * [Php54][Php80] Handle no scope on LongArrayToShortArrayRector+AnnotationToAttributeRector * Fixed 🎉 * clean up * phpstan * phpstan * final touch: eol * cs fix
- Loading branch information
1 parent
a80b3d3
commit 93b63b0
Showing
4 changed files
with
92 additions
and
1 deletion.
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
tests/Issues/ScopeNotAvailable/ArrayAnnotationToAttributeTest.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\Core\Tests\Issues\ScopeNotAvailable; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class ArrayAnnotationToAttributeTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureArrayAnnotationToAttribute'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/array_annotation_to_attribute.php'; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/Issues/ScopeNotAvailable/FixtureArrayAnnotationToAttribute/array_in_attribute.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,38 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\FixtureArrayAnnotationToAttribute\Fixture; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
class ArrayInAttribtue | ||
{ | ||
public function __construct( | ||
/** | ||
* @ORM\ManyToOne(targetEntity=OfferPrice::class, inversedBy="myEntities", cascade={"persist"}) | ||
*/ | ||
private OfferPrice $offerPrice | ||
) | ||
{ | ||
} | ||
|
||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\FixtureArrayAnnotationToAttribute\Fixture; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
class ArrayInAttribtue | ||
{ | ||
public function __construct( | ||
#[ORM\ManyToOne(targetEntity: OfferPrice::class, inversedBy: 'myEntities', cascade: ['persist'])] private OfferPrice $offerPrice | ||
) | ||
{ | ||
} | ||
|
||
} | ||
|
||
?> |
16 changes: 16 additions & 0 deletions
16
tests/Issues/ScopeNotAvailable/config/array_annotation_to_attribute.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector; | ||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; | ||
use Rector\Php80\ValueObject\AnnotationToAttribute; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(LongArrayToShortArrayRector::class); | ||
|
||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ | ||
new AnnotationToAttribute('Doctrine\ORM\Mapping\ManyToOne'), | ||
]); | ||
}; |