Skip to content

Commit 7d321e5

Browse files
committed
optimize code
1 parent 9d70842 commit 7d321e5

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#project
21
project(phpx)
3-
cmake_minimum_required(VERSION 2.4)
2+
cmake_minimum_required(VERSION 2.8.1)
43
aux_source_directory(src DIR_SRCS)
54
file(GLOB_RECURSE HEADER_FILES include/*.h)
65

script/gen_stub.php

+17-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ function processStubFile(string $stubFile, Context $context): ?FileInfo {
7676
if (($context->forceRegeneration || $stubHash !== $oldStubHash) && file_put_contents($legacyFile, $arginfoCode)) {
7777
echo "Saved $legacyFile\n";
7878
}
79+
80+
$arginfoFile_for_phpx = str_replace('.stub.php', '_x_arginfo.h', $stubFile);
81+
$content = "BEGIN_EXTERN_C()\n";
82+
83+
$content .= "#if PHP_VERSION_ID < 80000\n";
84+
$content .= "#include \"".basename($legacyFile)."\"\n";
85+
$content .= "#else\n";
86+
$content .= "#include \"".basename($arginfoFile)."\"\n";
87+
$content .= "#endif\n";
88+
$content .= "END_EXTERN_C()\n";
89+
$content .= "";
90+
91+
if (file_put_contents($arginfoFile_for_phpx, $content)) {
92+
echo "Saved $arginfoFile_for_phpx\n";
93+
}
7994
}
8095

8196
return $fileInfo;
@@ -2422,7 +2437,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
24222437

24232438
foreach ($methodSynopses as $filename => $content) {
24242439
if (file_put_contents("$methodSynopsesDirectory/$filename", $content)) {
2425-
echo "Saved $filename\n";
2440+
echo "[1] Saved $filename\n";
24262441
}
24272442
}
24282443
}
@@ -2433,7 +2448,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
24332448

24342449
foreach ($methodSynopses as $filename => $content) {
24352450
if (file_put_contents($filename, $content)) {
2436-
echo "Saved $filename\n";
2451+
echo "[2] Saved $filename\n";
24372452
}
24382453
}
24392454
}

src/base.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static inline ZEND_RESULT_CODE _check_args_num(zend_execute_data *data, int num_
334334
void _exec_function(zend_execute_data *data, zval *return_value) {
335335
auto iter_func = function_map.find((const char *) data->func->common.function_name->val);
336336
if (iter_func == function_map.end()) {
337-
error(E_WARNING, "function '%s' not found", data->func->common.function_name->val);
337+
error(E_WARNING, "[phpx::_exec_function] function '%s' not found", data->func->common.function_name->val);
338338
return;
339339
}
340340

@@ -359,12 +359,12 @@ void _exec_function(zend_execute_data *data, zval *return_value) {
359359
void _exec_method(zend_execute_data *data, zval *return_value) {
360360
auto iter_class = method_map.find((const char *) data->func->common.scope->name->val);
361361
if (iter_class == method_map.end()) {
362-
error(E_WARNING, "class '%s' not found", data->func->common.scope->name->val);
362+
error(E_WARNING, "[phpx::_exec_method] class '%s' not found", data->func->common.scope->name->val);
363363
return;
364364
}
365365
auto iter_method = iter_class->second.find((const char *) data->func->common.function_name->val);
366366
if (iter_method == iter_class->second.end()) {
367-
error(E_WARNING, "method '%s' not found", data->func->common.function_name->val);
367+
error(E_WARNING, "[phpx::_exec_method] method '%s' not found", data->func->common.function_name->val);
368368
return;
369369
}
370370

0 commit comments

Comments
 (0)