vanderlee /
Comprehend
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Vanderlee\Comprehend\Parser\Output; |
||
| 4 | |||
| 5 | use Vanderlee\Comprehend\Core\Token; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @author Martijn |
||
| 9 | */ |
||
| 10 | trait TokenTrait |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Name of the token. |
||
| 14 | * |
||
| 15 | * @var null |
||
| 16 | */ |
||
| 17 | private $tokenName = null; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Group to which this token belongs (mostly for standard Library tokens). |
||
| 21 | * |
||
| 22 | * @var string|null |
||
| 23 | */ |
||
| 24 | private $tokenGroup = null; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Is this token the deepest node in this tree to report a token on? |
||
| 28 | * |
||
| 29 | * @var bool |
||
| 30 | */ |
||
| 31 | private $tokenIsTerminal = false; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param string $token |
||
| 35 | * @param string|null $group |
||
| 36 | * @param bool $isTerminal |
||
| 37 | * |
||
| 38 | * @return $this |
||
| 39 | */ |
||
| 40 | 43 | public function token($token, $group = null, $isTerminal = false) |
|
| 41 | { |
||
| 42 | 43 | $this->tokenName = $token; |
|
|
0 ignored issues
–
show
|
|||
| 43 | 43 | $this->tokenGroup = $group; |
|
| 44 | 43 | $this->tokenIsTerminal = $isTerminal; |
|
| 45 | |||
| 46 | 43 | return $this; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Has a token been set for this Parser? |
||
| 51 | * |
||
| 52 | * @return bool |
||
| 53 | */ |
||
| 54 | 36 | public function hasToken() |
|
| 55 | { |
||
| 56 | 36 | return $this->tokenName !== null; |
|
| 57 | } |
||
| 58 | |||
| 59 | 8 | private function resolveToken($input, $offset, $length, &$children, $class) |
|
| 60 | { |
||
| 61 | 8 | if ($this->tokenIsTerminal) { |
|
| 62 | 1 | $children = []; |
|
| 63 | } |
||
| 64 | |||
| 65 | 8 | return new Token($this->tokenGroup, $this->tokenName, $input, $offset, $length, $children, $class); |
|
| 66 | } |
||
| 67 | } |
||
| 68 |
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..