Traits - Is it stable to use get_class_methods on a trait?

From: Date: Wed, 13 Mar 2013 14:46:55 +0000
Subject: Traits - Is it stable to use get_class_methods on a trait?
Groups: php.general 
Request: Send a blank email to php-general+get-320510@lists.php.net to get a copy of this message
Hello All, there is a trait which sits in a class. I need the names of the trait methods, and get_class_methods does this job. I am happy with that, but is it safe/stable? Is there a better way to get trait method names? Thanks a lot. Working example (My_Class and My_Trait are in different files):. ---------------------------------------------------------------------------------------------- trait My_Trait {     function trait_method_1() {}     function trait_method_2() {} } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - class My_Class {     use My_Trait;     function class_method_1() {         $trait_methods = get_class_methods( 'My_Trait' );         print_r( $trait_methods );     }     function class_method_2() {} } $my_object = new My_Class(); $my_object->class_method_1(); Result: ------------------------ [13-Mar-2013 14:41:22 UTC] Array (     [0] => trait_method_1     [1] => trait_method_2 )

« previous php.general (#320510) next »