mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Split PHP polyfills from include.php
This commit is contained in:
parent
cabc652aa2
commit
be70870b72
2 changed files with 31 additions and 18 deletions
|
|
@ -4,24 +4,8 @@ if (defined('APP_VERSION_ROOT_PATH')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PHP 8
|
// PHP 8
|
||||||
if (!function_exists('str_contains')) {
|
if (\PHP_VERSION_ID < 80000) {
|
||||||
function str_contains(string $haystack, string $needle) : bool
|
require __DIR__ . '/php8.php';
|
||||||
{
|
|
||||||
return false !== strpos($haystack, $needle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!function_exists('str_starts_with')) {
|
|
||||||
function str_starts_with(string $haystack, string $needle) : bool
|
|
||||||
{
|
|
||||||
return 0 === strncmp($haystack, $needle, strlen($needle));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!function_exists('str_ends_with')) {
|
|
||||||
function str_ends_with(string $haystack, string $needle) : bool
|
|
||||||
{
|
|
||||||
$length = strlen($needle);
|
|
||||||
return $length ? substr($haystack, -$length) === $needle : true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('APP_VERSION')) {
|
if (!defined('APP_VERSION')) {
|
||||||
|
|
|
||||||
29
snappymail/v/0.0.0/php8.php
Normal file
29
snappymail/v/0.0.0/php8.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (\PHP_VERSION_ID < 80000)
|
||||||
|
{
|
||||||
|
interface Stringable
|
||||||
|
{
|
||||||
|
public function __toString() : string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ValueError extends Error
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function str_contains(string $haystack, string $needle) : bool
|
||||||
|
{
|
||||||
|
return false !== strpos($haystack, $needle);
|
||||||
|
}
|
||||||
|
|
||||||
|
function str_starts_with(string $haystack, string $needle) : bool
|
||||||
|
{
|
||||||
|
return 0 === strncmp($haystack, $needle, strlen($needle));
|
||||||
|
}
|
||||||
|
|
||||||
|
function str_ends_with(string $haystack, string $needle) : bool
|
||||||
|
{
|
||||||
|
$length = strlen($needle);
|
||||||
|
return $length ? substr($haystack, -$length) === $needle : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue