Skip to content

Commit 2bcf8a6

Browse files
committed
Fixed #65213 - cannot cast SplFileInfo to boolean
1 parent 13aaba4 commit 2bcf8a6

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ PHP NEWS
2525
- SPL:
2626
. Fixed bug #66405 (RecursiveDirectoryIterator::CURRENT_AS_PATHNAME
2727
breaks the RecursiveIterator). (Paul Garvin)
28+
. Fixed bug #65213 (cannot cast SplFileInfo to boolean) (Tjerk)
2829

2930
11 Dec 2014, PHP 5.5.20
3031

ext/spl/spl_directory.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,9 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS
19071907
}
19081908
return SUCCESS;
19091909
}
1910+
} else if (type == IS_BOOL) {
1911+
ZVAL_BOOL(writeobj, 1);
1912+
return SUCCESS;
19101913
}
19111914
if (readobj == writeobj) {
19121915
zval_dtor(readobj);

ext/spl/tests/bug65213.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #65213 (cannot cast SplFileInfo to boolean)
3+
--FILE--
4+
<?php
5+
6+
$o = new SplFileInfo('.');
7+
var_dump((bool) $o);
8+
9+
?>
10+
===DONE===
11+
--EXPECT--
12+
bool(true)
13+
===DONE===

0 commit comments

Comments
 (0)