Resources
2 years ago
Php80.php
2 years ago
PhpToken.php
2 years ago
bootstrap.php
4 years ago
index.php
3 years ago
Php80.php
92 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Polyfill\Php80; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | final class Php80 |
| 5 | { |
| 6 | public static function fdiv(float $dividend, float $divisor) : float |
| 7 | { |
| 8 | return @($dividend / $divisor); |
| 9 | } |
| 10 | public static function get_debug_type($value) : string |
| 11 | { |
| 12 | switch (\true) { |
| 13 | case null === $value: |
| 14 | return 'null'; |
| 15 | case \is_bool($value): |
| 16 | return 'bool'; |
| 17 | case \is_string($value): |
| 18 | return 'string'; |
| 19 | case \is_array($value): |
| 20 | return 'array'; |
| 21 | case \is_int($value): |
| 22 | return 'int'; |
| 23 | case \is_float($value): |
| 24 | return 'float'; |
| 25 | case \is_object($value): |
| 26 | break; |
| 27 | case $value instanceof \__PHP_Incomplete_Class: |
| 28 | return '__PHP_Incomplete_Class'; |
| 29 | default: |
| 30 | if (null === ($type = @\get_resource_type($value))) { |
| 31 | return 'unknown'; |
| 32 | } |
| 33 | if ('Unknown' === $type) { |
| 34 | $type = 'closed'; |
| 35 | } |
| 36 | return "resource ({$type})"; |
| 37 | } |
| 38 | $class = \get_class($value); |
| 39 | if (\false === \strpos($class, '@')) { |
| 40 | return $class; |
| 41 | } |
| 42 | return ((\get_parent_class($class) ?: \key(\class_implements($class))) ?: 'class') . '@anonymous'; |
| 43 | } |
| 44 | public static function get_resource_id($res) : int |
| 45 | { |
| 46 | if (!\is_resource($res) && null === @\get_resource_type($res)) { |
| 47 | throw new \TypeError(\sprintf('Argument 1 passed to get_resource_id() must be of the type resource, %s given', \get_debug_type($res))); |
| 48 | } |
| 49 | return (int) $res; |
| 50 | } |
| 51 | public static function preg_last_error_msg() : string |
| 52 | { |
| 53 | switch (\preg_last_error()) { |
| 54 | case \PREG_INTERNAL_ERROR: |
| 55 | return 'Internal error'; |
| 56 | case \PREG_BAD_UTF8_ERROR: |
| 57 | return 'Malformed UTF-8 characters, possibly incorrectly encoded'; |
| 58 | case \PREG_BAD_UTF8_OFFSET_ERROR: |
| 59 | return 'The offset did not correspond to the beginning of a valid UTF-8 code point'; |
| 60 | case \PREG_BACKTRACK_LIMIT_ERROR: |
| 61 | return 'Backtrack limit exhausted'; |
| 62 | case \PREG_RECURSION_LIMIT_ERROR: |
| 63 | return 'Recursion limit exhausted'; |
| 64 | case \PREG_JIT_STACKLIMIT_ERROR: |
| 65 | return 'JIT stack limit exhausted'; |
| 66 | case \PREG_NO_ERROR: |
| 67 | return 'No error'; |
| 68 | default: |
| 69 | return 'Unknown error'; |
| 70 | } |
| 71 | } |
| 72 | public static function str_contains(string $haystack, string $needle) : bool |
| 73 | { |
| 74 | return '' === $needle || \false !== \strpos($haystack, $needle); |
| 75 | } |
| 76 | public static function str_starts_with(string $haystack, string $needle) : bool |
| 77 | { |
| 78 | return 0 === \strncmp($haystack, $needle, \strlen($needle)); |
| 79 | } |
| 80 | public static function str_ends_with(string $haystack, string $needle) : bool |
| 81 | { |
| 82 | if ('' === $needle || $needle === $haystack) { |
| 83 | return \true; |
| 84 | } |
| 85 | if ('' === $haystack) { |
| 86 | return \false; |
| 87 | } |
| 88 | $needleLength = \strlen($needle); |
| 89 | return $needleLength <= \strlen($haystack) && 0 === \substr_compare($haystack, $needle, -$needleLength); |
| 90 | } |
| 91 | } |
| 92 |