News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

MaltBlue.com:
Do We Use Magic Methods or Not?
December 13, 2013 @ 10:39:20

In the latest post to his MaltBlue.com site Matthew Setter takes a look at magic methods. He tries to answer a few basic questions about them - are they worth using and can you truly test effectively when they're in use.

As a freelance Zend Framework developer, I'm always looking to improve the quality of the applications I produce. So over the last 6 - 12 months, I've been learning as much as possible about testing. During this time, I've found the way I code's dramatically changing (and improving). [...] In a recent development session, I attempted to test some of my ZendDb based classes, specifically the code which used the magic methods for dynamically building where clauses. [...] I can't speak for what it's like using PHPUnit's mock objects, as I always use Mockery instead. But after attempting to do so in Mockery, I hit a stumbling block when trying to test the chained call.

His example is a call to "lessThanOrEqualTo" to create his where clause that makes use of the "__get" magic method to get and return "Where" object. After some research (and conversations on IRC) he started wondering if the magic methods were worth the trouble they may cause during testing. He references this post and lists several of the comments made about their use, most of them not in favor.

0 comments voice your opinion now!
magic method zendframework sql builder query unittest testing

Link: http://www.maltblue.com/php/php-magic-methods-or-not

blog comments powered by Disqus

Similar Posts

Dotvoid.com: Zend Feed for a Swedish web development blog aggregator

Juozas Kaziukenas' Blog: Zend Framework and Doctrine. Part 1

Padraic Brady's Blog: Zend Framework Community Review Team

Padraic Brady's Blog: PEAR::Encryption and Zend_Crypt Revisited

Zend Developer Zone: Zend Framework 1.7.5 Released (Security Fix)


Community Events





Don't see your event here?
Let us know!


laravel series library framework security interview version podcast community conference artisanfiles language opinion voicesoftheelephpant release composer introduction tool symfony list

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework