<?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>Fri, 29 Aug 2008 19:51:43 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Tobias Schlitt's Blog: Reflecting private properties]]></title>
      <guid>http://www.phpdeveloper.org/news/9645</guid>
      <link>http://www.phpdeveloper.org/news/9645</link>
      <description><![CDATA[<p>
<i>Tobias Schlitt</i> has <a href="http://schlitt.info/applications/blog/index.php?/archives/581-Reflecting-private-properties.html">posted a handy tip</a> about using the Reflection API in PHP5 - specifically its accessing of private properties in a class.
</p>
<blockquote>
I recently stumbled over reflecting private properties in PHP again. As you might know, this was not possible until now and if you tried this [code] PHP thanked it to you with this [error that is cannot access a non-public member].
</blockquote>
<p>
He notes that, while the <a href="http://schlitt.info/applications/blog/index.php?/archives/581-Reflecting-private-properties.html">behaviour is correct</a>, it still makes things like <a href="http://schlitt.info/applications/blog/exit.php?url_id=4456&entry_id=581">metaprogramming</a> impossible. So, what's a developer to do? Patch it of course! <i>Tobias</i> and <i>Derick Rethans</i> persuaded two other developers  (<i>Derick</i> and <i>Marcus Borger</i>) to include a patch that allows the Reflection API to see these private variables.
</p>
<p>
To make it work, you have to use the setAccessible method on the Reflection object to set which of the properties you want to be able to get at.
</p>]]></description>
      <pubDate>Fri, 15 Feb 2008 12:02:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Stefan Mischook's Blog: A Question about object properties in PHP Classes]]></title>
      <guid>http://www.phpdeveloper.org/news/9199</guid>
      <link>http://www.phpdeveloper.org/news/9199</link>
      <description><![CDATA[<p>
<i>Stefan Mischook</i> shares a little <a href="http://www.killerphp.com/articles/object-properties/">question and answer</a> he had recently concerning object properties in PHP.
</p>
<p>
The question asked about accessing properties outside the class and/or defining them as protected/private to prevent it. <i>Stefan</i>'s response was basically:
</p>
<blockquote>
Many OO techniques are designed for situations where you will have more than one programmer involved, now or later. By declaring variables as protected or private, you are adding security to the code base by forcing the use of getter and setter methods where you can control how objects are used.
</blockquote>]]></description>
      <pubDate>Fri, 07 Dec 2007 14:33:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Tobias Schlitt's Blog: Virtual Properties]]></title>
      <guid>http://www.phpdeveloper.org/news/7813</guid>
      <link>http://www.phpdeveloper.org/news/7813</link>
      <description><![CDATA[<p>
In response to <a href="http://www.phpdeveloper.org/news/7812">this previous post</a> from <i>Jeff Moore</i>, <i>Tobias Schlitt</i> <a href="http://schlitt.info/applications/blog/index.php?/archives/547-Virtual-properties.html">shares some of his own comments</a> on the subject - mainly that he wholeheartedly agrees.
</p>
<blockquote>
The usage of interceptors (<a href="http://de.php.net/manual/en/language.oop5.overloading.php">__get()/__set()/__isset()/__call()</a>) makes your API a lot more readable and comfortable, while maintaining the purpose behind getters and setters: Checking the correctness of values assigned to a property and wrapping around retrieval mechanisms for a property. I personally call the way of maintaining value-correctness for properties through interceptors virtual properties, which fits quite nice I think.
</blockquote>
<p>
<i>Tobias</i> gives an example of what he means by these "virtual properties" with <a href="http://schlitt.info/applications/blog/index.php?/archives/547-Virtual-properties.html">an illustration</a> from something widely used on the <a href="http://ez.no/ezcomponents">eZ Components</a> libraries - comparing one method of setting text to an object to another (just setting versus the wrappers).
</p>]]></description>
      <pubDate>Thu, 10 May 2007 07:57:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeff Moore's Blog: Let Your Properties be Properties]]></title>
      <guid>http://www.phpdeveloper.org/news/7812</guid>
      <link>http://www.phpdeveloper.org/news/7812</link>
      <description><![CDATA[<p>
In a <a href="http://www.procata.com/blog/archives/2007/05/08/let-your-properties-be-properties/">recent post</a> to his blog, <i>Jeff Moore</i> advocates the philosophy that, in your OOP application development, you should "let your properties be properties".
</p>
<blockquote>
<p>Some times there are some ancillary methods to deal with unsetting, checking for existence, setting via an array, or dealing with references in PHP 4. They can really clutter up the definition of a class. That's not good.
</p>
<p>
[...] I think the idea is to make the class extensible. But PHP is really ok with just setting new properties on a class. So why not just do this?
</p>
</blockquote>
<p>
He <a href="http://www.procata.com/blog/archives/2007/05/08/let-your-properties-be-properties/">argues</a> that getters and setters in a class are less useful than just setting the property yourself. Using the property name as part of the interface, though (like getting the $obj->foo value with $obj->getFoo) is stil clean enough to be useful.
</p>]]></description>
      <pubDate>Thu, 10 May 2007 07:11:45 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Mike Wallner's Blog: __get() and array rumors]]></title>
      <guid>http://www.phpdeveloper.org/news/6090</guid>
      <link>http://www.phpdeveloper.org/news/6090</link>
      <description><![CDATA[<p>
In <a href="http://blog.iworks.at/?/archives/47-__get-and-array-rumors.html">a brief new post</a>, <i>Mike Wallner</i> talks about some of the discussion surrounding overloaded array properties lately and something he's discovered about it.
</p>
<blockquote>
As arrays are the only complex types that are passed by value (resources don't really count here) the solution to described problem is simple: use an object; either an instance of stdClass or ArrayObject will do well, depending if you want to use array index notation.
</blockquote>
<p>
He <a href="http://blog.iworks.at/?/archives/47-__get-and-array-rumors.html">includes two code examples</a>, one just trying to overload it in a class with __get (yielding an error) and the other using the constructor to pass an ArrayObject out first, allowing for error-free assignment.
</p>]]></description>
      <pubDate>Mon, 21 Aug 2006 07:49:03 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Classes as PHP Functions]]></title>
      <guid>http://www.phpdeveloper.org/news/5985</guid>
      <link>http://www.phpdeveloper.org/news/5985</link>
      <description><![CDATA[<p>
Continuing on in their "PHP functions" series today, DevShed has posted <a href="http://www.devshed.com/c/a/PHP/Classes-as-PHP-Functions/">this next step</a> up the ladder, getting more advanced with the functions they're working with. This time, there's a focus on functions inside classes and creating the classes around them (a sort of introduction to object-oriented programming).
</p>
<blockquote>
Continuing our PHP functions article, we move on to creating classes. Let me say right at the start that you can write perfectly effective and useful PHP code without creating classes or going into object oriented programming. Object oriented programming can be very powerful and PHP programmers are increasingly taking advantage of these capabilities, which have been greatly expanded since PHP4.
</blockquote>
<p>
They <a href="http://www.devshed.com/c/a/PHP/Classes-as-PHP-Functions/">start with the creation</a> of a simple class - a human class with two $legs and two $arms. They show a simple display of this data and add another attribute to the class, one for hair color. They then capture the output they've been creating inside a function, report, and show how to execute it. Finally, they show how to use the special function that runs when the object is created - the constructor.
</p>]]></description>
      <pubDate>Wed, 09 Aug 2006 05:49:25 -0500</pubDate>
    </item>
  </channel>
</rss>
