Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Ctype.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Polyfill\Ctype;
013
014 /**
015 * Ctype implementation through regex.
016 *
017 * @internal
018 *
019 * @author Gert de Pagter <BackEndTea@gmail.com>
020 */
021 final class Ctype
022 {
023 /**
024 * Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
025 *
026 * @see https://php.net/ctype-alnum
027 *
028 * @param mixed $text
029 *
030 * @return bool
031 */
032 public static function ctype_alnum($text)
033 {
034 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
035
036 return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
037 }
038
039 /**
040 * Returns TRUE if every character in text is a letter, FALSE otherwise.
041 *
042 * @see https://php.net/ctype-alpha
043 *
044 * @param mixed $text
045 *
046 * @return bool
047 */
048 public static function ctype_alpha($text)
049 {
050 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
051
052 return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
053 }
054
055 /**
056 * Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
057 *
058 * @see https://php.net/ctype-cntrl
059 *
060 * @param mixed $text
061 *
062 * @return bool
063 */
064 public static function ctype_cntrl($text)
065 {
066 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
067
068 return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
069 }
070
071 /**
072 * Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
073 *
074 * @see https://php.net/ctype-digit
075 *
076 * @param mixed $text
077 *
078 * @return bool
079 */
080 public static function ctype_digit($text)
081 {
082 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
083
084 return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
085 }
086
087 /**
088 * Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
089 *
090 * @see https://php.net/ctype-graph
091 *
092 * @param mixed $text
093 *
094 * @return bool
095 */
096 public static function ctype_graph($text)
097 {
098 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
099
100 return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
101 }
102
103 /**
104 * Returns TRUE if every character in text is a lowercase letter.
105 *
106 * @see https://php.net/ctype-lower
107 *
108 * @param mixed $text
109 *
110 * @return bool
111 */
112 public static function ctype_lower($text)
113 {
114 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
115
116 return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
117 }
118
119 /**
120 * Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
121 *
122 * @see https://php.net/ctype-print
123 *
124 * @param mixed $text
125 *
126 * @return bool
127 */
128 public static function ctype_print($text)
129 {
130 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
131
132 return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
133 }
134
135 /**
136 * Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
137 *
138 * @see https://php.net/ctype-punct
139 *
140 * @param mixed $text
141 *
142 * @return bool
143 */
144 public static function ctype_punct($text)
145 {
146 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
147
148 return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
149 }
150
151 /**
152 * Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
153 *
154 * @see https://php.net/ctype-space
155 *
156 * @param mixed $text
157 *
158 * @return bool
159 */
160 public static function ctype_space($text)
161 {
162 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
163
164 return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
165 }
166
167 /**
168 * Returns TRUE if every character in text is an uppercase letter.
169 *
170 * @see https://php.net/ctype-upper
171 *
172 * @param mixed $text
173 *
174 * @return bool
175 */
176 public static function ctype_upper($text)
177 {
178 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
179
180 return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
181 }
182
183 /**
184 * Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
185 *
186 * @see https://php.net/ctype-xdigit
187 *
188 * @param mixed $text
189 *
190 * @return bool
191 */
192 public static function ctype_xdigit($text)
193 {
194 $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
195
196 return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
197 }
198
199 /**
200 * Converts integers to their char versions according to normal ctype behaviour, if needed.
201 *
202 * If an integer between -128 and 255 inclusive is provided,
203 * it is interpreted as the ASCII value of a single character
204 * (negative values have 256 added in order to allow characters in the Extended ASCII range).
205 * Any other integer is interpreted as a string containing the decimal digits of the integer.
206 *
207 * @param mixed $int
208 * @param string $function
209 *
210 * @return mixed
211 */
212 private static function convert_int_to_char_for_ctype($int, $function)
213 {
214 if (!\is_int($int)) {
215 return $int;
216 }
217
218 if ($int < -128 || $int > 255) {
219 return (string) $int;
220 }
221
222 if (\PHP_VERSION_ID >= 80100) {
223 @trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
224 }
225
226 if ($int < 0) {
227 $int += 256;
228 }
229
230 return \chr($int);
231 }
232 }
233