<?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, 19 May 2013 03:29:38 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[NetTuts.com: Reflection in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19484</guid>
      <link>http://www.phpdeveloper.org/news/19484</link>
      <description><![CDATA[<p>
On NetTuts.com today there's a new tutorial talking about a part of PHP that can be quite powerful but isn't used too often - <a href="http://net.tutsplus.com/tutorials/php/reflection-in-php/">reflection in PHP</a>. Using Reflection you can get information about your actual code and its elements without having to try to parse it yourself.
</p>
<blockquote>
Reflection is generally defined as a program's ability to inspect itself and modify its logic at execution time. In less technical terms, reflection is asking an object to tell you about its properties and methods, and altering those members (even private ones). In this lesson, we'll dig into how this is accomplished, and when it might prove useful.
</blockquote>
<p>
They provide a little context around the idea of "reflection" in programming languages and then jump right in with a few sample classes. They set up their "Nettuts", "Manager" and "Editor" classes and show how to use the <a href="http://php.net/reflectionclass">ReflectionClass</a> functionality to get their structure. The examples show how to get the class' methods, their properties and calling these methods using things like <a href="http://php.net/manual/en/reflectionmethod.invoke.php">invoke</a> and <a href="http://php.net/call_user_func">call_user_func</a>.
</p>
Link: http://net.tutsplus.com/tutorials/php/reflection-in-php]]></description>
      <pubDate>Fri, 19 Apr 2013 10:24:28 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Josh Adell's Blog: Command Invoker Pattern with the Open/Closed Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/17398</guid>
      <link>http://www.phpdeveloper.org/news/17398</link>
      <description><![CDATA[<p>
In a response to a <a href="http://phpdeveloper.org/news/17389">recent post</a> on DZone.com about the "Open/Closed Principle" <i>Josh Adell</i> has <a href="http://blog.everymansoftware.com/2012/01/command-invoker-pattern-with-openclosed.html">posted an example</a> of a " flexible and extendable command invocation solution" implementing this <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a> idea.
</p>
<blockquote>
Let's overcome some of these issues [with only being able to extend the invoker class and that the invoker needs to know how to create commands], and also make the code even more extensible. I'll use a simplified command invoker to demonstrate.
</blockquote>
<p>
His code is included - the creation of a "Command" interface and two comments that implement it: "HelloCommand" and "PwdCommand", each with "register" and "execute" methods. His "Invoker" class then only needs to be told how to map these commands and the "register" is called as they're needed. You can find the full example code for this invocation example <a href="http://gist.github.com/1610148">in this gist</a>.
</p>]]></description>
      <pubDate>Mon, 16 Jan 2012 10:04:42 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Ryan Gantt's Blog: Anonymous recursion in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16705</guid>
      <link>http://www.phpdeveloper.org/news/16705</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>Ryan Gantt</i> looks at an interesting way to get around a limitation in PHP dealing with <a href="http://zuttonet.com/articles/anonymous-recursion-php/">anonymous recursion and closures</a> that throws a Fatal error when called.
</p>
<blockquote>
Turns out that variables called as functions must be an instance of Closure, an instance of a class which implements __invoke(), or a string representing a named function in the global namespace. In the anonymous function body above, $fibonacci is none of these. It is an undeclared, free variable in the closure created by the anonymous function. At the time when it's called, it hasn't been bound-hence the Notice that you would have gotten if error reporting were set at a high enough threshold - and therefore can't be called as anything, let alone as a function.
</blockquote>
<p>
He tried using the "use" functionality PHP closures have to bring a variable/object/etc into the scope of the running function, but it still threw an error. As it turns out, the combination of "use"-ing the object and calling it by reference handles things correctly. He takes this method and applies it in two examples - one call in an <a href="http://php.net/array_map">array_map</a> function and another in an <a href="http://php.net/array_reduce">array_reduce</a>.
</p>]]></description>
      <pubDate>Thu, 11 Aug 2011 10:55:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Web Developer Juice: PHP Magic Functions: Best Part of Object Oriented PHP - Part 2]]></title>
      <guid>http://www.phpdeveloper.org/news/16361</guid>
      <link>http://www.phpdeveloper.org/news/16361</link>
      <description><![CDATA[<p>
Web Developer Juice has posted <a href="http://www.webdeveloperjuice.com/2011/05/09/php-magic-functions-best-part-of-object-oriented-php-%E2%80%93-part-2/">the second part of their series</a> looking at some of the "magic functions" that PHP has to offer - special functions that do automagic things in your scripts and classes. Part one can be <a href="http://phpdeveloper.org/news/16288">found here</a>.
</p>
<blockquote>
In my <a href="http://www.webdeveloperjuice.com/2011/04/28/php-magic-functions-best-part-of-object-oriente-php/">previous post</a> ( PHP Magic Functions ), I discussed about __construct, __destruct, __call and __callStatic. Lets explore a few more magic functions...
</blockquote>
<p>In this latest part of the series they look at three functions:</p>
<ul>
<li>__set/__get
<li>__invoke
</ul>]]></description>
      <pubDate>Thu, 19 May 2011 10:14:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: Reuse your closures with functors]]></title>
      <guid>http://www.phpdeveloper.org/news/15651</guid>
      <link>http://www.phpdeveloper.org/news/15651</link>
      <description><![CDATA[<p>
On DZone.com there's <a href="http://css.dzone.com/articles/reuse-your-closures-functors">a new tutorial</a> from <i>Giorgio Sironi</i> about reusing closures with the help of functors (a special kind of object instancing done in PHP with the help of __invoke).
</p>
<blockquote>
I like PHP closures and their superset, anomyous functions, as they implement the Command pattern very well when used correctly. However I feel that sometimes they are: difficult to reuse and difficult to force contracts on. [...] What if we wanted instead, a closure which we can instance even more than one time (maybe with different variables), and that we could type hint?
</blockquote>
<p>
He shows how to make this possible with a functor created using the __invoke magic method of PHP to handle the request to an object like a function. He includes some sample code to show it in action - a basic callback (SquareCallback) and how it compares to calling a normal closure. It also shows something a bit more technical, an "AdderCallback" class that can be defined as a type hint on a function.
</p>]]></description>
      <pubDate>Wed, 29 Dec 2010 10:50:19 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jose da Silva's Blog: Revisiting PHP 5.3 __invoke magic method]]></title>
      <guid>http://www.phpdeveloper.org/news/15392</guid>
      <link>http://www.phpdeveloper.org/news/15392</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Jose da Silva</i> <a href="http://blog.josedasilva.net/revisiting-php-5-3-__invoke-magic-method/">briefly looks at</a> a feature that was introduced in the PHP 5.3.x series of the language - the __invoke magic method.
</p>
<blockquote>
PHP version 5.3 introduced a new magic method designed __invoke, this method is called when a script tries to call an object as a function. [...] As php cannot accommodate pseudo-first-class functions, the __invoke method can be used to suppress this language limitation. On other hand you can use this for simpler things as pass a function around. 
</blockquote>
<p>
He includes a simple code example that shows a basic class being called via a variable name - $c('ford') - and the result of its __invoke method being called. He notes that <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.invoke">the method</a>, in his opinion, could make for less clean code.
</p>]]></description>
      <pubDate>Fri, 05 Nov 2010 12:42:04 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weier O'Phinney's Blog: A Primer for PHP 5.3's New Language Features]]></title>
      <guid>http://www.phpdeveloper.org/news/14307</guid>
      <link>http://www.phpdeveloper.org/news/14307</link>
      <description><![CDATA[<p>
Whether you're relatively new to the PHP 5.3 scene or just want to be sure you don't miss out on some of the cool new features it has to offer, check out <a href="http://weierophinney.net/matthew/archives/237-A-Primer-for-PHP-5.3s-New-Language-Features.html">this new guide</a> from <i>Matthew Weier O'Phinney</i> covering the new features of this great release.
</p>
<blockquote>
Most of the time, these features are straight-forward, and you can simply use them; in other cases, however, we've run into behaviors that were unexpected. This post will detail several of these, so you either don't run into the same issues -- or can capitalize on some of our discoveries. 
</blockquote>
<p>
He talks about some of the strange things he's come across like the fact that PHP doesn't like serializing closures, problems with using the new "__invoke" helper and some picky things that you need to know about namespacing your code.
</p>]]></description>
      <pubDate>Tue, 06 Apr 2010 14:45:00 -0500</pubDate>
    </item>
  </channel>
</rss>
