Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from MaxGoryunov/feature/52
Feature/52
- Loading branch information
Showing
9 changed files
with
115 additions
and
62 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,64 @@ | ||
<?php | ||
|
||
namespace MaxGoryunov\SavingIterator\Fakes; | ||
|
||
use Closure; | ||
use MaxGoryunov\SavingIterator\Src\Scalar; | ||
|
||
/** | ||
* Class for wrapping divergent program flows. It allows to structure a program | ||
* in such a way that there will be no need for a variable if it exists only in | ||
* order to be used in two places. | ||
* @todo #52:20min Create test file for this class and maybe change tests for | ||
* `Let` and `The`. | ||
* @template X subject type | ||
* @template Y result type | ||
* @implements \MaxGoryunov\SavingIterator\Src\Scalar<Y> | ||
*/ | ||
abstract class SurveyEnvelope implements Scalar | ||
{ | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @phpstan-param X $subject | ||
* @phpstan-param Closure(X): mixed $context | ||
* @phpstan-param Closure(X, Closure(X): mixed): Y $usage | ||
* @param mixed $subject element to be used in some context | ||
* @param Closure $context context for element | ||
* @param Closure $usage way of combining element and context | ||
*/ | ||
public function __construct( | ||
/** | ||
* Element to be used in some context. | ||
* | ||
* @var X | ||
*/ | ||
private mixed $subject, | ||
|
||
/** | ||
* Context for element. | ||
* | ||
* @var Closure(X): mixed | ||
*/ | ||
private Closure $context, | ||
|
||
/** | ||
* way of combining element and context. | ||
* | ||
* @var Closure(X, Closure(X): mixed): Y | ||
*/ | ||
private Closure $usage | ||
) { | ||
} | ||
|
||
/** | ||
* Returns result of applying context to element. | ||
* | ||
* @return Y | ||
*/ | ||
public final function value(): mixed | ||
{ | ||
return ($this->usage)($this->subject, $this->context); | ||
} | ||
} |
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
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
47db60b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
44-cdf39217
disappeared fromfakes/Let.php
, that's why I closed #52. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.47db60b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
52-3176158a
discovered infakes/SurveyEnvelope.php
and submitted as #68. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.47db60b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
52-c17a2651
discovered incodecov.yml
and submitted as #69. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.