1 | <?php |
||
17 | final class StringExcerpt |
||
18 | { |
||
19 | /** |
||
20 | * Array of lines. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $lines = []; |
||
25 | |||
26 | /** |
||
27 | * Current line. |
||
28 | * |
||
29 | * @var int |
||
30 | */ |
||
31 | protected $currentLine; |
||
32 | |||
33 | /** |
||
34 | * Current column. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $currentColumn; |
||
39 | |||
40 | /** |
||
41 | * The line numbers width. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $lineWidth; |
||
46 | |||
47 | /** |
||
48 | * Constructor. |
||
49 | * |
||
50 | * @param array $lines The array of lines |
||
51 | * @param int $currentLine The current line |
||
52 | * @param int $currentColumn The current column |
||
53 | */ |
||
54 | public function __construct(array $lines, $currentLine, $currentColumn = null) |
||
61 | |||
62 | /** |
||
63 | * Converts the exceprt to colorized string for terminal. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function toTerminal() |
||
91 | |||
92 | /** |
||
93 | * Converts the except to plain text. |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | public function toText() |
||
101 | |||
102 | /** |
||
103 | * Coverts the lines to HTML. |
||
104 | * |
||
105 | * @return string The HTML |
||
106 | */ |
||
107 | public function toHtml() |
||
132 | |||
133 | /** |
||
134 | * Converts the object to string. |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function __toString() |
||
142 | } |
||
143 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.