1 | <?php |
||
2 | |||
3 | namespace Vanderlee\Comprehend\Parser\Structure; |
||
4 | |||
5 | use Vanderlee\Comprehend\Core\ArgumentsTrait; |
||
6 | use Vanderlee\Comprehend\Core\Context; |
||
7 | use Vanderlee\Comprehend\Parser\Parser; |
||
8 | |||
9 | /** |
||
10 | * Classes implementing this can scan. |
||
11 | * |
||
12 | * @author Martijn |
||
13 | */ |
||
14 | trait SpacingTrait |
||
15 | { |
||
16 | use ArgumentsTrait; |
||
17 | |||
18 | /** |
||
19 | * Parser used for scanning the text. |
||
20 | * |
||
21 | * @var Parser |
||
22 | */ |
||
23 | private $spacer = false; |
||
24 | |||
25 | 198 | private function pushSpacer(Context $context) |
|
26 | { |
||
27 | 198 | if ($this->spacer !== false) { |
|
0 ignored issues
–
show
introduced
by
![]() |
|||
28 | 21 | $context->pushSpacer($this->spacer); |
|
29 | } |
||
30 | 198 | } |
|
31 | |||
32 | 197 | private function popSpacer(Context $context) |
|
33 | { |
||
34 | 197 | if ($this->spacer !== false) { |
|
0 ignored issues
–
show
|
|||
35 | 20 | $context->popSpacer(); |
|
36 | } |
||
37 | 197 | } |
|
38 | |||
39 | /** |
||
40 | * Set a spacing parser for this parser or disable or enable (if a previous |
||
41 | * spacing parser is enabled) spacing parsing. |
||
42 | * |
||
43 | * @param Parser|bool|null $spacer |
||
44 | * |
||
45 | * @return $this |
||
46 | */ |
||
47 | 7 | public function spacing($spacer = true) |
|
48 | { |
||
49 | 7 | if ($spacer === true) { |
|
50 | 1 | $this->spacer = true; |
|
0 ignored issues
–
show
It seems like
true of type true is incompatible with the declared type Vanderlee\Comprehend\Parser\Parser of property $spacer .
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.. ![]() |
|||
51 | 7 | } elseif ($spacer === null || $spacer === false) { |
|
0 ignored issues
–
show
|
|||
52 | 1 | $this->spacer = null; |
|
53 | } else { |
||
54 | 7 | $this->spacer = self::getArgument($spacer); |
|
55 | } |
||
56 | |||
57 | 7 | return $this; |
|
58 | } |
||
59 | } |
||
60 |