<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Manuel Pichler - staticReflection</title>
    <link>http://www.manuel-pichler.de/</link>
    <description>Trust is good, (phpUnder)Control is better.</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.3.1 - http://www.s9y.org/</generator>
    
    

<item>
    <title>staticReflection 0.1.4 released</title>
    <link>http://www.manuel-pichler.de/archives/76-staticReflection-0.1.4-released.html</link>
            <category>php</category>
            <category>phpugdo</category>
            <category>projects</category>
            <category>staticReflection</category>
    
    <comments>http://www.manuel-pichler.de/archives/76-staticReflection-0.1.4-released.html#comments</comments>
    <wfw:comment>http://www.manuel-pichler.de/wfwcomment.php?cid=76</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.manuel-pichler.de/rss.php?version=2.0&amp;type=comments&amp;cid=76</wfw:commentRss>
    

    <author>nospam@example.com (Manuel Pichler)</author>
    <content:encoded>
    &lt;p&gt;
  Today I have released version 0.1.4 of the staticReflection component. This release contains two critical bug fixes.
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Fixed &lt;a href=&quot;http://www.manuel-pichler.de/exit.php?url_id=2232&amp;amp;entry_id=76&quot; title=&quot;http://tracker.pdepend.org/static_reflection/issue_tracker/issue/5&quot;  onmouseover=&quot;window.status=&#039;http://tracker.pdepend.org/static_reflection/issue_tracker/issue/5&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;#5&lt;/a&gt;: Filenames not normalized from relative to absolute paths. Fixed in svn revision &lt;a href=&quot;http://www.manuel-pichler.de/exit.php?url_id=2233&amp;amp;entry_id=76&quot; title=&quot;http://tracker.pdepend.org/static_reflection/browse_code/revision/259&quot;  onmouseover=&quot;window.status=&#039;http://tracker.pdepend.org/static_reflection/browse_code/revision/259&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;#259&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Fixed &lt;a href=&quot;http://www.manuel-pichler.de/exit.php?url_id=2234&amp;amp;entry_id=76&quot; title=&quot;http://tracker.pdepend.org/static_reflection/issue_tracker/issue/6&quot;  onmouseover=&quot;window.status=&#039;http://tracker.pdepend.org/static_reflection/issue_tracker/issue/6&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;#6&lt;/a&gt;: Queries do not hold references to previous parsed classes and interfaces. Fixed in svn revision &lt;a href=&quot;http://www.manuel-pichler.de/exit.php?url_id=2235&amp;amp;entry_id=76&quot; title=&quot;http://tracker.pdepend.org/static_reflection/browse_code/revision/269&quot;  onmouseover=&quot;window.status=&#039;http://tracker.pdepend.org/static_reflection/browse_code/revision/269&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;#269&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;p&gt;
  You can get the latest stable version of the staticReflection component through its &lt;a href=&quot;http://www.manuel-pichler.de/exit.php?url_id=2237&amp;amp;entry_id=76&quot; title=&quot;http://pdepend.org&quot;  onmouseover=&quot;window.status=&#039;http://pdepend.org&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;PHP_Depend&#039;s&lt;/a&gt; PEAR channel:
&lt;/p&gt;

&lt;pre&gt;
mapi@arwen ~ $ pear channel-discover pear.pdepend.org
mapi@arwen ~ $ pear install pdepend/staticReflection-alpha
&lt;/pre&gt;

&lt;p&gt;
  or you can download the latest version from the staticReflection svn respository:
&lt;/p&gt;

&lt;pre&gt;
mapi@arwen ~ $ svn co http://svn.reflection.pdepend.org/trunk \
                      staticReflection
&lt;/pre&gt;
 
    </content:encoded>

    <pubDate>Sat, 02 Jan 2010 23:38:06 +0100</pubDate>
    <guid isPermaLink="false">http://www.manuel-pichler.de/archives/76-guid.html</guid>
    <category>php5</category>
<category>release announcement</category>
<category>static_reflection</category>

</item>
<item>
    <title>First release of the staticReflection component.</title>
    <link>http://www.manuel-pichler.de/archives/68-First-release-of-the-staticReflection-component..html</link>
            <category>php</category>
            <category>phpugdo</category>
            <category>planet-php</category>
            <category>projects</category>
            <category>staticReflection</category>
    
    <comments>http://www.manuel-pichler.de/archives/68-First-release-of-the-staticReflection-component..html#comments</comments>
    <wfw:comment>http://www.manuel-pichler.de/wfwcomment.php?cid=68</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.manuel-pichler.de/rss.php?version=2.0&amp;type=comments&amp;cid=68</wfw:commentRss>
    

    <author>nospam@example.com (Manuel Pichler)</author>
    <content:encoded>
    &lt;p&gt;
  Today I have released the first version of the staticReflection component. This component parses the source files of a project to provide reflection information identical to that provided by &lt;a href=&quot;http://php.net&quot;&gt;PHP&#039;s&lt;/a&gt; build in &lt;a href=&quot;http://php.net/reflection&quot;&gt;API&lt;/a&gt;, without loading the class declaration into the PHP runtime context. Due to the API compatibility the staticReflection component can simply be used as a drop-in replacement for the reflection extension.
&lt;/p&gt;

&lt;p&gt;
  A few weeks ago I started just another script that utilized the &lt;a href=&quot;http://&quot;&gt;tokenizer&lt;/a&gt; extension to extract some information from source code files. At that point I thought that the time had come to realize a project that was on my todo for a very long time. And here is the result of the first iteration, a userland reflection implementation that is api compatible with PHP&#039;s internal reflection extension. Beside the source parser and the reflection ast this component provides a unified interface to both reflection versions, which makes it easy to switch between different implementations.
&lt;/p&gt;

&lt;p&gt;
  As a first use case for this component I have choosen autoload files, as they are used by the &lt;a href=&quot;http://ezcomponents.org&quot;&gt;eZ Components&lt;/a&gt;. The generation of those files is really easy, simply parse a directory with source files and dump the result into a file.
&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php
use org\pdepend\reflection\Autoloader;
use org\pdepend\reflection\ReflectionSession;

// Include the bundled autoloader
include_once &#039;staticReflection/Autoloader.php&#039;;

// Register the autoload function
spl_autoload_register( array( new Autoloader(), &#039;autoload&#039; ) );

// Create a new session
$session = new ReflectionSession();

// Create a directory query
$query = $session-&amp;gt;createDirectoryQuery(  );

$autoload = array();
foreach ( $query-&amp;gt;find( __DIR__ . &#039;/../../source/&#039; ) as $class )
{
    $autoload[$class-&amp;gt;getName()] = $class-&amp;gt;getFileName();
}

var_export( $autoload ); 
&lt;/pre&gt;

&lt;p&gt;
  You can also use the static reflection implementation to analyze different versions of the same class in the same process, which is not possible with the build-in reflection API, because you cannot load multiple classes with the same name into the current runtime context. 
&lt;/p&gt;

&lt;p&gt;
  Beside parsing of a given directory or file the staticReflection component also supports direct access to a concrete class or interface through the name. Therefor it uses so called &lt;a href=&quot;http://tracker.pdepend.org/static_reflection/browse_code/view/source/interfaces/SourceResolver.php&quot;&gt;source resolvers&lt;/a&gt;, that perform a mapping between class names and the associated source files. The current release has two build-in resolvers, one using autoload arrays as they are used by the &lt;a href=&quot;http://ezcomponents.org&quot;&gt;eZ Components&lt;/a&gt; and the other one uses the &lt;a href=&quot;http://pear.php.net/manual/en/standards.naming.php&quot;&gt;PEAR naming conventions&lt;/a&gt; and the configured include_paths to determine the source file for a given class name. The following example illustrates the usage of the &lt;a href=&quot;http://tracker.pdepend.org/static_reflection/browse_code/view/source/resolvers/PearNamingResolver.php&quot;&gt;PEAR source resolver&lt;/a&gt;.
&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php
use org\pdepend\reflection\Autoloader;
use org\pdepend\reflection\ReflectionSession;
use org\pdepend\reflection\factories\StaticReflectionClassFactory;
use org\pdepend\reflection\resolvers\PearNamingResolver;

include_once &#039;staticReflection/Autoloader.php&#039;;

spl_autoload_register( array( new Autoloader(), &#039;autoload&#039; ) );

$session = ReflectionSession::createStaticSession(
    new PearNamingResolver()
);

$class = $session-&amp;gt;getClass( &#039;PEAR_Frontend&#039; );
echo &#039;- &#039;, $class-&amp;gt;getName(), PHP_EOL,
     &#039;    &#039;, $class-&amp;gt;getFileName(), PHP_EOL;
&lt;/pre&gt;

&lt;p&gt;
  This concept makes the component extremly flexible, because you can write your own source resolver that fulfills the requirements for your application.
&lt;/p&gt;

&lt;p&gt;
  Beside the source resolver concept the &lt;a href=&quot;http://tracker.pdepend.org/static_reflection/browse_code/view/source/ReflectionSession.php&quot;&gt;ReflectionSession&lt;/a&gt; can also be configured with a custom stack of &lt;a href=&quot;http://tracker.pdepend.org/static_reflection/browse_code/view/source/interfaces/ReflectionClassFactory.php&quot;&gt;ReflectionClassFactory&lt;/a&gt; objects that are used to retrieve a reflection class instance for a given class/interface name. To minimize the configuration overhead for common use cases the &lt;code&gt;ReflectionSession&lt;/code&gt; class provides three build-in factory methods that create default session configurations for you:
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;ReflectionSession::createDefaultSession( SourceResolver )&lt;/code&gt;: This session configuration uses three different backends. First it asks the native backend for a reflection class. When this backend cannot handle the request the static reflection factory is asked for a matching class. Finally this configuration uses the &lt;a href=&quot;http://tracker.pdepend.org/static_reflection/browse_code/view/source/factories/NullReflectionClassFactory.php&quot;&gt;null backend&lt;/a&gt;, which always returns an empty placeholder reflection class.&lt;br /&gt;&lt;br /&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;ReflectionSession::createStaticSession( SourceResolver )&lt;/code&gt;: This session setup first asks the static reflection implementation for a matching reflection class and falls back to the null backend when no matching class exists.&lt;br /&gt;&lt;br /&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;ReflectionSession::createInternalSession()&lt;/code&gt;: This factory method creates a session setup that is a simple wrapper around PHP&#039;s internal reflection api.&lt;br /&gt;&lt;br /&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;p&gt;
  But you can always build your own session configuration with a custom factory stack, by calling the &lt;code&gt;&lt;a href=&quot;http://tracker.pdepend.org/static_reflection/browse_code/view/source/ReflectionSession.php#line160&quot;&gt;ReflectionSession::addClassFactory()&lt;/a&gt;&lt;/code&gt; method on the session instance.
&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php
use org\pdepend\reflection\Autoloader;
use org\pdepend\reflection\ReflectionSession;

include_once &#039;staticReflection/Autoloader.php&#039;;

spl_autoload_register( array( new Autoloader(), &#039;autoload&#039; ) );

$session = new ReflectionSession();
$session-&amp;gt;addClassFactory( new MyFooFactory() );
$session-&amp;gt;addClassFactory( new MyBarFactory() );
&lt;/pre&gt;

&lt;p&gt;
  So how can you use this cool component in your application? This is really simple, just replace all &lt;code&gt;ReflectionClass&lt;/code&gt; instantiations with the following code:
&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php
// ...
// Previous instantiation
// $ref = new ReflectionClass( &#039;Foo_Bar_Baz&#039; );

// New cool solution
$ref = ReflectionSessionInstance::get()-&amp;gt;getClass( &#039;Foo_Bar_Baz&#039; );
&lt;/pre&gt;

&lt;p&gt;
  And add the following code to your bootstrap file:
&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php
// ...
ReflectionSessionInstance::set(
    ReflectionSession::createInternalSession()
);
&lt;/pre&gt;

&lt;p&gt;
  Finally some words to the requirements and the installation of this component. This component requires PHP in a version greater or equal 5.3.0. For installation you can use &lt;a href=&quot;http://pdepend.org&quot;&gt;PHP_Depend&#039;s&lt;/a&gt; PEAR channel:
&lt;/p&gt;

&lt;pre&gt;
mapi@arwen ~ $ pear channel-discover pear.pdepend.org
mapi@arwen ~ $ pear install pdepend/staticReflection-alpha
&lt;/pre&gt;

&lt;p&gt;
  or you can download the latest version from the staticReflection svn respository:
&lt;/p&gt;

&lt;pre&gt;
mapi@arwen ~ $ svn co http://svn.reflection.pdepend.org/trunk \
                      staticReflection
&lt;/pre&gt;

&lt;p&gt;
  Feel free to test this component and file bug-reports and/or feature-requests in the &lt;a href=&quot;http://tracker.pdepend.org/static_reflection/&quot;&gt;project issue tracker&lt;/a&gt;. 
&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 29 Nov 2009 21:45:00 +0100</pubDate>
    <guid isPermaLink="false">http://www.manuel-pichler.de/archives/68-guid.html</guid>
    <category>php</category>
<category>static code analysis</category>
<category>static_reflection</category>
<category>tools</category>

</item>

</channel>
</rss>