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 | public function __construct($thing) |
||
35 | |||
36 | /** |
||
37 | * @return mixed |
||
38 | */ |
||
39 | public function __get($name) |
||
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | public function __toString() |
||
51 | |||
52 | // ArrayAccess methods { |
||
53 | |||
54 | public function offsetExists($offset) |
||
59 | |||
60 | // END ArrayAccess methods } |
||
61 | |||
62 | // Iterator methods { |
||
63 | |||
64 | public function key() |
||
68 | |||
69 | public function next() |
||
73 | |||
74 | public function rewind() |
||
78 | |||
79 | public function valid() |
||
83 | |||
84 | // END Iterator methods } |
||
85 | |||
86 | abstract public function toArray($delim = '', $limit = null); |
||
87 | |||
88 | abstract public function compareTo($str, $mode = self::NORMAL, $length = 1); |
||
89 | |||
90 | /** |
||
91 | * @return AnyString |
||
92 | */ |
||
93 | abstract public function escape($mode = self::NORMAL, $charlist = ''); |
||
94 | |||
95 | abstract public function nextToken($delim); |
||
96 | |||
97 | abstract public function remove($str, $mode = self::NORMAL); |
||
98 | |||
99 | abstract public function repeat($times); |
||
100 | |||
101 | /** |
||
102 | * @param string $replace |
||
103 | */ |
||
104 | abstract public function replace($search, $replace, $mode = self::NORMAL); |
||
105 | |||
106 | /** |
||
107 | * @return AnyString |
||
108 | */ |
||
109 | public function replaceWhole($replacement = '') |
||
113 | |||
114 | abstract public function resetToken(); |
||
115 | |||
116 | abstract public function times($times); |
||
117 | |||
118 | abstract public function translate($search, $replace = ''); |
||
119 | |||
120 | /** |
||
121 | * @return AnyString |
||
122 | */ |
||
123 | abstract public function trim($mask = " \t\n\r\0\x0B", $mode = self::BOTH_ENDS); |
||
124 | |||
125 | abstract public function unescape($mode = self::NORMAL); |
||
126 | |||
127 | abstract public function uuDecode(); |
||
128 | |||
129 | abstract public function uuEncode(); |
||
130 | |||
131 | public function equals($str) |
||
138 | |||
139 | abstract public function isAscii(); |
||
140 | |||
141 | abstract public function isEmpty(); |
||
142 | |||
143 | protected static function testStringableObject($thing) |
||
157 | } |
||
158 |
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.