-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scalar type in PHPDoc can mean an existing class
- Loading branch information
1 parent
8f2e45c
commit cdf9cb5
Showing
3 changed files
with
60 additions
and
0 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
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 MaxGoryunov\SavingIterator\Src; | ||
/** | ||
* @template T | ||
*/ | ||
interface Scalar | ||
{ | ||
/** | ||
* @return T | ||
*/ | ||
public function value(): mixed; | ||
} | ||
|
||
namespace MaxGoryunov\SavingIterator\Fakes; | ||
|
||
use Closure; | ||
use MaxGoryunov\SavingIterator\Src\Scalar; | ||
|
||
/** | ||
* @template T | ||
* @implements Scalar<T> | ||
*/ | ||
class The implements Scalar | ||
{ | ||
/** | ||
* @param T $subject | ||
* @param Closure(T): mixed $context | ||
*/ | ||
public function __construct( | ||
/** | ||
* @var T | ||
*/ | ||
private mixed $subject, | ||
/** | ||
* @var Closure(T): mixed | ||
*/ | ||
private Closure $context | ||
) { | ||
} | ||
/** | ||
* @return T | ||
*/ | ||
public function value(): mixed | ||
{ | ||
($this->context)($this->subject); | ||
return $this->subject; | ||
} | ||
} |