ID:               45309
 Updated by:       [EMAIL PROTECTED]
 Reported By:      php at suteki dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: Linux (CentOS 5)
 PHP Version:      5.2.6
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

See previous comment.


Previous Comments:
------------------------------------------------------------------------

[2008-06-19 09:16:51] felix dot devliegher at gmail dot com

Have a look at SPL Reflection (http://be.php.net/reflection).
All functionality for getting a method's visibility is in there.

------------------------------------------------------------------------

[2008-06-19 03:40:56] php at suteki dot org

Description:
------------
I can't seem to be able to find any php functions that would check if a
method is public, private or protected before calling it.  This would be
used in a custom framework that loads classes as plugins.  Right now if
a method is private and the framework trys to call it and has no access,
I get a fatal error (which I would like to avoid).  I've worked around
it for the time by doing some goofy naming in my class and putting some
code into the function that dynamically calls the methods, but I think
there should be a better way to handle things.

Reproduce code:
---------------
This is how I'm working around it right now...

// Load the requested class.  Then run the requested method.  If the
method is not available, run the default event.
// Please name private methods with two leading underscores ( __ ) to
prevent errors from occuring because PHP has no way of checking if an
event is
// private before it trys to run it..
$currentModule = url::get()->moduleID;
$currentEvent = substr(url::get()->GET['event'], 0, 2) != '__' &&
url::get()->GET['event'] ? url::get()->GET['event'] :
config::$defaultEvent;
$$currentModule = new $currentModule;
if (method_exists($$currentModule, $currentEvent)) {
        $$currentModule->$currentEvent();
}


Expected result:
----------------
I would like to do something like this if possible...

// Load the requested module.  Then run the requested event.  If the
event is not available, run the default event.
$currentModule = url::get()->moduleID;
$currentEvent = url::get()->GET['event'] ? url::get()->GET['event'] :
config::$defaultEvent;
$$currentModule = new $currentModule;
if (method_exists($$currentModule, $currentEvent) &&
method_encapsulation($$currentModule, $currentEvent) == 'public') {
        $$currentModule->$currentEvent();
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45309&edit=1

Reply via email to