Skip to content

Commit e19225c

Browse files
committed
is_numeric frameless handler, flf decl refactoring
1 parent 8b8bd37 commit e19225c

9 files changed

+51
-31
lines changed

Zend/zend_builtin_functions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@
2020
#ifndef ZEND_BUILTIN_FUNCTIONS_H
2121
#define ZEND_BUILTIN_FUNCTIONS_H
2222

23-
#include "zend_frameless_function.h"
24-
2523
zend_result zend_startup_builtin_functions(void);
2624

2725
BEGIN_EXTERN_C()
2826
ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit);
29-
30-
extern ZEND_FRAMELESS_FUNCTION(class_exists, 1);
31-
extern ZEND_FRAMELESS_FUNCTION(class_exists, 2);
3227
END_EXTERN_C()
3328

3429
#endif /* ZEND_BUILTIN_FUNCTIONS_H */

Zend/zend_builtin_functions_arginfo.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Zend/zend_string.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "zend_types.h"
2323
#include "zend_gc.h"
2424
#include "zend_alloc.h"
25-
#include "zend_frameless_function.h"
2625

2726
BEGIN_EXTERN_C()
2827

@@ -643,14 +642,4 @@ ZEND_KNOWN_STRINGS(_ZEND_STR_ID)
643642
ZEND_STR_LAST_KNOWN
644643
} zend_known_string_id;
645644

646-
extern ZEND_FRAMELESS_FUNCTION(dirname, 1);
647-
extern ZEND_FRAMELESS_FUNCTION(dirname, 2);
648-
extern ZEND_FRAMELESS_FUNCTION(strpos, 2);
649-
extern ZEND_FRAMELESS_FUNCTION(strpos, 3);
650-
extern ZEND_FRAMELESS_FUNCTION(substr, 2);
651-
extern ZEND_FRAMELESS_FUNCTION(substr, 3);
652-
extern ZEND_FRAMELESS_FUNCTION(strstr, 2);
653-
extern ZEND_FRAMELESS_FUNCTION(strstr, 3);
654-
extern ZEND_FRAMELESS_FUNCTION(str_starts_with, 2);
655-
656645
#endif /* ZEND_STRING_H */

build/gen_stub.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4212,7 +4212,12 @@ function framelessFunctionInfoToCode(FileInfo $fileInfo, FuncInfo $funcInfo): ?s
42124212
return null;
42134213
}
42144214

4215-
$code = 'static const zend_frameless_function_info ' . $funcInfo->getFramelessFunctionInfosName() . "[] = {\n";
4215+
$code = '';
4216+
foreach ($funcInfo->framelessFunctionInfos as $framelessFunctionInfo) {
4217+
$code .= "ZEND_FRAMELESS_FUNCTION({$funcInfo->name->getFunctionName()}, {$framelessFunctionInfo->arity});\n";
4218+
}
4219+
4220+
$code .= 'static const zend_frameless_function_info ' . $funcInfo->getFramelessFunctionInfosName() . "[] = {\n";
42164221
foreach ($funcInfo->framelessFunctionInfos as $framelessFunctionInfo) {
42174222
$code .= "\t{ ZEND_FRAMELESS_FUNCTION_NAME({$funcInfo->name->getFunctionName()}, {$framelessFunctionInfo->arity}), {$framelessFunctionInfo->arity} },\n";
42184223
}

ext/standard/basic_functions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ PHPAPI php_basic_globals basic_globals;
115115

116116
#include "php_fopen_wrappers.h"
117117
#include "streamsfuncs.h"
118+
#include "zend_frameless_function.h"
118119
#include "basic_functions_arginfo.h"
119120

120121
typedef struct _user_tick_function_entry {

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,6 +3609,7 @@ function is_double(mixed $value): bool {}
36093609

36103610
/**
36113611
* @compile-time-eval
3612+
* @frameless-function {"arity": 1}
36123613
*/
36133614
function is_numeric(mixed $value): bool {}
36143615

ext/standard/basic_functions_arginfo.h

Lines changed: 19 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/php_array.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#define PHP_ARRAY_H
2222

2323
# include "ext/random/php_random.h"
24-
# include "zend_frameless_function.h"
2524

2625
PHP_MINIT_FUNCTION(array);
2726
PHP_MSHUTDOWN_FUNCTION(array);
@@ -70,7 +69,4 @@ ZEND_END_MODULE_GLOBALS(array)
7069

7170
#define ARRAYG(v) ZEND_MODULE_GLOBALS_ACCESSOR(array, v)
7271

73-
ZEND_FRAMELESS_FUNCTION(in_array, 2);
74-
ZEND_FRAMELESS_FUNCTION(in_array, 3);
75-
7672
#endif /* PHP_ARRAY_H */

ext/standard/type.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,8 @@ PHP_FUNCTION(is_object)
342342
}
343343
/* }}} */
344344

345-
/* {{{ Returns true if value is a number or a numeric string */
346-
PHP_FUNCTION(is_numeric)
345+
static inline void _zend_is_numeric(zval *return_value, zval *arg)
347346
{
348-
zval *arg;
349-
350-
ZEND_PARSE_PARAMETERS_START(1, 1)
351-
Z_PARAM_ZVAL(arg)
352-
ZEND_PARSE_PARAMETERS_END();
353-
354347
switch (Z_TYPE_P(arg)) {
355348
case IS_LONG:
356349
case IS_DOUBLE:
@@ -370,8 +363,29 @@ PHP_FUNCTION(is_numeric)
370363
break;
371364
}
372365
}
366+
367+
/* {{{ Returns true if value is a number or a numeric string */
368+
PHP_FUNCTION(is_numeric)
369+
{
370+
zval *arg;
371+
372+
ZEND_PARSE_PARAMETERS_START(1, 1)
373+
Z_PARAM_ZVAL(arg)
374+
ZEND_PARSE_PARAMETERS_END();
375+
376+
_zend_is_numeric(return_value, arg);
377+
}
373378
/* }}} */
374379

380+
ZEND_FRAMELESS_FUNCTION(is_numeric, 1)
381+
{
382+
zval *arg;
383+
384+
Z_FLF_PARAM_ZVAL(1, arg);
385+
386+
_zend_is_numeric(return_value, arg);
387+
}
388+
375389
/* {{{ Returns true if value is a scalar */
376390
PHP_FUNCTION(is_scalar)
377391
{

0 commit comments

Comments
 (0)