<?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, 22 May 2008 15:14:16 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Ibuildings Blog: Accessing object properties by reference]]></title>
      <guid>http://www.phpdeveloper.org/news/10114</guid>
      <link>http://www.phpdeveloper.org/news/10114</link>
      <description><![CDATA[<p>
On the Ibuildings blog today, <i>Harrie Verveer</i> has <a href="http://www.ibuildings.com/blog/archives/951-Accessing-object-properties-by-reference.html">posted about</a> an interesting quirk he found when working with objects and references:
</p>
<blockquote>
PHP is a loosely typed language. Most of the time this is very useful because you as a programmer don't have to worry about typecasting: it's done for you. However, on some occasions this can cause some unexpected trouble. [...] In this blog I want to point out what can happen if you try to access object properties by reference when the object is not initialized.
</blockquote>
<p>
<a href="http://www.ibuildings.com/blog/archives/951-Accessing-object-properties-by-reference.html">His example</a> shows the problem when it tries to grab a value from an array in a non-existent object by reference. It results in a dyanamically created object (of that type) with an empty array inside of it. It only works when you grab it by reference, but he shares a tip or two about how you can prevent hard to track down issues like this.
</p>]]></description>
      <pubDate>Mon, 05 May 2008 14:38:49 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Cal Evans' Blog: I called Zend_Json::encode(), so WTH are all my properties?]]></title>
      <guid>http://www.phpdeveloper.org/news/9687</guid>
      <link>http://www.phpdeveloper.org/news/9687</link>
      <description><![CDATA[<p>
In dealing with a little JSON encoding and objects in a project of his recently, <i>Cal Evans</i> <a href="http://blog.calevans.com/2008/02/21/zend_jsonencode-and-wth-are-all-my-properties/">bumped against a problem</a> when he was encoding an object and moving it back and forth between the back and front ends.
</p>
<blockquote>
The problem is simple, JSON encode a PHP object and send it back to the front end. Sounds simple and the last 100 times I wrote this code it was simple. This time, I was too smart for my own good. Here's the scenario.
</blockquote>
<p>
He illustrates his problem - the "dropping" of properties somewhere along the way - with a sample class that encodes the object and sends it along. He missed one key bit of information, though. His protected array of properties wasn't getting passed back out correctly and we're in the resulting JSON message. A quick hack of a getProperties() function call made this problem a thing of the past.
</p>]]></description>
      <pubDate>Fri, 22 Feb 2008 12:10:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Keeping Track of Objects when Using Destructors in PHP 5]]></title>
      <guid>http://www.phpdeveloper.org/news/9527</guid>
      <link>http://www.phpdeveloper.org/news/9527</link>
      <description><![CDATA[<p>
Devshed continues their series looking at the use of destructors in PHP5 applications with <A href="http://www.devshed.com/c/a/PHP/Keeping-Track-of-Objects-when-Using-Destructors-in-PHP-5/">part three</a>, a method for keeping track of objects you've created during execution.
</p>
<blockquote>
In this third part of the series, I'm going to show you how to retrieve some useful information about a specific object, including its properties and methods, prior to its being destroyed by the PHP parser via the implementation of a simple destructor.
</blockquote>
<p>
Their new <a href="http://www.devshed.com/c/a/PHP/Keeping-Track-of-Objects-when-Using-Destructors-in-PHP-5/2/">user class</a> extracts the details about each of the objects right before they're destroyed via a call to get_object_vars and a loop to display the property and its value.
</p>]]></description>
      <pubDate>Wed, 30 Jan 2008 11:19:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jan Kneschke's Blog: typesafe objects in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/7307</guid>
      <link>http://www.phpdeveloper.org/news/7307</link>
      <description><![CDATA[<p>
<i>Manfred Weber</i> <a href="http://manfred.dschini.org/2007/02/19/typesafe-objects-in-php/">points out</a> a <a href="http://jan.kneschke.de/2007/2/19/typesafe-objects-in-php">new blog post</a> from <i>Jan Kneschke</i> concerning the creation of and the idea of typesafe objects in PHP via doc-comments and the Reflection API.
</p>
<p>
From <i>Jan</i>:
</p>
<blockquote>
I always disliked the way PHP handles Objects. There is no way to assign a type to properties. Validators have to be glued against the fields externally and you can't just generate a Object-Description (like WSDL) from a object either.
</blockquote>
<p>
Because of this he's looked into an alternate solution - the typesafe objects. Since, by defauly, PHP's addition of object properties is pretty freeform, making things typesafe is a little difficult. His suggestion, though, uses a combination of comments in the code (declaring what the type of the property should be) and the Reflection API built in to PHP to "look back" at the comments and ensure the type of the property is correct. He even includes examples - a simple one about throwing an error, generating XML this way, and making safe encoded SQL statements.
</p>]]></description>
      <pubDate>Tue, 20 Feb 2007 07:29:00 -0600</pubDate>
    </item>
  </channel>
</rss>
