Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 60 additions & 8 deletions builtin-functions/_functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,6 @@ function setlocale ($category ::: int, $locale ::: string) ::: string | false;

function iconv ($input_encoding ::: string, $output_encoding ::: string, $input_str ::: string) ::: string | false;

function mb_check_encoding ($str ::: string, $encoding ::: string = "1251") ::: bool;
function mb_strlen ($str ::: string, $encoding ::: string = "1251") ::: int;
function mb_strpos ($haystack ::: string, $needle ::: string, $offset ::: int = 0, $encoding ::: string = "1251") ::: int | false;
function mb_stripos ($haystack ::: string, $needle ::: string, $offset ::: int = 0, $encoding ::: string = "1251") ::: int | false;
function mb_strtolower ($str ::: string, $encoding ::: string = "1251") ::: string;
function mb_strtoupper ($str ::: string, $encoding ::: string = "1251") ::: string;
function mb_substr ($str ::: string, $start ::: int, $length ::: mixed = PHP_INT_MAX, $encoding ::: string = "1251") ::: string;

define('PHP_ROUND_HALF_UP', 123423141);
define('PHP_ROUND_HALF_DOWN', 123423144);
define('PHP_ROUND_HALF_EVEN', 123423145);
Expand Down Expand Up @@ -1624,3 +1616,63 @@ class DateTimeImmutable implements DateTimeInterface {
}

function getenv(string $varname = '', bool $local_only = false): mixed;

function mb_check_encoding(array|string $value, ?string $encoding = null): bool;
function mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false;
function mb_strlen(string $string, ?string $encoding = null): int;
function mb_strpos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false;
function mb_stripos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false;
function mb_strtolower(string $string, ?string $encoding = null): string;
function mb_strtoupper(string $string, ?string $encoding = null): string;
function mb_substr(string $string, int $start, ?int $length = null, ?string $encoding = null): string;
function mb_chr(int $codepoint, ?string $encoding = null): string|false;
function mb_convert_case(string $string, int $mode, ?string $encoding = null): string;
function mb_convert_kana(string $string, string $mode = "KV", ?string $encoding = null): string;
function mb_convert_variables(string $to_encoding, array|string $from_encoding, mixed &$vars): string|false; // ??? (change variable bytes + kwargs)
function mb_decode_mimeheader(string $string): string;
function mb_decode_numericentity(string $string, array $map, ?string $encoding = null): string;
function mb_detect_encoding(string $string, array|string|null $encodings = null, bool $strict = false): string|false;
function mb_detect_order(array|string|null $encoding = null): mixed; // return array|bool
function mb_encode_mimeheader(string $string, ?string $charset = null, ?string $transfer_encoding = null, string $newline = "\r\n", int $indent = 0): string;
function mb_encode_numericentity(string $string, array $map, ?string $encoding = null, bool $hex = false): string;
function mb_encoding_aliases(string $encoding): array;
function mb_ereg_match(string $pattern, string $string, ?string $options = null): bool;
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, ?string $options = null): string|false|null;
function mb_ereg_replace(string $pattern, string $replacement, string $string, ?string $options = null): string|false|null;
function mb_ereg_search_getpos(): int;
function mb_ereg_search_getregs(): array|false;
function mb_ereg_search_init(string $string, ?string $pattern = null, ?string $options = null): bool;
function mb_ereg_search_pos(?string $pattern = null, ?string $options = null): array|false;
function mb_ereg_search_regs(?string $pattern = null, ?string $options = null): array|false;
function mb_ereg_search_setpos(int $offset): bool;
function mb_ereg_search(?string $pattern = null, ?string $options = null): bool;
function mb_ereg(string $pattern, string $string, array &$matches = null): bool;
function mb_eregi_replace(string $pattern, string $replacement, string $string, ?string $options = null): string|false|null;
function mb_eregi(string $pattern, string $string, array &$matches = null): bool;
function mb_get_info(string $type = "all"): array|string|int|false;
function mb_http_input(?string $type = null): array|string|false;
function mb_http_output(?string $encoding = null): string|false;
function mb_internal_encoding(?string $encoding = null): string|false;
function mb_language(?string $language = null): string|false;
function mb_list_encodings(): array;
function mb_ord(string $string, ?string $encoding = null): int|false;
function mb_output_handler(string $string, int $status): string;
function mb_parse_str(string $string, array &$result): bool;
function mb_preferred_mime_name(string $encoding): string|false;
function mb_regex_encoding(?string $encoding = null): string|false;
function mb_regex_set_options(?string $options = null): string;
function mb_scrub(string $string, ?string $encoding = null): string;
function mb_send_mail(string $to, string $subject, string $message, array|string $additional_headers = [], ?string $additional_params = null): bool;
function mb_split(string $pattern, string $string, int $limit = -1): array|false;
function mb_str_split(string $string, int $length = 1, ?string $encoding = null): array;
function mb_strcut(string $string, int $start, ?int $length = null, ?string $encoding = null): string;
function mb_strimwidth(string $string, int $start, int $width, string $trim_marker = "", ?string $encoding = null): string;
function mb_stristr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false;
function mb_strrchr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false;
function mb_strrichr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false;
function mb_strripos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false;
function mb_strrpos(string $haystack, string $needle, int $offset = 0, string $encoding = null): int|false;
function mb_strstr(string $haystack, string $needle, bool $before_needle = false, ?string $encoding = null): string|false;
function mb_strwidth(string $string, ?string $encoding = null): int;
function mb_substitute_character(string|int|null $substitute_character = null): string|int|false;
function mb_substr_count(string $haystack, string $needle, ?string $encoding = null): int;
42 changes: 29 additions & 13 deletions cmake/external-libraries.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
option(DOWNLOAD_MISSING_LIBRARIES "download and build missing libraries if needed" OFF)
option(MBFL "download and build libmbfl" OFF)
cmake_print_variables(DOWNLOAD_MISSING_LIBRARIES)
cmake_print_variables(MBFL)
function(handle_missing_library LIB_NAME)
message(STATUS "------${LIB_NAME}---------")
if(DOWNLOAD_MISSING_LIBRARIES)
Expand All @@ -9,6 +11,33 @@ function(handle_missing_library LIB_NAME)
endif()
endfunction()

find_library(KPHP_TIMELIB kphp-timelib)
if(KPHP_TIMELIB)
add_library(kphp-timelib STATIC IMPORTED ${KPHP_TIMELIB})
else()
handle_missing_library("kphp-timelib")
FetchContent_Declare(kphp-timelib GIT_REPOSITORY https://github.com/VKCOM/timelib)
message(STATUS "---------------------")
FetchContent_MakeAvailable(kphp-timelib)
include_directories(${kphp-timelib_SOURCE_DIR}/include)
add_definitions(-DKPHP_TIMELIB_LIB_DIR="${kphp-timelib_SOURCE_DIR}/objs")
add_link_options(-L${kphp-timelib_SOURCE_DIR}/objs)
endif()

if(MBFL)
message(STATUS "MBFL=On, libmbfl will be downloaded and built")
add_compile_options(-DMBFL)
FetchContent_Declare(libmbfl GIT_REPOSITORY https://github.com/andreylzmw/libmbfl)
FetchContent_MakeAvailable(libmbfl)
include_directories(${libmbfl_SOURCE_DIR}/include)
add_definitions(-DLIBMBFL_LIB_DIR="${libmbfl_SOURCE_DIR}/objs")
add_link_options(-L${libmbfl_SOURCE_DIR}/objs)
endif()

# '-Wno-redundant-move' flag works for C++/ObjC++ but not for C,
# so build C libraries above
add_compile_options(-Wno-redundant-move)

find_package(fmt QUIET)
if(NOT fmt_FOUND)
handle_missing_library("fmtlib")
Expand Down Expand Up @@ -41,19 +70,6 @@ if(KPHP_TESTS)
endif()
endif()

find_library(KPHP_TIMELIB kphp-timelib)
if(KPHP_TIMELIB)
add_library(kphp-timelib STATIC IMPORTED ${KPHP_TIMELIB})
else()
handle_missing_library("kphp-timelib")
FetchContent_Declare(kphp-timelib GIT_REPOSITORY https://github.com/VKCOM/timelib)
message(STATUS "---------------------")
FetchContent_MakeAvailable(kphp-timelib)
include_directories(${kphp-timelib_SOURCE_DIR}/include)
add_definitions(-DKPHP_TIMELIB_LIB_DIR="${kphp-timelib_SOURCE_DIR}/objs")
add_link_options(-L${kphp-timelib_SOURCE_DIR}/objs)
endif()

if(APPLE)
if (DEFINED ENV{EPOLL_SHIM_REPO})
FetchContent_Declare(
Expand Down
3 changes: 2 additions & 1 deletion cmake/init-compilation-flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ if (PDO_DRIVER_PGSQL)
add_definitions(-DPDO_DRIVER_PGSQL)
add_compile_definitions(PDO_DRIVER_PGSQL_VERSION=${PostgreSQL_VERSION})
endif()

cmake_print_variables(PDO_DRIVER_PGSQL)

option(KPHP_TESTS "Build the tests" ON)
Expand Down Expand Up @@ -118,7 +119,7 @@ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
endif()

add_compile_options(-Werror -Wall -Wextra -Wunused-function -Wfloat-conversion -Wno-sign-compare
-Wuninitialized -Wno-redundant-move -Wno-missing-field-initializers)
-Wuninitialized -Wno-missing-field-initializers)

if(NOT APPLE)
check_cxx_compiler_flag(-gz=zlib DEBUG_COMPRESSION_IS_FOUND)
Expand Down
8 changes: 8 additions & 0 deletions compiler/compiler-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ void CompilerSettings::init() {

remove_extra_spaces(extra_cxx_flags.value_);
std::stringstream ss;
#ifdef MBFL
ss << " -DMBFL ";
#endif
ss << extra_cxx_flags.get();
ss << " -iquote" << kphp_src_path.get()
<< " -iquote " << kphp_src_path.get() << "objs/generated/auto/runtime";
Expand Down Expand Up @@ -331,6 +334,11 @@ void CompilerSettings::init() {
ld_flags.value_ += " -L /usr/local/lib";
#endif

#ifdef LIBMBFL_LIB_DIR
external_static_libs.emplace_back("libmbfl");
ld_flags.value_ += " -L" LIBMBFL_LIB_DIR;
#endif

#if defined(__APPLE__) && defined(__arm64__)
// for development under M1, manual installation of libucontext is needed
// see the docs: https://vkcom.github.io/kphp/kphp-internals/developing-and-extending-kphp/compiling-kphp-from-sources.html
Expand Down
4 changes: 3 additions & 1 deletion runtime/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2379,8 +2379,10 @@ static void free_runtime_libs() {
free_kphp_backtrace();

free_migration_php8();
free_detect_incorrect_encoding_names();

#ifndef MBFL
free_detect_incorrect_encoding_names();
#endif
vk::singleton<JsonLogger>::get().reset_buffers();
#ifdef PDO_DRIVER_MYSQL
database_drivers::free_mysql_lib();
Expand Down
30 changes: 0 additions & 30 deletions runtime/mbstring.h

This file was deleted.

Loading