Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,7 @@ PHP 8.6 UPGRADE NOTES
. Reduced temporary allocations when iterating Phar directories.

- Standard:
. Improved performance of str_ends_with().
. Improved performance of array_fill_keys().
. Improved performance of array_intersect().
. Improved performance of array_map() with multiple arrays passed.
Expand Down
5 changes: 4 additions & 1 deletion ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2451,7 +2451,10 @@ function str_contains(string $haystack, string $needle): bool {}
*/
function str_starts_with(string $haystack, string $needle): bool {}

/** @compile-time-eval */
/**
* @compile-time-eval
* @frameless-function {"arity": 2}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why not all "compile-time-eval" functions are not frameless?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah Perhaps a good idea for me to look into later. At least some of them should be frameless. e.g. ltrim rtrim.

*/
function str_ends_with(string $haystack, string $needle): bool {}

/**
Expand Down
10 changes: 8 additions & 2 deletions ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions ext/standard/basic_functions_decl.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,21 @@ PHP_FUNCTION(str_ends_with)
}
/* }}} */

ZEND_FRAMELESS_FUNCTION(str_ends_with, 2)
{
zval haystack_tmp, needle_tmp;
zend_string *haystack, *needle;

Z_FLF_PARAM_STR(1, haystack, haystack_tmp);
Z_FLF_PARAM_STR(2, needle, needle_tmp);

RETVAL_BOOL(zend_string_ends_with(haystack, needle));

flf_clean:
Z_FLF_PARAM_FREE_STR(1, haystack_tmp);
Z_FLF_PARAM_FREE_STR(2, needle_tmp);
}

static zend_always_inline void _zend_strpos(zval *return_value, zend_string *haystack, zend_string *needle, zend_long offset)
{
const char *found = NULL;
Expand Down