Skip to content

ext/spl: Remove spl_engine.h header #14418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2024
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: 0 additions & 1 deletion ext/phar/phar_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include "Zend/zend_virtual_cwd.h"
#include "ext/spl/spl_array.h"
#include "ext/spl/spl_directory.h"
#include "ext/spl/spl_engine.h"
#include "ext/spl/spl_exceptions.h"
#include "ext/spl/spl_iterators.h"
#include "php_phar.h"
Expand Down
12 changes: 8 additions & 4 deletions ext/phar/phar_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -3540,9 +3540,7 @@ PHP_METHOD(Phar, offsetGet)
{
char *fname, *error;
size_t fname_len;
zval zfname;
phar_entry_info *entry;
zend_string *sfname;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_THROWS();
Expand Down Expand Up @@ -3574,10 +3572,16 @@ PHP_METHOD(Phar, offsetGet)
efree(entry);
}

sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
zend_string *sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
zval zfname;
ZVAL_NEW_STR(&zfname, sfname);
spl_instantiate_arg_ex1(phar_obj->spl.info_class, return_value, &zfname);

/* Instantiate object and call constructor */
zend_result is_initialized = object_init_with_constructor(return_value, phar_obj->spl.info_class, 1, &zfname, NULL);
zval_ptr_dtor(&zfname);
if (is_initialized == FAILURE) {
RETURN_THROWS();
}
}
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/config.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
PHP_ADD_EXTENSION_DEP(spl, pcre, true)
PHP_ADD_EXTENSION_DEP(spl, standard, true)
PHP_ADD_EXTENSION_DEP(spl, json)
2 changes: 1 addition & 1 deletion ext/spl/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

EXTENSION("spl", "php_spl.c spl_functions.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
PHP_SPL="yes";
PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h");
PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_array.h spl_directory.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h");
1 change: 0 additions & 1 deletion ext/spl/php_spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "php_spl.h"
#include "php_spl_arginfo.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_array.h"
#include "spl_directory.h"
#include "spl_iterators.h"
Expand Down
15 changes: 9 additions & 6 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "php_spl.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_iterators.h"
#include "spl_directory.h"
#include "spl_directory_arginfo.h"
Expand Down Expand Up @@ -1516,7 +1515,6 @@ PHP_METHOD(RecursiveDirectoryIterator, hasChildren)
/* {{{ Returns an iterator for the current entry if it is a directory */
PHP_METHOD(RecursiveDirectoryIterator, getChildren)
{
zval zpath, zflags;
spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS));
spl_filesystem_object *subdir;
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
Expand All @@ -1529,10 +1527,15 @@ PHP_METHOD(RecursiveDirectoryIterator, getChildren)
RETURN_THROWS();
}

ZVAL_LONG(&zflags, intern->flags);
ZVAL_STR_COPY(&zpath, intern->file_name);
spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &zpath, &zflags);
zval_ptr_dtor(&zpath);
zval params[2];
ZVAL_STR_COPY(&params[0], intern->file_name);
ZVAL_LONG(&params[1], intern->flags);

zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 2, params, NULL);
zval_ptr_dtor_str(&params[0]);
if (is_initialized == FAILURE) {
RETURN_THROWS();
}

subdir = spl_filesystem_from_obj(Z_OBJ_P(return_value));
if (subdir) {
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_dllist.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#endif

#include "php.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"
#include "zend_hash.h"

#include "php_spl.h"
#include "ext/standard/php_var.h"
#include "zend_smart_str.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_iterators.h"
#include "spl_dllist.h"
#include "spl_dllist_arginfo.h"
Expand Down
45 changes: 0 additions & 45 deletions ext/spl/spl_engine.h

This file was deleted.

2 changes: 1 addition & 1 deletion ext/spl/spl_fixedarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#endif

#include "php.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"

#include "php_spl.h"
#include "spl_fixedarray_arginfo.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_fixedarray.h"
#include "spl_exceptions.h"
#include "spl_iterators.h"
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#endif

#include "php.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"

#include "php_spl.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_iterators.h"
#include "spl_heap.h"
#include "spl_heap_arginfo.h"
Expand Down
123 changes: 76 additions & 47 deletions ext/spl/spl_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "php_spl.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_iterators.h"
#include "spl_iterators_arginfo.h"
#include "spl_directory.h"
Expand Down Expand Up @@ -539,7 +538,6 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla

switch (rit_type) {
case RIT_RecursiveTreeIterator: {
zval caching_it_flags;
zend_long user_caching_it_flags = CIT_CATCH_GET_CHILD;
mode = RIT_SELF_FIRST;
flags = RTIT_BYPASS_KEY;
Expand All @@ -558,10 +556,15 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
Z_ADDREF_P(iterator);
}

ZVAL_LONG(&caching_it_flags, user_caching_it_flags);
spl_instantiate_arg_ex2(spl_ce_RecursiveCachingIterator, &caching_it, iterator, &caching_it_flags);
zval_ptr_dtor(&caching_it_flags);
zval_ptr_dtor(iterator);
zval params[2];
ZVAL_COPY_VALUE(&params[0], iterator);
ZVAL_LONG(&params[1], user_caching_it_flags);
zend_result is_initialized = object_init_with_constructor(&caching_it, spl_ce_RecursiveCachingIterator, 2, params, NULL);
zval_ptr_dtor(&params[0]);
if (is_initialized == FAILURE) {
RETURN_THROWS();
}

iterator = &caching_it;
break;
}
Expand Down Expand Up @@ -1674,37 +1677,48 @@ PHP_METHOD(RecursiveFilterIterator, hasChildren)
PHP_METHOD(RecursiveFilterIterator, getChildren)
{
spl_dual_it_object *intern;
zval retval;

ZEND_PARSE_PARAMETERS_NONE();

SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);

zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
spl_instantiate_arg_ex1(Z_OBJCE_P(ZEND_THIS), return_value, &retval);
zval childrens;
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &childrens);
if (Z_TYPE(childrens) == IS_UNDEF) {
RETURN_THROWS();
}

zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 1, &childrens, NULL);
zval_ptr_dtor(&childrens);
if (is_initialized == FAILURE) {
RETURN_THROWS();
}
zval_ptr_dtor(&retval);
} /* }}} */

/* {{{ Return the inner iterator's children contained in a RecursiveCallbackFilterIterator */
PHP_METHOD(RecursiveCallbackFilterIterator, getChildren)
{
spl_dual_it_object *intern;
zval retval;
spl_dual_it_object *intern;

ZEND_PARSE_PARAMETERS_NONE();

SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);

zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
zval callable;
zend_get_callable_zval_from_fcc(&intern->u.callback_filter, &callable);
spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &retval, &callable);
zval_ptr_dtor(&callable);
zval params[2];
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &params[0]);
if (Z_TYPE(params[0]) == IS_UNDEF) {
RETURN_THROWS();
}

/* Get callable to pass to the constructor */
zend_get_callable_zval_from_fcc(&intern->u.callback_filter, &params[1]);

zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 2, params, NULL);
zval_ptr_dtor(&params[0]);
zval_ptr_dtor(&params[1]);
if (is_initialized == FAILURE) {
RETURN_THROWS();
}
zval_ptr_dtor(&retval);
} /* }}} */
/* {{{ Create a ParentIterator from a RecursiveIterator */
PHP_METHOD(ParentIterator, __construct)
Expand Down Expand Up @@ -1961,21 +1975,25 @@ PHP_METHOD(RecursiveRegexIterator, getChildren)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);

zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception)) {
zval args[5];
if (EG(exception)) {
zval_ptr_dtor(&retval);
RETURN_THROWS();
}

ZVAL_COPY(&args[0], &retval);
ZVAL_STR_COPY(&args[1], intern->u.regex.regex);
ZVAL_LONG(&args[2], intern->u.regex.mode);
ZVAL_LONG(&args[3], intern->u.regex.flags);
ZVAL_LONG(&args[4], intern->u.regex.preg_flags);
zval args[5];
ZVAL_COPY_VALUE(&args[0], &retval);
ZVAL_STR_COPY(&args[1], intern->u.regex.regex);
ZVAL_LONG(&args[2], intern->u.regex.mode);
ZVAL_LONG(&args[3], intern->u.regex.flags);
ZVAL_LONG(&args[4], intern->u.regex.preg_flags);

spl_instantiate_arg_n(Z_OBJCE_P(ZEND_THIS), return_value, 5, args);
zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 5, args, NULL);

zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor_str(&args[1]);
if (is_initialized == FAILURE) {
RETURN_THROWS();
}
zval_ptr_dtor(&retval);
} /* }}} */

PHP_METHOD(RecursiveRegexIterator, accept)
Expand Down Expand Up @@ -2246,7 +2264,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern)
}
/* Recursion ? */
if (intern->dit_type == DIT_RecursiveCachingIterator) {
zval retval, zchildren, zflags;
zval retval;
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "haschildren", &retval);
if (EG(exception)) {
zval_ptr_dtor(&retval);
Expand All @@ -2256,28 +2274,39 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern)
return;
}
} else {
if (zend_is_true(&retval)) {
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &zchildren);
bool has_children = zend_is_true(&retval);
zval_ptr_dtor(&retval);

if (has_children) {
zval args[2];

/* Store the children in the first constructor argument */
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &args[0]);
if (EG(exception)) {
zval_ptr_dtor(&zchildren);
zval_ptr_dtor(&args[0]);
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
zend_clear_exception();
} else {
zval_ptr_dtor(&retval);
return;
}
} else {
ZVAL_LONG(&zflags, intern->u.caching.flags & CIT_PUBLIC);
spl_instantiate_arg_ex2(spl_ce_RecursiveCachingIterator, &intern->u.caching.zchildren, &zchildren, &zflags);
zval_ptr_dtor(&zchildren);
}
}
zval_ptr_dtor(&retval);
if (EG(exception)) {
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
zend_clear_exception();
} else {
return;
ZVAL_LONG(&args[1], intern->u.caching.flags & CIT_PUBLIC);

zend_result is_initialized = object_init_with_constructor(
&intern->u.caching.zchildren,
spl_ce_RecursiveCachingIterator,
2,
args,
NULL
);
zval_ptr_dtor(&args[0]);
if (is_initialized == FAILURE) {
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
zend_clear_exception();
} else {
return;
}
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion ext/spl/spl_observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include "php_spl.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_observer.h"
#include "spl_observer_arginfo.h"
#include "spl_iterators.h"
Expand Down
Loading