1 | <?php |
||
17 | class Highlighter extends Component |
||
18 | { |
||
19 | /** |
||
20 | * Sugaring. |
||
21 | */ |
||
22 | use SaturateTrait; |
||
23 | |||
24 | /** |
||
25 | * @invisible |
||
26 | * @var Style |
||
27 | */ |
||
28 | private $style = null; |
||
29 | |||
30 | /** |
||
31 | * @invisible |
||
32 | * @var array |
||
33 | */ |
||
34 | private $tokens = []; |
||
35 | |||
36 | /** |
||
37 | * Highlighted source. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | private $highlighted = ''; |
||
42 | |||
43 | /** |
||
44 | * @param string $filename |
||
45 | * @param Style|null $style |
||
46 | * @param TokenizerInterface|null $tokenizer |
||
47 | */ |
||
48 | public function __construct( |
||
58 | |||
59 | /** |
||
60 | * Set highlighter styler. |
||
61 | * |
||
62 | * @param Style $style |
||
63 | * @return $this |
||
64 | */ |
||
65 | public function setStyle(Style $style) |
||
71 | |||
72 | /** |
||
73 | * Get highlighted source. |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | public function highlight() |
||
94 | |||
95 | /** |
||
96 | * Get only part of php file around specified line. |
||
97 | * |
||
98 | * @param int|null $line Set as null to avoid line highlighting. |
||
99 | * @param int|null $around Set as null to return every line. |
||
100 | * @return string |
||
101 | */ |
||
102 | public function lines($line = null, $around = null) |
||
127 | } |