<?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>Sun, 26 May 2013 04:23:23 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Nikita Popov's Blog: Scalar type hinting is harder than you think]]></title>
      <guid>http://www.phpdeveloper.org/news/17638</guid>
      <link>http://www.phpdeveloper.org/news/17638</link>
      <description><![CDATA[<p>
In <a href="http://nikic.github.com/2012/03/06/Scalar-type-hinting-is-harder-than-you-think">this new post</a> to his blog <i>Nikita</i> talks about scalar type hinting and why it's harder than most people think to accomplish.
</p>
<blockquote>
One of the features originally planned for PHP 5.4 was scalar type hinting. But as you know, they weren't included in the release. Recently the topic has come up again on the mailing list and there has been a hell lot of discussion about it. Yesterday ircmaxell published a <a href="http://blog.ircmaxell.com/2012/03/parameter-type-casting-in-php.html">blog post about his particular proposals</a>. The reactions on <a href="http://www.reddit.com/r/PHP/comments/qiniv/parameter_type_casting_in_php/">reddit</a> were mixed. On one hand it is clear that people do really want scalar type hints, on the other hand they didn't seem to like that particular proposal.
</blockquote>
<p>
He gets into some of the details of some of the current proposals and their problems like the strict versus loosely-typed nature of PHP and type hinting that was included but not enforced. One he does like, however, is one based on casting - how the variable ends up being cast rather than the specific type it is when it comes into the function/method. This one still has its flaws, so he suggests another method - weak type hints but with stricter input validation (without casting). He also briefly mentions something called "box based type hinting" that would allow users to define their own hinting rules.
</p>
<p>
Don't worry - code examples (pseudo-code obviously) <a href="http://nikic.github.com/2012/03/06/Scalar-type-hinting-is-harder-than-you-think">are included</a> for each of these proposals to help you understand the differences.
</p>]]></description>
      <pubDate>Wed, 07 Mar 2012 10:03:47 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP in Action: Type hints are more useful for scalars than objects]]></title>
      <guid>http://www.phpdeveloper.org/news/11002</guid>
      <link>http://www.phpdeveloper.org/news/11002</link>
      <description><![CDATA[<p>
On the PHP in Action blog, there's a <a href="http://www.reiersol.com/blog/1_php_in_action/archive/160_type_hints_are_more_useful_for_scalars_than_objects.html">new post</a> looking at a <a href="http://www.maxhorvath.com/2008/09/type-hints-for-scalar-values-phptypesafe-10-rc2-released.html">recent library</a> that was posted to support type hinting on scalars. They agree with his choice of subjects, noting that they see type hinting as much more useful on scalars than on objects.
</p>
<blockquote>
I admit that these judgments are hard to make. I could be wrong, more or less. Type hints are probably useful when code becomes stable enough and at the boundaries between modules. But I still tend to avoid using them until I get an actual bug that might have been prevented by a type hint. Their usefulness is and has to be an empirical question. The purpose of using them has to be catching errors earlier, so if they don't have that effect, there's no point.
</blockquote>
<p>
He lists three reasons why he had given up on type hinting before, one being the limited usefulness when it came to objects. Applying it to scalars is a different matter, though, and can prevent improper passing of array/scalars when the other is needed.
</p>]]></description>
      <pubDate>Thu, 11 Sep 2008 10:08:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Enforcing Object Types in PHP - Using the Type Hinting Feature in PHP 5]]></title>
      <guid>http://www.phpdeveloper.org/news/4923</guid>
      <link>http://www.phpdeveloper.org/news/4923</link>
      <description><![CDATA[DevShed has posted the <a href="http://www.devshed.com/c/a/PHP/Enforcing-Object-Types-in-PHP-Using-the-Type-Hinting-Feature-in-PHP-5/">last article</a> in their "Enforcing Object Types in PHP" series today - "Using the Type Hinting Feature in PHP5".
<p>
<quote>
<i>
[Returning] to the subject of this last tutorial, I'll introduce another method for enforcing object types in PHP 5: the "Type Hinting" feature. It can also be used in conjunction with the "instanceof" operator that you learned about before, in order to develop PHP applications that implement thorough routines for filtering unwanted objects. Generally speaking, when you finish reading this article, you should be armed with a few more methods for forcing object types in PHP, in this way expanding your overall knowledge of object-oriented programming.
</i>
</quote>
<p>
They <a href="http://www.devshed.com/c/a/PHP/Enforcing-Object-Types-in-PHP-Using-the-Type-Hinting-Feature-in-PHP-5/1/">start</a> with an introduction to type hinting and some basic examples of its use. From there, they build up a relevant example with the help of their (X)HTML widget class they've used throughout the series.]]></description>
      <pubDate>Thu, 02 Mar 2006 06:42:19 -0600</pubDate>
    </item>
  </channel>
</rss>
