<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ben McGraw's Egometry &#187; oop</title>
	<atom:link href="http://www.egometry.com/tags/oop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.egometry.com</link>
	<description>cogito ergo stfu</description>
	<lastBuildDate>Wed, 28 Jul 2010 20:12:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP5, you king of bastards (setting an instance member inside a static class call)</title>
		<link>http://www.egometry.com/tech/php5-you-king-of-bastards-setting-an-instance-member-inside-a-static-class-call/</link>
		<comments>http://www.egometry.com/tech/php5-you-king-of-bastards-setting-an-instance-member-inside-a-static-class-call/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 13:48:58 +0000</pubDate>
		<dc:creator>mcgrue</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scope]]></category>

		<guid isPermaLink="false">http://www.egometry.com/?p=888</guid>
		<description><![CDATA[If I&#8217;m in an instanced class, and I call another class&#8217;s method statically inside of a method in the first class, and that static method should happen to (erroneously) have $this->whatever inside of it&#8230; &#8230;it sets $whatever on my outer instanced class. Here&#8217;s some illustrative code: &#60;? &#160;&#160;&#160;&#160;class&#160;Inner_Static&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;function&#160;burrito()&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$this-&#62;_member&#160;=&#160;‘A&#160;keyboard.&#160;How&#160;quaint.’; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;class&#160;Outer_Instance&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;function&#160;taco()&#160;{ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Inner_Static::burrito(); [...]]]></description>
			<content:encoded><![CDATA[<p>If I&#8217;m in an instanced class, and I call another class&#8217;s method statically inside of a method in the first class, and that static method should happen to <i>(erroneously)</i> have $this->whatever inside of it&#8230;</p>
<p>&#8230;it sets $whatever on my outer instanced class.</p>
<p>Here&#8217;s some illustrative code:</p>
<pre style="padding: 8px; background-color: rgb(221, 221, 221);" >
&lt;?
&nbsp;&nbsp;&nbsp;&nbsp;class&nbsp;Inner_Static&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;burrito()&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;_member&nbsp;=&nbsp;‘A&nbsp;keyboard.&nbsp;How&nbsp;quaint.’;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;class&nbsp;Outer_Instance&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;taco()&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inner_Static::burrito();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;$my_guy&nbsp;=&nbsp;new&nbsp;Outer_Instance();
&nbsp;&nbsp;&nbsp;&nbsp;$my_guy-&gt;taco();

&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;‘$my_guy-&gt;_member:&nbsp;‘&nbsp;.&nbsp;$my_guy-&gt;_member;&nbsp;
</pre>
<p>This boggles my mind a bit.  Tracking it down cost me a bit of time.  Is there actually a sane use for this little tidbit, or am I justified in thinking that a good language would warn you that scope shenanigans are going on here?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.egometry.com/tech/php5-you-king-of-bastards-setting-an-instance-member-inside-a-static-class-call/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
