PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu May 28, 2020 1:17 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Feb 26, 2010 7:14 pm 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria


Last edited by Darhazer on Fri Mar 12, 2010 4:21 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Feb 26, 2010 7:21 pm 
Offline
DevNet Master
User avatar

Joined: Fri Jan 18, 2008 1:36 am
Posts: 3549
Location: Israel, ME


Top
 Profile  
 
PostPosted: Fri Feb 26, 2010 7:29 pm 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria
Yeah, but returning either an object or not an object makes chaining dangerous. And the point of using fluent interface is chaining calls, isn't it? Why would you even call translate() just to receive the same instance, without changing / performing anything?


Top
 Profile  
 
PostPosted: Fri Feb 26, 2010 9:02 pm 
Offline
DevNet Master
User avatar

Joined: Fri Jan 18, 2008 1:36 am
Posts: 3549
Location: Israel, ME
Translate is a view method which instantiates the helper. They were probably trying to accommodate several configuration styles, such as the one shown in the manual:
Syntax: [ Download ] [ Hide ]
$adapter = new Zend_Translate('array', array('simple' => 'einfach'), 'de');
$this->translate()->setTranslator($adapter)->translate('simple');


Top
 Profile  
 
PostPosted: Sat Feb 27, 2010 4:51 am 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria
Now I see
Thanks pytrin
Wouldn't it be better, if there is a getTranslatedString() method, which returns the translation, and translate() always to return an object? As written in a book: never return nulls, or you are most likely to get a null pointer exception somewhere ;) Yeah, it does not return null, but returning not an object from a method that return an object as well, is the same problem anyway.

Once again, thank you for taking your time to explain this to me.


Top
 Profile  
 
PostPosted: Sat Feb 27, 2010 8:54 am 
Offline
DevNet Master
User avatar

Joined: Fri Jan 18, 2008 1:36 am
Posts: 3549
Location: Israel, ME
You could file an issue with this at their issue tracker. They're usually pretty responsive


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group