1 | <?php |
||
5 | abstract class AnyString implements \ArrayAccess, \Countable, \Iterator |
||
6 | { |
||
7 | // CONSTANTS |
||
8 | |||
9 | const START = 0; |
||
10 | const END = 1; |
||
11 | const BOTH_ENDS = 2; |
||
12 | const NORMAL = 0; |
||
13 | const CASE_INSENSITIVE = 1; |
||
14 | const REVERSE = 2; |
||
15 | const EXACT_POSITION = 4; |
||
16 | const CURRENT_LOCALE = 2; |
||
17 | const NATURAL_ORDER = 4; |
||
18 | const FIRST_N = 8; |
||
19 | const C_STYLE = 1; |
||
20 | const META = 2; |
||
21 | const GREEDY = 0; |
||
22 | const LAZY = 1; |
||
23 | |||
24 | // PROPERTIES |
||
25 | |||
26 | protected $raw; |
||
27 | protected $caret = 0; |
||
28 | |||
29 | |||
30 | /** |
||
31 | * @param mixed $thing Anything that can be cast to a string |
||
32 | */ |
||
33 | public function __construct($thing) |
||
38 | |||
39 | /** |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function __get($name) |
||
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | public function __toString() |
||
54 | |||
55 | // ArrayAccess methods { |
||
56 | |||
57 | public function offsetExists($offset) |
||
62 | |||
63 | // END ArrayAccess methods } |
||
64 | |||
65 | // Iterator methods { |
||
66 | |||
67 | public function key() |
||
71 | |||
72 | public function next() |
||
76 | |||
77 | public function rewind() |
||
81 | |||
82 | public function valid() |
||
86 | |||
87 | // END Iterator methods } |
||
88 | |||
89 | public function equals($str) |
||
96 | |||
97 | abstract public function isAscii(); |
||
98 | |||
99 | abstract public function isEmpty(); |
||
100 | |||
101 | /** |
||
102 | * @return array |
||
103 | */ |
||
104 | abstract public function toArray($delim = '', $limit = null); |
||
105 | |||
106 | abstract public function append($str); |
||
107 | |||
108 | abstract public function compareTo($str, $mode = self::NORMAL, $length = 1); |
||
109 | |||
110 | public function concat($str) |
||
114 | |||
115 | /** |
||
116 | * @return AnyString |
||
117 | */ |
||
118 | abstract public function escape($mode = self::NORMAL, $charlist = ''); |
||
119 | |||
120 | public function hexDecode() |
||
124 | |||
125 | public function hexEncode() |
||
129 | |||
130 | public function nextToken($delim) |
||
138 | |||
139 | abstract public function prepend($str); |
||
140 | |||
141 | abstract public function remove($str, $mode = self::NORMAL); |
||
142 | |||
143 | abstract public function removeSubstr($start, $length = null); |
||
144 | |||
145 | abstract public function repeat($times); |
||
146 | |||
147 | /** |
||
148 | * @param string $replace |
||
149 | */ |
||
150 | abstract public function replace($search, $replace, $mode = self::NORMAL); |
||
151 | |||
152 | abstract public function replaceSubstr($replacement, $start, $length = null); |
||
153 | |||
154 | /** |
||
155 | * @return AnyString |
||
156 | */ |
||
157 | public function replaceWhole($replacement = '') |
||
161 | |||
162 | public function resetToken() |
||
166 | |||
167 | public function times($times) |
||
171 | |||
172 | abstract public function translate($search, $replace = ''); |
||
173 | |||
174 | /** |
||
175 | * @return AnyString |
||
176 | */ |
||
177 | abstract public function trim($mask = " \t\n\r\0\x0B", $mode = self::BOTH_ENDS); |
||
178 | |||
179 | abstract public function unescape($mode = self::NORMAL); |
||
180 | |||
181 | public function uuDecode() |
||
185 | |||
186 | public function uuEncode() |
||
190 | |||
191 | protected static function testStringableObject($thing) |
||
205 | } |
||
206 |
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@return
doc comment to communicate to implementors of these methods what they are expected to return.