-
-
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.
[TypeDeclaration] Handle crash on @mixin usage on ReturnTypeFromStric…
…tTypedCallRector (#5823) * [TypeDeclaration] Handle with @mixin on ReturnTypeFromStrictTypedCallRector * Fix
- Loading branch information
1 parent
2b811af
commit 8cf4340
Showing
4 changed files
with
92 additions
and
2 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
59 changes: 59 additions & 0 deletions
59
...on/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/FixturePhp80/with_mixin.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,59 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\FixturePhp80; | ||
|
||
// future note: this 2 classes here on purpose to reproduce crash | ||
// see https://github.com/rectorphp/rector/issues/8600 | ||
|
||
/** | ||
* @method static mixed get(array|string $key, mixed|\Closure $default = null) | ||
* | ||
* @mixin \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source\Repository | ||
*/ | ||
class Cache | ||
{ | ||
} | ||
|
||
class WithMixin | ||
{ | ||
/** | ||
* @throws GuzzleException | ||
* @throws JsonException | ||
*/ | ||
protected function getOauthToken(string $key) | ||
{ | ||
return Cache::get($key); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\FixturePhp80; | ||
|
||
// future note: this 2 classes here on purpose to reproduce crash | ||
// see https://github.com/rectorphp/rector/issues/8600 | ||
|
||
/** | ||
* @method static mixed get(array|string $key, mixed|\Closure $default = null) | ||
* | ||
* @mixin \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source\Repository | ||
*/ | ||
class Cache | ||
{ | ||
} | ||
|
||
class WithMixin | ||
{ | ||
/** | ||
* @throws GuzzleException | ||
* @throws JsonException | ||
*/ | ||
protected function getOauthToken(string $key): mixed | ||
{ | ||
return Cache::get($key); | ||
} | ||
} | ||
|
||
?> |
16 changes: 16 additions & 0 deletions
16
...eDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Source/Repository.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source; | ||
|
||
class Repository | ||
{ | ||
/** | ||
* @template TCacheValue | ||
* @return (TCacheValue is null ? mixed : TCacheValue) | ||
*/ | ||
public function get($key, $default = null): mixed | ||
{ | ||
} | ||
} |
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