kadet1090 /
KeyLighter
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Highlighter |
||
| 4 | *1 |
||
| 5 | * Copyright (C) 2015, Some right reserved. |
||
| 6 | * |
||
| 7 | * @author Kacper "Kadet" Donat <[email protected]> |
||
| 8 | * |
||
| 9 | * Contact with author: |
||
| 10 | * Xmpp: [email protected] |
||
| 11 | * E-mail: [email protected] |
||
| 12 | * |
||
| 13 | * From Kadet with love. |
||
| 14 | */ |
||
| 15 | |||
| 16 | namespace Kadet\Highlighter\Parser; |
||
| 17 | |||
| 18 | |||
| 19 | use Kadet\Highlighter\Language\Language; |
||
| 20 | |||
| 21 | class ContextualToken extends Token |
||
| 22 | { |
||
| 23 | 2 | public function __construct($options) |
|
| 24 | { |
||
| 25 | 2 | parent::__construct($options); |
|
| 26 | 2 | } |
|
| 27 | |||
| 28 | 2 | protected function validate(Language $language, $context) |
|
| 29 | { |
||
| 30 | 2 | if($language !== $this->getRule()->language) { |
|
| 31 | 1 | $this->setValid(false); |
|
| 32 | 1 | return false; |
|
| 33 | } |
||
| 34 | |||
| 35 | 2 | $start = !in_array($this->name, $context, false); |
|
| 36 | |||
| 37 | 2 | if ($start) { |
|
| 38 | 2 | View Code Duplication | if (!$this->getRule()->validateContext($context)) { |
|
1 ignored issue
–
show
|
|||
| 39 | 1 | $this->setValid(false); |
|
| 40 | 1 | } else { |
|
| 41 | 1 | $this->_valid = true; |
|
| 42 | 1 | $this->_end->_valid = false; |
|
| 43 | } |
||
| 44 | 2 | View Code Duplication | } else { |
|
1 ignored issue
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 45 | 1 | if (!$this->getRule()->validateContext($context, [$this->name => Rule::CONTEXT_IN])) { |
|
| 46 | $this->setValid(false); |
||
| 47 | } else { |
||
| 48 | 1 | $this->_valid = false; |
|
| 49 | 1 | $this->_end->_valid = true; |
|
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | 2 | $this->_end->_start = false; |
|
|
0 ignored issues
–
show
It seems like
false of type false is incompatible with the declared type object<Kadet\Highlighter\Parser\Token> of property $_start.
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.. Loading history...
|
|||
| 54 | 2 | $this->_end = false; |
|
|
0 ignored issues
–
show
It seems like
false of type false is incompatible with the declared type object<Kadet\Highlighter\Parser\Token> of property $_end.
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.. Loading history...
|
|||
| 55 | |||
| 56 | 2 | return true; |
|
| 57 | } |
||
| 58 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.