<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Thu, 24 May 2012 09:12:26 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Chris Hartjes' Blog: Metatesting: Extending Your Testing Tools]]></title>
      <guid>http://www.phpdeveloper.org/news/17851</guid>
      <link>http://www.phpdeveloper.org/news/17851</link>
      <description><![CDATA[<p>
<i>Chris Hartjes</i> has had a few posts about "metatesting" already and in <a href="http://www.littlehart.net/atthekeyboard/2012/04/19/metatesting-extending-your-testing-tools/">this latest article</a> he takes the series one more step. He looks at moving outside of the current toolset and expanding on them to meet your testing needs.
</p>
<blockquote>
While <a href="http://phpunit.de/">PHPUnit</a> is awesome out of the box, it still lacks some tools that are required to do things like test protected class methods or assign values to protected class attributes. Lucky for me we have an awesome testing engineer at Kaplan named <a href="https://twitter.com/FreshWillisms">Will Parker</a> who has shown me some ways that they have extended PHPUnit itself to make testing certain things easier.
</blockquote>
<p>
<i>Chris</i> talks about things like testing protected methods (easy thanks to a helper) and checking the value of a class property. The key to both of them lies in using PHP's own <a href="http://php.net/reflection">Reflection</a> functionality to alter properties on the class objects themselves.
</p>]]></description>
      <pubDate>Mon, 23 Apr 2012 11:27:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Josh Adell's Blog: GetSet Methods vs. Public Properties]]></title>
      <guid>http://www.phpdeveloper.org/news/17623</guid>
      <link>http://www.phpdeveloper.org/news/17623</link>
      <description><![CDATA[<p>
<i>Josh Adell</i> has a new post to his blog talking about a debate between developers over which is the better method - <a href="http://blog.everymansoftware.com/2012/03/getset-methods-vs-public-properties.html">using public properties or getters and setters</a> to work with values on your objects.
</p>
<blockquote>
I was recently having a debate with a coworker over the utility of writing getter and setter methods for protected properties of classes. On the one hand, having getters and setters seems like additional boilerplate and programming overhead for very little gain. On the other hand, exposing the value properties of a class seems like bad encapsulation and will overall lead to code that is more difficult to maintain. I come down firmly on the get/set method side of the fence. 
</blockquote>
<p>
In his opinion, the getter/setter method provides an explicit interface to the class that describes what it can do and how you can work with it. He gives code examples, comparing the two methods - simple setting of properties on one object and using get*/set* methods on the other. He brings up the point that, if ever in the future you wanted to handle the data for a property differently, say always make it an array or object. He also points out that this still doesn't prevent the setting of new properties directly, so he uses the magic __get and __set to deal with that.
</p>]]></description>
      <pubDate>Mon, 05 Mar 2012 09:50:21 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Freek Lijten's Blog: Currently on PHP's internals - Property Accessors]]></title>
      <guid>http://www.phpdeveloper.org/news/17493</guid>
      <link>http://www.phpdeveloper.org/news/17493</link>
      <description><![CDATA[<p>
<i>Freek Lijten</i> has <a href="http://www.freeklijten.nl/home/2012/02/02/Currently-on-PHPs-internals-Property-Accessors">posted another</a> "Currently on PHP's internals..." post to his blog today (<a href="http://phpdeveloper.org/news/16476">here's</a> the previous one) with a look at the discussions around the idea of having "property accessors" in PHP - a standardized way of defining getters/setters in objects.
</p>
<blockquote>
 Today I will be discussing a feature that at this moment is called "Property Accessor". It is a method of defining getters and setters. Originally an RFC was defined as early as september 2009, but recently new discussion took place and an actual patch was created. There is no certainty this feature will ever make a PHP version but discussion seems to target implementation details and not the feature itself, so things are looking bright for this feature.
</blockquote>
<p>
There's two RFCs posted about the topic - <a href="https://wiki.php.net/rfc/propertygetsetsyntax">the original proposal</a> (from <i>Dennis Robinson</i>) and <a href="https://wiki.php.net/rfc/propertygetsetsyntax-as-implemented">a patch</a> for implementing them (from <i>Clint Priest</i>). The proposal replaces the common magic getters/setters (__get & __set) with the optional "get" and "set" keywords inside of custom-defined properties.
</p>]]></description>
      <pubDate>Fri, 03 Feb 2012 09:39:14 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weier O'Phinney's Blog: Proxies in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16555</guid>
      <link>http://www.phpdeveloper.org/news/16555</link>
      <description><![CDATA[<p>
In a new blog post <i>Matthew Weier O'Phinney</i> has <a href="http://weierophinney.net/matthew/archives/263-Proxies-in-PHP.html">taken a look at proxy objects</a> (the Proxy design pattern) and how it differs from some of the other popular patterns.
</p>
<blockquote>
Of the other patterns mentioned, the one closest to the Proxy is the Decorator. In the case of a Decorator, the focus is on adding functionality to an existing object -- for instance, adding methods, processing input before delegating to the target object, or filtering the return of a method from a target object.
</blockquote>
<p>
Proxies stand in for objects and have several benefits for your application that may or may not need all of the overhead a full object could cause. <i>Matthew</i> focuses on one benefit in particular - consuming and controlling access to another object. He sets up a problem of wanting to use properties/methods on objects that aren't exposed directly (like a protected method). His solution is a proxy layer class on top of the original object. He includes a few "gotchas" to look out for when using this technique including overwriting all necessary methods and copying over all of the needed properties.
</p>]]></description>
      <pubDate>Wed, 06 Jul 2011 08:10:08 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Shawn Stratton's Blog: Accesors and Religion]]></title>
      <guid>http://www.phpdeveloper.org/news/16349</guid>
      <link>http://www.phpdeveloper.org/news/16349</link>
      <description><![CDATA[<p>
<i>Shawn Stratton</i> has a new post to his blog talking about a topic he calls "flame bait" - the use of <a href="http://www.shawnstratton.info/accesors-and-religion/">accessors in PHP applications</a> (getters and setters) to access class properties.
</p>
<blockquote>
Objects have prop­er­ties which some­times need spe­cial logic on how they are retrieved and set.  There are sev­eral solu­tions to this and every­body has a dif­fer­ent view point about which is cor­rect, none are pretty and all have draw­backs which range from writ­ing extra code, cre­at­ing some­thing that has poor exten­si­bil­ity, or has issues with con­sis­tency.  These don't even breach the issues with IDE code com­ple­tion and analy­sis.  Lets look at some of these solutions.
</blockquote>
<p>
The solutions are the direct access to the class properties (which can cause some painful inconsistencies when things get complicated) and the alternative of setting up getters/setters for everything. <i>Shawn</i>'s alternative makes use of the __get and __set magic methods to catch the property values being set and handle them correctly, developers being none the wiser.
</p>]]></description>
      <pubDate>Tue, 17 May 2011 14:46:32 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Cal Evans' Blog: Six ways to be a better client for your developer - Point 8]]></title>
      <guid>http://www.phpdeveloper.org/news/15957</guid>
      <link>http://www.phpdeveloper.org/news/15957</link>
      <description><![CDATA[<p>
<i>Cal Evans</i> has posted the <a href="http://blog.calevans.com/2011/02/22/six-ways-to-be-a-better-client-for-your-developer-point-8/">eighth tip</a> in his six-tip series (but who's counting) about how a client can coordinate better with a developer and make a better relationship for the project. In this new tip, he suggests that the client "own it".
</p>
<blockquote>
No, I'm not talking about own it as in Point 7 - "Do your part", I mean make sure that at the end of the project, you own the project, not your developer.
</blockquote>
<p>
He mentions two of the aspects you, the client, will need to worry about once the last line of bug free code has been committed and delivered. Be sure that you own the domain name for the project and have a clear understanding of any intellectual property concerns that might come up (what codebase is it built on, who owns the code - client or developer, etc).
</p>]]></description>
      <pubDate>Thu, 24 Feb 2011 11:03:59 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Label Media Blog: Design Patterns in PHP - Decorator Pattern]]></title>
      <guid>http://www.phpdeveloper.org/news/15547</guid>
      <link>http://www.phpdeveloper.org/news/15547</link>
      <description><![CDATA[<p>
<i>Tom Rawcliffe</i> has <a href="http://www.labelmedia.co.uk/blog/posts/design-patterns-decorator-pattern.html">posted the latest installment</a> of his look at design patterns in PHP. This time his focus is on the Decorator pattern.
</p>
<blockquote>
Continuing my series on PHP design patterns, today it's the turn of the Decorator. In contrast to last week's <a href="http://www.labelmedia.co.uk/blog/posts/design-patterns-strategy-pattern.html">Strategy Pattern</a> which is used to change the 'œguts' of a class, the Decorator Pattern is used to extend the behavior of a class with different functionality at run time. This is achieved by implementing a 'œdecorator' class that implements the same interface as the object that you wish to 'œdecorate' and wraps it's content.
</blockquote>
<p>
The Decorator pattern lets you "decorate" your objects with additional features. He illustrates with a sample "Property" class (that implements an interface) that he wants to extend past the normal property handling. He add a "PropertyDecorator" to the mix that lets it use deocrators for uppercasing and padding the string. There's an example script included at the end that shows how to put it all to use.
</p>]]></description>
      <pubDate>Wed, 08 Dec 2010 09:13:55 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Wojciech Sznapka's Blog: Accessing private object property from other object in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/15439</guid>
      <link>http://www.phpdeveloper.org/news/15439</link>
      <description><![CDATA[<p>
<i>Wojciech Sznapka</i> has a new post to his blog showing an interesting OOP programming strick related to <a href="http://blog.sznapka.pl/accessing-private-object-property-from-other-object/">accessing private properties</a> in one object from another if they're derived from the same class.
</p>
<blockquote>
Last time I wrote about <a href="http://blog.sznapka.pl/weirdest-php-construction-ive-ever-seen/">Weirdest PHP construction I've ever seen</a>, now I found another unusual PHP solution. PHP offers 3 visibility modifiers: private, protected and public. Private properties and methods can't be accessed outside the object, as well as from inherited classes. With one exception... They can be accessed by other instances of the same class. You can read more about it in the <a href="http://www.php.net/manual/en/language.oop5.visibility.php#language.oop5.visibility-other-objects">PHP manual</a>.
</blockquote>
<p>
In his code example he shows how to create two objects of the Foo class and, using getters and setters change the value of a private property from the first object on the second object.
</p>]]></description>
      <pubDate>Tue, 16 Nov 2010 12:25:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Vance Lucas' Blog:  Get Only Public Class Properties for the Current Class in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/13786</guid>
      <link>http://www.phpdeveloper.org/news/13786</link>
      <description><![CDATA[<p>
On his blog today <i>Vance Lucas</i> has <a href="http://www.vancelucas.com/blog/get-only-public-class-properties-for-current-class-in-php">posted a method</a> you can use to only get the properties of your class that are in the "public" scope.
</p>
<blockquote>
PHP provides two built-in functions to retrieve properties of a given class '" <a href="http://php.net/get_object_vars">get_object_vars</a> and <a href="http://php.net/get_class_vars">get_class_vars</a>. Both these functions behave the same exact way, one taking an object as a variable and the other taking a string class name. The tricky thing about the two functions is that they behave differently depending on the call scope, returning all of the class variables available within the called scope.
</blockquote>
<p>
As a bit of a hack (in lower than PHP 5.3) he shows how to use the <a href="http://php.net/create_function">create_function</a> function to create a small statement in a different scope that returns the only the variables seen from the "outside" - just the public ones. PHP 5.3 users can do it much more cleanly with closures. Code examples for both are included.
</p>]]></description>
      <pubDate>Wed, 06 Jan 2010 10:06:29 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Fabien Potencier's Blog: What is Dependency Injection?]]></title>
      <guid>http://www.phpdeveloper.org/news/12224</guid>
      <link>http://www.phpdeveloper.org/news/12224</link>
      <description><![CDATA[<p>
<i>Fabien Potencier</i> has <a href="http://fabien.potencier.org/article/11/what-is-dependency-injection">posted a look</a> at dependency injections - what they are and how they can effect your code (usually for the good).
</p>
<blockquote>
Dependency Injection is probably one of the most dead simple design pattern I know. And odds are you have probably already used Dependency Injection. But it is also one of the most difficult one to explain well. I think it is partly due to the nonsense examples used in most introductions to Dependency Injection. I have tried to come up with examples that fits the PHP world better. As PHP is a language mainly used for web development, let's take a simple Web example.
</blockquote>
<p>
His example uses a session variable, setting it to a language preference and wrapping a class around it to handle the getting and setting. The dependency injection comes in when he adds a SessionStorage class into the mix, a tool that could change the place and method where that session information is held. He suggests that the best place to set these kinds of dependencies is usually the constructor but it can be done as a setter or property injection too. It just depends on the need for the script at the time.
</p>]]></description>
      <pubDate>Fri, 27 Mar 2009 11:16:10 -0500</pubDate>
    </item>
  </channel>
</rss>

