<?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, 12 Feb 2012 20:17:23 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Slawek Lukasiewicz's Blog: Zend Framework: Reflection]]></title>
      <guid>http://www.phpdeveloper.org/news/16403</guid>
      <link>http://www.phpdeveloper.org/news/16403</link>
      <description><![CDATA[<p>
<i>Slawek Lukasiewicz</i> has a recent post to his blog looking at a tool that comes bundled with PHP that can help you find out more about your own code (or really any other piece of code out there) - <a href="http://www.leftjoin.net/2011/05/zend-framework-reflection/">the Reflection API</a>. In his post he looks specifically at the functionality the <a href="http://framework.zend.com">Zend Framework</a> has built on top of the base <a href="http://php.net/reflection">PHP API</a>.
</p>
<blockquote>
Zend Framework has own Reflection extension. It is mostly build upon genuine <a href="http://php.net/manual/en/book.reflection.php">PHP Reflection API</a> and extends existing features. The completely new Zend_Reflection module feature is introspection of docBlock tags.
</blockquote>
<p>
He includes two code examples using this component of the framework - grabbing the docblock off of a specific method (and even how to grab specific tags from inside it) and how to grab the body content out of a given method, with or without the docblock attached.
</p>]]></description>
      <pubDate>Tue, 31 May 2011 08:18:56 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Reflection over PHPDoc with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16143</guid>
      <link>http://www.phpdeveloper.org/news/16143</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has a new post to his blog today talking about a regular expression-laden script he's some up with to <a href="http://gonzalo123.wordpress.com/2011/04/04/reflection-over-phpdoc-with-php/">reflect over a PHP file</a> and pull out the document's comments (PHPDoc-style).
</p>
<blockquote>
I want to parse PHPDoc code. Let me explain a little bit what I want to do. Imagine a dummy function documented with PHPDoc. [...] PHP has a great reflection API, but as at least in the current PHP version (as far as I know) we only can get the PHPDoc as a string, without parse it. I need to get the parameters and the type of them with reflection. [...] But the type is different. 
</blockquote>
<p>
His script (based loosely on a bit of a component from the <a href="http://framework.zend.com">Zend Framework</a>) parses the file and its comments and grabs the variable types from the PHPDoc blocks on each method and associates them.
</p>
<p>
If you're looking for a more mature solution than just this script, take a look at <a href="https://github.com/mvriel/Docblox">Docblox</a>, a PHP 5.3 documentation generator.
</p>]]></description>
      <pubDate>Mon, 04 Apr 2011 12:51:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Eric Lamb's Blog: Practical PHP Reflection]]></title>
      <guid>http://www.phpdeveloper.org/news/16000</guid>
      <link>http://www.phpdeveloper.org/news/16000</link>
      <description><![CDATA[<p>
<i>Eric Lamb</i> came up against an interesting situation recently and found that PHP's Reflection API was the best thing to <a href="http://blog.ericlamb.net/2011/03/practical-php-reflection/">come to his rescue</a>.
</p>
<blockquote>
The perfect problem where the Reflection API appears to be the perfect solution. For me this came up a couple months ago while I was working on a European zip code radius project that had to be built using one of those obfuscated and ill documented 3rd party commercial programs (nothing worse than when the platform is forced on you). So, I had to use this program that was intentionally encoded to prevent me from doing what I wanted to do. I couldn't even look at the code; it was completely obfuscated.
</blockquote>
<p>
To illustrate his point, he gives examples of two built-in classes that PHP has and the result of their reflected output - SimpleXMLElement and DateTime. He shows how to get the structure of the class in general and how to use some of the more specific functions to get things like properties, methods and constants for the class. This is perfect for those undocumented features and isn't too far of a jump away from building out your own documentation.
</p>]]></description>
      <pubDate>Fri, 04 Mar 2011 12:23:28 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Box UK Labs: Dependency Injection and Reflection library]]></title>
      <guid>http://www.phpdeveloper.org/news/15607</guid>
      <link>http://www.phpdeveloper.org/news/15607</link>
      <description><![CDATA[<p>
On the Box UK Labs site there's <a href="http://www.boxuk.com/labs/dependency-injection-and-reflection-library">an interesting dependency injection tool</a> that uses Reflection to get some of the work done. 
</p>
<blockquote>
Dependency injection is a well known concept, and there are currently a plethora of DI containers available from one of the interweb's many pipes. These include Symfony and Crafty, while the Zend Framework also has its own DI container. So why another? One of my personal goals as a developer is to make things so simple, even I can understand them. But most of the DI containers I've come across require too much configuration, and usually via XML - yuck! So how is ours different?
</blockquote>
<p>
The tool, <a href="http://github.com/boxuk/boxuk-di">boxuk-di</a>, makes use of the <a href="http://code.google.com/p/addendum/">Addendum</a> tool to create injectable objects easily accessed via a namespace. You can also use type hinting, scoping and annotations to do special things (like make singleton injection objects). The also mention how primitives are used as well as dispelling some of the misconceptions around reflection and this particular tool.
</p>]]></description>
      <pubDate>Tue, 21 Dec 2010 08:45:24 -0600</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[Simas Toleikis's Blog: Idea for a PHP Validator]]></title>
      <guid>http://www.phpdeveloper.org/news/15254</guid>
      <link>http://www.phpdeveloper.org/news/15254</link>
      <description><![CDATA[<p>
<i>Simas Toleikis</i> has posted <a href="http://simas.posterous.com/idea-for-a-php-validator">an interesting idea for a validator</a> that would look at the incoming source of an application/script and determine what the requirements for it might be.
</p>
<blockquote>
How about creating a PHP code validator? Got this idea by looking at <a href="http://php.net/tokenizer">tokenizer</a> and <a href="http://php.net/reflection">reflection</a> extensions. I doubt I will find the time to work on this myself but then someone else might be interested to pick it up. From user's point of view there will be a form made of a large textarea box and a single file upload input. One could paste code snippet on that textarea or upload a ZIP'ed source code archive (or a single .php file) for validation.
</blockquote>
<p>
His proposed result would show a list of "Required Extensions", PHP versions, E_STRICT compatibility and possibly total lines of code in the project. He points out a few issues that might pop up in writing such a tool such as the requirement for it to be able to use the tokenizer extension itself (a sort of catch-22 since it's not always installed).
</p>]]></description>
      <pubDate>Fri, 08 Oct 2010 13:48:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Stanislav Malyshev's Blog: Adding new extensions to Zend Studio]]></title>
      <guid>http://www.phpdeveloper.org/news/15092</guid>
      <link>http://www.phpdeveloper.org/news/15092</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Stanislav Malyshev</i> talks about how Zend Studio users can <a href="http://php100.wordpress.com/2010/09/08/adding-new-exts-to-zend-studio/">get the tool to recognize new extensions</a> by adding in stubs with PHPDocumentor markup.
</p>
<blockquote>
If you have some extension, create stub file with PHPDOC descriptions [...] for each extension function, Studio will know to pick it up. You can put this file into Studio's prototypes directory - easiest way to find it is just write something like chdir() anywhere, select the name and press F3, the directory of the file that you'll get is the one you need.
</blockquote>
<p>
Not wanting to have to generate all of the stubs himself, he created the <a href="http://github.com/smalyshev/Reflector">Reflector</a> script that will, when pointed at an extension, create the stub file with definitions for each method it can use. There's also the <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.pdt/plugins/org.eclipse.php.core/Resources/language/generate.php?root=Tools_Project&view=markup">generator script</a> that's a part of Zend Studio that works similarly.
</p>]]></description>
      <pubDate>Wed, 08 Sep 2010 08:32:31 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Chris Tankersley's Blog: Getting Started with Reflection]]></title>
      <guid>http://www.phpdeveloper.org/news/15077</guid>
      <link>http://www.phpdeveloper.org/news/15077</link>
      <description><![CDATA[<p>
<i>Chris Tankersley</i> has a new post to how blog looking at a powerful but sometimes seldom used feature of PHP - Reflection. <a href="http://ctankersley.com/2010/09/03/getting-started-with-reflection/">His post</a> introduces you to some of the basics you can use to have your code find out more about itself.
</p>
<blockquote>
Reflection  is a metaprogramming construct that allows a program to look into itself and do a multitude of different things - gain meaning, watch execution, call code, or even provide feedback. [...] With PHP 5, PHP gained a robust reflection class that allows a developer to gain access to just about every aspect of an object and interact with it. The key is figuring out what is available, and then exploiting it to gain additional benefits.
</blockquote>
<p>
He gives examples from <a href="http://github.com/dragonmantank/PhpORM">his project</a> where it uses the <a href="http://www.php.net/manual/en/class.reflectionclass.php">ReflectionClass</a> feature to pull in the values of a class including properties and methods in a class (a set of <a href="http://www.php.net/manual/en/class.reflectionobject.php">ReflectionMethods</a>). Some code is provided to make the examples a bit more clear.
</p>]]></description>
      <pubDate>Fri, 03 Sep 2010 14:12:13 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Three Advanced Object-Oriented PHP Features You Need to Know ]]></title>
      <guid>http://www.phpdeveloper.org/news/14657</guid>
      <link>http://www.phpdeveloper.org/news/14657</link>
      <description><![CDATA[<p>
On PHPBuilder.com there's a <a href="http://www.phpbuilder.com/columns/Jason_Gilmore061510.php3">new article on OOP</a> in PHP applications, specifically some of the things that PHP5 has to offer you if you're not using it to its fullest potential.
</p>
<blockquote>
I'll introduce you to three of PHP's advanced object-oriented features which seem to not have garnered the attention they deserve. The topics discussed here should be useful whether you're a relative newcomer to object-oriented development and are looking to expand your knowledge, or have a background using languages such as Java or C# and are trying to learn more about what PHP has to offer.
</blockquote>
<p>
These three things he introduces are Reflection (PHP's <a href="http://us2.php.net/reflection">API for introspection</a> of code), the SPL (Standard PHP Library) set of objects and tools and a more recent addition - late static binding.
</p>]]></description>
      <pubDate>Wed, 16 Jun 2010 09:13:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: Testing Your Privates]]></title>
      <guid>http://www.phpdeveloper.org/news/13992</guid>
      <link>http://www.phpdeveloper.org/news/13992</link>
      <description><![CDATA[<p>
In a new post to his blog today <i>Sebastian Bergmann</i> looks at a way you can test your privates (no, not that) - <a href="http://sebastian-bergmann.de/archives/881-Testing-Your-Privates.html">private methods in your classes</a> with <a href="http://phpunit.de">PHPUnit</a>. The key lies in the Reflection API.
</p>
<blockquote>
One question I get over and over again when talking about <a href="http://en.wikipedia.org/wiki/Unit_Testing">Unit Testing</a> is this: "How do I test the private attributes and methods of my objects?" [...] PHP 5.3.2 introduces the ReflectionMethod::setAccessible() method to allow the invocation of protected and private methods through the Reflection API.
</blockquote>
<p>
This method lets you, at runtime, change the access level on the method away from private or protected and down to public so the contents can be executed normally. Though he warns one thing about doing it this way - just because you can, doesn't mean it's a good thing. You application is meant to be tested in a certain way and you should probably stick to that.
</p>]]></description>
      <pubDate>Tue, 09 Feb 2010 11:48:42 -0600</pubDate>
    </item>
  </channel>
</rss>

