PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.2
Defender Security – Malware Scanner, Login Security & Firewall v5.7.2
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / thecodingmachine / safe / generated / pcre.php

pcre.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.2, at vendor/thecodingmachine/safe/generated/pcre.php

660 lines 11.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Safe;
4
5 use Safe\Exceptions\PcreException;
6
7 /**
8 * Searches subject for all matches to the regular
9 * expression given in pattern and puts them in
10 * matches in the order specified by
11 * flags.
12 *
13 * After the first match is found, the subsequent searches are continued
14 * on from end of the last match.
15 *
16 * @param string $pattern The pattern to search for, as a string.
17 * @param string $subject The input string.
18 * @param array $matches Array of all matches in multi-dimensional array ordered according to
19 * flags.
20 * @param int $flags Can be a combination of the following flags (note that it doesn't make
21 * sense to use PREG_PATTERN_ORDER together with
22 * PREG_SET_ORDER):
23 *
24 *
25 * PREG_PATTERN_ORDER
26 *
27 *
28 * Orders results so that $matches[0] is an array of full
29 * pattern matches, $matches[1] is an array of strings matched by
30 * the first parenthesized subpattern, and so on.
31 *
32 *
33 *
34 *
35 *
36 * ]]>
37 *
38 * The above example will output:
39 *
40 * example: , this is a test
41 * example: , this is a test
42 * ]]>
43 *
44 *
45 * So, $out[0] contains array of strings that matched full pattern,
46 * and $out[1] contains array of strings enclosed by tags.
47 *
48 *
49 *
50 *
51 * If the pattern contains named subpatterns, $matches
52 * additionally contains entries for keys with the subpattern name.
53 *
54 *
55 * If the pattern contains duplicate named subpatterns, only the rightmost
56 * subpattern is stored in $matches[NAME].
57 *
58 *
59 *
60 * ]]>
61 *
62 * The above example will output:
63 *
64 *
65 * [1] => bar
66 * )
67 * ]]>
68 *
69 *
70 *
71 *
72 *
73 *
74 * PREG_SET_ORDER
75 *
76 *
77 * Orders results so that $matches[0] is an array of first set
78 * of matches, $matches[1] is an array of second set of matches,
79 * and so on.
80 *
81 *
82 *
83 * ]]>
84 *
85 * The above example will output:
86 *
87 * example: , example:
88 * this is a test, this is a test
89 * ]]>
90 *
91 *
92 *
93 *
94 *
95 *
96 * PREG_OFFSET_CAPTURE
97 *
98 *
99 * If this flag is passed, for every occurring match the appendant string
100 * offset (in bytes) will also be returned. Note that this changes the value of
101 * matches into an array of arrays where every element is an
102 * array consisting of the matched string at offset 0
103 * and its string offset into subject at offset
104 * 1.
105 *
106 *
107 *
108 * ]]>
109 *
110 * The above example will output:
111 *
112 * Array
113 * (
114 * [0] => Array
115 * (
116 * [0] => foobarbaz
117 * [1] => 0
118 * )
119 *
120 * )
121 *
122 * [1] => Array
123 * (
124 * [0] => Array
125 * (
126 * [0] => foo
127 * [1] => 0
128 * )
129 *
130 * )
131 *
132 * [2] => Array
133 * (
134 * [0] => Array
135 * (
136 * [0] => bar
137 * [1] => 3
138 * )
139 *
140 * )
141 *
142 * [3] => Array
143 * (
144 * [0] => Array
145 * (
146 * [0] => baz
147 * [1] => 6
148 * )
149 *
150 * )
151 *
152 * )
153 * ]]>
154 *
155 *
156 *
157 *
158 *
159 *
160 * PREG_UNMATCHED_AS_NULL
161 *
162 *
163 * If this flag is passed, unmatched subpatterns are reported as NULL;
164 * otherwise they are reported as an empty string.
165 *
166 *
167 *
168 *
169 *
170 * Orders results so that $matches[0] is an array of full
171 * pattern matches, $matches[1] is an array of strings matched by
172 * the first parenthesized subpattern, and so on.
173 *
174 *
175 *
176 *
177 * ]]>
178 *
179 * The above example will output:
180 *
181 * example: , this is a test
182 * example: , this is a test
183 * ]]>
184 *
185 *
186 * So, $out[0] contains array of strings that matched full pattern,
187 * and $out[1] contains array of strings enclosed by tags.
188 *
189 *
190 *
191 * The above example will output:
192 *
193 * So, $out[0] contains array of strings that matched full pattern,
194 * and $out[1] contains array of strings enclosed by tags.
195 *
196 * If the pattern contains named subpatterns, $matches
197 * additionally contains entries for keys with the subpattern name.
198 *
199 * If the pattern contains duplicate named subpatterns, only the rightmost
200 * subpattern is stored in $matches[NAME].
201 *
202 *
203 *
204 * ]]>
205 *
206 * The above example will output:
207 *
208 *
209 * [1] => bar
210 * )
211 * ]]>
212 *
213 *
214 *
215 * The above example will output:
216 *
217 * Orders results so that $matches[0] is an array of first set
218 * of matches, $matches[1] is an array of second set of matches,
219 * and so on.
220 *
221 *
222 *
223 * ]]>
224 *
225 * The above example will output:
226 *
227 * example: , example:
228 * this is a test, this is a test
229 * ]]>
230 *
231 *
232 *
233 * The above example will output:
234 *
235 * If this flag is passed, for every occurring match the appendant string
236 * offset (in bytes) will also be returned. Note that this changes the value of
237 * matches into an array of arrays where every element is an
238 * array consisting of the matched string at offset 0
239 * and its string offset into subject at offset
240 * 1.
241 *
242 *
243 *
244 * ]]>
245 *
246 * The above example will output:
247 *
248 * Array
249 * (
250 * [0] => Array
251 * (
252 * [0] => foobarbaz
253 * [1] => 0
254 * )
255 *
256 * )
257 *
258 * [1] => Array
259 * (
260 * [0] => Array
261 * (
262 * [0] => foo
263 * [1] => 0
264 * )
265 *
266 * )
267 *
268 * [2] => Array
269 * (
270 * [0] => Array
271 * (
272 * [0] => bar
273 * [1] => 3
274 * )
275 *
276 * )
277 *
278 * [3] => Array
279 * (
280 * [0] => Array
281 * (
282 * [0] => baz
283 * [1] => 6
284 * )
285 *
286 * )
287 *
288 * )
289 * ]]>
290 *
291 *
292 *
293 * The above example will output:
294 *
295 * If this flag is passed, unmatched subpatterns are reported as NULL;
296 * otherwise they are reported as an empty string.
297 *
298 * If no order flag is given, PREG_PATTERN_ORDER is
299 * assumed.
300 * @param int $offset Orders results so that $matches[0] is an array of full
301 * pattern matches, $matches[1] is an array of strings matched by
302 * the first parenthesized subpattern, and so on.
303 *
304 *
305 *
306 *
307 * ]]>
308 *
309 * The above example will output:
310 *
311 * example: , this is a test
312 * example: , this is a test
313 * ]]>
314 *
315 *
316 * So, $out[0] contains array of strings that matched full pattern,
317 * and $out[1] contains array of strings enclosed by tags.
318 *
319 *
320 *
321 * The above example will output:
322 *
323 * So, $out[0] contains array of strings that matched full pattern,
324 * and $out[1] contains array of strings enclosed by tags.
325 *
326 * If the pattern contains named subpatterns, $matches
327 * additionally contains entries for keys with the subpattern name.
328 *
329 * If the pattern contains duplicate named subpatterns, only the rightmost
330 * subpattern is stored in $matches[NAME].
331 *
332 *
333 *
334 * ]]>
335 *
336 * The above example will output:
337 *
338 *
339 * [1] => bar
340 * )
341 * ]]>
342 *
343 *
344 *
345 * The above example will output:
346 * @return int Returns the number of full pattern matches (which might be zero).
347 * @throws PcreException
348 *
349 */
350 function preg_match_all(string $pattern, string $subject, array &$matches = null, int $flags = PREG_PATTERN_ORDER, int $offset = 0): int
351 {
352 error_clear_last();
353 $result = \preg_match_all($pattern, $subject, $matches, $flags, $offset);
354 if ($result === false) {
355 throw PcreException::createFromPhpError();
356 }
357 return $result;
358 }
359
360
361 /**
362 * Searches subject for a match to the regular
363 * expression given in pattern.
364 *
365 * @param string $pattern The pattern to search for, as a string.
366 * @param string $subject The input string.
367 * @param array $matches If matches is provided, then it is filled with
368 * the results of search. $matches[0] will contain the
369 * text that matched the full pattern, $matches[1]
370 * will have the text that matched the first captured parenthesized
371 * subpattern, and so on.
372 * @param int $flags flags can be a combination of the following flags:
373 *
374 *
375 * PREG_OFFSET_CAPTURE
376 *
377 *
378 * If this flag is passed, for every occurring match the appendant string
379 * offset (in bytes) will also be returned. Note that this changes the value of
380 * matches into an array where every element is an
381 * array consisting of the matched string at offset 0
382 * and its string offset into subject at offset
383 * 1.
384 *
385 *
386 *
387 * ]]>
388 *
389 * The above example will output:
390 *
391 * Array
392 * (
393 * [0] => foobarbaz
394 * [1] => 0
395 * )
396 *
397 * [1] => Array
398 * (
399 * [0] => foo
400 * [1] => 0
401 * )
402 *
403 * [2] => Array
404 * (
405 * [0] => bar
406 * [1] => 3
407 * )
408 *
409 * [3] => Array
410 * (
411 * [0] => baz
412 * [1] => 6
413 * )
414 *
415 * )
416 * ]]>
417 *
418 *
419 *
420 *
421 *
422 *
423 * PREG_UNMATCHED_AS_NULL
424 *
425 *
426 * If this flag is passed, unmatched subpatterns are reported as NULL;
427 * otherwise they are reported as an empty string.
428 *
429 *
430 *
431 * ]]>
432 *
433 * The above example will output:
434 *
435 *
436 * string(2) "ac"
437 * [1]=>
438 * string(1) "a"
439 * [2]=>
440 * string(0) ""
441 * [3]=>
442 * string(1) "c"
443 * }
444 * array(4) {
445 * [0]=>
446 * string(2) "ac"
447 * [1]=>
448 * string(1) "a"
449 * [2]=>
450 * NULL
451 * [3]=>
452 * string(1) "c"
453 * }
454 * ]]>
455 *
456 *
457 *
458 *
459 *
460 *
461 *
462 * If this flag is passed, for every occurring match the appendant string
463 * offset (in bytes) will also be returned. Note that this changes the value of
464 * matches into an array where every element is an
465 * array consisting of the matched string at offset 0
466 * and its string offset into subject at offset
467 * 1.
468 *
469 *
470 *
471 * ]]>
472 *
473 * The above example will output:
474 *
475 * Array
476 * (
477 * [0] => foobarbaz
478 * [1] => 0
479 * )
480 *
481 * [1] => Array
482 * (
483 * [0] => foo
484 * [1] => 0
485 * )
486 *
487 * [2] => Array
488 * (
489 * [0] => bar
490 * [1] => 3
491 * )
492 *
493 * [3] => Array
494 * (
495 * [0] => baz
496 * [1] => 6
497 * )
498 *
499 * )
500 * ]]>
501 *
502 *
503 *
504 * The above example will output:
505 *
506 * If this flag is passed, unmatched subpatterns are reported as NULL;
507 * otherwise they are reported as an empty string.
508 *
509 *
510 *
511 * ]]>
512 *
513 * The above example will output:
514 *
515 *
516 * string(2) "ac"
517 * [1]=>
518 * string(1) "a"
519 * [2]=>
520 * string(0) ""
521 * [3]=>
522 * string(1) "c"
523 * }
524 * array(4) {
525 * [0]=>
526 * string(2) "ac"
527 * [1]=>
528 * string(1) "a"
529 * [2]=>
530 * NULL
531 * [3]=>
532 * string(1) "c"
533 * }
534 * ]]>
535 *
536 *
537 *
538 * The above example will output:
539 * @param int $offset If this flag is passed, for every occurring match the appendant string
540 * offset (in bytes) will also be returned. Note that this changes the value of
541 * matches into an array where every element is an
542 * array consisting of the matched string at offset 0
543 * and its string offset into subject at offset
544 * 1.
545 *
546 *
547 *
548 * ]]>
549 *
550 * The above example will output:
551 *
552 * Array
553 * (
554 * [0] => foobarbaz
555 * [1] => 0
556 * )
557 *
558 * [1] => Array
559 * (
560 * [0] => foo
561 * [1] => 0
562 * )
563 *
564 * [2] => Array
565 * (
566 * [0] => bar
567 * [1] => 3
568 * )
569 *
570 * [3] => Array
571 * (
572 * [0] => baz
573 * [1] => 6
574 * )
575 *
576 * )
577 * ]]>
578 *
579 *
580 *
581 * The above example will output:
582 * @return int preg_match returns 1 if the pattern
583 * matches given subject, 0 if it does not.
584 * @throws PcreException
585 *
586 */
587 function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int
588 {
589 error_clear_last();
590 $result = \preg_match($pattern, $subject, $matches, $flags, $offset);
591 if ($result === false) {
592 throw PcreException::createFromPhpError();
593 }
594 return $result;
595 }
596
597
598 /**
599 * Split the given string by a regular expression.
600 *
601 * @param string $pattern The pattern to search for, as a string.
602 * @param string $subject The input string.
603 * @param int|null $limit If specified, then only substrings up to limit
604 * are returned with the rest of the string being placed in the last
605 * substring. A limit of -1 or 0 means "no limit".
606 * @param int $flags flags can be any combination of the following
607 * flags (combined with the | bitwise operator):
608 *
609 *
610 * PREG_SPLIT_NO_EMPTY
611 *
612 *
613 * If this flag is set, only non-empty pieces will be returned by
614 * preg_split.
615 *
616 *
617 *
618 *
619 * PREG_SPLIT_DELIM_CAPTURE
620 *
621 *
622 * If this flag is set, parenthesized expression in the delimiter pattern
623 * will be captured and returned as well.
624 *
625 *
626 *
627 *
628 * PREG_SPLIT_OFFSET_CAPTURE
629 *
630 *
631 * If this flag is set, for every occurring match the appendant string
632 * offset will also be returned. Note that this changes the return
633 * value in an array where every element is an array consisting of the
634 * matched string at offset 0 and its string offset
635 * into subject at offset 1.
636 *
637 *
638 *
639 *
640 *
641 * If this flag is set, for every occurring match the appendant string
642 * offset will also be returned. Note that this changes the return
643 * value in an array where every element is an array consisting of the
644 * matched string at offset 0 and its string offset
645 * into subject at offset 1.
646 * @return array Returns an array containing substrings of subject
647 * split along boundaries matched by pattern.
648 * @throws PcreException
649 *
650 */
651 function preg_split(string $pattern, string $subject, ?int $limit = -1, int $flags = 0): array
652 {
653 error_clear_last();
654 $result = \preg_split($pattern, $subject, $limit, $flags);
655 if ($result === false) {
656 throw PcreException::createFromPhpError();
657 }
658 return $result;
659 }
660