Skip to content

Commit 8b8bd37

Browse files
committed
Add frameless handler fro str_starts_with
1 parent 6e130dd commit 8b8bd37

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

Zend/zend_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,5 +651,6 @@ extern ZEND_FRAMELESS_FUNCTION(substr, 2);
651651
extern ZEND_FRAMELESS_FUNCTION(substr, 3);
652652
extern ZEND_FRAMELESS_FUNCTION(strstr, 2);
653653
extern ZEND_FRAMELESS_FUNCTION(strstr, 3);
654+
extern ZEND_FRAMELESS_FUNCTION(str_starts_with, 2);
654655

655656
#endif /* ZEND_STRING_H */

ext/standard/basic_functions.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,10 @@ function strrchr(string $haystack, string $needle, bool $before_needle = false):
24122412
/** @compile-time-eval */
24132413
function str_contains(string $haystack, string $needle): bool {}
24142414

2415-
/** @compile-time-eval */
2415+
/**
2416+
* @compile-time-eval
2417+
* @frameless-function {"arity": 2}
2418+
* */
24162419
function str_starts_with(string $haystack, string $needle): bool {}
24172420

24182421
/** @compile-time-eval */

ext/standard/basic_functions_arginfo.h

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

ext/standard/string.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,21 @@ PHP_FUNCTION(str_starts_with)
18091809
}
18101810
/* }}} */
18111811

1812+
ZEND_FRAMELESS_FUNCTION(str_starts_with, 2)
1813+
{
1814+
zval haystack_tmp, needle_tmp;
1815+
zend_string *haystack, *needle;
1816+
1817+
Z_FLF_PARAM_STR(1, haystack, haystack_tmp);
1818+
Z_FLF_PARAM_STR(2, needle, needle_tmp);
1819+
1820+
RETVAL_BOOL(zend_string_starts_with(haystack, needle));
1821+
1822+
flf_clean:
1823+
Z_FLF_PARAM_FREE_STR(1, haystack_tmp);
1824+
Z_FLF_PARAM_FREE_STR(2, needle_tmp);
1825+
}
1826+
18121827
/* {{{ Checks if haystack ends with needle */
18131828
PHP_FUNCTION(str_ends_with)
18141829
{

0 commit comments

Comments
 (0)