File tree 3 files changed +38
-7
lines changed
tests/classes/inner_classes
3 files changed +38
-7
lines changed Original file line number Diff line number Diff line change 22
22
#include "zend_hash.h"
23
23
24
24
zend_class_entry * create_namespace (zend_string * name ) {
25
- zend_class_entry * ns = pemalloc (sizeof (zend_class_entry ), 0 );
25
+ zend_class_entry * ns = malloc (sizeof (zend_class_entry ));
26
26
zend_initialize_class_data (ns , 1 );
27
27
ns -> type = ZEND_NAMESPACE_CLASS ;
28
28
ns -> ce_flags |= ZEND_ACC_UNINSTANTIABLE ;
@@ -39,8 +39,8 @@ static zend_class_entry *insert_namespace(const zend_string *name) {
39
39
const char * pos = start ;
40
40
size_t len = 0 ;
41
41
42
- while (pos < end ) {
43
- if (* pos == '\\' ) {
42
+ while (pos <= end ) {
43
+ if (pos == end || * pos == '\\' ) {
44
44
len = pos - start ;
45
45
zend_string * needle = zend_string_init (ZSTR_VAL (name ), len , 0 );
46
46
@@ -100,10 +100,6 @@ void zend_destroy_namespaces(void) {
100
100
zend_hash_destroy (EG (namespaces ));
101
101
FREE_HASHTABLE (EG (namespaces ));
102
102
EG (namespaces ) = NULL ;
103
- }
104
-
105
- if (EG (global_namespace ) != NULL ) {
106
- pefree (EG (global_namespace ), 0 );
107
103
EG (global_namespace ) = NULL ;
108
104
}
109
105
}
Original file line number Diff line number Diff line change @@ -432,6 +432,7 @@ ZEND_API void destroy_zend_class(zval *zv)
432
432
}
433
433
break ;
434
434
case ZEND_INTERNAL_CLASS :
435
+ case ZEND_NAMESPACE_CLASS :
435
436
if (ce -> doc_comment ) {
436
437
zend_string_release_ex (ce -> doc_comment , 1 );
437
438
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ failed inheritance
3
+ --FILE--
4
+ <?php
5
+
6
+ class Outer {
7
+ public class Middle {
8
+ }
9
+ public static function testSelf (): Middle {
10
+ return new Middle ();
11
+ }
12
+ }
13
+
14
+ class Outer2 extends Outer {
15
+ public class Middle {
16
+ }
17
+
18
+ public static function testParent (): Outer \Middle {
19
+ return new Outer \Middle ();
20
+ }
21
+
22
+ public static function testSelf (): Middle {
23
+ return new Middle ();
24
+ }
25
+ }
26
+
27
+ var_dump (Outer::testSelf ());
28
+ var_dump (Outer2::testParent ());
29
+ var_dump (Outer2::testSelf ());
30
+ var_dump (Outer2::testSelf ());
31
+
32
+ ?>
33
+ --EXPECTF--
34
+ Fatal error: Declaration of Outer2::testSelf(): Outer2\middle must be compatible with Outer::testSelf(): Outer\middle in %s on line %d
You can’t perform that action at this time.
0 commit comments