-
-
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.
[Php80] Add $object::class support on GetDebugTypeRector (#3039)
* [Php80] Add $object::class support already on GetDebugTypeRector * implemented 🎉 * Final touch: clean up and add more fixtures * Really Final touch: clean up, values identical already checked in areValuesIdentical() method * Really final touch: method rename
- Loading branch information
1 parent
10346ee
commit 10c6a30
Showing
4 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
rules-tests/Php80/Rector/Ternary/GetDebugTypeRector/Fixture/class_const_fetch_if.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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Ternary\GetDebugTypeRector\Fixture; | ||
|
||
class ClassConstFetchClass | ||
{ | ||
public function run($value) | ||
{ | ||
return is_object($value) ? $value::class : gettype($value); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Ternary\GetDebugTypeRector\Fixture; | ||
|
||
class ClassConstFetchClass | ||
{ | ||
public function run($value) | ||
{ | ||
return get_debug_type($value); | ||
} | ||
} | ||
|
||
?> |
11 changes: 11 additions & 0 deletions
11
...ector/Ternary/GetDebugTypeRector/Fixture/skip_class_const_fetch_if_different_name.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,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Ternary\GetDebugTypeRector\Fixture; | ||
|
||
class SkipClassConstFetchIfDifferentName | ||
{ | ||
public function run($value) | ||
{ | ||
return is_object($value) ? $value::SOME_CONSTANT : gettype($value); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...tor/Ternary/GetDebugTypeRector/Fixture/skip_class_const_fetch_if_different_object.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,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Ternary\GetDebugTypeRector\Fixture; | ||
|
||
class SkipClassConstFetchIfDifferentObject | ||
{ | ||
public function run($value, $differentObject) | ||
{ | ||
return is_object($value) ? $differentObject::class : gettype($value); | ||
} | ||
} |
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