<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP Magic Accessors Make Me Want to Punch Babies</title>
	<atom:link href="http://johnwyles.com/2010/02/10/php-magic-accessors-make-me-want-to-punch-babies/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnwyles.com/2010/02/10/php-magic-accessors-make-me-want-to-punch-babies/</link>
	<description>a man a plan a blog san francisco</description>
	<lastBuildDate>Sat, 24 Jul 2010 18:08:48 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John Wyles</title>
		<link>http://johnwyles.com/2010/02/10/php-magic-accessors-make-me-want-to-punch-babies/comment-page-1/#comment-23</link>
		<dc:creator>John Wyles</dc:creator>
		<pubDate>Thu, 25 Mar 2010 15:44:48 +0000</pubDate>
		<guid isPermaLink="false">http://johnwyles.com/?p=123#comment-23</guid>
		<description>I thought about that, and that is definitely a step towards using setters and getters more explicitly, but in my case I didn&#039;t want any &quot;magic&quot; to happen (not to mention the performance characteristics between the two).  You most certainly can do it that way, and I suppose many would, in fact, prefer it that way.  In fact, this is what we ended up implementing on the project, but I wanted to go to the extreme in this post and propose the strict enforcement of being completely explicit in the values set and got.  However, if this is code you maintain and you are not managing a huge project with multiple developers with a need to be super performant I would say go for it.

All of which is just a long way of saying YMMV</description>
		<content:encoded><![CDATA[<p>I thought about that, and that is definitely a step towards using setters and getters more explicitly, but in my case I didn&#8217;t want any &#8220;magic&#8221; to happen (not to mention the performance characteristics between the two).  You most certainly can do it that way, and I suppose many would, in fact, prefer it that way.  In fact, this is what we ended up implementing on the project, but I wanted to go to the extreme in this post and propose the strict enforcement of being completely explicit in the values set and got.  However, if this is code you maintain and you are not managing a huge project with multiple developers with a need to be super performant I would say go for it.</p>
<p>All of which is just a long way of saying YMMV</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Pearce</title>
		<link>http://johnwyles.com/2010/02/10/php-magic-accessors-make-me-want-to-punch-babies/comment-page-1/#comment-20</link>
		<dc:creator>Mike Pearce</dc:creator>
		<pubDate>Fri, 19 Mar 2010 17:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://johnwyles.com/?p=123#comment-20</guid>
		<description>Good post, exactly what I was thinking. However, why not use the __set() function to see if the method exists, otherwise throw an exception. In your example, why not then just do:

$user = new User;
$user-&gt;age = &#039;22&#039;;

Then change the __Set to:

 public function __set($key, $value)
    {
        if (method_exists($this, $method = &quot;set&quot;. $variable))
        {
            $this-&gt;$method($value);
        }
        else {
                throw new Exception(&#039;User::__set(&#039; . $key . &#039;, &#039; . $value . &#039;): Attempt to set a non-existent attribute [&#039; . $key . &#039;] to value [&#039; . $value . &#039;]&#039;);
        }
    }
 
Best of both worlds then.</description>
		<content:encoded><![CDATA[<p>Good post, exactly what I was thinking. However, why not use the __set() function to see if the method exists, otherwise throw an exception. In your example, why not then just do:</p>
<p>$user = new User;<br />
$user-&gt;age = &#8216;22&#8242;;</p>
<p>Then change the __Set to:</p>
<p> public function __set($key, $value)<br />
    {<br />
        if (method_exists($this, $method = &#8220;set&#8221;. $variable))<br />
        {<br />
            $this-&gt;$method($value);<br />
        }<br />
        else {<br />
                throw new Exception(&#8216;User::__set(&#8216; . $key . &#8216;, &#8216; . $value . &#8216;): Attempt to set a non-existent attribute [' . $key . '] to value [' . $value . ']&#8216;);<br />
        }<br />
    }</p>
<p>Best of both worlds then.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
