<?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 for Septuro</title>
	<atom:link href="http://www.septuro.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.septuro.com</link>
	<description>Open Source PHP / XSL Framework</description>
	<lastBuildDate>Tue, 23 Feb 2010 03:53:40 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by visual77</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-50</link>
		<dc:creator>visual77</dc:creator>
		<pubDate>Tue, 23 Feb 2010 03:53:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-50</guid>
		<description>&lt;blockquote cite=&quot;#commentbody-47&quot;&gt;
&lt;strong&gt;&lt;a href=&quot;#comment-47&quot; rel=&quot;nofollow&quot;&gt;Andrew Farley&lt;/a&gt; :&lt;/strong&gt;
&lt;p&gt;There is a bit of a problem with this code that makes it not exactly equal to PHP 5.3’s get_called_class().  The get_called_class() works when calling the static function with the prefix classname, but it doesn’t work when called from within another static method of that class with self::  For example…&lt;/p&gt;
&lt;p&gt;class Account extends Generic {&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;class Generic {&lt;br&gt;
    public static function getDBName_static() {&lt;br&gt;
        return strtolower(get_called_class());&lt;br&gt;
    }&lt;/p&gt;
&lt;p&gt;    public static function this_fails() {&lt;br&gt;
        return self::getDBName_static();&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;
&lt;p&gt;When I call Account::getDBName_static(); it properly returns “account”.  But, when I call self:: this_fails(); it returns “self”, when it should be returning “account”.  This is a odd use-case, but since I’m extending my base class with other classes I cannot define the class name as in my first example, I must use self:: in my static methods so they extend properly.  I don’t have time to fix it right now, but I will have to fix it eventually, just wanted to see if anyone has noticed this, and/or anyone has fixed this problem already.&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;
&lt;/blockquote&gt;

This could be fixed with a simple while loop after the backtrace, where it continues to seek back while the class name is self.</description>
		<content:encoded><![CDATA[<blockquote cite="#commentbody-47"><p>
<strong><a href="#comment-47" rel="nofollow">Andrew Farley</a> :</strong></p>
<p>There is a bit of a problem with this code that makes it not exactly equal to PHP 5.3’s get_called_class().  The get_called_class() works when calling the static function with the prefix classname, but it doesn’t work when called from within another static method of that class with self::  For example…</p>
<p>class Account extends Generic {</p>
<p>}</p>
<p>class Generic {<br />
    public static function getDBName_static() {<br />
        return strtolower(get_called_class());<br />
    }</p>
<p>    public static function this_fails() {<br />
        return self::getDBName_static();<br />
    }<br />
}</p>
<p>When I call Account::getDBName_static(); it properly returns “account”.  But, when I call self:: this_fails(); it returns “self”, when it should be returning “account”.  This is a odd use-case, but since I’m extending my base class with other classes I cannot define the class name as in my first example, I must use self:: in my static methods so they extend properly.  I don’t have time to fix it right now, but I will have to fix it eventually, just wanted to see if anyone has noticed this, and/or anyone has fixed this problem already.</p>
<p>Cheers!</p>
</blockquote>
<p>This could be fixed with a simple while loop after the backtrace, where it continues to seek back while the class name is self.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by visual77</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-49</link>
		<dc:creator>visual77</dc:creator>
		<pubDate>Tue, 23 Feb 2010 03:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-49</guid>
		<description>&lt;a href=&quot;#comment-48&quot; rel=&quot;nofollow&quot;&gt;@Andrew Farley &lt;/a&gt; 

It has been awhile since I wrote this function, but I believe the purpose of the static variables was in a case where get_called_class() was called in such a way that it backtraces to the same line. Without the static variables, it would return the first class both times, but with the static variables, it would recognize that this is the second scan of the same line.

Line 13 / 14 should reset the variables if it is not the same as last time, but it sounds like it is not working properly.</description>
		<content:encoded><![CDATA[<p><a href="#comment-48" rel="nofollow">@Andrew Farley </a> </p>
<p>It has been awhile since I wrote this function, but I believe the purpose of the static variables was in a case where get_called_class() was called in such a way that it backtraces to the same line. Without the static variables, it would return the first class both times, but with the static variables, it would recognize that this is the second scan of the same line.</p>
<p>Line 13 / 14 should reset the variables if it is not the same as last time, but it sounds like it is not working properly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by Andrew Farley</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-48</link>
		<dc:creator>Andrew Farley</dc:creator>
		<pubDate>Tue, 23 Feb 2010 01:26:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-48</guid>
		<description>Also found that calling this function twice fails.  You need to reset the values of $i and $fl between each call.  Sounds like a fundamental design problem, I haven&#039;t the time to dive in right now, but I&#039;m not sure why $i and $fl need to be static as you&#039;re not calling this function recursively.  So why aren&#039;t they just defined and unset at the start and end of this function?  :\  I did that quickly and it seemed to work ok.  I am very happy someone took the time to do this though, thanks a LOT, just found some problems with it.  :)</description>
		<content:encoded><![CDATA[<p>Also found that calling this function twice fails.  You need to reset the values of $i and $fl between each call.  Sounds like a fundamental design problem, I haven&#8217;t the time to dive in right now, but I&#8217;m not sure why $i and $fl need to be static as you&#8217;re not calling this function recursively.  So why aren&#8217;t they just defined and unset at the start and end of this function?  :\  I did that quickly and it seemed to work ok.  I am very happy someone took the time to do this though, thanks a LOT, just found some problems with it.  <img src='http://www.septuro.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by Andrew Farley</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-47</link>
		<dc:creator>Andrew Farley</dc:creator>
		<pubDate>Tue, 23 Feb 2010 01:05:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-47</guid>
		<description>There is a bit of a problem with this code that makes it not exactly equal to PHP 5.3&#039;s get_called_class().  The get_called_class() works when calling the static function with the prefix classname, but it doesn&#039;t work when called from within another static method of that class with self::  For example...

class Account extends Generic {

}

class Generic {
    public static function getDBName_static() {
        return strtolower(get_called_class());
    }

    public static function this_fails() {
        return self::getDBName_static();
    }
}

When I call Account::getDBName_static(); it properly returns &quot;account&quot;.  But, when I call self:: this_fails(); it returns &quot;self&quot;, when it should be returning &quot;account&quot;.  This is a odd use-case, but since I&#039;m extending my base class with other classes I cannot define the class name as in my first example, I must use self:: in my static methods so they extend properly.  I don&#039;t have time to fix it right now, but I will have to fix it eventually, just wanted to see if anyone has noticed this, and/or anyone has fixed this problem already.

Cheers!</description>
		<content:encoded><![CDATA[<p>There is a bit of a problem with this code that makes it not exactly equal to PHP 5.3&#8217;s get_called_class().  The get_called_class() works when calling the static function with the prefix classname, but it doesn&#8217;t work when called from within another static method of that class with self::  For example&#8230;</p>
<p>class Account extends Generic {</p>
<p>}</p>
<p>class Generic {<br />
    public static function getDBName_static() {<br />
        return strtolower(get_called_class());<br />
    }</p>
<p>    public static function this_fails() {<br />
        return self::getDBName_static();<br />
    }<br />
}</p>
<p>When I call Account::getDBName_static(); it properly returns &#8220;account&#8221;.  But, when I call self:: this_fails(); it returns &#8220;self&#8221;, when it should be returning &#8220;account&#8221;.  This is a odd use-case, but since I&#8217;m extending my base class with other classes I cannot define the class name as in my first example, I must use self:: in my static methods so they extend properly.  I don&#8217;t have time to fix it right now, but I will have to fix it eventually, just wanted to see if anyone has noticed this, and/or anyone has fixed this problem already.</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by keepitmassive</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-46</link>
		<dc:creator>keepitmassive</dc:creator>
		<pubDate>Fri, 19 Feb 2010 09:23:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-46</guid>
		<description>Made my day! Thank you!</description>
		<content:encoded><![CDATA[<p>Made my day! Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by Waldson Patricio</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-42</link>
		<dc:creator>Waldson Patricio</dc:creator>
		<pubDate>Tue, 01 Dec 2009 14:19:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-42</guid>
		<description>Thank you very much. I was trying to figure out how to do this and then i find you. I make my own improved version of this function based on your post, comments on php.net get_called_class function and Jrgns comments. Awesome. Thx again.

My function works with instance calls, self calls, call_user_func(_array)? calls (thx Jrgns) and return false when called outside a class</description>
		<content:encoded><![CDATA[<p>Thank you very much. I was trying to figure out how to do this and then i find you. I make my own improved version of this function based on your post, comments on php.net get_called_class function and Jrgns comments. Awesome. Thx again.</p>
<p>My function works with instance calls, self calls, call_user_func(_array)? calls (thx Jrgns) and return false when called outside a class</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by Jrgns</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-41</link>
		<dc:creator>Jrgns</dc:creator>
		<pubDate>Wed, 25 Nov 2009 06:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-41</guid>
		<description>You can add the following code after line 23 to determine the called class if the function was called in call_user_func or call_user_func_array:

    if (array_key_exists(3, $bt)
        &amp;&amp; array_key_exists(&#039;function&#039;, $bt[3])
        &amp;&amp; in_array($bt[3][&#039;function&#039;],
            array(&#039;call_user_func&#039;, &#039;call_user_func_array&#039;))
    ) {
        if (is_array($bt[3][&#039;args&#039;][0])) {
            $toret = $bt[3][&#039;args&#039;][0][0];
        }
    }</description>
		<content:encoded><![CDATA[<p>You can add the following code after line 23 to determine the called class if the function was called in call_user_func or call_user_func_array:</p>
<p>    if (array_key_exists(3, $bt)<br />
        &amp;&amp; array_key_exists(&#8217;function&#8217;, $bt[3])<br />
        &amp;&amp; in_array($bt[3]['function'],<br />
            array(&#8217;call_user_func&#8217;, &#8216;call_user_func_array&#8217;))<br />
    ) {<br />
        if (is_array($bt[3]['args'][0])) {<br />
            $toret = $bt[3]['args'][0][0];<br />
        }<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2, late static binding, get_called_class() and $self = new self() by Jrgns</title>
		<link>http://www.septuro.com/2009/07/php-5-2-late-static-binding-get_called_class-and-self-new-self/comment-page-1/#comment-39</link>
		<dc:creator>Jrgns</dc:creator>
		<pubDate>Fri, 09 Oct 2009 06:05:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.septuro.com/?p=99#comment-39</guid>
		<description>Awesome! Great help, thanx!</description>
		<content:encoded><![CDATA[<p>Awesome! Great help, thanx!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
