@@ -8665,6 +8665,97 @@ ZEND_METHOD(ReflectionNamedType, getGenericArguments)
86658665 }
86668666}
86678667
8668+ static void reflection_build_named_args_list (zval * return_value , const zend_type * boxed ,
8669+ zend_class_entry * declaring_class )
8670+ {
8671+ if (!ZEND_TYPE_HAS_NAMED_WITH_ARGS (* boxed )) {
8672+ RETURN_NULL ();
8673+ }
8674+
8675+ zend_type_named_with_args * named = ZEND_TYPE_NAMED_WITH_ARGS (* boxed );
8676+ array_init_size (return_value , named -> count );
8677+ for (uint32_t i = 0 ; i < named -> count ; i ++ ) {
8678+ zval entry ;
8679+ reflection_type_factory_ex (named -> args [i ], & entry , false,
8680+ (zend_type ) ZEND_TYPE_INIT_NONE (0 ),
8681+ declaring_class , NULL );
8682+ zend_hash_next_index_insert_new (Z_ARRVAL_P (return_value ), & entry );
8683+ }
8684+ }
8685+
8686+ ZEND_METHOD (ReflectionClass , getGenericArgumentsForParentClass )
8687+ {
8688+ reflection_object * intern ;
8689+ zend_class_entry * ce ;
8690+
8691+ ZEND_PARSE_PARAMETERS_NONE ();
8692+ GET_REFLECTION_OBJECT_PTR (ce );
8693+
8694+ if (!ce -> generic_types || !ce -> generic_types -> extends ) {
8695+ RETURN_NULL ();
8696+ }
8697+
8698+ reflection_build_named_args_list (return_value , ce -> generic_types -> extends , ce );
8699+ }
8700+
8701+ ZEND_METHOD (ReflectionClass , getGenericArgumentsForParentInterface )
8702+ {
8703+ reflection_object * intern ;
8704+ zend_class_entry * ce ;
8705+ zend_string * name ;
8706+
8707+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
8708+ Z_PARAM_STR (name )
8709+ ZEND_PARSE_PARAMETERS_END ();
8710+ GET_REFLECTION_OBJECT_PTR (ce );
8711+
8712+ if (!ce -> generic_types || !ce -> generic_types -> implements ) {
8713+ RETURN_NULL ();
8714+ }
8715+
8716+ zval * zv ;
8717+ ZEND_HASH_FOREACH_VAL (ce -> generic_types -> implements , zv ) {
8718+ zend_type * boxed = (zend_type * ) Z_PTR_P (zv );
8719+ if (ZEND_TYPE_HAS_NAMED_WITH_ARGS (* boxed )) {
8720+ zend_type_named_with_args * named = ZEND_TYPE_NAMED_WITH_ARGS (* boxed );
8721+ if (zend_string_equals_ci (named -> name , name )) {
8722+ reflection_build_named_args_list (return_value , boxed , ce );
8723+ return ;
8724+ }
8725+ }
8726+ } ZEND_HASH_FOREACH_END ();
8727+ RETURN_NULL ();
8728+ }
8729+
8730+ ZEND_METHOD (ReflectionClass , getGenericArgumentsForUsedTrait )
8731+ {
8732+ reflection_object * intern ;
8733+ zend_class_entry * ce ;
8734+ zend_string * name ;
8735+
8736+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
8737+ Z_PARAM_STR (name )
8738+ ZEND_PARSE_PARAMETERS_END ();
8739+ GET_REFLECTION_OBJECT_PTR (ce );
8740+
8741+ if (!ce -> generic_types || !ce -> generic_types -> trait_uses ) {
8742+ RETURN_NULL ();
8743+ }
8744+
8745+ zval * zv ;
8746+ ZEND_HASH_FOREACH_VAL (ce -> generic_types -> trait_uses , zv ) {
8747+ zend_type * boxed = (zend_type * ) Z_PTR_P (zv );
8748+ if (ZEND_TYPE_HAS_NAMED_WITH_ARGS (* boxed )) {
8749+ zend_type_named_with_args * named = ZEND_TYPE_NAMED_WITH_ARGS (* boxed );
8750+ if (zend_string_equals_ci (named -> name , name )) {
8751+ reflection_build_named_args_list (return_value , boxed , ce );
8752+ return ;
8753+ }
8754+ }
8755+ } ZEND_HASH_FOREACH_END ();
8756+ RETURN_NULL ();
8757+ }
8758+
86688759PHP_MINIT_FUNCTION (reflection ) /* {{{ */
86698760{
86708761 memcpy (& reflection_object_handlers , & std_object_handlers , sizeof (zend_object_handlers ));
0 commit comments