Skip to content

Commit 894fa15

Browse files
committed
Add frameless handler for str_contains
1 parent 2b5fda8 commit 894fa15

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,13 +2409,16 @@ function strripos(string $haystack, string $needle, int $offset = 0): int|false
24092409
*/
24102410
function strrchr(string $haystack, string $needle, bool $before_needle = false): string|false {}
24112411

2412-
/** @compile-time-eval */
2412+
/**
2413+
* @compile-time-eval
2414+
* @frameless-function {"arity": 2}
2415+
*/
24132416
function str_contains(string $haystack, string $needle): bool {}
24142417

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

24212424
/** @compile-time-eval */

ext/standard/basic_functions_arginfo.h

Lines changed: 8 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
@@ -1795,6 +1795,21 @@ PHP_FUNCTION(str_contains)
17951795
}
17961796
/* }}} */
17971797

1798+
ZEND_FRAMELESS_FUNCTION(str_contains, 2)
1799+
{
1800+
zval haystack_tmp, needle_tmp;
1801+
zend_string *haystack, *needle;
1802+
1803+
Z_FLF_PARAM_STR(1, haystack, haystack_tmp);
1804+
Z_FLF_PARAM_STR(2, needle, needle_tmp);
1805+
1806+
RETVAL_BOOL(php_memnstr(ZSTR_VAL(haystack), ZSTR_VAL(needle), ZSTR_LEN(needle), ZSTR_VAL(haystack) + ZSTR_LEN(haystack)));
1807+
1808+
flf_clean:
1809+
Z_FLF_PARAM_FREE_STR(1, haystack_tmp);
1810+
Z_FLF_PARAM_FREE_STR(2, needle_tmp);
1811+
}
1812+
17981813
/* {{{ Checks if haystack starts with needle */
17991814
PHP_FUNCTION(str_starts_with)
18001815
{

0 commit comments

Comments
 (0)