1 | <?php |
||
10 | class Emphasis extends AbstractPass |
||
11 | { |
||
12 | /** |
||
13 | * {@inheritdoc} |
||
14 | */ |
||
15 | 263 | public function parse() |
|
20 | |||
21 | /** |
||
22 | * Parse emphasis and strong applied using given character |
||
23 | * |
||
24 | * @param string $character Markup character, either * or _ |
||
25 | * @param string $regexp Regexp used to match the series of emphasis character |
||
26 | * @return void |
||
27 | */ |
||
28 | 263 | protected function parseEmphasisByCharacter($character, $regexp) |
|
29 | { |
||
30 | 263 | $pos = $this->text->indexOf($character); |
|
31 | 263 | if ($pos === false) |
|
32 | 263 | { |
|
33 | 263 | return; |
|
34 | } |
||
35 | |||
36 | 60 | foreach ($this->getEmphasisByBlock($regexp, $pos) as $block) |
|
1 ignored issue
–
show
|
|||
37 | { |
||
38 | 60 | $this->processEmphasisBlock($block); |
|
39 | 60 | } |
|
40 | 60 | } |
|
41 | |||
42 | /** |
||
43 | * Get emphasis markup split by block |
||
44 | * |
||
45 | * @param string $regexp Regexp used to match emphasis |
||
46 | * @param integer $pos Position in the text of the first emphasis character |
||
47 | * @return array[] Each array contains a list of [matchPos, matchLen] pairs |
||
48 | */ |
||
49 | 60 | protected function getEmphasisByBlock($regexp, $pos) |
|
79 | |||
80 | /** |
||
81 | * Test whether emphasis should be ignored at the given position in the text |
||
82 | * |
||
83 | * @param integer $matchPos Position of the emphasis in the text |
||
84 | * @param integer $matchLen Length of the emphasis |
||
85 | * @return bool |
||
86 | */ |
||
87 | 60 | protected function ignoreEmphasis($matchPos, $matchLen) |
|
92 | |||
93 | /** |
||
94 | * Process a list of emphasis markup strings |
||
95 | * |
||
96 | * @param array[] $block List of [matchPos, matchLen] pairs |
||
97 | * @return void |
||
98 | */ |
||
99 | 60 | protected function processEmphasisBlock(array $block) |
|
165 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.