summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-30 13:35:36 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-01-30 14:00:16 +0100
commit0dfd918ee7a3520836b875b8c24f0a5f98fbee15 (patch)
tree2f9645b0f4bcef2f5a3d0ae702bf27470b6f397b /ext
parente93bbf4d5d2812c698a4711fc0ff751b170bdf2b (diff)
downloadphp-git-0dfd918ee7a3520836b875b8c24f0a5f98fbee15.tar.gz
Remove support for __autoload()
There are probably some improvements we can do to the SPL implementation now that __autoload() is gone. In particular having EG(autoload_func) as a property zend function, rather than a simple callback probably doesn't make sense.
Diffstat (limited to 'ext')
-rw-r--r--ext/phar/tests/fatal_error_webphar.phpt2
-rw-r--r--ext/phar/tests/phar_commitwrite.phpt14
-rw-r--r--ext/phar/tests/phar_create_in_cwd.phpt14
-rw-r--r--ext/phar/tests/tar/phar_commitwrite.phpt14
-rw-r--r--ext/phar/tests/zip/phar_commitwrite.phpt14
-rw-r--r--ext/spl/php_spl.c16
6 files changed, 30 insertions, 44 deletions
diff --git a/ext/phar/tests/fatal_error_webphar.phpt b/ext/phar/tests/fatal_error_webphar.phpt
index ce3e8980ad..21df0775b0 100644
--- a/ext/phar/tests/fatal_error_webphar.phpt
+++ b/ext/phar/tests/fatal_error_webphar.phpt
@@ -1,5 +1,7 @@
--TEST--
Phar web-based phar with fatal error
+--XFAIL--
+Uses no longer supported __autoload() function, new phar needed
--INI--
default_charset=UTF-8
--SKIPIF--
diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt
index 8d7068f19a..56d3498d54 100644
--- a/ext/phar/tests/phar_commitwrite.phpt
+++ b/ext/phar/tests/phar_commitwrite.phpt
@@ -12,10 +12,9 @@ $p['file1.txt'] = 'hi';
$p->stopBuffering();
var_dump(strlen($p->getStub()));
$p->setStub("<?php
-function __autoload(\$class)
-{
+spl_autoload_register(function(\$class) {
include 'phar://' . str_replace('_', '/', \$class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER();
@@ -28,13 +27,12 @@ var_dump($p->getStub());
unlink(dirname(__FILE__) . '/brandnewphar.phar');
__HALT_COMPILER();
?>
---EXPECT--
+--EXPECTF--
int(6641)
-string(200) "<?php
-function __autoload($class)
-{
+string(%d) "<?php
+spl_autoload_register(function($class) {
include 'phar://' . str_replace('_', '/', $class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt
index 0e0903d1dd..c1ed9555ed 100644
--- a/ext/phar/tests/phar_create_in_cwd.phpt
+++ b/ext/phar/tests/phar_create_in_cwd.phpt
@@ -13,10 +13,9 @@ try {
$p['file1.txt'] = 'hi';
var_dump(strlen($p->getStub()));
$p->setStub("<?php
-function __autoload(\$class)
-{
+spl_autoload_register(function(\$class) {
include 'phar://' . str_replace('_', '/', \$class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER();
@@ -31,13 +30,12 @@ __HALT_COMPILER();
<?php
unlink(dirname(__FILE__) . '/brandnewphar.phar');
?>
---EXPECT--
+--EXPECTF--
int(6641)
-string(200) "<?php
-function __autoload($class)
-{
+string(%d) "<?php
+spl_autoload_register(function($class) {
include 'phar://' . str_replace('_', '/', $class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/tar/phar_commitwrite.phpt b/ext/phar/tests/tar/phar_commitwrite.phpt
index cdfc449c1c..6d785d287f 100644
--- a/ext/phar/tests/tar/phar_commitwrite.phpt
+++ b/ext/phar/tests/tar/phar_commitwrite.phpt
@@ -12,10 +12,9 @@ $p['file1.txt'] = 'hi';
$p->stopBuffering();
var_dump($p->getStub());
$p->setStub("<?php
-function __autoload(\$class)
-{
+spl_autoload_register(function(\$class) {
include 'phar://' . str_replace('_', '/', \$class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER();
@@ -28,14 +27,13 @@ var_dump($p->isFileFormat(Phar::TAR));
<?php
unlink(dirname(__FILE__) . '/brandnewphar.phar.tar');
?>
---EXPECT--
+--EXPECTF--
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
-string(200) "<?php
-function __autoload($class)
-{
+string(%d) "<?php
+spl_autoload_register(function($class) {
include 'phar://' . str_replace('_', '/', $class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER(); ?>
diff --git a/ext/phar/tests/zip/phar_commitwrite.phpt b/ext/phar/tests/zip/phar_commitwrite.phpt
index cb7fa0f35c..7a7499eb28 100644
--- a/ext/phar/tests/zip/phar_commitwrite.phpt
+++ b/ext/phar/tests/zip/phar_commitwrite.phpt
@@ -12,10 +12,9 @@ $p['file1.txt'] = 'hi';
$p->stopBuffering();
var_dump($p->getStub());
$p->setStub("<?php
-function __autoload(\$class)
-{
+spl_autoload_register(function(\$class) {
include 'phar://' . str_replace('_', '/', \$class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER();
@@ -28,14 +27,13 @@ var_dump($p->isFileFormat(Phar::ZIP));
<?php
unlink(dirname(__FILE__) . '/brandnewphar.phar.zip');
?>
---EXPECT--
+--EXPECTF--
string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();"
-string(200) "<?php
-function __autoload($class)
-{
+string(%d) "<?php
+spl_autoload_register(function($class) {
include 'phar://' . str_replace('_', '/', $class);
-}
+});
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER(); ?>
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index c8c45b0d9d..bc81dc3ba2 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -302,7 +302,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha
} /* }}} */
/* {{{ proto void spl_autoload(string class_name [, string file_extensions])
- Default implementation for __autoload() */
+ Default autoloader implementation */
PHP_FUNCTION(spl_autoload)
{
int pos_len, pos1_len;
@@ -494,7 +494,7 @@ PHP_FUNCTION(spl_autoload_call)
} while (0)
/* {{{ proto bool spl_autoload_register([mixed autoload_function [, bool throw [, bool prepend]]])
- Register given function as __autoload() implementation */
+ Register given function as autoloader */
PHP_FUNCTION(spl_autoload_register)
{
zend_string *func_name;
@@ -668,7 +668,7 @@ skip:
} /* }}} */
/* {{{ proto bool spl_autoload_unregister(mixed autoload_function)
- Unregister given function as __autoload() implementation */
+ Unregister given function as autoloader */
PHP_FUNCTION(spl_autoload_unregister)
{
zend_string *func_name = NULL;
@@ -752,7 +752,7 @@ PHP_FUNCTION(spl_autoload_unregister)
} /* }}} */
/* {{{ proto false|array spl_autoload_functions()
- Return all registered __autoload() functionns */
+ Return all registered autoloader functions */
PHP_FUNCTION(spl_autoload_functions)
{
zend_function *fptr;
@@ -763,14 +763,6 @@ PHP_FUNCTION(spl_autoload_functions)
}
if (!EG(autoload_func)) {
- if ((fptr = zend_hash_find_ptr(EG(function_table), ZSTR_KNOWN(ZEND_STR_MAGIC_AUTOLOAD)))) {
- zval tmp;
-
- array_init(return_value);
- ZVAL_STR_COPY(&tmp, ZSTR_KNOWN(ZEND_STR_MAGIC_AUTOLOAD));
- zend_hash_next_index_insert_new(Z_ARR_P(return_value), &tmp);
- return;
- }
RETURN_FALSE;
}