-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Experiment] Rework child classes detection on DynamicSourceLocatorPr…
…ovider (#5735) * [Experiment] Rework child classes detection on DynamicSourceLocatorProvider * trigger by locate by identifier type * fix test * cs fix * collect classes * Trigger collect clases collection * clean up calls * only run on non-phpunit * Fix test * added back FamilyRelationsAnalyzer::getChildrenOfClassReflection() * cs fix * add fixture to skip change abstract method, with child different type * Fix * final touch: allow collect classes on OptimizedSingleFileSourceLocator on non-phpunit env * final touch: future note: comment * final touch: no need to collect classes on phpunit env * final touch: future note for infinite loop reason * final touch: rollback TestModifyReprintTest * final touch: clean up * really final touch: clean up * final touch: no need to collect class on single file locator * Really final touch: make reflectionProvider nullable to avoid BC break on usage * final touch: comment * Really final touch: add e2e test for proof * Really final touch: inject by PHPStanServicesFactory * final touch: use autowire() for consistency * really final touch: early create IdentifierType object before loop * final touch: cs fix
- Loading branch information
1 parent
8281a06
commit 9bcded0
Showing
11 changed files
with
198 additions
and
3 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
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 @@ | ||
/vendor |
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,7 @@ | ||
{ | ||
"require": { | ||
"php": "^8.1" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector; | ||
use Rector\ValueObject\PhpVersionFeature; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(ReturnTypeFromReturnNewRector::class); | ||
$rectorConfig->phpVersion(PhpVersionFeature::STATIC_RETURN_TYPE); | ||
$rectorConfig->paths([__DIR__ . '/src']); | ||
}; |
11 changes: 11 additions & 0 deletions
11
e2e/skip-add-return-has-child/src/SkipChangeAbstractMethodDifferentType.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 | ||
|
||
namespace App; | ||
|
||
abstract class SkipChangeAbstractMethodDifferentType | ||
{ | ||
public function run() | ||
{ | ||
return new static(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
e2e/skip-add-return-has-child/src/SkipChangeAbstractMethodDifferentTypeChild.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 | ||
|
||
namespace App; | ||
|
||
class SkipChangeAbstractMethodDifferentTypeChild extends SkipChangeAbstractMethodDifferentType | ||
{ | ||
public function run(): string | ||
{ | ||
return 'a'; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../ReturnTypeFromReturnNewRector/Fixture/skip_change_abstract_method_different_type.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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture; | ||
|
||
abstract class SkipChangeAbstractMethodDifferentType | ||
{ | ||
public function run() | ||
{ | ||
return new static(); | ||
} | ||
} | ||
|
||
class SkipChangeAbstractMethodDifferentTypeChild extends SkipChangeAbstractMethodDifferentType | ||
{ | ||
public function run(): string | ||
{ | ||
return 'a'; | ||
} | ||
} |
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
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