<?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, 23 May 2013 03:51:17 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Type Hinting in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17627</guid>
      <link>http://www.phpdeveloper.org/news/17627</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial posted about <a href="http://phpmaster.com/type-hinting-in-php/">using type hinting</a> in your PHP applications to restrict the values passed into your methods.
</p>
<blockquote>
Since PHP 5 you can use type hinting to specify the expected data type of an argument in a function declaration. When you call the function, PHP will check whether or not the arguments are of the specified type. If not, the run-time will raise an error and execution will be halted.
</blockquote>
<p>
Included in the post are code examples showing how to define custom types in a function definition and what happens if you pass the wrong type in. Also mentioned is one of the main limitations to hinting - the fact that it can't be used on default PHP variable types. 
</p>]]></description>
      <pubDate>Mon, 05 Mar 2012 13:19:24 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Andrew Eddie's Blog: Making the most out of Code Assist in Eclipse/PDT and Zend Studio for PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17198</guid>
      <link>http://www.phpdeveloper.org/news/17198</link>
      <description><![CDATA[<p>
<i>Andrew Eddie</i> has posted a helpful tutorial for Eclipse users out there showing how to <a href="http://www.theartofjoomla.com/home/9-developer/136-making-the-most-out-of-code-assist-in-eclipsepdt-and-zend-studio-for-php.html">get the most our of code assist</a> in Eclipse PDT/Zend Studio.
</p>
<blockquote>
One of the powerful features of an IDE like Eclipse is the ability for it to "read" your code and give you some assistance about your API as you type. This could include things like class property or methods names, constants, functions, argument lists, and so on. Eclipse/PDT and ZendStudio do this by parsing a PHP class directly, but they also look at your docblocks and some other special comments where the raw PHP is not enough. This article is a bag of tricks that help you get the most out of code assistance using Eclipse/PDT or Zend Studio in those awkward corners of your code that you might have through previously inaccessible.
</blockquote>
<p>
Among his tips are things like adding "@var" declarations to help with code completion, type hinting on methods/functions, using the "@property" annotation and using a "this" trick to override what class the IDE sees as the local object.
,/p>]]></description>
      <pubDate>Thu, 01 Dec 2011 12:55:32 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Zoomzum Blog: 10 Powerful PHP Regular Expression For Developers]]></title>
      <guid>http://www.phpdeveloper.org/news/16639</guid>
      <link>http://www.phpdeveloper.org/news/16639</link>
      <description><![CDATA[<p>
On the Zoomzum blog there's a new post with <a href="http://zoomzum.com/10-powerful-php-regular-expression-for-developers/">ten regular expressions</a> PHP developers can use to accomplish some common tasks (like email validation and date formatting checks).
</p>
<blockquote>
Regular expression for the PHP developers, on of the most popular tool for validating data is the regular expression. In this list we provides some validation - string match, password match validation, email address validation, date format and many more which helps developer to make their application more fast and easy to execute. [...] Have you note that, regular expressions are more slower than the basic string function, its takes a short time to execute than any others.
</blockquote>
<p>Included in their list are things like:</p>
<ul>
<li>Password Match Validation
<li>Validate URL
<li>Validate  URL using Preg_match
<li>UK Postcode Validation
<li>SSN,ISBN and Zipcode Validation
</ul>
<p>
A few of these could be done with either one or two string calls or some of the filtering functions that are included in PHP.
</p>]]></description>
      <pubDate>Wed, 27 Jul 2011 09:02:10 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Chris Shiflett's Blog: Sorting Multi-Dimensional Arrays in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16543</guid>
      <link>http://www.phpdeveloper.org/news/16543</link>
      <description><![CDATA[<p>
In a sort of "remind himself later" kind of post, <i>Chris Shiflett</i> has shared a quick example of a common task PHP developers face <a href="http://shiflett.org/blog/2011/jun/sorting-multi-dimensional-arrays-in-php">sorting a multi-dimensional array</a>.
</p>
<blockquote>
Every time I need to sort a multi-dimensional array in PHP, I have to remind myself how to do it. It's not quite as quick and easy to look up as most things, so I'm going to blog a quick example. I've always felt like there must be a better way to do this, so please let me know if there is, and I'll update this post accordingly.
</blockquote>
<p>
His method sorts a multi-dimensional array of user data using the <a href="http://php.net/array_multisort">array_multisort</a> function together with a list of the usernames in each record. In the comments, people recommend using <a href="http://php.net/usort">usort</a> instead with a callback+closure combo that keeps things nice and clean.
</p>]]></description>
      <pubDate>Fri, 01 Jul 2011 09:48:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: Scalar Type Hints in PHP 5.3.99]]></title>
      <guid>http://www.phpdeveloper.org/news/15484</guid>
      <link>http://www.phpdeveloper.org/news/15484</link>
      <description><![CDATA[<p>
In the theme of <a href="http://phpdeveloper.org/news/15476">other recent posts</a> mentioning the scalar type hinting that has been included in the main line of code that is headed towards the next PHP release, <i>Sebastian Bergmann</i> <a href="http://sebastian-bergmann.de/archives/900-Scalar-Type-Hints-in-PHP-5.3.99.html">has a new post</a> about their inclusion in PHP 5.3.99 (yes, that's PHP 5.4) and the new syntax it introduces.
</p>
<blockquote>
In a nutshell, this means that PHP 5.3.99 introduces new syntax -- scalar type hints -- but no new semantics. The latter can either be implemented as an extension written in C/C++, in userland PHP code, or in a tool that statically analyzes the code.
</blockquote>
<p>
He includes an example fro userland with a "php_check_parameters" function that looks at the arguments of the current method and uses <a href="http://php.net/reflection">Reflection</a> to check against the type hints for the correct value type.
</p>]]></description>
      <pubDate>Wed, 24 Nov 2010 10:04:06 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Johannes Schluter's Blog: Scalar type hints in PHP trunk]]></title>
      <guid>http://www.phpdeveloper.org/news/14923</guid>
      <link>http://www.phpdeveloper.org/news/14923</link>
      <description><![CDATA[<p>
As <i>Johannes Schluter</i> mentions in his <a href="http://schlueters.de/blog/archives/139-Scalar-type-hints-in-PHP-trunk.html">latest blog post</a>, another new feature has been added to the trunk of the PHP project - scalar type hints.
</p>
<blockquote>
So in my blog series I try to cover all additions to PHP trunk so I have to mention scalar type hints.
</blockquote>
<p>
He gives examples of both simple hinting (ensuring a value is a float) and a more complex example setting an attribute on a PDO connection (checking for an integer). Sample error messages are included as well. He also gives some advice on mixing strong and weak typing in your apps - it's like "opening a can of worms".
</p>]]></description>
      <pubDate>Mon, 09 Aug 2010 08:44:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ilia Alshanetsky's Blog: Scalar Type Hints are Here!]]></title>
      <guid>http://www.phpdeveloper.org/news/14547</guid>
      <link>http://www.phpdeveloper.org/news/14547</link>
      <description><![CDATA[<p>
<i>Ilia Alshanetsky</i> has a quick new post with some great news for some PHP developers out there - scalar type hinting has been introduced into the latest trunk of the PHP project.
</p>
<blockquote>
About an hour ago, something I've been fighting for almost 2 years happened. The Scalar Type Hinting patch for PHP (<a href="http://ilia.ws/patch/type_hint_final.txt">the one I wrote almost a year ago</a>) has been adjusted for PHP's trunk tree and <a href="http://svn.php.net/viewvc?view=revision&revision=299534">committed</a> by <a href="http://derickrethans.nl/">Derick</a>.
</blockquote>
<p>
You can see some of the type hinting features already included in PHP in <a href="http://php.net/manual/en/language.oop5.typehinting.php">the manual</a>. This patch adds hinting ability for the other (non-object and non-array) variable types.
</p>]]></description>
      <pubDate>Mon, 24 May 2010 11:48:19 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Alex Netkachov's Blog: PHP micro-optimization tips]]></title>
      <guid>http://www.phpdeveloper.org/news/12099</guid>
      <link>http://www.phpdeveloper.org/news/12099</link>
      <description><![CDATA[<p>
For those trying to squeeze the absolute most out of their applications, check out <a href="http://www.alexatnet.com/node/196">these suggestions</a> from <i>Alex Netkachov</i> on a few "micro" kinds of things that could help speed things up in the long run.
</p>
<blockquote>
Why "micro-"? Because changing logic of your application may give you much better performance boost then applying all these tips. But they still can make your code better. You always need to output something, why do not use "echo" instead of "print"?
</blockquote>
<p>He has a list of about thirty things you can do including:</p>
<ul>
<li>calling a function is faster then calling a static method
<li>accessing an initialized variable is faster then accessing an uninitialized variable
<li>avoid @ (error control operator)
<li>adding method parameter type hint increases calling time
<li>cache page output or result of resource-consuming functions
<li>pre-increment (++$i) is faster then post-increment ($i++)
<li>an array is a faster alternative to a class with several fields
</ul>
<p>
These hints aren't going to make amazing differences in your code, but they could help get you out of a sticky place where your code just doesn't want to behave.
</p>]]></description>
      <pubDate>Tue, 10 Mar 2009 08:47:38 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Misko Hevery's Blog: Guide: Writing Testable Code]]></title>
      <guid>http://www.phpdeveloper.org/news/11690</guid>
      <link>http://www.phpdeveloper.org/news/11690</link>
      <description><![CDATA[<p>
In <a href="http://misko.hevery.com/code-reviewers-guide/">this slightly older (Nov 2008) but useful post</a> to <i>Misko</i>'s blog, he takes a look at a few common flaws that you should avoid in writing up your code (in any language really).
</p>
<blockquote>
To keep our code at Google in the best possible shape we provided our software engineers with these constant reminders. Now, we are happy to share them with the world.
</blockquote>
<p>Here's the list of the flaws:</p>
<ul>
<li>Flaw #1: Constructor does Real Work
<li>Flaw #2: Digging into Collaborators
<li>Flaw #3: Brittle Global State & Singletons
<li>Flaw #4: Class Does Too Much
</ul>
<p>
Each includes some warning signs to keep an eye out for to see if you and your code might be straying the wrong way.
</p>]]></description>
      <pubDate>Wed, 07 Jan 2009 10:29:39 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jani Hartikainen's Blog: Static/Dynamic typing sweet spot]]></title>
      <guid>http://www.phpdeveloper.org/news/11168</guid>
      <link>http://www.phpdeveloper.org/news/11168</link>
      <description><![CDATA[<p>
In a <a href="http://codeutopia.net/blog/2008/10/08/staticdynamic-typing-sweet-spot/">new post</a> today <i>Jani Hartikainen</i> takes a look at one of the things that makes PHP both powerful and unpredictable at times - its variable typing, static versus dynamic.
</p>
<blockquote>
It seems that PHP has moved a bit towards static typing, and languages like C# seem to be implementing some dynamic features. Are we going towards a "mixed" language with static and dynamic typing? What's the "sweet spot" between completely static (like C++) and completely dynamic typing (like Python)?
</blockquote>
<p>
He compares the benefits of static and dynamic, and a particular place where PHP falls a bit flat - type hinting in certain situations. He agrees, though, that dynamic typing is "the way to go" since it gives the developer the flexibility they might need for more "typing tricks" in their apps. Oh, and "duck typing"...
</p>]]></description>
      <pubDate>Wed, 08 Oct 2008 10:24:28 -0500</pubDate>
    </item>
  </channel>
</rss>
