summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--ext/spl/spl_directory.c3
-rw-r--r--ext/spl/tests/bug65213.phpt13
3 files changed, 17 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 115484323c..65df546662 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ PHP NEWS
- SPL:
. Fixed bug #66405 (RecursiveDirectoryIterator::CURRENT_AS_PATHNAME
breaks the RecursiveIterator). (Paul Garvin)
+ . Fixed bug #65213 (cannot cast SplFileInfo to boolean) (Tjerk)
11 Dec 2014, PHP 5.5.20
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 124a665991..9f4e43f727 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1907,6 +1907,9 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS
}
return SUCCESS;
}
+ } else if (type == IS_BOOL) {
+ ZVAL_BOOL(writeobj, 1);
+ return SUCCESS;
}
if (readobj == writeobj) {
zval_dtor(readobj);
diff --git a/ext/spl/tests/bug65213.phpt b/ext/spl/tests/bug65213.phpt
new file mode 100644
index 0000000000..5e34d9549c
--- /dev/null
+++ b/ext/spl/tests/bug65213.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #65213 (cannot cast SplFileInfo to boolean)
+--FILE--
+<?php
+
+$o = new SplFileInfo('.');
+var_dump((bool) $o);
+
+?>
+===DONE===
+--EXPECT--
+bool(true)
+===DONE===