<?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>Tue, 21 May 2013 07:42:23 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: Freezing and Thawing PHP Objects]]></title>
      <guid>http://www.phpdeveloper.org/news/11479</guid>
      <link>http://www.phpdeveloper.org/news/11479</link>
      <description><![CDATA[<p>
<i>Sebastian Bergmann</i> has <A href="http://sebastian-bergmann.de/archives/831-Freezing-and-Thawing-PHP-Objects.html">posted details</a> (and a <a href="http://news.php.net/php.cvs/54561">patch</a>) for freezing and unfreezing objects via the new setAccessible method included in the SPL in PHP 5.3.
</p>
<blockquote>
One of the many new features that have been added for <a href="http://cvs.php.net/viewvc.cgi/php-src/NEWS?view=markup&pathrev=PHP_5_3">PHP 5.3</a> is the setAccessible() method of the ReflectionProperty class that is part of PHP's <a href="http://www.php.net/reflection">Reflection API</a>. This method makes protected and private attributes (unfortunately, the class is called ReflectionProperty instead of ReflectionAttribute) of a class or object accessible for the ReflectionProperty::getValue() and ReflectionProperty::setValue() methods, thus making protected and private attributes "open" for full read and write access from the outside.
</blockquote>
<p>
A bit of code shows how to "freeze" and "thaw" the objects out - creating an object, calling the freeze() method on it to protect it from use, then the thaw() method to bring it back out where it can be accessed. <a href="http://www.priebsch.de/">Stefan Priebsch</a> helped to create this class and the <a href="http://news.php.net/php.cvs/54561">patch</a>.
</p>]]></description>
      <pubDate>Mon, 01 Dec 2008 11:12:18 -0600</pubDate>
    </item>
    <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>
  </channel>
</rss>
