/
The.php
55 lines (49 loc) · 1.2 KB
/
The.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace MaxGoryunov\SavingIterator\Fakes;
use Closure;
/**
* Class for applying contexts to elements without changing them.
* @todo #92:30min Remove extension of SurveyEnvelope because it is not needed
* anymore.
* @template T subject type
* @extends SurveyEnvelope<T, T>
* @implements Block<mixed>
*/
class The extends SurveyEnvelope implements Block
{
/**
* Subject for a context.
*
* @var mixed
*/
private mixed $subject;
/**
* Ctor.
*
* @phpstan-param T $subject repeating element
* @phpstan-param Closure(T): mixed $context context for element
* @param mixed $subject
* @param Closure $context
*/
public function __construct(mixed $subject, Closure $context)
{
parent::__construct(
$subject,
$context,
function (mixed $subject, Closure $context): mixed
{
$context($subject);
return $subject;
}
);
$this->subject = $subject;
}
/**
* {@inheritDoc}
*/
public function act(Closure $context): mixed
{
$context($this->subject);
return $this->subject;
}
}