Skip to content

Commit 3fd2257

Browse files
committed
ext/spl: Remove spl_engine.h header
This doesn't really make the calling code clearer and it is barely used on top of that.
1 parent 51379d6 commit 3fd2257

14 files changed

+119
-110
lines changed

UPGRADING.INTERNALS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,18 @@ PHP 8.4 INTERNALS UPGRADE NOTES
263263
- The ext/session/php_session.h doesn't transitively include the
264264
ext/hash/php_hash.h header anymore.
265265

266+
i. ext/spl
267+
- The spl_engine.h header has been removed, this includes the following 3
268+
functions it was defining:
269+
- spl_instantiate_arg_ex1
270+
- spl_instantiate_arg_ex2
271+
- spl_instantiate_arg_n
272+
Instead manually instantiate the object with object_init_ex() and call
273+
the constructor via one of the zend_call_known_instance_method*()
274+
API. E.g. zend_call_known_instance_method_with_1_params(
275+
ce->constructor, Z_OBJ_P(return_value), NULL, &arg1);
276+
or use the new object_init_with_constructor() API
277+
266278
========================
267279
4. OpCode changes
268280
========================

ext/phar/phar_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#include "Zend/zend_virtual_cwd.h"
5353
#include "ext/spl/spl_array.h"
5454
#include "ext/spl/spl_directory.h"
55-
#include "ext/spl/spl_engine.h"
5655
#include "ext/spl/spl_exceptions.h"
5756
#include "ext/spl/spl_iterators.h"
5857
#include "php_phar.h"

ext/phar/phar_object.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,9 +3540,7 @@ PHP_METHOD(Phar, offsetGet)
35403540
{
35413541
char *fname, *error;
35423542
size_t fname_len;
3543-
zval zfname;
35443543
phar_entry_info *entry;
3545-
zend_string *sfname;
35463544

35473545
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
35483546
RETURN_THROWS();
@@ -3574,10 +3572,16 @@ PHP_METHOD(Phar, offsetGet)
35743572
efree(entry);
35753573
}
35763574

3577-
sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
3575+
zend_string *sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
3576+
zval zfname;
35783577
ZVAL_NEW_STR(&zfname, sfname);
3579-
spl_instantiate_arg_ex1(phar_obj->spl.info_class, return_value, &zfname);
3578+
3579+
/* Instantiate object and call constructor */
3580+
zend_result is_initialized = object_init_with_constructor(return_value, phar_obj->spl.info_class, 1, &zfname, NULL);
35803581
zval_ptr_dtor(&zfname);
3582+
if (is_initialized == FAILURE) {
3583+
RETURN_THROWS();
3584+
}
35813585
}
35823586
}
35833587
/* }}} */

ext/spl/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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)
2-
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])
2+
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])
33
PHP_ADD_EXTENSION_DEP(spl, pcre, true)
44
PHP_ADD_EXTENSION_DEP(spl, standard, true)
55
PHP_ADD_EXTENSION_DEP(spl, json)

ext/spl/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
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");
44
PHP_SPL="yes";
5-
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");
5+
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");

ext/spl/php_spl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "php_spl.h"
2626
#include "php_spl_arginfo.h"
2727
#include "spl_functions.h"
28-
#include "spl_engine.h"
2928
#include "spl_array.h"
3029
#include "spl_directory.h"
3130
#include "spl_iterators.h"

ext/spl/spl_directory.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
#include "php_spl.h"
3232
#include "spl_functions.h"
33-
#include "spl_engine.h"
3433
#include "spl_iterators.h"
3534
#include "spl_directory.h"
3635
#include "spl_directory_arginfo.h"
@@ -1517,7 +1516,6 @@ PHP_METHOD(RecursiveDirectoryIterator, hasChildren)
15171516
/* {{{ Returns an iterator for the current entry if it is a directory */
15181517
PHP_METHOD(RecursiveDirectoryIterator, getChildren)
15191518
{
1520-
zval zpath, zflags;
15211519
spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS));
15221520
spl_filesystem_object *subdir;
15231521
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
@@ -1530,10 +1528,16 @@ PHP_METHOD(RecursiveDirectoryIterator, getChildren)
15301528
RETURN_THROWS();
15311529
}
15321530

1533-
ZVAL_LONG(&zflags, intern->flags);
1534-
ZVAL_STR_COPY(&zpath, intern->file_name);
1535-
spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &zpath, &zflags);
1536-
zval_ptr_dtor(&zpath);
1531+
zval params[2];
1532+
ZVAL_STR_COPY(&params[0], intern->file_name);
1533+
ZVAL_LONG(&params[1], intern->flags);
1534+
/* Instantiate object and call constructor */
1535+
zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 2, params, NULL);
1536+
zval_ptr_dtor(&params[0]);
1537+
zval_ptr_dtor(&params[1]);
1538+
if (is_initialized == FAILURE) {
1539+
RETURN_THROWS();
1540+
}
15371541

15381542
subdir = spl_filesystem_from_obj(Z_OBJ_P(return_value));
15391543
if (subdir) {

ext/spl/spl_dllist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#endif
2020

2121
#include "php.h"
22+
#include "zend_interfaces.h"
2223
#include "zend_exceptions.h"
2324
#include "zend_hash.h"
2425

@@ -27,7 +28,6 @@
2728
#include "ext/standard/php_var.h"
2829
#include "zend_smart_str.h"
2930
#include "spl_functions.h"
30-
#include "spl_engine.h"
3131
#include "spl_iterators.h"
3232
#include "spl_dllist.h"
3333
#include "spl_dllist_arginfo.h"

ext/spl/spl_engine.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

ext/spl/spl_exceptions.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include "php_spl.h"
2929
#include "spl_functions.h"
30-
#include "spl_engine.h"
3130
#include "spl_exceptions.h"
3231

3332
PHPAPI zend_class_entry *spl_ce_LogicException;

0 commit comments

Comments
 (0)