Req #64514 [Wfx->Csd]: Traits - ask for get_trait_methods
| From: | namarpi at yahoo dot com | Date: | Tue, 26 Mar 2013 13:51:57 +0000 |
| Subject: | Req #64514 [Wfx->Csd]: Traits - ask for get_trait_methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-178110@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64514&edit=1
ID: 64514
User updated by: namarpi at yahoo dot com
Reported by: namarpi at yahoo dot com
Summary: Traits - ask for get_trait_methods
-Status: Wont fix
+Status: Closed
Type: Feature/Change Request
Package: Class/Object related
Operating System: Irrelevant
PHP Version: 5.4.13
Block user comment: N
Private report: N
New Comment:
Thank you very much for your time. I come with a strong typing background,
and tend to forget about PHP attributes, sorry for that.
And of course, an alias does not make sense.
Previous Comments:
------------------------------------------------------------------------
[2013-03-26 13:26:54] nikic@php.net
I have a hard time understanding what it is that you want. As you already pointed out, you can use
get_class_methods to get the methods of both classes and traits (and interfaces for that matter).
Are you suggesting that we add a get_trait_methods alias? If so, no, that won't be done.
------------------------------------------------------------------------
[2013-03-26 09:26:59] namarpi at yahoo dot com
Sorry, the problem is that that I do not know which trait will be the dominent
at the place of "use My_Trait_Admin, My_Trait_Front".
------------------------------------------------------------------------
[2013-03-26 09:04:22] namarpi at yahoo dot com
Thank you for the hint, but it leads me to complete the example a little bit.
The problem is the method name conflict and the absence of possibility of resolving
them dynamically (or, I do not know the know-how).
Please have a look at the new example which contains three files:
My_Class, My_Trait_Admin, My_Trait_Front.
https://github.com/NaMarPi/php-reports/blob/master/trait_conflict_resolution.php
------------------------------------------------------------------------
[2013-03-26 08:02:07] laruence@php.net
you may want to see: http://php.net/manual/en/function.class-uses.php
and works like: get_class_methods(current(class_uses("My_Class")));
------------------------------------------------------------------------
[2013-03-26 06:53:28] namarpi at yahoo dot com
The aim is not to bother My_Class with plenty of methods, I can pick up them, and put them into a
separate My_Trait file. And, the other advantage is that the user do not need to dig into the
My_Class, it is enough him/her to know the more simpler My_Trait.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=64514
--
Edit this bug report at https://bugs.php.net/bug.php?id=64514&edit=1