-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support class-const-fetch in ReturnTypeFromStrictTypedCallRector (#4520)
* Support class-const-fetch in ReturnTypeFromStrictTypedCallRector * Create skip_unknown_constant_int_returns.php.inc * Update skip_unknown_constant_int_returns.php.inc * Create skip_wrong_typed_constant.php.inc * Create wrong_typed_constant_returns.php.inc
- Loading branch information
Showing
5 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...ethod/ReturnTypeFromStrictTypedCallRector/Fixture/same_typed_constant_int_returns.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,49 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class SameTypedIntConstantReturns | ||
{ | ||
const INT = 0; | ||
|
||
public function getData() | ||
{ | ||
if (rand(0,1)) { | ||
return self::INT; | ||
} | ||
|
||
return $this->getInt(); | ||
} | ||
|
||
public function getInt(): int | ||
{ | ||
|
||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class SameTypedIntConstantReturns | ||
{ | ||
const INT = 0; | ||
|
||
public function getData(): int | ||
{ | ||
if (rand(0,1)) { | ||
return self::INT; | ||
} | ||
|
||
return $this->getInt(); | ||
} | ||
|
||
public function getInt(): int | ||
{ | ||
|
||
} | ||
} | ||
|
||
?> |
22 changes: 22 additions & 0 deletions
22
...hod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_unknown_constant_int_returns.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class SkipUnknownConstantIntReturns | ||
{ | ||
public function getData() | ||
{ | ||
if (rand(0,1)) { | ||
return self::NOT_DEFINED; | ||
} | ||
|
||
return $this->getInt(); | ||
} | ||
|
||
public function getInt(): int | ||
{ | ||
|
||
} | ||
} | ||
|
||
?> |
24 changes: 24 additions & 0 deletions
24
...ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_wrong_typed_constant.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,24 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class SkipWrongTypedConstant | ||
{ | ||
const STRING = 'hello'; | ||
|
||
public function getData() | ||
{ | ||
if (rand(0,1)) { | ||
return self::STRING; | ||
} | ||
|
||
return $this->getInt(); | ||
} | ||
|
||
public function getInt(): int | ||
{ | ||
|
||
} | ||
} | ||
|
||
?> |
55 changes: 55 additions & 0 deletions
55
...ssMethod/ReturnTypeFromStrictTypedCallRector/Fixture/wrong_typed_constant_returns.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,55 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class WrongTypedIntConstant | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
const WRONG_TYPED = 0; | ||
|
||
public function getData() | ||
{ | ||
if (rand(0,1)) { | ||
return self::WRONG_TYPED; | ||
} | ||
|
||
return $this->getInt(); | ||
} | ||
|
||
public function getInt(): int | ||
{ | ||
|
||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class WrongTypedIntConstant | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
const WRONG_TYPED = 0; | ||
|
||
public function getData(): int | ||
{ | ||
if (rand(0,1)) { | ||
return self::WRONG_TYPED; | ||
} | ||
|
||
return $this->getInt(); | ||
} | ||
|
||
public function getInt(): int | ||
{ | ||
|
||
} | ||
} | ||
|
||
?> |
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