myself = getThis(); \
if (myself) { \
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(myself), "handle", sizeof("handle")-1)) == NULL) { \
- php_error_docref(NULL, E_WARNING, "Unable to find my handle property"); \
- RETURN_FALSE; \
+ zend_throw_error(NULL, "Unable to find my handle property"); \
+ return; \
} \
if ((dirp = (php_stream *)zend_fetch_resource_ex(tmp, "Directory", php_file_le_stream())) == NULL) { \
- RETURN_FALSE; \
+ return; \
} \
} else { \
if (!DIRG(default_dir) || \
(dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
- RETURN_FALSE; \
+ return; \
} \
} \
} else { \
if ((dirp = (php_stream *)zend_fetch_resource(Z_RES_P(id), "Directory", php_file_le_stream())) == NULL) { \
- RETURN_FALSE; \
+ return; \
} \
}
echo "Cannot instantiate a valid Directory directly:\n";
$d = new Directory(getcwd());
var_dump($d);
-var_dump($d->read());
+
+try {
+ var_dump($d->read());
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
?>
--EXPECTF--
Cannot instantiate a valid Directory directly:
object(Directory)#%d (0) {
}
-
-Warning: Directory::read(): Unable to find my handle property in %s on line 15
-bool(false)
+Unable to find my handle property
echo "\n--> Try all methods with no handle:\n";
$d = new Directory($d);
unset($d->handle);
-var_dump($d->read());
-var_dump($d->rewind());
-var_dump($d->close());
+
+try {
+ var_dump($d->read());
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($d->rewind());
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($d->close());
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
?>
--CLEAN--
rmdir($d);
?>
---EXPECTF--
+--EXPECT--
--> Try all methods with bad handle:
Directory::read(): supplied argument is not a valid Directory resource
Directory::rewind(): supplied argument is not a valid Directory resource
Directory::close(): supplied argument is not a valid Directory resource
--> Try all methods with no handle:
+Unable to find my handle property
+Unable to find my handle property
+Unable to find my handle property
-Warning: Directory::read(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::close(): Unable to find my handle property in %s on line %d
-bool(false)
echo "\n--> Try all methods with no handle:\n";
$d = new Directory(getcwd());
unset($d->handle);
-var_dump($d->read());
-var_dump($d->rewind());
-var_dump($d->close());
+
+try {
+ var_dump($d->read());
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($d->rewind());
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($d->close());
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
?>
---EXPECTF--
+--EXPECT--
--> Try all methods with bad handle:
Directory::read(): supplied argument is not a valid Directory resource
Directory::rewind(): supplied argument is not a valid Directory resource
Directory::close(): supplied argument is not a valid Directory resource
--> Try all methods with no handle:
-
-Warning: Directory::read(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::close(): Unable to find my handle property in %s on line %d
-bool(false)
+Unable to find my handle property
+Unable to find my handle property
+Unable to find my handle property