1 | <?php |
||
3 | trait Misc { |
||
4 | /** |
||
5 | * Get client ip-address |
||
6 | * |
||
7 | * @return string User ip-address |
||
8 | */ |
||
9 | public static function get_client_ip_address() { |
||
26 | |||
27 | /** |
||
28 | * parse url, try to correct errors and return valid url + display-url. |
||
29 | * |
||
30 | * @example http:/wwww.example.com/lorum.html => http://www.example.com/lorum.html |
||
31 | * @example gopher:/ww.example.com => gopher://www.example.com |
||
32 | * @example http:/www3.example.com/?q=asd&f=#asd =>http://www3.example.com/?q=asd&f=#asd |
||
33 | * @example asd://.example.com/folder/folder/ =>http://example.com/folder/folder/ |
||
34 | * @example .example.com/ => http://example.com/ |
||
35 | * @example example.com =>http://example.com |
||
36 | * @example subdomain.example.com => http://subdomain.example.com |
||
37 | * |
||
38 | * @param string $url Any somewhat valid url. |
||
39 | * @return string[] "url" contains an auto-corrected url. "url_display" host.tld or subdomain.host.tld |
||
|
|||
40 | */ |
||
41 | public static function url_parser($url) { |
||
103 | |||
104 | /** |
||
105 | * Generate a password-suggestion. |
||
106 | * |
||
107 | * @param int $length Length of password |
||
108 | * @param bool $simple Limit character-set to first 33 characters. |
||
109 | * @return string |
||
110 | */ |
||
111 | public static function generate_password($length = 8, $simple = false) { |
||
133 | |||
134 | /** |
||
135 | * Convert <textarea> to [textarea]. |
||
136 | * |
||
137 | * @param string $html |
||
138 | * @return string |
||
139 | */ |
||
140 | public static function textarea_encode($html) { |
||
143 | |||
144 | /** |
||
145 | * Convert [textarea] to <textarea>. |
||
146 | * |
||
147 | * @param string $html |
||
148 | * @return string |
||
149 | */ |
||
150 | public static function textarea_decode($html) { |
||
153 | |||
154 | } |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.