]> granicus.if.org Git - php/commitdiff
Fixed #65213 - cannot cast SplFileInfo to boolean
authorTjerk Meesters <datibbaw@php.net>
Wed, 3 Dec 2014 23:17:33 +0000 (07:17 +0800)
committerTjerk Meesters <datibbaw@php.net>
Wed, 3 Dec 2014 23:17:33 +0000 (07:17 +0800)
NEWS
ext/spl/spl_directory.c
ext/spl/tests/bug65213.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 115484323cc939a12aaf957c3b92a671ca643f17..65df546662112c948e204a66981375a876ec827c 100644 (file)
--- 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
 
index 124a665991a8e9a9685aefbf9a5ef2c10ed092ea..9f4e43f727f697b542ac2ccc696ba754279bb300 100644 (file)
@@ -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 (file)
index 0000000..5e34d95
--- /dev/null
@@ -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===