<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://schmalls.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://schmalls.com/feed.php">
        <title>Schmalls blog</title>
        <description></description>
        <link>http://schmalls.com/</link>
        <image rdf:resource="http://schmalls.com/lib/images/favicon.ico" />
       <dc:date>2010-03-11T12:43:44-06:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://schmalls.com/blog/2009/10/install-trac-as-a-windows-service"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2008/12/home-server-project-part-1"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2008/08/a-pluggable-preprocessor-for-php"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2008/08/a-plugabble-preprocessor-for-php"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2008/05/solidworks-batch-runner"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2008/02/infinite-recursion-ie-hard-to-spot-error"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2007/10/return-to-prototype-based-programming-in-php"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2006/12/eclipse-php-ide"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2006/11/prototype-based-programming-in-php"/>
                <rdf:li rdf:resource="http://schmalls.com/blog/2006/02/double-your-dvd-collection"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://schmalls.com/lib/images/favicon.ico">
        <title>Schmalls</title>
        <link>http://schmalls.com/</link>
        <url>http://schmalls.com/lib/images/favicon.ico</url>
    </image>
    <item rdf:about="http://schmalls.com/blog/2009/10/install-trac-as-a-windows-service">
        <dc:format>text/html</dc:format>
        <dc:date>2009-10-01T20:09:29-06:00</dc:date>
        <title>Install Trac As A Windows Service</title>
        <link>http://schmalls.com/blog/2009/10/install-trac-as-a-windows-service</link>
        <description>
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

What follows is a how-to for installing Trac as a Windows service. The benefit of this is being able to log off of the server machine without stopping the tracd server.
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;

The bulk of the information used to figure this out come from Microsoft&amp;#039;s &lt;a href=&quot;http://support.microsoft.com/kb/q137890/&quot; class=&quot;urlextern&quot; title=&quot;http://support.microsoft.com/kb/q137890/&quot;  rel=&quot;nofollow&quot;&gt;How To Create a User-Defined Service&lt;/a&gt; and a guide for &lt;a href=&quot;http://www.hume.com/html84/man1/srvany.html&quot; class=&quot;urlextern&quot; title=&quot;http://www.hume.com/html84/man1/srvany.html&quot;  rel=&quot;nofollow&quot;&gt;Windows NT Tcl/Tk Server Installation&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
The steps are actually pretty simple:

&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Download the &lt;span class=&quot;wrap_download&quot;&gt;&lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;amp;displaylang=en&quot; class=&quot;urlextern&quot; title=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;amp;displaylang=en&quot;  rel=&quot;nofollow&quot;&gt;Windows 2003 Resource Kit Tools&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Run the following command (after making the appropriate path replacements):&lt;pre class=&quot;code dos&quot;&gt;C:\Program Files\Resource Kit\Instsrv.exe Tracd C:\Program Files\Resource Kit\Srvany.exe&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Run regedit.&lt;/div&gt;
&lt;ol&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; Add a new key: &lt;code&gt;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tracd\Parameters]&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; Add the following string values:&lt;/div&gt;
&lt;ol&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;Application&lt;/code&gt; with the path to the tracd executable.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;AppParameters&lt;/code&gt; with the parameters you use to run tracd.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;AppDirectory&lt;/code&gt; with the path to the directory which contains the tracd executable.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Open the Services panel.&lt;/div&gt;
&lt;ol&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; Set the new Tracd service to automatic.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; Start the Tracd service.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;

Now you should be able to log out and still access the Trac server.
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/trac?do=showtag&amp;amp;tag=tag%3Atrac&quot; class=&quot;wikilink1&quot; title=&quot;tag:trac&quot; rel=&quot;tag&quot;&gt;Trac&lt;/a&gt;,
	&lt;a href=&quot;http://schmalls.com/tag/windows?do=showtag&amp;amp;tag=tag%3Awindows&quot; class=&quot;wikilink1&quot; title=&quot;tag:windows&quot; rel=&quot;tag&quot;&gt;Windows&lt;/a&gt;,
	&lt;a href=&quot;http://schmalls.com/tag/tips?do=showtag&amp;amp;tag=tag%3Atips&quot; class=&quot;wikilink1&quot; title=&quot;tag:tips&quot; rel=&quot;tag&quot;&gt;Tips&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2009/10/install-trac-as-a-windows-service#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2008/12/home-server-project-part-1">
        <dc:format>text/html</dc:format>
        <dc:date>2008-12-30T15:38:42-06:00</dc:date>
        <title>Home Server Project - Part 1</title>
        <link>http://schmalls.com/blog/2008/12/home-server-project-part-1</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

Explains the history behind and first steps of my home server project.
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;

&lt;h4&gt;&lt;a name=&quot;the-history&quot; id=&quot;the-history&quot;&gt;The History&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;

&lt;img src=&quot;http://schmalls.com/_media/blog/2008/12/trinity_college_library_dub.jpg&quot; class=&quot;mediaright&quot; align=&quot;right&quot; title=&quot;It is hard to find an image that conveys history, this is my best shot.&quot; alt=&quot;It is hard to find an image that conveys history, this is my best shot.&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
I currently live in a house with three other guys (see &lt;a href=&quot;http://en.wikipedia.org/wiki/Bachelor_pad&quot; class=&quot;urlextern&quot; title=&quot;http://en.wikipedia.org/wiki/Bachelor_pad&quot;  rel=&quot;nofollow&quot;&gt;bachelor pad&lt;/a&gt;). Between us we have 3 desktops, 3 laptops, 3 XBOX 360s, and 3 iPhones. The desktops and laptops are running ether XP or Vista. The first year in the house saw the addition of network connections to all of the bedrooms and the living room, serviced by a cable modem, wireless and wired routers, and an 8-port hub. The living room has one of the XBOXes, a projector, digital cable box, and a Pioneer receiver.
&lt;/p&gt;

&lt;p&gt;
Over my Christmas vacation, instead of relaxing, I decided to start yet another project. I wanted to better integrate the home network and I also wanted to get my feet wet with home automation. So the idea was to setup some network shares and also to make a remote interface for the living room that can be used from the iPhone (or any web browser). After some research I settled on using &lt;a href=&quot;http://www.ubuntu.com/products/whatIsubuntu/serveredition&quot; class=&quot;urlextern&quot; title=&quot;http://www.ubuntu.com/products/whatIsubuntu/serveredition&quot;  rel=&quot;nofollow&quot;&gt;Ubuntu Server&lt;/a&gt; with &lt;a href=&quot;http://www.samba.org&quot; class=&quot;urlextern&quot; title=&quot;http://www.samba.org&quot;  rel=&quot;nofollow&quot;&gt;Samba&lt;/a&gt; for the shared drives (it was around this point I also decided to work on implementing &lt;a href=&quot;http://en.wikipedia.org/wiki/Roaming_user_profile&quot; class=&quot;urlextern&quot; title=&quot;http://en.wikipedia.org/wiki/Roaming_user_profile&quot;  rel=&quot;nofollow&quot;&gt;Roaming Profiles&lt;/a&gt;), &lt;a href=&quot;http://www.lirc.org/&quot; class=&quot;urlextern&quot; title=&quot;http://www.lirc.org/&quot;  rel=&quot;nofollow&quot;&gt;lirc&lt;/a&gt; and the &lt;a href=&quot;http://iguanaworks.net/&quot; class=&quot;urlextern&quot; title=&quot;http://iguanaworks.net/&quot;  rel=&quot;nofollow&quot;&gt;IguanaWorks&lt;/a&gt; &lt;a href=&quot;http://iguanaworks.net/product1.psp&quot; class=&quot;urlextern&quot; title=&quot;http://iguanaworks.net/product1.psp&quot;  rel=&quot;nofollow&quot;&gt;USB IR Transceiver&lt;/a&gt; for replacing all the remotes in the living room, and &lt;a href=&quot;http://ushare.geexbox.org/&quot; class=&quot;urlextern&quot; title=&quot;http://ushare.geexbox.org/&quot;  rel=&quot;nofollow&quot;&gt;uShare&lt;/a&gt; to share media with the XBOX 360s. Of course the web interface for the living room remotes will be backed by &lt;a href=&quot;http://php.net/&quot; class=&quot;urlextern&quot; title=&quot;http://php.net/&quot;  rel=&quot;nofollow&quot;&gt;PHP&lt;/a&gt; and &lt;a href=&quot;http://jquery.com/&quot; class=&quot;urlextern&quot; title=&quot;http://jquery.com/&quot;  rel=&quot;nofollow&quot;&gt;jQuery&lt;/a&gt;.
&lt;/p&gt;


&lt;div class=&quot;styler styler-clear-both&quot;&gt;&lt;/div&gt;


&lt;/div&gt;

&lt;h4&gt;&lt;a name=&quot;the-hardware&quot; id=&quot;the-hardware&quot;&gt;The Hardware&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;

&lt;img src=&quot;http://schmalls.com/_media/blog/2008/12/vycital_hdwe_store2.jpg&quot; class=&quot;medialeft&quot; align=&quot;left&quot; title=&quot;You won&amp;#039;t find many hardware stores like this around anymore.&quot; alt=&quot;You won&amp;#039;t find many hardware stores like this around anymore.&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
The next step was to find some hardware to run all of this. My first stop was &lt;a href=&quot;http://www.newegg.com/&quot; class=&quot;urlextern&quot; title=&quot;http://www.newegg.com/&quot;  rel=&quot;nofollow&quot;&gt;Newegg&lt;/a&gt; followed by a stop at &lt;a href=&quot;http://iguanaworks.net/&quot; class=&quot;urlextern&quot; title=&quot;http://iguanaworks.net/&quot;  rel=&quot;nofollow&quot;&gt;IguanaWorks&lt;/a&gt;.

&lt;/p&gt;
&lt;table class=&quot;inline&quot;&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;(1) &lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16856167032&quot; class=&quot;urlextern&quot; title=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16856167032&quot;  rel=&quot;nofollow&quot;&gt;MSI Wind PC Intel 945GC 1 x 200Pin Intel GMA 950 Black Barebone - Retail&lt;/a&gt;                      &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; $139.99&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0&quot;&gt;(1) &lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16822136284&quot; class=&quot;urlextern&quot; title=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16822136284&quot;  rel=&quot;nofollow&quot;&gt;Western Digital Caviar Black WD1001FALS 1TB 7200 RPM 32MB Cache SATA 3.0Gb/s Hard Drive - OEM&lt;/a&gt; &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; $119.99&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;(1) &lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16820231163&quot; class=&quot;urlextern&quot; title=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16820231163&quot;  rel=&quot;nofollow&quot;&gt;G.SKILL 2GB 200-Pin DDR2 SO-DIMM DDR2 533 (PC2 4200) Laptop Memory - Retail&lt;/a&gt;                   &lt;/td&gt;&lt;td class=&quot;col1 rightalign&quot;&gt;  $21.99&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;(1) Newegg Shipping                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col1 rightalign&quot;&gt;  $20.49&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;(1) &lt;a href=&quot;http://iguanaworks.net/product1.psp&quot; class=&quot;urlextern&quot; title=&quot;http://iguanaworks.net/product1.psp&quot;  rel=&quot;nofollow&quot;&gt;USB IR Transceiver&lt;/a&gt;                                                                                                        &lt;/td&gt;&lt;td class=&quot;col1 rightalign&quot;&gt;  $40.00&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row5&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;(2) &lt;a href=&quot;http://iguanaworks.net/product1.psp#acc&quot; class=&quot;urlextern&quot; title=&quot;http://iguanaworks.net/product1.psp#acc&quot;  rel=&quot;nofollow&quot;&gt;5 foot wired IR emitters&lt;/a&gt;                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 rightalign&quot;&gt;  $10.00&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row6&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;(1) IguanaWorks Shipping                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 rightalign&quot;&gt;   $5.00&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row7&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;Total                                                                                                                                                                 &lt;/th&gt;&lt;th class=&quot;col1&quot;&gt; $357.46&lt;/th&gt;
	&lt;/tr&gt;
&lt;/table&gt;


&lt;div class=&quot;styler styler-clear-both&quot;&gt;&lt;/div&gt;


&lt;/div&gt;

&lt;h4&gt;&lt;a name=&quot;the-wait&quot; id=&quot;the-wait&quot;&gt;The Wait&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;

&lt;img src=&quot;http://schmalls.com/_media/blog/2008/12/wait_ill_fix_it_410.jpg&quot; class=&quot;mediaright&quot; align=&quot;right&quot; title=&quot;(Un)fortunately I don&amp;#039;t have a cat to help me with the installation.&quot; alt=&quot;(Un)fortunately I don&amp;#039;t have a cat to help me with the installation.&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Since I ordered all of the components, I have been waiting on the pieces to arrive. I also ordered a 4Gb flash drive from Newegg, because I couldn&amp;#039;t find mine and I can use it to install the operating system (instead of getting an SATA or USB CD drive). While waiting I have just been reading up on all of the documentation to prepare myself for the installation process. Stay tuned for the next part in the series.
&lt;/p&gt;


&lt;div class=&quot;styler styler-clear-both&quot;&gt;&lt;/div&gt;

&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/computers?do=showtag&amp;amp;tag=tag%3Acomputers&quot; class=&quot;wikilink1&quot; title=&quot;tag:computers&quot; rel=&quot;tag&quot;&gt;Computers&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2008/12/home-server-project-part-1#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2008/08/a-pluggable-preprocessor-for-php">
        <dc:format>text/html</dc:format>
        <dc:date>2008-08-31T10:37:50-06:00</dc:date>
        <title>A Pluggable Preprocessor for PHP</title>
        <link>http://schmalls.com/blog/2008/08/a-pluggable-preprocessor-for-php</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

After reading Stan Vassilev&amp;#039;s post on &lt;a href=&quot;http://c7y.phparch.com/c/entry/1/art,practical_uses_tokenizer&quot; class=&quot;urlextern&quot; title=&quot;http://c7y.phparch.com/c/entry/1/art,practical_uses_tokenizer&quot;  rel=&quot;nofollow&quot;&gt;Practical Uses for the PHP Tokenizer&lt;/a&gt;, I got to thinking about his example of a preprocessor. It makes a lot of sense for the library developer. They could easily create multiple versions of their code depending on &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; version, target platform, backend database, etc. So I started working on my own implementation of a preprocessor with the goal of making it easy to add plugins for additional functionality. It was during the construction of the core of the preprocessor, that it hit me: why can&amp;#039;t we implement new language features in the preprocessor. The first things that came to mind for me were traits and scalar type hints. So without further ado, I present version 0.1.0-dev of PPP (with its own doubly recursive meaning: PPP &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; PreProcessor).
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;

The first version is very basic and only includes a plugin for traits handling (which is an ugly, but functional implementation). It also requires &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; 5.3 because of the use of namespaces. I plan on removing this limitation after I add a plugin for conditional macro statements (i.e. PPP will be able to preprocess itself). If you take a look at the tests folder, you will find some incomplete (sorry) PHPUnit tests of the functionality, which should give you an idea of how to interact with PPP.
&lt;/p&gt;

&lt;p&gt;
My implementation of traits is a simple one. I believe the goal of traits are to put the power into the programmers hands. So the trait syntax I use only allows renaming (not aliasing) or excluding methods. It isn&amp;#039;t very strict currently (i.e. variables, constants, etc. in the trait definition will make it through). I plan on adding the ability to exclude all methods (&lt;code&gt;* as null&lt;/code&gt;), to remove the only problem I can see with the implementation: if traits maintained by another individual or group add methods. With the ability to exclude all unaliased methods, the programmer can insure that &lt;em&gt;only&lt;/em&gt; the methods (s)he expects can be included, at the expense of verbosity of the aliases.
&lt;/p&gt;

&lt;p&gt;
My main goal for the future of the preprocessor is to reduce the amount of coding required by the programmer by adding syntactic sugar to &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt;. You can download  and let me know what you think in the comments.
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/php?do=showtag&amp;amp;tag=tag%3Aphp&quot; class=&quot;wikilink1&quot; title=&quot;tag:php&quot; rel=&quot;tag&quot;&gt;PHP&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2008/08/a-pluggable-preprocessor-for-php#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2008/08/a-plugabble-preprocessor-for-php">
        <dc:format>text/html</dc:format>
        <dc:date>2008-08-31T10:37:50-06:00</dc:date>
        <title></title>
        <link>http://schmalls.com/blog/2008/08/a-plugabble-preprocessor-for-php</link>
        <description>
&lt;p&gt;

</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2008/05/solidworks-batch-runner">
        <dc:format>text/html</dc:format>
        <dc:date>2008-05-05T13:03:40-06:00</dc:date>
        <title>Solidworks Batch Runner</title>
        <link>http://schmalls.com/blog/2008/05/solidworks-batch-runner</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

In my everyday work, I spend a lot of time waiting on SolidWorks to finish a task. The SolidWorks task scheduler is able to remove some of these burdens by allowing them to be run overnight. The great thing about the task scheduler is that it allows me to select folders or groups of files and runs the task in a separate SolidWorks instance for each file it finds. It also has a timeout for each file to complete its task. This means it can keep churning through all of the files and recover from a problem with one of the files (SolidWorks 2008 is notoriously unstable).
&lt;/p&gt;

&lt;p&gt;
The problem is that the number of tasks available is limited. There is the Custom Task which allows you to run a custom program or macro, but for some reason removes the file selection capability. It is for this reason that I set out to recreate the functionality of the task scheduler, but with the ability to run any macro (or multiple macros) in separate instances of SolidWorks for entire groups of files. I call it SolidWorksBatchRunner.
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;

Let me start with the usage statement for SolidWorksBatchRunner and continue with some examples of its functionality.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;
Usage: SolidWorksBatchRunner /m:MacroFile[|MacroModule[|MacroProcedure]] ..
       [/l:LogFile] [/n] [/r] [/s [/q]] [/t:Timeout] FileSearch ..
Runs the specified macros on the files found from the specified file
searches.
       /m:MacroFile|MacroModule|MacroProcedure
              The macro(s) to run on the specified files. MacroModule
              defaults to MacroFile - extension + 1. MacroProcedure
              defaults to main
       /l:LogFile
              The log file to use. Defaults to the current date/time:
              yyy-MM-dd HH-mm-ss.log.
       /n
              Specifies that each macro should be ran in a new SolidWorks
              instance.
       /q
              Specifies that the files should be rebuilt after all macros
              have run. Cannot be used without /s switch.
       /r
              Searches will also include subdirectories.
       /s
              Specifies that the files should be saved after all macros
              have run.
       /t
              The time, in seconds, each macro is given to complete its
              task. The default is 300 seconds.
       /?
       /h
       /help
              Prints this usage statement and exits.
&lt;/pre&gt;

&lt;p&gt;
I have included several options that I have found useful to a task scheduler application. So lets say you want to take a group of drawings and run your “DXFExport” macro on all the files. We don&amp;#039;t need to save the SolidWorks files afterward because we didn&amp;#039;t change anything. A command to do this could look like:
&lt;/p&gt;
&lt;pre class=&quot;code dos&quot;&gt;SolidWorksBatchRunner /m:&amp;quot;C:\My SW Macro Folder\DXFExport.swp&amp;quot; &amp;quot;C:\My Drawings Folder\*.SLDDRW&amp;quot;&lt;/pre&gt;
&lt;p&gt;
A couple of assumptions have been made.

&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The DXFExport module&amp;#039;s name is DXFExport1.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The DXFExport1 module method&amp;#039;s name is main.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; *.SLDDRW will find all the SolidWorks drawings in “C:\My Drawings Folder”.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A file log with the current time and date is created to store log messages.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;

The previous example shows how to run one macro on one file search, but it is possible to do multiple of each. We can also specify  the name of a log file to create.
&lt;/p&gt;
&lt;pre class=&quot;code dos&quot;&gt;SolidWorksBatchRunner ^
  /m:&amp;quot;C:\My SW Macro Folder\Macro1.swp|Macro11|main&amp;quot; ^
  /m:&amp;quot;C:\My SW Macro Folder\Macro1.swp|Macro11|alternate&amp;quot; ^
  /m:&amp;quot;C:\My SW Macro Folder\Macro2.swp&amp;quot; ^
  /s /q /r ^
  /l:&amp;quot;My Log File Name.log&amp;quot; ^
  &amp;quot;C:\My Drawings Folder\Folder &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;\*.SLDDRW&amp;quot; ^
  &amp;quot;C:\My Drawings Folder\Folder &lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;\*.SLDDRW&amp;quot; ^
  &amp;quot;C:\My Drawings Folder\Folder &lt;span class=&quot;nu0&quot;&gt;3&lt;/span&gt;\Start*End.SLDDRW&amp;quot;&lt;/pre&gt;
&lt;p&gt;
With this example:

&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; On each file Macro1 is called twice, once with the main method followed by the alternate method.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; On each file Macro2 is then called. All the macros run within one SolidWorks instance per file which can be changed by adding the /n switch.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; /s saves each file after the macros have run (like Ctrl-S).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; /q rebuilds each file before saving (like Ctrl-Q).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; /r causes the file searches to recursively search subdirectories on all of the file searches.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The first file search finds all drawings in Folder 1 and its subdirectories (because of the /r switch).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The second file search finds all drawings in Folder 2 and its subdirectories (because of the /r switch).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The third file search finds only the drawings whose filename begins with “Start” and ends with “End” in Folder 3 and its subdirectories (because of the /r switch)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Status information is written to the command line as well as to the “My Log File Name.log” file.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;

I have uploaded a zipped up Visual Studio Express project file used to make this program as well as a zipped up file of the executable and the SolidWorks libraries that it uses. The code is released under the &lt;a href=&quot;http://en.wikipedia.org/wiki/ISC_license&quot; class=&quot;urlextern&quot; title=&quot;http://en.wikipedia.org/wiki/ISC_license&quot;  rel=&quot;nofollow&quot;&gt;ISC License&lt;/a&gt;. I have only tested it with SolidWorks 2008 SP3.1 and .NET framework 3.5 installed. If anyone runs into any problems or has a suggestion, let me know by posting a comment to this post.
&lt;/p&gt;
&lt;div class=&quot;wrap_download&quot;&gt;
&lt;strong&gt;Files&lt;/strong&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;a href=&quot;http://schmalls.com/_media/blog/2008/05/solidworksbatchrunner.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;blog:2008:05:solidworksbatchrunner.zip&quot;&gt;SolidWorksBatchRunner Executable&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;a href=&quot;http://schmalls.com/_media/blog/2008/05/solidworksbatchrunner-project-file.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;blog:2008:05:solidworksbatchrunner-project-file.zip&quot;&gt;SolidWorksBatchRunner Project File&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/solidworks?do=showtag&amp;amp;tag=tag%3Asolidworks&quot; class=&quot;wikilink1&quot; title=&quot;tag:solidworks&quot; rel=&quot;tag&quot;&gt;SolidWorks&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2008/05/solidworks-batch-runner#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2008/02/infinite-recursion-ie-hard-to-spot-error">
        <dc:format>text/html</dc:format>
        <dc:date>2008-02-12T18:01:42-06:00</dc:date>
        <title>Infinite Recursion (i.e. Hard To Spot Error)</title>
        <link>http://schmalls.com/blog/2008/02/infinite-recursion-ie-hard-to-spot-error</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

I ran into a hard to spot bug the other day and decided to share it. I worked on some code for a while and then fired up my browser to test it. I would be using &lt;a href=&quot;http://xdebug.org/&quot; class=&quot;urlextern&quot; title=&quot;http://xdebug.org/&quot;  rel=&quot;nofollow&quot;&gt;Xdebug&lt;/a&gt; straight from &lt;a href=&quot;http://www.eclipse.org/pdt/&quot; class=&quot;urlextern&quot; title=&quot;http://www.eclipse.org/pdt/&quot;  rel=&quot;nofollow&quot;&gt;Eclipse PDT&lt;/a&gt;, but I can&amp;#039;t get it to work with the latest php snapshots for Windows. Anyway, when I went to test it, there was no output. It turns out that php-cgi had segfaulted. I spent the better half of a day trying to figure out the problem. When I thought I had figured it out, I would try to write up a test script for just that problem, and all of them ran just fine. Just when I was about to give up, I found the problem in this little class I was sure couldn&amp;#039;t be wrong.
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
It is the base class for a &lt;a href=&quot;http://en.wikipedia.org/wiki/Graph_%28data_structure%29&quot; class=&quot;urlextern&quot; title=&quot;http://en.wikipedia.org/wiki/Graph_%28data_structure%29&quot;  rel=&quot;nofollow&quot;&gt;graph&lt;/a&gt; edge. All the class does is constructs an object with references to its two vertices with a function to retrieve each. And here is the code (comments removed):
&lt;/p&gt;
&lt;pre class=&quot;code php&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; Edge
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$firstVertex&lt;/span&gt;;
&amp;nbsp;
    &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$secondVertex&lt;/span&gt;;
&amp;nbsp;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __construct&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$first_vertex&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$second_vertex&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;firstVertex&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$first_vertex&lt;/span&gt;;
        &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;secondVertex&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$second_vertex&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; firstVertex&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;firstVertex&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; secondVertex&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;secondVertex&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
The problem was in the last function. Instead of returning the private variable value, I called the function recursively. Since this is infinite recursion, the &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; interpreter will eventually crash (in under a second in most of my cases) and not output anything. At first, I thought this would be a bug, but these &lt;a href=&quot;http://bugs.php.net/bug.php?id=39160&quot; class=&quot;urlextern&quot; title=&quot;http://bugs.php.net/bug.php?id=39160&quot;  rel=&quot;nofollow&quot;&gt;bogus&lt;/a&gt; &lt;a href=&quot;http://bugs.php.net/bug.php?id=17945&quot; class=&quot;urlextern&quot; title=&quot;http://bugs.php.net/bug.php?id=17945&quot;  rel=&quot;nofollow&quot;&gt;bug&lt;/a&gt; &lt;a href=&quot;http://bugs.php.net/bug.php?id=8471&quot; class=&quot;urlextern&quot; title=&quot;http://bugs.php.net/bug.php?id=8471&quot;  rel=&quot;nofollow&quot;&gt;reports&lt;/a&gt; say that it is the expected behavior. I wish I could get Xdebug working to catch something like this (one of the bug reports say it would). So if anyone knows how to get Xdebug working on Windows with the latest &lt;a href=&quot;http://snaps.php.net&quot; class=&quot;urlextern&quot; title=&quot;http://snaps.php.net&quot;  rel=&quot;nofollow&quot;&gt;PHP snapshots&lt;/a&gt;, let me know.
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/php?do=showtag&amp;amp;tag=tag%3Aphp&quot; class=&quot;wikilink1&quot; title=&quot;tag:php&quot; rel=&quot;tag&quot;&gt;PHP&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2008/02/infinite-recursion-ie-hard-to-spot-error#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2007/10/return-to-prototype-based-programming-in-php">
        <dc:format>text/html</dc:format>
        <dc:date>2007-10-29T18:19:26-06:00</dc:date>
        <title>Return to Prototype Based Programming in PHP</title>
        <link>http://schmalls.com/blog/2007/10/return-to-prototype-based-programming-in-php</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

With the implementation of the &lt;code&gt;get_called_class()&lt;/code&gt; function in &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt;, prototype based programming in &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; is possible. The new function is in both PHP5.3 and PHP6 &lt;a href=&quot;http://snaps.php.net&quot; class=&quot;urlextern&quot; title=&quot;http://snaps.php.net&quot;  rel=&quot;nofollow&quot;&gt;snapshots&lt;/a&gt;. So, I went back to the drawing board and came up with a fully capable class. The &lt;code&gt;$this&lt;/code&gt; keyword is usable, as well as being able to use the &lt;code&gt;self&lt;/code&gt;, &lt;code&gt;parent&lt;/code&gt;, and &lt;code&gt;static&lt;/code&gt; (new with the &lt;a href=&quot;http://www.ds-o.com/archives/65-Late-static-binding....sorta.html&quot; class=&quot;urlextern&quot; title=&quot;http://www.ds-o.com/archives/65-Late-static-binding....sorta.html&quot;  rel=&quot;nofollow&quot;&gt;late static binding patch&lt;/a&gt;) keywords. Code after the jump.
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;

So let&amp;#039;s get straight to the code that does it.
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;prototype.php&lt;/strong&gt;

&lt;/p&gt;
&lt;pre class=&quot;code php&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt;
namespace com&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;schmalls&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;personal&lt;/span&gt;;
&amp;nbsp;
&lt;span class=&quot;co4&quot;&gt;/**
 * This class holds the prototype capabilities
 * 
 * Extending this class makes it prototype capable.
 * Instantiating this class with the param and
 * method values allows a runtime method to be
 * added to a class.
 */&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; prototype
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Holds the object prototype methods for all subclasses
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;re0&quot;&gt;$_object_methods&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Holds the static prototype methods for all subclasses
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;re0&quot;&gt;$_static_methods&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Holds all of the local prototype methods for this object
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$_local_methods&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Holds an instance of the prototype class
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Method parameters
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$___params&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Method body
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$___method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Whether the method has static method calls
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$___static_calls&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Holds the last called class
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$___class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Whether the last call was static
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$___static&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Default constructor
   * 
   * Child classes should not call this class. When called with the params
   * and method values, it can be used to set a new prototype method.
   * 
   * @param   mixed $params string input like create_user_function or array of argument names
   * @param   string $method method body
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __construct&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$params&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// check if we are being used to make a prototype method&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$params&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// check if this is an array&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/is_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;is_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$params&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// make the parameter string&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$params&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/implode&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;implode&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$params&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;', '&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// check if this method uses the this keyword&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strpos&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strpos&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$this'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// splits the method body by parts in which the this keyword should not be altered&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$regex&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;st_h&quot;&gt;'~'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// start regular expression&lt;/span&gt;
                    &lt;span class=&quot;st_h&quot;&gt;'(/\*.*?\*/)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;       &lt;span class=&quot;co1&quot;&gt;// /* */ style comments&lt;/span&gt;
                    &lt;span class=&quot;st_h&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                 &lt;span class=&quot;co1&quot;&gt;// or&lt;/span&gt;
                    &lt;span class=&quot;st_h&quot;&gt;'(#.*?$)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;           &lt;span class=&quot;co1&quot;&gt;// # style comments&lt;/span&gt;
                    &lt;span class=&quot;st_h&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                 &lt;span class=&quot;co1&quot;&gt;// or&lt;/span&gt;
                    &lt;span class=&quot;st_h&quot;&gt;'(//.*?$)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;          &lt;span class=&quot;co1&quot;&gt;// // style comments&lt;/span&gt;
                    &lt;span class=&quot;st_h&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                 &lt;span class=&quot;co1&quot;&gt;// or&lt;/span&gt;
                    &lt;span class=&quot;st_h&quot;&gt;'(&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;.*?[^&lt;span class=&quot;es_h&quot;&gt;\\\\&lt;/span&gt;]&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;// single quote strings&lt;/span&gt;
                  &lt;span class=&quot;st_h&quot;&gt;'~'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// end regular expression&lt;/span&gt;
                  &lt;span class=&quot;st_h&quot;&gt;'i'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// match case insensitive&lt;/span&gt;
                  &lt;span class=&quot;st_h&quot;&gt;'s'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// dot matches all characters including newlines&lt;/span&gt;
                  &lt;span class=&quot;st_h&quot;&gt;'m'&lt;/span&gt;;                    &lt;span class=&quot;co1&quot;&gt;// match multiline;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$pieces&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/preg_split&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;preg_split&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$regex&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;co1&quot;&gt;// store how many keywords have been replaced&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu19&quot;&gt;0&lt;/span&gt;;
        &lt;span class=&quot;co1&quot;&gt;// loop through each of the split pieces&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$pieces&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;co1&quot;&gt;// replace the this keyword with a safer name&lt;/span&gt;
          &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/substr_replace&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;substr_replace&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;                         &lt;span class=&quot;co1&quot;&gt;// begin substring replace of piece section&lt;/span&gt;
                        &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                            &lt;span class=&quot;co1&quot;&gt;// the main method body&lt;/span&gt;
                        &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;                       &lt;span class=&quot;co1&quot;&gt;// begin preg replace of this keyword&lt;/span&gt;
                          &lt;span class=&quot;st_h&quot;&gt;'/'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                             &lt;span class=&quot;co1&quot;&gt;// start regular expression&lt;/span&gt;
                            &lt;span class=&quot;st_h&quot;&gt;'\$this'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                      &lt;span class=&quot;co1&quot;&gt;// match the this keyword&lt;/span&gt;
                            &lt;span class=&quot;st_h&quot;&gt;'(?![[a-zA-Z0-9_\x7f-\xff])'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;// not followed by another valid variable name character&lt;/span&gt;
                          &lt;span class=&quot;st_h&quot;&gt;'/'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                             &lt;span class=&quot;co1&quot;&gt;// end regular expression&lt;/span&gt;
                          &lt;span class=&quot;st_h&quot;&gt;'i'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                              &lt;span class=&quot;co1&quot;&gt;// match case insensitive&lt;/span&gt;
                          &lt;span class=&quot;st_h&quot;&gt;'$___this'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                       &lt;span class=&quot;co1&quot;&gt;// replace with $___this&lt;/span&gt;
                          &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu19&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                        &lt;span class=&quot;co1&quot;&gt;// the piece string&lt;/span&gt;
                          &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                               &lt;span class=&quot;co1&quot;&gt;// no limit&lt;/span&gt;
                          &lt;span class=&quot;re0&quot;&gt;$j&lt;/span&gt;                                &lt;span class=&quot;co1&quot;&gt;// number of matches&lt;/span&gt;
                        &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                                  &lt;span class=&quot;co1&quot;&gt;// end preg replace&lt;/span&gt;
                        &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;         &lt;span class=&quot;co1&quot;&gt;// offset to beginning of piece&lt;/span&gt;
                        &lt;a href=&quot;http://www.php.net/strlen&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strlen&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu19&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;                 &lt;span class=&quot;co1&quot;&gt;// length of piece&lt;/span&gt;
                      &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;                                    &lt;span class=&quot;co1&quot;&gt;// end substring replace&lt;/span&gt;
          &lt;span class=&quot;co1&quot;&gt;// increase how many keyword replacements have been made&lt;/span&gt;
          &lt;span class=&quot;re0&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$j&lt;/span&gt;;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// set the method parameters string including space for the this reference&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___params &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/trim&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;trim&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$params&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___params &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;''&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___params &lt;span class=&quot;sy0&quot;&gt;.=&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'&amp;amp;$___this = null'&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___params &lt;span class=&quot;sy0&quot;&gt;.=&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;', &amp;amp;$___this = null'&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// set the method body string&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___method &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;;
      &lt;span class=&quot;co1&quot;&gt;// check whether this method makes static calls and therefore has to be recreated on each call&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___static_calls &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strpos&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strpos&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'self'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; ||
          &lt;a href=&quot;http://www.php.net/strpos&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strpos&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'parent'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; ||
          &lt;a href=&quot;http://www.php.net/strpos&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strpos&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'static'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
          &lt;span class=&quot;sy0&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Allows the prototype variable to be used within objects as well as setting up the called class
   * 
   * @param   string $name
   * @return  prototype
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __get&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// see if we are getting the prototype&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'prototype'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// see if the static prototype variable has been instantiated&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; get_called_class&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// set the calling class and set to dynamic&lt;/span&gt;
      &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___class &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; get_called_class&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___static &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * This is where the magic happens for dynamic prototype method calls
   * 
   * @param   string $name
   * @param   array $arguments
   * @return  mixed
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __call&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// fix name&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strtolower&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strtolower&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; get_called_class&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;co1&quot;&gt;// add this to arguments&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;;
    &lt;span class=&quot;co1&quot;&gt;// check if this is a local class method&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_local_methods&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// check if the method has static calls&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/is_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;is_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_local_methods&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;                            &lt;span class=&quot;co1&quot;&gt;// create function with static calls&lt;/span&gt;
                    &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_local_methods&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'params'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;   &lt;span class=&quot;co1&quot;&gt;// parameters&lt;/span&gt;
                    &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_fixStaticMethodCalls&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;              &lt;span class=&quot;co1&quot;&gt;// fix static calls&lt;/span&gt;
                      &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_local_methods&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'method'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// method body&lt;/span&gt;
                      &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                                 &lt;span class=&quot;co1&quot;&gt;// self&lt;/span&gt;
                      &lt;a href=&quot;http://www.php.net/get_parent_class&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;get_parent_class&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;             &lt;span class=&quot;co1&quot;&gt;// parent&lt;/span&gt;
                      &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt;                                  &lt;span class=&quot;co1&quot;&gt;// static&lt;/span&gt;
                    &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;                                         &lt;span class=&quot;co1&quot;&gt;// end fix static calls&lt;/span&gt;
                  &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;                                          &lt;span class=&quot;co1&quot;&gt;// end create function&lt;/span&gt;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// use previously created function&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_local_methods&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// call the method&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.php.net/call_user_func_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;call_user_func_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// try object method&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_getCallingChain&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;kw1&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// get the current chain location&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_getCur&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_object_methods&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;co1&quot;&gt;// check if the method has static calls&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/is_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;is_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;                        &lt;span class=&quot;co1&quot;&gt;// create function with static calls&lt;/span&gt;
                        &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'params'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;    &lt;span class=&quot;co1&quot;&gt;// parameters&lt;/span&gt;
                        &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_fixStaticMethodCalls&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;          &lt;span class=&quot;co1&quot;&gt;// fix static calls&lt;/span&gt;
                          &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'method'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;// method body&lt;/span&gt;
                          &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;        &lt;span class=&quot;co1&quot;&gt;// self&lt;/span&gt;
                          &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;        &lt;span class=&quot;co1&quot;&gt;// parent&lt;/span&gt;
                          &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt;                              &lt;span class=&quot;co1&quot;&gt;// static&lt;/span&gt;
                        &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;                                     &lt;span class=&quot;co1&quot;&gt;// end fix static calls&lt;/span&gt;
                      &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;                                      &lt;span class=&quot;co1&quot;&gt;// end create function&lt;/span&gt;
          &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;co1&quot;&gt;// use previously created method&lt;/span&gt;
            &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;;
          &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
          &lt;span class=&quot;co1&quot;&gt;// call the method&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.php.net/call_user_func_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;call_user_func_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array_pop&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array_pop&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;co1&quot;&gt;// apparently no object method, try static method&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_staticCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Static call method
   * 
   * @param   string $name
   * @param   array $arguments
   * @return  mixed
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __callStatic&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// fix name&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strtolower&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strtolower&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; get_called_class&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_staticCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * This is where the magic happens for setting prototype functions
   * 
   * Child classes should call this if it is overridden
   * 
   * @param   string $name
   * @param   mixed $value
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __set&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// check if this is an instance of the prototype class with the correct format&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt; instanceof &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___params &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___method &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// fix name&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strtolower&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strtolower&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;co1&quot;&gt;// check for this keyword in non-object context&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___static &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strpos&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strpos&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___method&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$___this'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;a href=&quot;http://www.php.net/trigger_error&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;trigger_error&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'Using $this when not in object context'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;E_USER_ERROR&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; get_called_class&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;co1&quot;&gt;// if we have static calls, we have to delay creation&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___static_calls &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'params'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___params&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'method'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___method &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___params&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___method &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// check if this was through the prototype object&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;__CLASS__&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// get the calling chain&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_getCallingChain&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___class &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;co1&quot;&gt;// check if the prototype object was called statically&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___static &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;re0&quot;&gt;$methods&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_static_methods&lt;/span&gt;;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;re0&quot;&gt;$methods&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_object_methods&lt;/span&gt;;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// get current location in calling chain&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_getCur&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$methods&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;co1&quot;&gt;// set the method&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_local_methods&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// this wasn't a prototype method&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Returns the prototype holder class
   * 
   * The prototype holder is used to add prototype methods to
   * child classes that are global to all objects. The functions
   * also allow inheritance. This function should only be called
   * statically (i.e. mySubClass::prototype()-&amp;gt;newMethod = new
   * prototype( '$arg', 'echo $arg;' ) ). To create object
   * methods, use the prototype variable (i.e. $my_object-&amp;gt;
   * prototype-&amp;gt;newMethod = new prototype( '$arg', 'echo $arg;' )
   * ). To create a local object method, don't use prototype
   * (i.e. $my_object-&amp;gt;newMethod = new prototype( '$arg',
   * 'echo $arg;' ) ).
   * 
   * @return  prototype
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// see if the static prototype variable has been instantiated&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; get_called_class&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// set the calling class and set to static&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___class &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; get_called_class&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;___static &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_prototype&lt;/span&gt;;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Walks though parent classes and returns an array of the
   * calling chain
   * 
   * @param   string $class
   * @return  array
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;_getCallingChain&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;co1&quot;&gt;// get classes until we hit the prototype class&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;__CLASS__&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/get_parent_class&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;get_parent_class&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// reverse the array to get the calling chain&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array_reverse&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array_reverse&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Gets the current location in the function holding array
   * 
   * @param   array &amp;amp;$chain
   * @param   array &amp;amp;$cur
   * @return  array
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;_getCur&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// loop until we have the current location&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * Fixes static method calls (self, parent, and static keywords)
   * 
   * @param   string $method
   * @param   string $self
   * @param   string $parent
   * @param   string $static
   * @return  string
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; _fixStaticMethodCalls&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$parent&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$static&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// splits the method body by parts in which the keywords should not be altered&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$regex&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;st_h&quot;&gt;'~'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// start regular expression&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'(/\*.*?\*/)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;       &lt;span class=&quot;co1&quot;&gt;// /* */ style comments&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                 &lt;span class=&quot;co1&quot;&gt;// or&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'(#.*?$)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;           &lt;span class=&quot;co1&quot;&gt;// # style comments&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                 &lt;span class=&quot;co1&quot;&gt;// or&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'(//.*?$)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;          &lt;span class=&quot;co1&quot;&gt;// // style comments&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'|'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                 &lt;span class=&quot;co1&quot;&gt;// or&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'(&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;.*?[^&lt;span class=&quot;es_h&quot;&gt;\\\\&lt;/span&gt;]&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;// single quote strings&lt;/span&gt;
              &lt;span class=&quot;st_h&quot;&gt;'~'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// end regular expression&lt;/span&gt;
              &lt;span class=&quot;st_h&quot;&gt;'i'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// match case insensitive&lt;/span&gt;
              &lt;span class=&quot;st_h&quot;&gt;'s'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// dot matches all characters including newlines&lt;/span&gt;
              &lt;span class=&quot;st_h&quot;&gt;'m'&lt;/span&gt;;                    &lt;span class=&quot;co1&quot;&gt;// match multiline&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$pieces&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/preg_split&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;preg_split&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$regex&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;re0&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu19&quot;&gt;0&lt;/span&gt;;
    &lt;span class=&quot;co1&quot;&gt;// build the search array&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$search&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'/'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;
                  &lt;span class=&quot;st_h&quot;&gt;'(?&amp;lt;=$|[^a-zA-Z0-9_\x7f-\xff])'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// match beginning of line or any non variable character&lt;/span&gt;
                  &lt;span class=&quot;st_h&quot;&gt;'self'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                          &lt;span class=&quot;co1&quot;&gt;// match the self keyword&lt;/span&gt;
                  &lt;span class=&quot;st_h&quot;&gt;'(?=\s*::|$)'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                   &lt;span class=&quot;co1&quot;&gt;// match paamayim nekudotayim or end of string&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'/'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;                               &lt;span class=&quot;co1&quot;&gt;// end regular expression&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'i'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                                &lt;span class=&quot;co1&quot;&gt;// match case insensitive&lt;/span&gt;
                &lt;span class=&quot;co1&quot;&gt;// same for parent keyword&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'/(?&amp;lt;=$|[^a-zA-Z0-9_\x7f-\xff])parent(?=\s*::|$)/i'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;co1&quot;&gt;// same for static keyword&lt;/span&gt;
                &lt;span class=&quot;st_h&quot;&gt;'/(?&amp;lt;=$|[^a-zA-Z0-9_\x7f-\xff])static(?=\s*::|$)/i'&lt;/span&gt;
              &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;co1&quot;&gt;// build the replace array&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$replace&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$parent&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$static&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;co1&quot;&gt;// loop thorugh each piece&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$pieces&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// replace the static calls&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$updated&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$search&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$replace&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu19&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$j&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;co1&quot;&gt;// get the length of the original&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$length&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strlen&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strlen&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu19&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;co1&quot;&gt;// replace the piece&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/substr_replace&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;substr_replace&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$updated&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$piece&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$length&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;co1&quot;&gt;// update how much has been added (or removed) from the method&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/strlen&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strlen&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$updated&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$length&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co4&quot;&gt;/**
   * This is where the magic happens for static prototype method calls
   * 
   * @param   string $name
   * @param   array $arguments
   * @param   string $class
   * @return  mixed
   */&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; _staticCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_getCallingChain&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;kw1&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// get the current chain location&lt;/span&gt;
      &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;self&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_getCur&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$_static_methods&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// check if the method has static calls&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/is_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;is_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;                        &lt;span class=&quot;co1&quot;&gt;// create function with static calls&lt;/span&gt;
                      &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'params'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;    &lt;span class=&quot;co1&quot;&gt;// parameters&lt;/span&gt;
                      &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;_fixStaticMethodCalls&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;          &lt;span class=&quot;co1&quot;&gt;// fix static calls&lt;/span&gt;
                        &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'method'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;// method body&lt;/span&gt;
                        &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;        &lt;span class=&quot;co1&quot;&gt;// self&lt;/span&gt;
                        &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;        &lt;span class=&quot;co1&quot;&gt;// parent&lt;/span&gt;
                        &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt;                              &lt;span class=&quot;co1&quot;&gt;// static&lt;/span&gt;
                      &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;                                     &lt;span class=&quot;co1&quot;&gt;// end fix static calls&lt;/span&gt;
                    &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;                                      &lt;span class=&quot;co1&quot;&gt;// end create function&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;co1&quot;&gt;// use previously created method&lt;/span&gt;
          &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$cur&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;st_h&quot;&gt;'_methods'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// call the method&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.php.net/call_user_func_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;call_user_func_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$method&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array_pop&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array_pop&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$chain&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;co1&quot;&gt;// the method doesn't exist&lt;/span&gt;
    &lt;a href=&quot;http://www.php.net/trigger_error&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;trigger_error&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'Call to undefined method '&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$class&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'::'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'()'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;E_USER_ERROR&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
I tried to document it as much as possible in the code, so I won&amp;#039;t explain it too much. I will point out that all of the regular expression calls have to do with runtime created functions not being able to use the &lt;code&gt;$this&lt;/code&gt; keyword directly as well as allowing the static keywords to be used.
&lt;/p&gt;

&lt;p&gt;
Now let&amp;#039;s do some sample code usage.

&lt;/p&gt;
&lt;pre class=&quot;code php&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'com/schmalls/personal/prototype.php'&lt;/span&gt;;
import com&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;schmalls&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;personal&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;prototype&lt;/span&gt;;
&amp;nbsp;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; A &lt;span class=&quot;kw2&quot;&gt;extends&lt;/span&gt; prototype
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$monkey&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'monkey'&lt;/span&gt;;
  &lt;span class=&quot;kw2&quot;&gt;const&lt;/span&gt; yes &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'yes'&lt;/span&gt;;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; C &lt;span class=&quot;kw2&quot;&gt;extends&lt;/span&gt; A &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;re0&quot;&gt;$a&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; A&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$b&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; A&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$c&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; C&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// create an object method that calls a static method&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$a&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;objectMethod&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$test'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
  /**
   * comment
   */
  echo $test, &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt; $this&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;, &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;&amp;lt;br /&amp;gt;&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;, &amp;quot;\n&amp;quot;; // test
  echo $this-&amp;gt;monkey, &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;&amp;lt;br /&amp;gt;&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;, &amp;quot;\n&amp;quot;;
  # monkey
  $this-&amp;gt;monkey = &amp;quot;cool&amp;quot;;
  self::staticMethod();
  '&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// create a static method that uses self&lt;/span&gt;
A&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;staticMethod&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;''&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
  echo self::yes, &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;&amp;lt;br /&amp;gt;&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;, &amp;quot;\n&amp;quot;;
  echo &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;&amp;lt;br /&amp;gt;&lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;, &amp;quot;\n&amp;quot;;
  '&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// create a local method&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$a&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;localMethod&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$test'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
  // call the object method
  $this-&amp;gt;objectMethod( $test );
  '&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// all three objects can call the object method,&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// but none of the static calls work&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$a&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;objectMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$a-&amp;gt;objectMethod'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$b&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;objectMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$b-&amp;gt;objectMethod'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$c&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;objectMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$c-&amp;gt;objectMethod'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;//A::objectMethod( 'A::objectMethod' );&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;//C::objectMethod( 'B::objectMethod' );&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// all three objects can call the static method,&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// and all static calls work&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$a&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;staticMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$b&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;staticMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$c&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;staticMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
A&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;staticMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
C&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;staticMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// only the $a object can call this one&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$a&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;localMethod&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$a-&amp;gt;localMethod'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;//$b-&amp;gt;localMethod( '$b-&amp;gt;localMethod' );&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;//$c-&amp;gt;localMethod( '$c-&amp;gt;localMethod' );&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;//A::localMethod( 'A::localMethod' );&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;//C::localMethod( 'C::localMethod' );&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/php?do=showtag&amp;amp;tag=tag%3Aphp&quot; class=&quot;wikilink1&quot; title=&quot;tag:php&quot; rel=&quot;tag&quot;&gt;PHP&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2007/10/return-to-prototype-based-programming-in-php#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2006/12/eclipse-php-ide">
        <dc:format>text/html</dc:format>
        <dc:date>2006-12-28T23:36:48-06:00</dc:date>
        <title>Eclipse PHP IDE</title>
        <link>http://schmalls.com/blog/2006/12/eclipse-php-ide</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

I have been using &lt;a href=&quot;http://www.phpeclipse.net&quot; class=&quot;urlextern&quot; title=&quot;http://www.phpeclipse.net&quot;  rel=&quot;nofollow&quot;&gt;PHPEclipse&lt;/a&gt; for quite some time. I have used the Eclipse Java debugger and was impressed with how much debugging time it saved. However, when I tried to get the debugger working in PHPEclipse, I ran into some problems. This might have something to do with using the latest version of Eclipse, but I never spent the time to figure it all out. I had some spare time today, and decided to try out the &lt;a href=&quot;http://www.eclipse.org/php/&quot; class=&quot;urlextern&quot; title=&quot;http://www.eclipse.org/php/&quot;  rel=&quot;nofollow&quot;&gt;Eclipse PHP IDE&lt;/a&gt;.
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;

So I went over to the &lt;a href=&quot;http://www.zend.com/phpide&quot; class=&quot;urlextern&quot; title=&quot;http://www.zend.com/phpide&quot;  rel=&quot;nofollow&quot;&gt;Zend site&lt;/a&gt; and downloaded the &lt;a href=&quot;http://downloads.zend.com/phpide/all-in-one/&quot; class=&quot;urlextern&quot; title=&quot;http://downloads.zend.com/phpide/all-in-one/&quot;  rel=&quot;nofollow&quot;&gt;all-in-one package&lt;/a&gt; (keeps my PHPEclipse install safe) and the &lt;a href=&quot;http://downloads.zend.com/phpide/server-debugger/&quot; class=&quot;urlextern&quot; title=&quot;http://downloads.zend.com/phpide/server-debugger/&quot;  rel=&quot;nofollow&quot;&gt;debugger extension&lt;/a&gt; (just followed the instructions in the readme). After a quick install of &lt;a href=&quot;http://www.polarion.org/index.php?page=overview&amp;amp;project=subversive&quot; class=&quot;urlextern&quot; title=&quot;http://www.polarion.org/index.php?page=overview&amp;amp;project=subversive&quot;  rel=&quot;nofollow&quot;&gt;Subversive&lt;/a&gt; and a checkout of &lt;a href=&quot;http://anjel.schmalls.com&quot; class=&quot;urlextern&quot; title=&quot;http://anjel.schmalls.com&quot;  rel=&quot;nofollow&quot;&gt;ANJEL&lt;/a&gt;, I was off to test the debugger.
&lt;/p&gt;

&lt;p&gt;
ANJEL is an extension for &lt;a href=&quot;http://www.joomla.org&quot; class=&quot;urlextern&quot; title=&quot;http://www.joomla.org&quot;  rel=&quot;nofollow&quot;&gt;Joomla&lt;/a&gt; so during development I run an Ant task to copy the files to the Joomla server directory for testing. There was an option to &lt;em&gt;Publish files to server&lt;/em&gt; in the debug options, but no way to selectively publish the files (at least not that I could see). Since I don&amp;#039;t want to copy all of the files over, I decided to go ahead and run the Ant task as I have been doing, but add the Joomla server directory as a &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; Project so I can add breakpoints and do some debugging. So far this works just fine.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;http://schmalls.com/_detail/blog/2006/12/eclipse.png?id=blog%3A2006%3A12%3Aeclipse-php-ide&quot; class=&quot;media&quot; title=&quot;blog:2006:12:eclipse.png&quot;&gt;&lt;img src=&quot;http://schmalls.com/_media/blog/2006/12/eclipse.png?w=128&amp;amp;h=79&quot; class=&quot;media&quot; alt=&quot;&quot; width=&quot;128&quot; height=&quot;79&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
I was able to get the breakpoints to work successfully, and I have to say I am very impressed with the &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; IDE. Some features that I have missed or not been able to get to work correctly in PHPEclipse are here. One of these is including projects in another project. I can add the Joomla project as a dependency of ANJEL and links (CTRL+click) in ANJEL source can take me to the Joomla code. It saves a lot of lookup time. You also get all the hover documentation along with it. Also, extended classes are shown directly in the file outline for quick access to inherited methods and properties.
&lt;/p&gt;

&lt;p&gt;
There are still a few minor things missing from the configuration. The syntax highlighting is not as fine grained as I would like. There are not options for function or method highlight colors, etc. Also, the &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; file templates need a few more variables to be useful. For example, a file or path variable could help in automatic class naming for new files and documentation. The file templates also don&amp;#039;t use the &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; editor like they do in PHPEclipse. This can be solved by writing the template in the editor and copying it, but it shouldn&amp;#039;t be too hard to implement it.
&lt;/p&gt;

&lt;p&gt;
One more big issue is the time required to build the “php model” on each start of Eclipse. It can take a lot of time depending on how big and how many projects are open. Hopefully as it matures, it will get better performance. Also, if you just leave Eclipse open, this won&amp;#039;t be a problem.
&lt;/p&gt;

&lt;p&gt;
As of right now, I would say the pros outweigh the cons, and I will probably be spending some development time with the &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; IDE in the future. And since we haven&amp;#039;t even gotten to the 0.7 release yet (should be in February), I would expect this to become the Eclipse user&amp;#039;s &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; IDE of choice, especially as the documentation for it becomes available.
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/php?do=showtag&amp;amp;tag=tag%3Aphp&quot; class=&quot;wikilink1&quot; title=&quot;tag:php&quot; rel=&quot;tag&quot;&gt;PHP&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2006/12/eclipse-php-ide#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2006/11/prototype-based-programming-in-php">
        <dc:format>text/html</dc:format>
        <dc:date>2006-11-06T21:33:22-06:00</dc:date>
        <title>Prototype-based programming in PHP</title>
        <link>http://schmalls.com/blog/2006/11/prototype-based-programming-in-php</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

For those who have been doing a lot of Javascript programming, you know what &lt;a href=&quot;http://en.wikipedia.org/wiki/Prototype-based_programming&quot; class=&quot;urlextern&quot; title=&quot;http://en.wikipedia.org/wiki/Prototype-based_programming&quot;  rel=&quot;nofollow&quot;&gt;prototype-based programming&lt;/a&gt; is all about. The basic idea is that functions can be added to classes dynamically. In Javascript functions can be added to a static class (using &lt;em&gt;prototype&lt;/em&gt;) and it will be added to all instances of the class, or they can be added to a specific instance and only be added to that instance.
&lt;/p&gt;

&lt;p&gt;
Anyway, lets get to the point. I decided to try adding this functionality to &lt;acronym title=&quot;Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt;. I&amp;#039;m not sure why its a good idea, or if it even is, but I&amp;#039;ll let you be the judge of that.
&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;

So here is the class I came up with:
&lt;/p&gt;
&lt;pre class=&quot;code php&quot;&gt;&lt;span class=&quot;co4&quot;&gt;/**
 * @copyright   (C) 2006, Schmalls / Joshua Thompson, All Rights Reserved
 * @license     http://www.opensource.org/licenses/bsd-license.php New BSD
 * @author      Joshua Thompson &amp;lt;spam.goes.in.here@gmail.com&amp;gt;
 * @version     1.0.0
 * @link        http://www.countercubed.com
 */&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co4&quot;&gt;/**
 * This class holds the prototype capabilities
 * 
 * Extending this class makes it prototype capable
 */&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; Prototype
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co4&quot;&gt;/**
     * Holds prototype functions
     * 
     * @var		array
     */&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$_functions&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span class=&quot;co4&quot;&gt;/**
     * Default constructor
     * 
     * This is here so that php doesn't complain about the prototype function
     */&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __construct&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co4&quot;&gt;/**
     * Sets the prototype functions or variables
     * 
     * @param   string $name
     * @param   mixed $value
     */&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __set&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/function_exists&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;function_exists&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_functions&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$value&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;endif&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co4&quot;&gt;/**
     * Gets static prototype variables if they exist
     * 
     * @param	string $name
     * @return	mixed
     */&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __get&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;a href=&quot;http://www.php.net/trigger_error&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;trigger_error&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'Undefined property: '&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;__CLASS__&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'::'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;E_USER_NOTICE&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;endif&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co4&quot;&gt;/**
     * Calls a static prototype function
     * 
     * @param   string $name
     * @param   array $arguments
     * @return  mixed
     */&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; __call&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_functions&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.php.net/call_user_func_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;call_user_func_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_functions&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;elseif&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;isCallable&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.php.net/call_user_func_array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;call_user_func_array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$arguments&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;a href=&quot;http://www.php.net/trigger_error&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;trigger_error&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'Call to undefined method '&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;__CLASS__&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'::'&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'()'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;E_USER_ERROR&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;endif&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co4&quot;&gt;/**
     * Returns the static prototype holder
     * 
     * @return	Prototype
     */&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;re0&quot;&gt;$prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;;
&amp;nbsp;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;re0&quot;&gt;$prototype&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; Prototype&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span class=&quot;kw1&quot;&gt;endif&lt;/span&gt;;
&amp;nbsp;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$prototype&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co4&quot;&gt;/**
     * Needed for the static calling functionality
     * 
     * @return	boolean
     */&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;function&lt;/span&gt; isCallable&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;_functions&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Now all a class needs to do is extend the &lt;em&gt;Prototype&lt;/em&gt; class. A sample of its use follows:
&lt;/p&gt;
&lt;pre class=&quot;code php&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// make some prototype classes&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; Test1 &lt;span class=&quot;kw2&quot;&gt;extends&lt;/span&gt; Prototype
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; Test2 &lt;span class=&quot;kw2&quot;&gt;extends&lt;/span&gt; Prototype
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; Test3 &lt;span class=&quot;kw2&quot;&gt;extends&lt;/span&gt; Test1
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// lets create some test static functions&lt;/span&gt;
Test1&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun1&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$arg1'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
	echo &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;Static Test1::fun1 &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt; . $arg1 . &amp;quot;\n&amp;quot;;
'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
Test2&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun2&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$arg1'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
	echo &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;Static Test2::fun2 &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt; . $arg1 . &amp;quot;\n&amp;quot;;
'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// now instantiate the objects&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test1&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; Test1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$test2&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; Test2&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// and make some more functions&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun3&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$arg2'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
	echo &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;Test1::fun3 &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt; . $arg2 . &amp;quot;\n&amp;quot;;
'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;re0&quot;&gt;$test2&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun4&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$arg2'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
	echo &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;Test2::fun4 &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt; . $arg2 . &amp;quot;\n&amp;quot;;
'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// output: Static Test1::fun1 bob&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'bob'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// create another function&lt;/span&gt;
Test1&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun2&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/create_function&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;create_function&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'$arg1'&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'
	echo &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt;Static Test1::fun2 &lt;span class=&quot;es_h&quot;&gt;\'&lt;/span&gt; . $arg1 . &amp;quot;\n&amp;quot;;
'&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// output: Static Test1::fun2 bobby&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'bobby'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// output: Static Test2::fun2 robert&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test2&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'robert'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// output: Test1::fun3 robby&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun3&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'robby'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// output: Test2::fun4 rob&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test2&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun4&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'rob'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// another instance still has the static functions&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test1_2&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; Test1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// output: Static Test1::fun1 bob&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test1_2&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'bob'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
&lt;span class=&quot;re0&quot;&gt;$test3&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; Test3&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;co1&quot;&gt;// this will give an error because prototype functions do not extend down to a child class&lt;/span&gt;
&lt;span class=&quot;re0&quot;&gt;$test3&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fun1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;st_h&quot;&gt;'roberto'&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;
&lt;p&gt;
Once again, I don&amp;#039;t know how useful it is, but let me know what you think.
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/php?do=showtag&amp;amp;tag=tag%3Aphp&quot; class=&quot;wikilink1&quot; title=&quot;tag:php&quot; rel=&quot;tag&quot;&gt;PHP&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2006/11/prototype-based-programming-in-php#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
    <item rdf:about="http://schmalls.com/blog/2006/02/double-your-dvd-collection">
        <dc:format>text/html</dc:format>
        <dc:date>2006-02-14T08:55:34-06:00</dc:date>
        <title>Double Your DVD Collection</title>
        <link>http://schmalls.com/blog/2006/02/double-your-dvd-collection</link>
        <description>


&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

I was having a conversation with my friend the other day when he suggested that the &lt;em&gt;best&lt;/em&gt; thing about getting married was merging the two DVD collections. This was funny by itself, until my other friend gave his counter-argument of the other obvious benefits of being married. I won&amp;#039;t give you the exact words, because it would make it less funny for me, and I believe it will be more humorous to you if you just imagine what he said.
&lt;/p&gt;

&lt;p&gt;
Anyway, the conversation didn&amp;#039;t end here. Then I said something about my DVD collection, and he said that it may be the reason I am single, because &lt;em&gt;everyone&lt;/em&gt; knows that women are just looking for a guy with all the right DVDs. I thought about arguing against this, but then I realized the DVD collection is a perfect scapegoat for singleness. Just blame it on the DVD collection, not your other inadequacies. So for all the single people out there, its not your fault, its your DVD collection&amp;#039;s.
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;http://schmalls.com/tag/random_thoughts?do=showtag&amp;amp;tag=tag%3Arandom_thoughts&quot; class=&quot;wikilink1&quot; title=&quot;tag:random_thoughts&quot; rel=&quot;tag&quot;&gt;Random Thoughts&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;span class=&quot;plugin_feedmod_comments&quot;&gt;
  &lt;a href=&quot;http://schmalls.com/blog/2006/02/double-your-dvd-collection#discussion__section&quot; title=&quot;Read or add comments to this article&quot;&gt;Read or add comments to this article&lt;/a&gt;
&lt;/span&gt;
</description>
    </item>
</rdf:RDF>
