-
-
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.
[CodeQuality] Skip Child class of \DateTime on DateTimeToDateTimeInte…
…rfaceRector (#703) * Add failing test fixture for DateTimeToDateTimeInterfaceRector Relates to #6641 * Change order of namespace and imports Previous one was generated by Rector's Demo. Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com> * Do not force \DateTimeInterface for args based on \DateTime child classes * Rename fixture file name * Add more tests for skipping refactorization Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
- Loading branch information
1 parent
91ac830
commit c1b7a97
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...ity/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector/Fixture/skip_child_class.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,26 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector\Fixture; | ||
|
||
use DateTime as PhpDateTime; | ||
|
||
class DateTime extends PhpDateTime | ||
{ | ||
public function getDateTimeCustomFormat(): ?string | ||
{ | ||
return $this->format('Y-m-d H:i:s'); | ||
} | ||
} | ||
|
||
class Foo | ||
{ | ||
public static function bar(?DateTime $datetime) | ||
{ | ||
// ... | ||
} | ||
|
||
public static function baz(DateTime $datetime) | ||
{ | ||
// ... | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
.../Rector/ClassMethod/DateTimeToDateTimeInterfaceRector/Fixture/skip_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,12 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector\Fixture; | ||
|
||
use stdClass; | ||
|
||
class SkipDifferentType | ||
{ | ||
public static function run(stdClass $stdClass) | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...Quality/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector/Fixture/skip_no_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,10 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector\Fixture; | ||
|
||
class SkipNoType | ||
{ | ||
public static function run($param) | ||
{ | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...lity/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector/Fixture/skip_union_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,13 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector\Fixture; | ||
|
||
use DateTime; | ||
use DateTimeImmutable; | ||
|
||
class SkipUnionType | ||
{ | ||
public function run(DateTime|DateTimeImmutable $dateTime) | ||
{ | ||
} | ||
} |
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