<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Dynamically Add Functions to PHP Classes</title>
	<atom:link href="http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 10 May 2010 06:32:39 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Katsuke</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-1814</link>
		<dc:creator>Katsuke</dc:creator>
		<pubDate>Tue, 21 Jul 2009 15:42:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-1814</guid>
		<description>Excellent article, thanks a lot ^&amp;^</description>
		<content:encoded><![CDATA[<p>Excellent article, thanks a lot ^&amp;^</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-1270</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Fri, 15 May 2009 16:21:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-1270</guid>
		<description>I wouldn&#039;t say you&#039;re dampening the spirit... if the decorator pattern works better, it&#039;s certainly a more elegant solution to the problem than this one.

I think I&#039;ve actually looked at it before, and can&#039;t quite remember if it suited the needs of the problem I was working on that inspired me to write the article tho.  Here&#039;s an article I found on the subject if anyone&#039;s interested: &lt;a href=&quot;http://tinyurl.com/5etz97&quot; rel=&quot;nofollow&quot;&gt;http://tinyurl.com/5etz97&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>I wouldn&#8217;t say you&#8217;re dampening the spirit&#8230; if the decorator pattern works better, it&#8217;s certainly a more elegant solution to the problem than this one.</p>
<p>I think I&#8217;ve actually looked at it before, and can&#8217;t quite remember if it suited the needs of the problem I was working on that inspired me to write the article tho.  Here&#8217;s an article I found on the subject if anyone&#8217;s interested: <a href="http://tinyurl.com/5etz97" rel="nofollow">http://tinyurl.com/5etz97</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-1266</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Fri, 15 May 2009 14:46:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-1266</guid>
		<description>Nice technique I must say however not wanting to dampen everyone&#039;s spirit on the subject, I am left with the feeling the same pretty much could be accomplished, more easily I might add, using a Decorator.

In this case, there is no desire to alter the public API so Decorator would be my first choice.</description>
		<content:encoded><![CDATA[<p>Nice technique I must say however not wanting to dampen everyone&#8217;s spirit on the subject, I am left with the feeling the same pretty much could be accomplished, more easily I might add, using a Decorator.</p>
<p>In this case, there is no desire to alter the public API so Decorator would be my first choice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ap</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-734</link>
		<dc:creator>ap</dc:creator>
		<pubDate>Thu, 22 Jan 2009 18:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-734</guid>
		<description>Here&#039;s an &lt;a&gt;interesting thread&lt;/a&gt; that eventually leads to &lt;a href=&quot;http://code.google.com/p/phpplexus/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. Perhaps it is of interest to you.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s an <a>interesting thread</a> that eventually leads to <a href="http://code.google.com/p/phpplexus/" rel="nofollow">this</a>. Perhaps it is of interest to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-571</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Tue, 13 Jan 2009 16:39:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-571</guid>
		<description>Ooops, the array_unshift line in my example is cruft.</description>
		<content:encoded><![CDATA[<p>Ooops, the array_unshift line in my example is cruft.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-570</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Tue, 13 Jan 2009 16:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-570</guid>
		<description>Isn&#039;t call_user_func_array deprecated?

I took a crack at the idea... I ended up going with a parent class for the Extend-able stuff and the Extensions, using magic functions a lot, so it&#039;s probably slow, but I worked around the need to have the Extend-able class add it&#039;s own extensions. Anyway - read it and weep:

http://pastebin.com/f14aeced8</description>
		<content:encoded><![CDATA[<p>Isn&#8217;t call_user_func_array deprecated?</p>
<p>I took a crack at the idea&#8230; I ended up going with a parent class for the Extend-able stuff and the Extensions, using magic functions a lot, so it&#8217;s probably slow, but I worked around the need to have the Extend-able class add it&#8217;s own extensions. Anyway &#8211; read it and weep:</p>
<p><a href="http://pastebin.com/f14aeced8" rel="nofollow">http://pastebin.com/f14aeced8</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-562</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Tue, 13 Jan 2009 14:29:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-562</guid>
		<description>I was thinking it was similar to an Observer pattern, but Decorator might be closer. I should look them both up again and refresh myself...

If you look into some of the recent PHP5 specific frameworks like Kohana, they&#039;re all using magic functions now, even for getters and setters in their Object relational stuff.

Anyway, congratulations, my young friend. I bought you a cup of coffee.</description>
		<content:encoded><![CDATA[<p>I was thinking it was similar to an Observer pattern, but Decorator might be closer. I should look them both up again and refresh myself&#8230;</p>
<p>If you look into some of the recent PHP5 specific frameworks like Kohana, they&#8217;re all using magic functions now, even for getters and setters in their Object relational stuff.</p>
<p>Anyway, congratulations, my young friend. I bought you a cup of coffee.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Pietschmann</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-509</link>
		<dc:creator>Martin Pietschmann</dc:creator>
		<pubDate>Sat, 10 Jan 2009 17:23:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-509</guid>
		<description>@Ian
Yes, the magic functions might be very slow, but they are necessary to implement this kind of multiple inheritance :-)

Here is my new version: http://pastebin.com/f29f852ad
Demo: http://tinyurl.com/8ml54k
Demo code: http://pastebin.com/f27b70275

Now you have only one base class, so you can build a chain of imports.
But now you can have the diamond problem:
&#039;boat&#039; imports &#039;car&#039;
&#039;automobile&#039; imports &#039;car&#039;
&#039;amphibian vehicle&#039; imports &#039;automobile&#039; and &#039;boat&#039;

Therefor I expanded the import function as well as the __get and __set function to redirect all access to the lastly imported &#039;car&#039; object. This is like virtual inheritance in c++.

Unfortunately there are still problems with dublicated functionnames.</description>
		<content:encoded><![CDATA[<p>@Ian<br />
Yes, the magic functions might be very slow, but they are necessary to implement this kind of multiple inheritance <img src='http://www.gen-x-design.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Here is my new version: <a href="http://pastebin.com/f29f852ad" rel="nofollow">http://pastebin.com/f29f852ad</a><br />
Demo: <a href="http://tinyurl.com/8ml54k" rel="nofollow">http://tinyurl.com/8ml54k</a><br />
Demo code: <a href="http://pastebin.com/f27b70275" rel="nofollow">http://pastebin.com/f27b70275</a></p>
<p>Now you have only one base class, so you can build a chain of imports.<br />
But now you can have the diamond problem:<br />
&#8216;boat&#8217; imports &#8216;car&#8217;<br />
&#8216;automobile&#8217; imports &#8216;car&#8217;<br />
&#8216;amphibian vehicle&#8217; imports &#8216;automobile&#8217; and &#8216;boat&#8217;</p>
<p>Therefor I expanded the import function as well as the __get and __set function to redirect all access to the lastly imported &#8216;car&#8217; object. This is like virtual inheritance in c++.</p>
<p>Unfortunately there are still problems with dublicated functionnames.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-488</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Fri, 09 Jan 2009 17:21:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-488</guid>
		<description>@Martin,
I do like it, but it looks like a combination of my example and the example posted by @crem0r.  However, the spin you&#039;ve put on it is quite nice.  I personally wouldn&#039;t use it because I don&#039;t like using magic functions any more than I absolutely have to (as they&#039;re usually very slow and unoptomized).  However, all that being said, you still did a fantastic nice job!</description>
		<content:encoded><![CDATA[<p>@Martin,<br />
I do like it, but it looks like a combination of my example and the example posted by @crem0r.  However, the spin you&#8217;ve put on it is quite nice.  I personally wouldn&#8217;t use it because I don&#8217;t like using magic functions any more than I absolutely have to (as they&#8217;re usually very slow and unoptomized).  However, all that being said, you still did a fantastic nice job!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Pietschmann</title>
		<link>http://www.gen-x-design.com/archives/dynamically-add-functions-to-php-classes/#comment-480</link>
		<dc:creator>Martin Pietschmann</dc:creator>
		<pubDate>Fri, 09 Jan 2009 12:18:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.gen-x-design.com/?p=124#comment-480</guid>
		<description>Hello, I had just the same idea a few days ago :-)
So here is my version: http://pastebin.com/fd1812de

Now attributes of imported classes are also accessible in the base class and the imported classes have access to the public AND protected vars of the base class.
Within imported classes your have also access to functions and vars of other imported classes.
You can now simply use $this instead of $this-&gt;that inside imported classes to access functions and vars of the base class or other imported classes.

I hope you like it.</description>
		<content:encoded><![CDATA[<p>Hello, I had just the same idea a few days ago <img src='http://www.gen-x-design.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
So here is my version: <a href="http://pastebin.com/fd1812de" rel="nofollow">http://pastebin.com/fd1812de</a></p>
<p>Now attributes of imported classes are also accessible in the base class and the imported classes have access to the public AND protected vars of the base class.<br />
Within imported classes your have also access to functions and vars of other imported classes.<br />
You can now simply use $this instead of $this-&gt;that inside imported classes to access functions and vars of the base class or other imported classes.</p>
<p>I hope you like it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
