Cecilapp /
Cecil
| 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 | use Psr\Log\LoggerInterface; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Abstract step class. |
||
| 22 | * |
||
| 23 | * This class provides a base implementation for steps in the build process. |
||
| 24 | * It implements the StepInterface and provides common functionality such as |
||
| 25 | * initialization, checking if the step can be processed, and a constructor |
||
| 26 | * that accepts a Builder instance. |
||
| 27 | */ |
||
| 28 | abstract class AbstractStep implements StepInterface |
||
| 29 | { |
||
| 30 | /** @var Builder */ |
||
| 31 | protected $builder; |
||
| 32 | |||
| 33 | /** @var Config */ |
||
| 34 | protected $config; |
||
| 35 | |||
| 36 | /** @var LoggerInterface */ |
||
| 37 | protected $logger; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Configuration options for the step. |
||
| 41 | * @var Builder::OPTIONS |
||
| 42 | */ |
||
| 43 | protected $options; |
||
| 44 | |||
| 45 | /** @var bool */ |
||
| 46 | protected $canProcess = false; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Flexible constructor supporting dependency injection or legacy mode. |
||
| 50 | */ |
||
| 51 | 1 | public function __construct(Builder $builder, ?Config $config = null, ?LoggerInterface $logger = null) |
|
| 52 | { |
||
| 53 | 1 | $this->builder = $builder; |
|
| 54 | 1 | $this->config = $config ?? $builder->getConfig(); |
|
| 55 | 1 | $this->logger = $logger ?? $builder->getLogger(); |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * {@inheritdoc} |
||
| 60 | */ |
||
| 61 | 1 | public function init(array $options): void |
|
| 62 | { |
||
| 63 | 1 | $this->options = $options; |
|
|
0 ignored issues
–
show
|
|||
| 64 | 1 | $this->canProcess = true; |
|
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * {@inheritdoc} |
||
| 69 | * |
||
| 70 | * If init() is used, true by default. |
||
| 71 | */ |
||
| 72 | 1 | public function canProcess(): bool |
|
| 73 | { |
||
| 74 | 1 | return $this->canProcess; |
|
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * {@inheritdoc} |
||
| 79 | */ |
||
| 80 | abstract public function process(): void; |
||
| 81 | } |
||
| 82 |
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..