|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Cecil. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Arnaud Ligny <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Cecil\Step; |
|
15
|
|
|
|
|
16
|
|
|
use Cecil\Builder; |
|
17
|
|
|
use Cecil\Config; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Abstract step class. |
|
21
|
|
|
* |
|
22
|
|
|
* This class provides a base implementation for steps in the build process. |
|
23
|
|
|
* It implements the StepInterface and provides common functionality such as |
|
24
|
|
|
* initialization, checking if the step can be processed, and a constructor |
|
25
|
|
|
* that accepts a Builder instance. |
|
26
|
|
|
*/ |
|
27
|
|
|
abstract class AbstractStep implements StepInterface |
|
28
|
|
|
{ |
|
29
|
|
|
/** @var Builder */ |
|
30
|
|
|
protected $builder; |
|
31
|
|
|
|
|
32
|
|
|
/** @var Config */ |
|
33
|
|
|
protected $config; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Configuration options for the step. |
|
37
|
|
|
* @var Builder::OPTIONS |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $options; |
|
40
|
|
|
|
|
41
|
|
|
/** @var bool */ |
|
42
|
|
|
protected $canProcess = false; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* {@inheritdoc} |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct(Builder $builder) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->builder = $builder; |
|
50
|
|
|
$this->config = $builder->getConfig(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Sets the builder instance. |
|
55
|
|
|
* This method is called by the StepRegistry when using DI. |
|
56
|
|
|
* It allows steps to receive the builder after construction with other dependencies. |
|
57
|
|
|
*/ |
|
58
|
|
|
public function setBuilder(Builder $builder): void |
|
59
|
|
|
{ |
|
60
|
|
|
$this->builder = $builder; |
|
61
|
|
|
$this->config = $builder->getConfig(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* {@inheritdoc} |
|
66
|
|
|
*/ |
|
67
|
|
|
public function init(array $options): void |
|
68
|
|
|
{ |
|
69
|
|
|
$this->options = $options; |
|
|
|
|
|
|
70
|
|
|
$this->canProcess = true; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
* |
|
76
|
|
|
* If init() is used, true by default. |
|
77
|
|
|
*/ |
|
78
|
|
|
public function canProcess(): bool |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->canProcess; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritdoc} |
|
85
|
|
|
*/ |
|
86
|
|
|
abstract public function process(): void; |
|
87
|
|
|
} |
|
88
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..