-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AutoImport] Handle DeclareStrictTypesRector on importNames() enabled…
… on no namespace (#5241) * [AutoImport] Handle DeclareStrictTypesRector on importNames() enabled * update fixture * update fixture * update fixture * Fix * Fix
- Loading branch information
1 parent
2f74b02
commit 7e7304b
Showing
5 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...ts/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector/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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class AutoImportTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImport'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/auto_import_configured_rule.php'; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ector/StmtsAwareInterface/DeclareStrictTypesRector/FixtureAutoImport/no_namespace.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,15 @@ | ||
<?php | ||
|
||
// no namespace on purpose to reproduce issue | ||
\Foo\Bar::BAZ; | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Foo\Bar; | ||
|
||
// no namespace on purpose to reproduce issue | ||
Bar::BAZ; |
16 changes: 16 additions & 0 deletions
16
...tor/StmtsAwareInterface/DeclareStrictTypesRector/FixtureAutoImport/with_namespace.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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector\FixtureAutoImport; | ||
|
||
\Foo\Bar::BAZ; | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector\FixtureAutoImport; | ||
|
||
use Foo\Bar; | ||
Bar::BAZ; |
11 changes: 11 additions & 0 deletions
11
...ector/StmtsAwareInterface/DeclareStrictTypesRector/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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->importNames(); | ||
$rectorConfig->rule(DeclareStrictTypesRector::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