@@ -884,11 +884,42 @@ static void le_throwing_resource_dtor(zend_resource *rsrc)
884
884
zend_throw_exception (NULL , "Throwing resource destructor called" , 0 );
885
885
}
886
886
887
+ // We need to "manually" generate this property because gen_stubs.php
888
+ // does not support codegen for DNF types.
889
+ static void register_ZendTestClass_dnf_property (zend_class_entry * ce ) {
890
+ zend_string * class_Iterator = zend_string_init_interned ("Iterator" , sizeof ("Iterator" ) - 1 , true);
891
+ zend_alloc_ce_cache (class_Iterator );
892
+ zend_string * class_Traversable = zend_string_init_interned ("Traversable" , sizeof ("Traversable" ) - 1 , true);
893
+ zend_alloc_ce_cache (class_Traversable );
894
+ zend_string * class_Countable = zend_string_init_interned ("Countable" , sizeof ("Countable" ) - 1 , true);
895
+ zend_alloc_ce_cache (class_Countable );
896
+ //
897
+ zend_type_list * intersection_type_list = malloc (ZEND_TYPE_LIST_SIZE (2 ));
898
+ intersection_type_list -> num_types = 2 ;
899
+ intersection_type_list -> types [0 ] = (zend_type ) ZEND_TYPE_INIT_CLASS (class_Traversable , 0 , 0 );
900
+ intersection_type_list -> types [1 ] = (zend_type ) ZEND_TYPE_INIT_CLASS (class_Countable , 0 , 0 );
901
+ zend_type_list * union_type_list = malloc (ZEND_TYPE_LIST_SIZE (2 ));
902
+ union_type_list -> num_types = 2 ;
903
+ union_type_list -> types [0 ] = (zend_type ) ZEND_TYPE_INIT_CLASS (class_Iterator , 0 , 0 );
904
+ union_type_list -> types [1 ] = (zend_type ) ZEND_TYPE_INIT_INTERSECTION (intersection_type_list , 0 );
905
+ zend_type prop_type = (zend_type ) ZEND_TYPE_INIT_UNION (union_type_list , 0 );
906
+ //
907
+ zend_string * prop_name = zend_string_init_interned ("dnfProperty" , sizeof ("dnfProperty" ) - 1 , true);
908
+ zval default_value ;
909
+ ZVAL_UNDEF (& default_value );
910
+ // We need this hack because some debug assertions incorrectly reject valid DNF types.
911
+ // see https://github.com/php/php-src/issues/10120#issuecomment-1360682804
912
+ zend_type hack = {0 };
913
+ zend_property_info * prop = zend_declare_typed_property (ce , prop_name , & default_value , ZEND_ACC_PUBLIC , NULL , hack );
914
+ prop -> type = prop_type ;
915
+ }
916
+
887
917
PHP_MINIT_FUNCTION (zend_test )
888
918
{
889
919
zend_test_interface = register_class__ZendTestInterface ();
890
920
891
921
zend_test_class = register_class__ZendTestClass (zend_test_interface );
922
+ register_ZendTestClass_dnf_property (zend_test_class );
892
923
zend_test_class -> create_object = zend_test_class_new ;
893
924
zend_test_class -> get_static_method = zend_test_class_static_method_get ;
894
925
0 commit comments