<?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>Sat, 25 May 2013 02:31:46 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Slawek Lukasiewicz's Blog: Throwing Exception with Type Hinting Failed]]></title>
      <guid>http://www.phpdeveloper.org/news/16699</guid>
      <link>http://www.phpdeveloper.org/news/16699</link>
      <description><![CDATA[<p>
<i>Slawek Lukasiewicz</i> has a helpful hint posted to his blog today about handling type hinting failures in a what he sees as a "more correct" way than just throwing an error - <a href="http://www.leftjoin.net/2011/08/throwing-exception-when-type-hinting-failed">throwing an exception</a> when the hinting criteria's not met.
</p>
<blockquote>
One of the most annoying behavior of PHP type hinting feature is triggering error instead of throwing exception when instance type is invalid.
</blockquote>
<p>
By default, a failure generates a "catchable error" that, thanks to the <a href="http://www.php.net/manual/en/function.set-error-handler.php">custom error handling</a> methods PHP includes, can be correctly handled. He includes a snippet of code that defines the errorHandler method that checks the error type for E_RECOVERABLE_ERROR  and throws the exception (an ErrorException) if found.
</p>]]></description>
      <pubDate>Wed, 10 Aug 2011 09:58:57 -0500</pubDate>
    </item>
  </channel>
</rss>
