diff options
| author | Ondřej Surý <ondrej@sury.org> | 2013-02-25 16:11:05 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2013-02-25 16:11:05 +0100 |
| commit | c8013604b48675ec2b266aa186bb6c3126c47cca (patch) | |
| tree | de627cca2457af7c3c0a6498906ff49b4d2f722d /ext/spl | |
| parent | 28f17d3b49950d50f3900f84d74d7cc0822b123d (diff) | |
| download | php-upstream/5.4.12.tar.gz | |
Imported Upstream version 5.4.12upstream/5.4.12
Diffstat (limited to 'ext/spl')
| -rw-r--r-- | ext/spl/spl_directory.c | 4 | ||||
| -rw-r--r-- | ext/spl/tests/bug64023.phpt | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 61d6324d5..f43a3709e 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1874,6 +1874,10 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(readobj TSRMLS_CC); if (type == IS_STRING) { + if (Z_OBJCE_P(readobj)->__tostring) { + return std_object_handlers.cast_object(readobj, writeobj, type TSRMLS_CC); + } + switch (intern->type) { case SPL_FS_INFO: case SPL_FS_FILE: diff --git a/ext/spl/tests/bug64023.phpt b/ext/spl/tests/bug64023.phpt new file mode 100644 index 000000000..2c177f951 --- /dev/null +++ b/ext/spl/tests/bug64023.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #64023: Overloading __toString() in SplFileInfo has no effect +--FILE-- +<?php +class A extends \SplFileInfo +{ + public function __toString() {return ' -expected- ';} +} + +$a = new A('/'); + +// Works +echo $a, $a->__toString(), $a->__toString() . '', "\n"; + +// Does not work - outputs parent::__toString() +echo $a . '', "\n"; + +--EXPECT-- + -expected- -expected- -expected- + -expected- |
