ionik Posted May 3, 2009 Share Posted May 3, 2009 Hello, Got a bit of a tougher problem that I cant seem to hack. I have a static object that stores a registry, of other objects/string/arrays etc etc..... Currently as the setup is to access anything in the registry I simply call Unus::registry($name); It returns the registry data or null, what I want to accomplish and have not yet been able to get is the following // Call the session object register a new session and add the lifetime and some info Unus::registry('session')->registerSession('Foo', array('ioan1k' => 'PHP Developer'), array('lifetime' => '86400')); /// TURN THAT INTO THIS Unus::session()->registerSession('Foo', array('ioan1k' => 'PHP Developer'), array('lifetime' => '86400')); I am aware of PHP 5.3 will support this but is there any way to hack around this until its release, as __call does not support this. The only alternative I can think of is doing the following, but it defeats the purpose of it being a statically called object, and results in more code than I had originally in the first place $that = Unus::getInstance(); var_dump($that->session()); Dumping Object Unus::dump(Unus::registry('session')); object(Unus_Session)#64 (2) { ["_namespace:private"] => string(7) "Default" ["_data:protected"] => array(1) { ["Default"] => object(Unus_Session_Handler)#59 (2) { ["_namespaceDefault:private"] => string(7) "Default" ["_data:protected"] => array(2) { ["identifier"] => string(7) "Default" ["namespace"] => object(Unus_Session_Namespace)#63 (1) { ["_data:protected"] => array(2) { ["identifier"] => string(7) "Default" ["config"] => object(Unus_Session_Namespace_Config)#62 (2) { ["config"] => array(4) { ["lifetime"] => int(86400) ["allow_modify"] => bool(true) ["hop_expires"] => NULL ["lock"] => bool(false) } ["_data:protected"] => array(4) { ["lifetime"] => int(1241395854) ["allow_modify"] => bool(true) ["hop_expires"] => NULL ["lock"] => bool(false) } } } } } } } } Unus::dump(Unus::session()); Fatal error: Call to undefined method Unus::session() in /var/www/unus/index.php on line 65 Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 What do you get if you do: var_dump(Unus::session()); ? Quote Link to comment Share on other sites More sharing options...
ionik Posted May 3, 2009 Author Share Posted May 3, 2009 What do you get if you do: var_dump(Unus::session()); ? Fatal error: Call to undefined method Unus::session() in /var/www/unus/index.php on line 65 Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 If you don't have the function session, how do you expect to do anything with that? Quote Link to comment Share on other sites More sharing options...
ionik Posted May 3, 2009 Author Share Posted May 3, 2009 If you don't have the function session, how do you expect to do anything with that? Ken, I don't believe you understand what I am trying to explain. I am not calling the session method ( it is a method not a function ). I am calling the registry and getting the session entry via method overloading. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 Can't you define the method session in Unus? public static function session () { return $this->registry('session'); } Quote Link to comment Share on other sites More sharing options...
ionik Posted May 3, 2009 Author Share Posted May 3, 2009 Can't you define the method session in Unus? public static function session () { return $this->registry('session'); } This would defeat the purpose of overloading. "The registry is a singleton class object that stores core values which entries can be added / retrieved at anytime via static methods, no properties are used and all data is stored in a class object." Creating a method to retrieve each registry entry would be to overwhelming and impossible because of the nature of the class. This is why they must be overloaded. Ken here is the definition of overloading..... http://us.php.net/manual/en/language.oop5.overloading.php Looks like its a bug that has been reported..... http://bugs.php.net/bug.php?id=30310 Anyone have a workaround? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.