File tree 4 files changed +52
-34
lines changed 4 files changed +52
-34
lines changed Original file line number Diff line number Diff line change @@ -68,21 +68,21 @@ static zend_class_entry *dir_class_entry_ptr;
68
68
myself = getThis(); \
69
69
if (myself) { \
70
70
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(myself), "handle", sizeof("handle")-1)) == NULL) { \
71
- php_error_docref (NULL, E_WARNING , "Unable to find my handle property"); \
72
- RETURN_FALSE ; \
71
+ zend_throw_error (NULL, "Unable to find my handle property"); \
72
+ return ; \
73
73
} \
74
74
if ((dirp = (php_stream *)zend_fetch_resource_ex(tmp, "Directory", php_file_le_stream())) == NULL) { \
75
- RETURN_FALSE ; \
75
+ return ; \
76
76
} \
77
77
} else { \
78
78
if (!DIRG(default_dir) || \
79
79
(dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
80
- RETURN_FALSE ; \
80
+ return ; \
81
81
} \
82
82
} \
83
83
} else { \
84
84
if ((dirp = (php_stream *)zend_fetch_resource(Z_RES_P(id), "Directory", php_file_le_stream())) == NULL) { \
85
- RETURN_FALSE ; \
85
+ return ; \
86
86
} \
87
87
}
88
88
Original file line number Diff line number Diff line change @@ -15,7 +15,12 @@ echo $rc;
15
15
echo "Cannot instantiate a valid Directory directly: \n" ;
16
16
$ d = new Directory (getcwd ());
17
17
var_dump ($ d );
18
- var_dump ($ d ->read ());
18
+
19
+ try {
20
+ var_dump ($ d ->read ());
21
+ } catch (\Error $ e ) {
22
+ echo $ e ->getMessage () . "\n" ;
23
+ }
19
24
20
25
?>
21
26
--EXPECTF--
@@ -60,6 +65,4 @@ Class [ <internal%s> class Directory ] {
60
65
Cannot instantiate a valid Directory directly:
61
66
object(Directory)#%d (0) {
62
67
}
63
-
64
- Warning: Directory::read(): Unable to find my handle property in %s on line 15
65
- bool(false)
68
+ Unable to find my handle property
Original file line number Diff line number Diff line change 29
29
echo "\n--> Try all methods with no handle: \n" ;
30
30
$ d = new Directory ($ d );
31
31
unset($ d ->handle );
32
- var_dump ($ d ->read ());
33
- var_dump ($ d ->rewind ());
34
- var_dump ($ d ->close ());
32
+
33
+ try {
34
+ var_dump ($ d ->read ());
35
+ } catch (\Error $ e ) {
36
+ echo $ e ->getMessage () . "\n" ;
37
+ }
38
+ try {
39
+ var_dump ($ d ->rewind ());
40
+ } catch (\Error $ e ) {
41
+ echo $ e ->getMessage () . "\n" ;
42
+ }
43
+ try {
44
+ var_dump ($ d ->close ());
45
+ } catch (\Error $ e ) {
46
+ echo $ e ->getMessage () . "\n" ;
47
+ }
35
48
36
49
?>
37
50
--CLEAN--
@@ -40,19 +53,14 @@ $d = getcwd().PATH_SEPARATOR."私はガラスを食べられます";
40
53
rmdir ($ d );
41
54
42
55
?>
43
- --EXPECTF --
56
+ --EXPECT --
44
57
--> Try all methods with bad handle:
45
58
Directory::read(): supplied argument is not a valid Directory resource
46
59
Directory::rewind(): supplied argument is not a valid Directory resource
47
60
Directory::close(): supplied argument is not a valid Directory resource
48
61
49
62
--> Try all methods with no handle:
63
+ Unable to find my handle property
64
+ Unable to find my handle property
65
+ Unable to find my handle property
50
66
51
- Warning: Directory::read(): Unable to find my handle property in %s on line %d
52
- bool(false)
53
-
54
- Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
55
- bool(false)
56
-
57
- Warning: Directory::close(): Unable to find my handle property in %s on line %d
58
- bool(false)
Original file line number Diff line number Diff line change @@ -25,24 +25,31 @@ try {
25
25
echo "\n--> Try all methods with no handle: \n" ;
26
26
$ d = new Directory (getcwd ());
27
27
unset($ d ->handle );
28
- var_dump ($ d ->read ());
29
- var_dump ($ d ->rewind ());
30
- var_dump ($ d ->close ());
28
+
29
+ try {
30
+ var_dump ($ d ->read ());
31
+ } catch (\Error $ e ) {
32
+ echo $ e ->getMessage () . "\n" ;
33
+ }
34
+ try {
35
+ var_dump ($ d ->rewind ());
36
+ } catch (\Error $ e ) {
37
+ echo $ e ->getMessage () . "\n" ;
38
+ }
39
+ try {
40
+ var_dump ($ d ->close ());
41
+ } catch (\Error $ e ) {
42
+ echo $ e ->getMessage () . "\n" ;
43
+ }
31
44
32
45
?>
33
- --EXPECTF --
46
+ --EXPECT --
34
47
--> Try all methods with bad handle:
35
48
Directory::read(): supplied argument is not a valid Directory resource
36
49
Directory::rewind(): supplied argument is not a valid Directory resource
37
50
Directory::close(): supplied argument is not a valid Directory resource
38
51
39
52
--> Try all methods with no handle:
40
-
41
- Warning: Directory::read(): Unable to find my handle property in %s on line %d
42
- bool(false)
43
-
44
- Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
45
- bool(false)
46
-
47
- Warning: Directory::close(): Unable to find my handle property in %s on line %d
48
- bool(false)
53
+ Unable to find my handle property
54
+ Unable to find my handle property
55
+ Unable to find my handle property
You can’t perform that action at this time.
0 commit comments