Skip to content

Commit 2f48c24

Browse files
committed
add constants
1 parent a697261 commit 2f48c24

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

frankenphp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ PHP_FUNCTION(frankenphp_log) {
571571
}
572572

573573
PHP_MINIT_FUNCTION(frankenphp) {
574+
register_frankenphp_symbols(module_number);
575+
574576
zend_function *func;
575577

576578
// Override putenv

frankenphp.stub.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
/** @generate-class-entries */
44

5+
/** @var int */
6+
const FRANKENPHP_LOG_LEVEL_DEBUG = -4;
7+
8+
/** @var int */
9+
const FRANKENPHP_LOG_LEVEL_INFO = 0;
10+
11+
/** @var int */
12+
const FRANKENPHP_LOG_LEVEL_WARN = 4;
13+
14+
/** @var int */
15+
const FRANKENPHP_LOG_LEVEL_ERROR = 8;
16+
517
function frankenphp_handle_request(callable $callback): bool {}
618

719
function headers_send(int $status = 200): int {}
@@ -38,7 +50,7 @@ function apache_response_headers(): array|bool {}
3850
function mercure_publish(string|array $topics, string $data = '', bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null): string {}
3951

4052
/**
41-
* @param int $level The importance or severity of a log event. The higher the level, the more important or severe the event. Common levels are -4 for debug, 0 for info, 4 for warn, and 8 for error. For more details, see: https://pkg.go.dev/log/slog#Level
53+
* @param int $level The importance or severity of a log event. The higher the level, the more important or severe the event. For more details, see: https://pkg.go.dev/log/slog#Level
4254
* array<string, any> $context Values of the array will be converted to the corresponding Go type (if supported by FrankenPHP) and added to the context of the structured logs using https://pkg.go.dev/log/slog#Attr
4355
*/
4456
function frankenphp_log(string $message, int $level = 0, array $context = []): void {}

frankenphp_arginfo.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 28aa97e2c6102b3e51059dbd001ac65679f0bfda */
2+
* Stub hash: 60f0d27c04f94d7b24c052e91ef294595a2bc421 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_frankenphp_handle_request, 0, 1, _IS_BOOL, 0)
55
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
@@ -41,6 +41,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_frankenphp_log, 0, 1, IS_VOID, 0
4141
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_ARRAY, 0, "[]")
4242
ZEND_END_ARG_INFO()
4343

44+
4445
ZEND_FUNCTION(frankenphp_handle_request);
4546
ZEND_FUNCTION(headers_send);
4647
ZEND_FUNCTION(frankenphp_finish_request);
@@ -49,6 +50,7 @@ ZEND_FUNCTION(frankenphp_response_headers);
4950
ZEND_FUNCTION(mercure_publish);
5051
ZEND_FUNCTION(frankenphp_log);
5152

53+
5254
static const zend_function_entry ext_functions[] = {
5355
ZEND_FE(frankenphp_handle_request, arginfo_frankenphp_handle_request)
5456
ZEND_FE(headers_send, arginfo_headers_send)
@@ -63,3 +65,11 @@ static const zend_function_entry ext_functions[] = {
6365
ZEND_FE(frankenphp_log, arginfo_frankenphp_log)
6466
ZEND_FE_END
6567
};
68+
69+
static void register_frankenphp_symbols(int module_number)
70+
{
71+
REGISTER_LONG_CONSTANT("FRANKENPHP_LOG_LEVEL_DEBUG", -4, CONST_PERSISTENT);
72+
REGISTER_LONG_CONSTANT("FRANKENPHP_LOG_LEVEL_INFO", 0, CONST_PERSISTENT);
73+
REGISTER_LONG_CONSTANT("FRANKENPHP_LOG_LEVEL_WARN", 4, CONST_PERSISTENT);
74+
REGISTER_LONG_CONSTANT("FRANKENPHP_LOG_LEVEL_ERROR", 8, CONST_PERSISTENT);
75+
}

0 commit comments

Comments
 (0)