1 | <?php |
||
2 | |||
3 | namespace Vanderlee\Comprehend\Parser\Structure; |
||
4 | |||
5 | use Vanderlee\Comprehend\Core\Context; |
||
6 | use Vanderlee\Comprehend\Directive\Prefer; |
||
7 | use Vanderlee\Comprehend\Parser\Parser; |
||
8 | |||
9 | /** |
||
10 | * Classes implementing this can scan. |
||
11 | * |
||
12 | * @author Martijn |
||
13 | */ |
||
14 | trait PreferTrait |
||
15 | { |
||
16 | /** |
||
17 | * Parser used for scanning the text. |
||
18 | * |
||
19 | * @var Parser |
||
20 | */ |
||
21 | private $preference = null; |
||
22 | |||
23 | 104 | private function pushPreferenceToContext(Context $context) |
|
24 | { |
||
25 | 104 | if ($this->preference) { |
|
26 | 36 | $context->pushPreference($this->preference); |
|
27 | } |
||
28 | 104 | } |
|
29 | |||
30 | 104 | private function popPreferenceFromContext(Context $context) |
|
31 | { |
||
32 | 104 | if ($this->preference) { |
|
33 | 36 | $context->popPreference(); |
|
34 | } |
||
35 | 104 | } |
|
36 | |||
37 | /** |
||
38 | * @param string $preference |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | 1 | public function setPreference($preference) |
|
43 | { |
||
44 | 1 | $this->preference = $preference; |
|
0 ignored issues
–
show
|
|||
45 | |||
46 | 1 | return $this; |
|
47 | } |
||
48 | |||
49 | 1 | public function preferShortest() |
|
50 | { |
||
51 | 1 | $this->preference = Prefer::SHORTEST; |
|
0 ignored issues
–
show
It seems like
Vanderlee\Comprehend\Directive\Prefer::SHORTEST of type string is incompatible with the declared type Vanderlee\Comprehend\Parser\Parser of property $preference .
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.. ![]() |
|||
52 | |||
53 | 1 | return $this; |
|
54 | } |
||
55 | |||
56 | 2 | public function preferLongest() |
|
57 | { |
||
58 | 2 | $this->preference = Prefer::LONGEST; |
|
0 ignored issues
–
show
It seems like
Vanderlee\Comprehend\Directive\Prefer::LONGEST of type string is incompatible with the declared type Vanderlee\Comprehend\Parser\Parser of property $preference .
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.. ![]() |
|||
59 | |||
60 | 2 | return $this; |
|
61 | } |
||
62 | |||
63 | 1 | public function preferFirst() |
|
64 | { |
||
65 | 1 | $this->preference = Prefer::FIRST; |
|
0 ignored issues
–
show
It seems like
Vanderlee\Comprehend\Directive\Prefer::FIRST of type string is incompatible with the declared type Vanderlee\Comprehend\Parser\Parser of property $preference .
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.. ![]() |
|||
66 | |||
67 | 1 | return $this; |
|
68 | } |
||
69 | } |
||
70 |
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..