<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PHP-BR</title>
	<atom:link href="http://phpbr.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpbr.wordpress.com</link>
	<description>Informação sobre PHP de forma simples e interessante</description>
	<lastBuildDate>Thu, 17 Apr 2008 00:02:47 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='phpbr.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/6e6f3596855356282b32032502d82a3d?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>PHP-BR</title>
		<link>http://phpbr.wordpress.com</link>
	</image>
			<item>
		<title>Link: Vamos todos impedir a regulamentação da profissão de analista de sistema</title>
		<link>http://phpbr.wordpress.com/2008/04/17/link-vamos-todos-impedir-a-regulamentacao-da-profissao-de-analista-de-sistema/</link>
		<comments>http://phpbr.wordpress.com/2008/04/17/link-vamos-todos-impedir-a-regulamentacao-da-profissao-de-analista-de-sistema/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 00:02:47 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/?p=122</guid>
		<description><![CDATA[Poderia escrever longo texto explicando porque não é uma boa coisa a regulamentação, mas já fizeram isso muito bem em diversos blogs, foruns, listas de discussão, etc etc etc&#8230; 
Que tal essa sugestão para demonstrar seu descontentamento com isso ?
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=122&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Poderia escrever longo texto explicando porque não é uma boa coisa a regulamentação, mas já fizeram isso muito bem em diversos blogs, foruns, listas de discussão, etc etc etc&#8230; </p>
<p>Que tal <a href="http://www.kumpera.net/blog/index.php/2008/04/16/vamos-todos-impedir-a-regulamentacao-da-profissao-de-analista-de-sistema/">essa sugestão</a> para demonstrar seu descontentamento com isso ?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/122/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/122/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=122&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2008/04/17/link-vamos-todos-impedir-a-regulamentacao-da-profissao-de-analista-de-sistema/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>off: Locaweb sux</title>
		<link>http://phpbr.wordpress.com/2008/03/30/off-locaweb-sux/</link>
		<comments>http://phpbr.wordpress.com/2008/03/30/off-locaweb-sux/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 17:18:34 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Notas]]></category>
		<category><![CDATA[Não Categorizado]]></category>
		<category><![CDATA[Opiniões]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/?p=119</guid>
		<description><![CDATA[Não tenho postado muita coisa aqui (apesar de ter o que postar) principalmente por falta de tempo.
De forma resumida, ultimas duas semanas, problemas na locaweb em 14 dias&#8230;
Problemas pra resolver nomes, lentidao, servidor web fora, e nesse momento servidor mysql fora. Só espero que não tenham sumido com meu banco, últimos 4 backups remotos não [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=119&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Não tenho postado muita coisa aqui (apesar de ter o que postar) principalmente por falta de tempo.</p>
<p>De forma resumida, ultimas duas semanas, problemas na locaweb em 14 dias&#8230;</p>
<p>Problemas pra resolver nomes, lentidao, servidor web fora, e nesse momento servidor mysql fora. Só espero que não tenham sumido com meu banco, últimos 4 backups remotos não foram bem sucedidos&#8230; </p>
<p><a href='http://phpbr.files.wordpress.com/2008/03/locaweb1.png' title='locaweb'><img src='http://phpbr.files.wordpress.com/2008/03/locaweb1.png' alt='locaweb' /></a></p>
<p>E um viva para locaweb&#8230;</p>
<p>Update:<br />
Segundo o <a href="http://internetsupervision.com/scripts/urlcheck/check.aspx?checkurl=http://www.google.com">internetsupervision</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/119/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/119/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=119&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2008/03/30/off-locaweb-sux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>

		<media:content url="http://phpbr.files.wordpress.com/2008/03/locaweb1.png" medium="image">
			<media:title type="html">locaweb</media:title>
		</media:content>
	</item>
		<item>
		<title>uhmmmm: php2java</title>
		<link>http://phpbr.wordpress.com/2008/03/04/uhmmmm-php2java/</link>
		<comments>http://phpbr.wordpress.com/2008/03/04/uhmmmm-php2java/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 23:29:10 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[pog]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/?p=118</guid>
		<description><![CDATA[Segue o link
http://www.numiton.com
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=118&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Segue o link<br />
http://www.numiton.com</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/118/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/118/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=118&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2008/03/04/uhmmmm-php2java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>Linq for php</title>
		<link>http://phpbr.wordpress.com/2008/01/25/linq-for-php/</link>
		<comments>http://phpbr.wordpress.com/2008/01/25/linq-for-php/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 12:25:22 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[pog]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/?p=117</guid>
		<description><![CDATA[Segue o link:
http://blog.maartenballiauw.be/post/2008/01/LINQ-for-PHP-Language-Integrated-Query-for-PHP.aspx
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=117&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Segue o link:</p>
<p><a href="http://blog.maartenballiauw.be/post/2008/01/LINQ-for-PHP-Language-Integrated-Query-for-PHP.aspx">http://blog.maartenballiauw.be/post/2008/01/LINQ-for-PHP-Language-Integrated-Query-for-PHP.aspx</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/117/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/117/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=117&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2008/01/25/linq-for-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>Dica rápida: printf(&#8220;{0} {1} {0} &#8220;, &#8216;foo&#8217;, &#8216;bar&#8217;);</title>
		<link>http://phpbr.wordpress.com/2007/12/14/dica-rapida-printf0-1-0-foo-bar/</link>
		<comments>http://phpbr.wordpress.com/2007/12/14/dica-rapida-printf0-1-0-foo-bar/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 20:52:03 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[pog]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/12/14/dica-rapida-printf0-1-0-foo-bar/</guid>
		<description><![CDATA[Ok, não é bem isso, mas é quase. Segue a conversa:
&#60;anmsx&#62; printf(&#34;ola {0}, hoje &#233; {1}. Ja disse seu nome, {0} ? &#34;, &#8216;anmsx&#8217;, &#8216;domingo&#8217;);
&#60;anmsx&#62; queria algo assim no php
&#60;anmsx&#62; tipo q tem no c#
&#60;ecl&#62; ahhaha
&#60;anmsx&#62; sacou a ideia ?
&#60;ecl&#62; sim
&#60;anmsx&#62; da pra fazer em codigo mesmo
&#60;ecl&#62; mas da pra fazer isso atualmente com o [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=116&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ok, não é bem isso, mas é quase. Segue a conversa:</p>
<p>&lt;anmsx&gt; printf(&quot;ola {0}, hoje &eacute; {1}. Ja disse seu nome, {0} ? &quot;, &#8216;anmsx&#8217;, &#8216;domingo&#8217;);<br />
&lt;anmsx&gt; queria algo assim no php<br />
&lt;anmsx&gt; tipo q tem no c#<br />
&lt;ecl&gt; ahhaha<br />
&lt;anmsx&gt; sacou a ideia ?<br />
&lt;ecl&gt; sim<br />
&lt;anmsx&gt; da pra fazer em codigo mesmo<br />
&lt;ecl&gt; mas da pra fazer isso atualmente com o recurso atual tambem, ta ligado?<br />
&lt;anmsx&gt; si<br />
&lt;ecl&gt; hahah, falei cheio de redundancia<br />
&lt;anmsx&gt; func_get_args ou coisa assim, nao ?<br />
&lt;ecl&gt; anmsx: falo no printf mesmo<br />
&lt;anmsx&gt; ah &eacute; ?<br />
&lt;anmsx&gt; como ?<br />
&lt;anmsx&gt; isso eu nao sei<br />
&lt;ecl&gt; %[numero do arg]$[tipo]<br />
&lt;anmsx&gt; 5.3 ?<br />
&lt;ecl&gt; nao<br />
&lt;ecl&gt; antigo.<br />
&lt;anmsx&gt; xover<br />
&lt;ecl&gt; de qualquer forma, usando o {N} para string, seria legal<br />
&lt;anmsx&gt; certeza q &eacute; dessa forma q colocou ?<br />
&lt;anmsx&gt; onde tem isso na doc ?<br />
&lt;anmsx&gt; nao funcionou<br />
&lt;anmsx&gt; $ php -r &#8216;echo printf(&quot;Ola %1\$s hoje &eacute; %2\$s, certo %1\$s ?&quot;, &quot;anmsx&quot;, &quot;domingo&quot;);&#8217;<br />
&lt;anmsx&gt; Ola anmsx hoje &eacute; domingo, certo anmsx ?<br />
&lt;anmsx&gt; cool</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/116/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/116/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=116&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/12/14/dica-rapida-printf0-1-0-foo-bar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>Link: Dezenas de slides</title>
		<link>http://phpbr.wordpress.com/2007/11/22/link-dezenas-de-slides/</link>
		<comments>http://phpbr.wordpress.com/2007/11/22/link-dezenas-de-slides/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 14:27:28 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/11/22/link-dezenas-de-slides/</guid>
		<description><![CDATA[Vale umas horas as apresentações do Marcus Börger:


This page is the home of slides i used for my various talks at conferences around the world. They are available in one or more formats as shown below.


Fonte: ecl @ #php.br / irc.freenode.net 
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=115&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Vale umas horas as apresentações do <a href="http://www.marcus-boerger.de/">Marcus Börger</a>:</p>
<blockquote><p>
<a href="http://talks.somabo.de/"><br />
This page is the home of slides i used for my various talks at conferences around the world. They are available in one or more formats as shown below.<br />
</a>
</p></blockquote>
<p>Fonte: <a href="http://eclesiastes.wordpress.com/">ecl @ #php.br / irc.freenode.net </a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/115/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/115/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=115&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/11/22/link-dezenas-de-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>Rapidinha: Obter cotação da bolsa de valores em tempo real &#8230;</title>
		<link>http://phpbr.wordpress.com/2007/11/19/rapidinha-obter-cotacao-da-bolsa-de-valores-em-tempo-real/</link>
		<comments>http://phpbr.wordpress.com/2007/11/19/rapidinha-obter-cotacao-da-bolsa-de-valores-em-tempo-real/#comments</comments>
		<pubDate>Mon, 19 Nov 2007 20:54:40 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Codes]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[pog]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/11/19/rapidinha-obter-cotacao-da-bolsa-de-valores-em-tempo-real/</guid>
		<description><![CDATA[&#8230; claro, com um pequeno atraso de 15 minutos. E ajuda do sempre útil simplexml, do PHP5. Segue:

&#60;?php
// author: Eziel Silva
@list($self, $papel, $time, $tot) = $argv;
if (!$papel) {
    echo sprintf('uso:    %s &#60;PAPEL&#62; [temp][valor]%s', $self, "\n");
    echo sprintf('PAPEL:  VALE5%s', "\n");
    echo sprintf('temp:  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=113&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#8230; claro, com um pequeno atraso de 15 minutos. E ajuda do sempre útil simplexml, do PHP5. Segue:</p>
<pre>
<span style="font-weight:bold;color:#000000;">&lt;?php</span>
<span style="font-style:italic;color:#808080;">// author: Eziel Silva</span>
<span style="color:#000000;">@list(</span><span style="color:#5555ff;">$self</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$papel</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$time</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$tot</span><span style="color:#000000;">) = </span><span style="color:#5555ff;">$argv</span><span style="color:#000000;">;</span>
<span style="color:#a1a100;">if</span><span style="color:#000000;"> (!</span><span style="color:#5555ff;">$papel</span><span style="color:#000000;">) {</span>
<span style="color:#000000;">    </span><span style="color:#000080;">echo</span><span style="color:#000000;"> </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'uso:    %s &lt;PAPEL&gt; [temp][valor]%s'</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$self</span><span style="color:#000000;">, </span><span style="color:#dd0000;">"</span><span style="font-weight:bold;color:#0f0f8f;">\n</span><span style="color:#dd0000;">"</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    </span><span style="color:#000080;">echo</span><span style="color:#000000;"> </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'PAPEL:  VALE5%s'</span><span style="color:#000000;">, </span><span style="color:#dd0000;">"</span><span style="font-weight:bold;color:#0f0f8f;">\n</span><span style="color:#dd0000;">"</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    </span><span style="color:#000080;">echo</span><span style="color:#000000;"> </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'temp:   tempo de atualizacao - default = 20%s'</span><span style="color:#000000;">, </span><span style="color:#dd0000;">"</span><span style="font-weight:bold;color:#0f0f8f;">\n</span><span style="color:#dd0000;">"</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    </span><span style="color:#000080;">echo</span><span style="color:#000000;"> </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'valor:  quanto em papeis da empresa voce possui%s'</span><span style="color:#000000;">, </span><span style="color:#dd0000;">"</span><span style="font-weight:bold;color:#0f0f8f;">\n</span><span style="color:#dd0000;">"</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    </span><span style="color:#a1a100;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">1</span><span style="color:#000000;">;</span>
<span style="color:#000000;">}</span>

<span style="color:#5555ff;">$url</span><span style="color:#000000;">  = </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'http://www.bovespa.com.br/Cotacoes2000/formCotacoesMobile.asp?codsocemi=%s'</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$papel</span><span style="color:#000000;">);</span>
<span style="color:#5555ff;">$sXml</span><span style="color:#000000;"> = @simplexml_load_string(@file_get_contents(</span><span style="color:#5555ff;">$url</span><span style="color:#000000;">));</span>

<span style="color:#a1a100;">if</span><span style="color:#000000;"> (!</span><span style="color:#5555ff;">$sXml</span><span style="color:#000000;">) {</span>
<span style="color:#000000;">    </span><span style="color:#000080;">echo</span><span style="color:#000000;"> </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'Simbolo "%s" nao encontrado'</span><span style="color:#000000;">, $papel);</span>
<span style="color:#000000;">    </span><span style="color:#a1a100;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">1</span><span style="color:#000000;">;</span>
<span style="color:#000000;">}</span>

<span style="color:#5555ff;">$format</span><span style="color:#000000;"> = </span><span style="color:#dd0000;">"Hor: %s Osc.: %s%% Rend.: %s</span><span style="font-weight:bold;color:#0f0f8f;">\n</span><span style="color:#dd0000;">"</span><span style="color:#000000;">;</span>
<span style="color:#a1a100;">if</span><span style="color:#000000;"> (!</span><span style="color:#5555ff;">$tot</span><span style="color:#000000;">) {</span>
<span style="color:#000000;">    </span><span style="color:#5555ff;">$format</span><span style="color:#000000;"> = </span><span style="color:#dd0000;">"Hor: %s Osc.: %s%%</span><span style="font-weight:bold;color:#0f0f8f;">\n</span><span style="color:#dd0000;">"</span><span style="color:#000000;">;</span>
<span style="color:#000000;">}</span>
<span style="color:#a1a100;">if</span><span style="color:#000000;"> (!</span><span style="color:#5555ff;">$time</span><span style="color:#000000;">) {</span>
<span style="color:#000000;">    </span><span style="color:#5555ff;">$time</span><span style="color:#000000;"> = </span><span style="color:#0000ff;">20</span><span style="color:#000000;">;</span>
<span style="color:#000000;">}</span>

<span style="color:#a1a100;">while</span><span style="color:#000000;">(</span><span style="font-weight:bold;color:#000000;">true</span><span style="color:#000000;">) {</span>
<span style="color:#000000;">    </span><span style="color:#5555ff;">$sXml</span><span style="color:#000000;"> = @simplexml_load_string(@file_get_contents(</span><span style="color:#5555ff;">$url</span><span style="color:#000000;">));</span>
<span style="color:#000000;">    </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (!</span><span style="color:#5555ff;">$sXml</span><span style="color:#000000;">) {</span>
<span style="color:#000000;">        </span><span style="color:#000080;">echo</span><span style="color:#000000;"> </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'Erro atualizando... aguardando 5s%s'</span><span style="color:#000000;">,</span><span style="color:#dd0000;">"</span><span style="font-weight:bold;color:#0f0f8f;">\n</span><span style="color:#dd0000;">"</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="color:#000080;">sleep</span><span style="color:#000000;">(</span><span style="color:#0000ff;">5</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">continue</span><span style="color:#000000;">;</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span><span style="color:#5555ff;">$c</span><span style="color:#000000;"> = </span><span style="color:#5555ff;">$tot</span><span style="color:#000000;"> * </span><span style="color:#000080;">str_replace</span><span style="color:#000000;">(</span><span style="color:#dd0000;">','</span><span style="color:#000000;">,</span><span style="color:#dd0000;">'.'</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$sXml</span><span style="color:#000000;">-&gt;PAPEL[</span><span style="color:#dd0000;">'OSCILACAO'</span><span style="color:#000000;">]) / </span><span style="color:#0000ff;">100</span><span style="color:#000000;">;</span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#808080;">// hack pra me deixar feliz... caso esteja perdendo $$$, </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#808080;">// descomente a linha abaixo</span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#808080;">//$c = $c * -1; </span>
<span style="color:#000000;">    </span><span style="color:#000080;">echo</span><span style="color:#000000;"> </span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$format</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$sXml</span><span style="color:#000000;">-&gt;PAPEL[</span><span style="color:#dd0000;">'HORA'</span><span style="color:#000000;">], </span><span style="color:#5555ff;">$sXml</span><span style="color:#000000;">-&gt;PAPEL[</span><span style="color:#dd0000;">'OSCILACAO'</span><span style="color:#000000;">], </span><span style="color:#5555ff;">$c</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    </span><span style="color:#000080;">sleep</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$time</span><span style="color:#000000;">);</span>
<span style="color:#000000;">}</span>
</pre>
<blockquote><p>
$ php bov.php<br />
uso:    bov.php  [temp][valor]<br />
PAPEL:  VALE5<br />
temp:   tempo de atualizacao &#8211; default = 20<br />
valor:  quanto em papeis da empresa voce possui</p>
<p>$ php bov.php VALE5<br />
Hor: 18:08:06 Osc.: -3,55%</p>
<p>$ php bov.php VALE5 5 1000<br />
Hor: 18:08:06 Osc.: -3,55% Rend.: -35.5
</p></blockquote>
<p>Arquivo:<br />
<a href='http://phpbr.files.wordpress.com/2007/11/bov.txt' title='bov.php'>bov.php</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/113/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/113/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=113&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/11/19/rapidinha-obter-cotacao-da-bolsa-de-valores-em-tempo-real/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP / CruiseControl</title>
		<link>http://phpbr.wordpress.com/2007/11/19/php-cruisecontrol/</link>
		<comments>http://phpbr.wordpress.com/2007/11/19/php-cruisecontrol/#comments</comments>
		<pubDate>Mon, 19 Nov 2007 14:02:52 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Notas]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/11/19/php-cruisecontrol/</guid>
		<description><![CDATA[Não conhecia, vi hoje por meio do phpdeveloper:
phpUnderControl
phpUnderControl aims to make the first steps with CruiseControl and PHP as easy as possible. It integrates three of the best PHP development tools into CruiseControl, combined with an easy setup routine and a small example project. With the provided XSL stylesheets, the generated output of PHPUnit, PHP_CodeSniffer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=111&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Não conhecia, vi hoje por meio do <a href="http://www.phpdeveloper.com/">phpdeveloper</a>:</p>
<p><a href="http://www.phpunit.de/wiki/phpUnderControl">phpUnderControl</a></p>
<blockquote><p><a href="http://www.phpunit.de/wiki/phpUnderControl">phpUnderControl aims to make the first steps with CruiseControl and PHP as easy as possible. It integrates three of the best PHP development tools into CruiseControl, combined with an easy setup routine and a small example project. With the provided XSL stylesheets, the generated output of PHPUnit, PHP_CodeSniffer and phpDocumentor can be visualized in CruiseControl, as you can see in the following screenshot.</a>
</p></blockquote>
<p><a href="http://cruisecontrol.sourceforge.net/">CruiseControl</a>, <a href="http://www.phpunit.de/">PHPUnit</a>, <a href="http://pear.php.net/package/PHP_CodeSniffer">PHP_CodeSniffer</a> e <a href="http://www.phpdoc.org/">phpDocumentor</a> já conhecia, o que não havia visto era isso tudo integrado.</p>
<p>Irei testar isso em algum projeto em andamento e verei se funciona legal. Ai coloco aqui minhas impressões.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/111/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/111/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=111&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/11/19/php-cruisecontrol/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP + TDD + &#8220;Generics&#8221;</title>
		<link>http://phpbr.wordpress.com/2007/11/16/php-tdd-generics/</link>
		<comments>http://phpbr.wordpress.com/2007/11/16/php-tdd-generics/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 20:38:16 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Artigos]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Codes]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/11/16/php-tdd-generics/</guid>
		<description><![CDATA[(Observação: Poucas coisas são tão terríveis quanto se formatar um post nesse wordpress. Todos devem ficar assim&#8230;)
&#8220;Test-Driven Development (TDD) is a software development technique consisting of short iterations where new test cases covering the desired improvement or new functionality are written first, then the production code necessary to pass the tests is implemented, and finally [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=106&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>(Observação: Poucas coisas são tão terríveis quanto se formatar um post nesse wordpress. Todos devem ficar assim&#8230;)</p>
<p>&#8220;Test-Driven Development (TDD) is a software development technique consisting of short iterations where new test cases covering the desired improvement or new functionality are written first, then the production code necessary to pass the tests is implemented, and finally the software is refactored to accommodate changes. The availability of tests before actual development ensures rapid feedback after any change. Practitioners emphasize that test-driven development is a method of designing software, not merely a method of testing.&#8221;</p>
<p>Acredito que já conheçam TDD. O que ??? Não conhece ??? Ok, ótima hora para conhecer:</p>
<p><a href="http://en.wikipedia.org/wiki/Test-driven_development">Wikipedia &#8211; TDD</a><br />
<a href="http://www.agiledata.org/essays/tdd.html">Introduction to Test Driven Design (TDD)</a><br />
<a href="http://www.testdriven.com/modules/news/">testdriven.com</a><br />
<a href="http://www.improveit.com.br/xp/praticas/tdd">improveit &#8211; tdd</a><br />
<a href="http://www.phpunit.de/">phpunit</a></p>
<p>Não será eu quem vai dizer os benefícios de se utilizar TDD, até porque não é o objetivo deste post. Vamos ver de forma bem rápida como podemos criar uma classe que tem o comportamente semelhante a <a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">generics em java</a>. E, novamente, não será eu que vai dizer o que são <a href="http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html">generics</a>.</p>
<p>1 &#8211; Os testes<br />
Vejamos um simples teste, com os comentários:</p>
<p>TestGenericList.php</p>
<pre>
<span style="font-weight:bold;color:#000000;">&lt;?php</span>

<span style="color:#a1a100;">include</span><span style="color:#000000;"> </span><span style="color:#dd0000;">'g.class.php'</span><span style="color:#000000;">;</span>
<span style="color:#a1a100;">include</span><span style="color:#000000;"> </span><span style="color:#dd0000;">'invalidgenerictypeexception.class.php'</span><span style="color:#000000;">;</span>
<span style="color:#a1a100;">include</span><span style="color:#000000;"> </span><span style="color:#dd0000;">'genericlist.class.php'</span><span style="color:#000000;">;</span>

<span style="font-style:italic;color:#808080;">// Classe que servira de modelo e teste para o que</span>
<span style="font-style:italic;color:#808080;">// vamos desenvolver</span>
<span style="font-weight:bold;color:#000000;">class</span><span style="color:#000000;"> TestGenericList </span><span style="font-weight:bold;color:#000000;">extends</span><span style="color:#000000;"> PHPUnit_Framework_TestCase {</span>

<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Testa o tamanho da nossa lista</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testSize()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// instanciamos a GenericList</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// o parametro que vamos passar indica</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// o tipo de lista que teremos, neste</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// caso uma lista de Integer (int)</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// List l = new List&lt;Integer&gt;()</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::Integer);</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">1</span><span style="color:#000000;">); </span><span style="font-style:italic;color:#808080;">// adicionamos um item...</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">2</span><span style="color:#000000;">); </span><span style="font-style:italic;color:#808080;">// ... e mais um ...</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">3</span><span style="color:#000000;">); </span><span style="font-style:italic;color:#808080;">// ... e mais um, totalizando tres</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// testamos se o tamanho da nossa lista</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// realmente eh igual a 3</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;assertEquals(</span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;size(), </span><span style="color:#0000ff;">3</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    }</span>

<span style="color:#000000;">    </span><span style="font-style:italic;color:#808080;">/*</span>
<span style="font-style:italic;color:#808080;">        Note que ao final do teste acima, ja temos pelo menos</span>
<span style="font-style:italic;color:#808080;">        tres metodos e duas propriedades definidas:</span>
<span style="font-style:italic;color:#808080;">        __construct($param):</span>
<span style="font-style:italic;color:#808080;">            O construtor da classe, vai receber pelo menos um</span>
<span style="font-style:italic;color:#808080;">            parametro, indicando o tipo de lista. $param</span>
<span style="font-style:italic;color:#808080;">            devera ser salvo para uso futuro, entao teremos</span>
<span style="font-style:italic;color:#808080;">            uma propriedade na classe para isso</span>
<span style="font-style:italic;color:#808080;">        add($param):</span>
<span style="font-style:italic;color:#808080;">            Adiciona um item na lista. Assim como o parametro</span>
<span style="font-style:italic;color:#808080;">            passado no construtor, deveremos salvar este parametro</span>
<span style="font-style:italic;color:#808080;">            para uso futuro. Entao teremos mais uma propriedade na </span>
<span style="font-style:italic;color:#808080;">            classe</span>
<span style="font-style:italic;color:#808080;">        size():</span>
<span style="font-style:italic;color:#808080;">            Retorna o tamanho da lista. Provavelmente vai retornar</span>
<span style="font-style:italic;color:#808080;">            a quantidade de itens adicionados em add($param), que</span>
<span style="font-style:italic;color:#808080;">            estao armazenados em uma propriedade da classe, que</span>
<span style="font-style:italic;color:#808080;">            certamente sera um array. Pensando em sizeof() ?</span>
<span style="font-style:italic;color:#808080;">    */</span>

<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Testa uma lista de Integers se aceita adicao</span>
<span style="font-style:italic;color:#0000ff;">    * de somente novos integers</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddSameTypeInteger()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos uma lista de integers</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::Integer);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// adicionamos um integer</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// se tudo deu certo, teremos um integer</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// na lista e ela vai ter um tamanho = 1</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;assertEquals(</span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;size(), </span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Testa uma lista de Strings se aceita adicao</span>
<span style="font-style:italic;color:#0000ff;">    * de somente novas Strings</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddSameTypeString()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos uma lista de Strings</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::String);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// adicionamos uma string</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#dd0000;">'foo'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// se tudo deu certo, teremos uma string</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// na lista e ela vai ter um tamanho = 1</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;assertEquals(</span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;size(), </span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    }</span>

<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Testa uma lista de Doubles se aceita adicao</span>
<span style="font-style:italic;color:#0000ff;">    * de somente novas Doubles</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddSameTypeDouble()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos uma lista de doubles</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::Double);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// adicionamos um double</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#800080;">10.1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// e se tudo deu certo, teremos um double</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// na lista e ela vai ter um tamanho = 1</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;assertEquals(</span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;size(), </span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Testa uma lista de Objetos se aceita adicao</span>
<span style="font-style:italic;color:#0000ff;">    * de somente novas Objetos DO MESMO TIPO. Ou seja</span>
<span style="font-style:italic;color:#0000ff;">    * Uma lista de "new Pessoa()" deve aceitar adicao</span>
<span style="font-style:italic;color:#0000ff;">    * de somente "new Pessoa()"</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddSameTypeObject()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos um objeto que servira de</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// modelo para a lista...</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> StdClass();</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// ...e um objeto que sera adiciona na lista.</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// Note que ambos sao instancias de StdClass</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj2</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> StdClass();</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos uma lista de objetos do tipo</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// stdclass</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// e adicionamos um objeto a esta lista</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#5555ff;">$obj2</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// se tudo deu certo, teremos um objeto</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// na lista e ela vai ter um tamanho = 1</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;assertEquals(</span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;size(), </span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>

<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// novamente criamos uma lista de objetos do tipo</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// stdclass, mas desta vez ao inves de passar um objeto</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// da classe, passamos o tipo de objeto que a lista</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// ira conter</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::type(</span><span style="color:#dd0000;">'stdclass'</span><span style="color:#000000;">)); </span><span style="font-style:italic;color:#808080;">// same as above, but using class name</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// e adicionamos um objeto do tipo especificado a lista</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#5555ff;">$obj2</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// novamente, se tudo deu certo, teremos uma</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// lista de tamanho = 1, e testamos isso</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;assertEquals(</span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;size(), </span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Aqui iremos forcar um erro no teste</span>
<span style="font-style:italic;color:#0000ff;">    * Vamos criar uma lista de Integer e tentar</span>
<span style="font-style:italic;color:#0000ff;">    * adicionar outros tipos. Em todos os casos</span>
<span style="font-style:italic;color:#0000ff;">    * diferentes do tipo original, devera ocorrer</span>
<span style="font-style:italic;color:#0000ff;">    * um erro</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddDifferentTypeInteger()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos a lista de integer</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::Integer);</span>

<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// nos casos em que vamos utilizar algo diferente</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// de integer, utilizamos bloco try/catch. O</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// comportamento da lista sera de gerar uma</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// exception no caso de adicao de um tipo diferente</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// tentamos adicionar uma string na lista de</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// integer</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#dd0000;">'foo'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// nao deveria chegar neste ponto, visto que</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// na linha acima deveria ter sido gerada. Entao</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// dizemos ao phpunit que este teste falhou</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Integer accepted a string'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#800080;">2.1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Integer accepted a double'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> StdClass());</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Integer accepted a object'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Aqui iremos forcar um erro no teste</span>
<span style="font-style:italic;color:#0000ff;">    * Vamos criar uma lista de Strings e tentar</span>
<span style="font-style:italic;color:#0000ff;">    * adicionar outros tipos. Em todos os casos</span>
<span style="font-style:italic;color:#0000ff;">    * diferentes do tipo original, devera ocorrer</span>
<span style="font-style:italic;color:#0000ff;">    * um erro</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddDifferentTypeString()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos a lista de strings</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::String);</span>

<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// e tentamos adicionar outros tipos, do mesmo</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// modo que fazemos no teste anterior</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic String accepted a integer'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#800080;">1.0</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic String accepted a double'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> StdClass());</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic String accepted a object'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Aqui tambem iremos forcar um erro no teste</span>
<span style="font-style:italic;color:#0000ff;">    * Vamos criar uma lista de Double e tentar</span>
<span style="font-style:italic;color:#0000ff;">    * adicionar outros tipos. Em todos os casos</span>
<span style="font-style:italic;color:#0000ff;">    * diferentes do tipo original, devera ocorrer</span>
<span style="font-style:italic;color:#0000ff;">    * um erro</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddDifferentTypeDouble()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos a lista de Double</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::Double);</span>

<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// e depois eh aquilo...</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Double accepted a integer'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#dd0000;">'foo'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Double accepted a string'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> StdClass());</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Double accepted a object'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Novamente o erro.</span>
<span style="font-style:italic;color:#0000ff;">    * Vamos criar uma lista de Objetos e tentar</span>
<span style="font-style:italic;color:#0000ff;">    * adicionar outros tipos. Em todos os casos</span>
<span style="font-style:italic;color:#0000ff;">    * diferentes do tipo original, devera ocorrer</span>
<span style="font-style:italic;color:#0000ff;">    * um erro</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddDifferentTypeObject()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> StdClass();</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos uma lista de objetos StdClass</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">);</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// nao podemos adicionar Integer</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Object accepted a integer'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// e nem String</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#dd0000;">'foo'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Object accepted a string'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// nem double</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#800080;">2.5</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Object accepted a double'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// e nem outro tipo de objeto, neste caso uma</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// Exception</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add( </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Exception());</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Object accepted a Exception'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// mesma ideia, mas utilizando uma lista criada</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// com o nome da classe</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> StdClass();</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::type(</span><span style="color:#dd0000;">'stdclass'</span><span style="color:#000000;">));</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="color:#0000ff;">1</span><span style="color:#000000;">);</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Object accepted a integer'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) {}</span>

<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Neste teste vamos verificar se a nossa lista</span>
<span style="font-style:italic;color:#0000ff;">    * aceita um objeto de uma classe diferente da</span>
<span style="font-style:italic;color:#0000ff;">    * classe definida como o tipo da lista, mas sendo</span>
<span style="font-style:italic;color:#0000ff;">    * uma classe "extendida":</span>
<span style="font-style:italic;color:#0000ff;">    *</span>
<span style="font-style:italic;color:#0000ff;">    * class Car{}</span>
<span style="font-style:italic;color:#0000ff;">    * class Ferrari extends Car {}</span>
<span style="font-style:italic;color:#0000ff;">    *</span>
<span style="font-style:italic;color:#0000ff;">    * criamos uma lista de Car e tentaremos adicionar</span>
<span style="font-style:italic;color:#0000ff;">    * uma Ferrari</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> testAddParentClassObject()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos 2 classes em runtime</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// php nao aceita criacao de nested classes</span>
<span style="color:#000000;">        </span><span style="color:#000080;">eval</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'class Car {}'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span><span style="color:#000080;">eval</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'class Ferrari extends Car {}'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Car();</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// criamos uma lista de Car, da mesma forma que criavamos</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// anteriormente. Entao se tentarmos adicionar uma Ferrari</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// na lista, devera ser gerada uma exception</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">); </span><span style="font-style:italic;color:#808080;">// creates a Car's list</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// adicionar uma Ferrari em uma lista de Car</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// deve gerar uma exception</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Ferrari()); </span><span style="font-style:italic;color:#808080;">// must throw a exception</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Object accepted a parent class object without G::extend'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) { }</span>

<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Car();</span>

<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// agora vamos definir que a nossa lista pode</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// receber alem de Car, classes que herdem Car</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// Collection c = new Collection&lt;? extends Car&gt;()</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::extend(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">));</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// Ferrari herda Car, entao esperamos que funcione</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Ferrari()); </span>

<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// fazemos a mesma coisa, mas utilizando o nome da classe</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// ao inves de um objeto</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Car();</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::type(</span><span style="color:#dd0000;">'car'</span><span style="color:#000000;">)); </span><span style="font-style:italic;color:#808080;">// creates a Car's list</span>

<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">try</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Ferrari()); </span><span style="font-style:italic;color:#808080;">// must throw a exception</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;fail(</span><span style="color:#dd0000;">'Generic Object accepted a parent class object without G::extend'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        } </span><span style="font-weight:bold;color:#000000;">catch</span><span style="color:#000000;"> (InvalidGenericTypeException </span><span style="color:#5555ff;">$e</span><span style="color:#000000;">) { }</span>

<span style="color:#000000;">        </span><span style="color:#5555ff;">$obj</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Car();</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> GenericList(G::extend(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">));</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$list</span><span style="color:#000000;">-&gt;add(</span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> Ferrari()); </span><span style="font-style:italic;color:#808080;">// should work</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">}</span>
</pre>
<p>Após terminarmos de escrever o teste, temos bem definido uma grande parte da classe que vamos implementar. Já temos pelo menos 3 métodos públicos definidos:</p>
<p>    __construct($param):<br />
        O construtor da classe, vai receber pelo menos um<br />
        parâmetro, indicando o tipo de lista. $param<br />
        deverá ser salvo para uso futuro, então teremos<br />
        uma propriedade na classe para isso</p>
<p>    add($param):<br />
        Adiciona um item na lista. Assim como o parâmetro<br />
        passado no construtor, deveremos salvar este parâmetro<br />
        para uso futuro. Então teremos mais uma propriedade na<br />
        classe</p>
<p>    size():<br />
        Retorna o tamanho da lista. Provavelmente vai retornar<br />
        a quantidade de itens adicionados em add($param), que<br />
        estao armazenados em uma propriedade da classe, que<br />
        certamente sera um array. Pensando em sizeof() ?</p>
<p>E também pelo menos 2 propriedades.<br />
Observando o teste notamos também mais duas classes: G, que contem os tipos disponíveis e dois métodos, e também uma classe InvalidGenericTypeException, que representa as exceptions geradas por GenericList.</p>
<p>2 &#8211; Implementação: g.class.php<br />
A Classe G (de Generic), contém tres constantes &#8211; Integer, String e Double &#8211; e dois métodos estáticos &#8211; extend e type.<br />
O método type será utilizado para informar para lista o tipo de valor que ela vai conter, sem que ela precise descobrir por si. Já o método extend será utilizado para informar a lista que o tipo a ser utilizado pode ser também subtipos. Os dois métodos vão retornar um array que será trabalhado pela lista. Vamos a implementação:</p>
<p>g.class.php</p>
<pre>
<span style="font-weight:bold;color:#000000;">&lt;?php</span>
<span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">* Classe que contem a definicao dos tipos disponiveis</span>
<span style="font-style:italic;color:#0000ff;">*/</span>
<span style="font-weight:bold;color:#000000;">class</span><span style="color:#000000;"> G {</span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Constantes com os tipos</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">const</span><span style="color:#000000;"> Integer = </span><span style="color:#dd0000;">'integer'</span><span style="color:#000000;">;</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">const</span><span style="color:#000000;"> String  = </span><span style="color:#dd0000;">'string'</span><span style="color:#000000;">;</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">const</span><span style="color:#000000;"> Double  = </span><span style="color:#dd0000;">'double'</span><span style="color:#000000;">;</span>

<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">static</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> extend(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">)</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (!</span><span style="color:#000080;">is_object</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">)) {</span>
<span style="color:#000000;">            </span><span style="font-weight:bold;color:#000000;">throw</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> InvalidGenericTypeException(</span><span style="color:#dd0000;">'G::parentsOf must be called with a valid object'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">        }</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">return</span><span style="color:#000000;"> </span><span style="color:#000080;">array</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'extend'</span><span style="color:#000000;"> =&gt; </span><span style="color:#000080;">strtolower</span><span style="color:#000000;">(</span><span style="color:#000080;">get_class</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$obj</span><span style="color:#000000;">)));</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">static</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> type(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">)</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">return</span><span style="color:#000000;"> </span><span style="color:#000080;">array</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'type'</span><span style="color:#000000;"> =&gt; </span><span style="color:#000080;">strtolower</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">));</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">}</span>
</pre>
<p>2 &#8211; Implementação: invalidgenerictypeexception.class.php<br />
Uma exception simples, desnecessária explicação</p>
<p>invalidgenerictypeexception.class.php</p>
<pre>
<span style="font-weight:bold;color:#000000;">&lt;?php</span>
<span style="font-weight:bold;color:#000000;">class</span><span style="color:#000000;"> InvalidGenericTypeException </span><span style="font-weight:bold;color:#000000;">extends</span><span style="color:#000000;"> Exception {</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> </span><span style="color:#000080;">__construct</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$message</span><span style="color:#000000;">)</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-weight:bold;color:#000000;">parent</span><span style="color:#000000;">::</span><span style="color:#000080;">__construct</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$message</span><span style="color:#000000;">);</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">}</span>
</pre>
<p>4 &#8211; Implementação: genericlist.class.php<br />
Aqui temos, finalmente, a implementação da lista em si. Note que esta implementação chega a ser bem mais simples que o teste. Veja o código e acompanhe pelos comentários:</p>
<p>genericlist.class.php</p>
<pre>
<span style="font-weight:bold;color:#000000;">&lt;?php</span>
<span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">* Implementacao da lista</span>
<span style="font-style:italic;color:#0000ff;">*</span>
<span style="font-style:italic;color:#0000ff;">* Tem apenas proposito educacional, poderia implementar</span>
<span style="font-style:italic;color:#0000ff;">* algum iterator, ter metodos para remover ou retornar</span>
<span style="font-style:italic;color:#0000ff;">* um item, buscar por um item, etc.</span>
<span style="font-style:italic;color:#0000ff;">*/</span>
<span style="font-weight:bold;color:#000000;">class</span><span style="color:#000000;"> GenericList {</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Tipo de valores da lista</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">private</span><span style="color:#000000;"> </span><span style="color:#5555ff;">$type</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">null</span><span style="color:#000000;">;</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Valores da lista</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">private</span><span style="color:#000000;"> </span><span style="color:#5555ff;">$values</span><span style="color:#000000;"> = </span><span style="color:#000080;">array</span><span style="color:#000000;">();</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Informa se o tipo deve levar em consideracao</span>
<span style="font-style:italic;color:#0000ff;">    * tambem os subtipos</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">private</span><span style="color:#000000;"> </span><span style="color:#5555ff;">$useExtend</span><span style="color:#000000;"> = </span><span style="font-weight:bold;color:#000000;">false</span><span style="color:#000000;">;</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Construtor da classe</span>
<span style="font-style:italic;color:#0000ff;">    *</span>
<span style="font-style:italic;color:#0000ff;">    * Baseado no parametro recebido, inicializa as propriedades</span>
<span style="font-style:italic;color:#0000ff;">    * $this-&gt;type e $this-&gt;useExtend</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> </span><span style="color:#000080;">__construct</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$type</span><span style="color:#000000;">)</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// se o parametro for um objeto, o tipo</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// da lista sera definido para o nome da</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// classe utilizada para criacao do objeto,</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// em minusculo</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (</span><span style="color:#000080;">is_object</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$type</span><span style="color:#000000;">)) {</span>
<span style="color:#000000;">            </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type = </span><span style="color:#000080;">strtolower</span><span style="color:#000000;">(</span><span style="color:#000080;">get_class</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$type</span><span style="color:#000000;">));</span>
<span style="color:#000000;">        } </span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// se nao for um objeto, pode ser um array,</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// G::String, G::Double ou G::Integer</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">else</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// caso seja um array...</span>
<span style="color:#000000;">            </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (</span><span style="color:#000080;">is_array</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$type</span><span style="color:#000000;">)) {</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// ... verifica se existe a chave</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// extend. Caso exista, significa que</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// o tipo foi definido por meio de</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// G::extend</span>
<span style="color:#000000;">                </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (</span><span style="color:#000080;">array_key_exists</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'extend'</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$type</span><span style="color:#000000;">)) {</span>
<span style="color:#000000;">                    </span><span style="font-style:italic;color:#808080;">// define que estara levando em consideracao</span>
<span style="color:#000000;">                    </span><span style="font-style:italic;color:#808080;">// os subtipos do tipo</span>
<span style="color:#000000;">                    </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;useExtend = </span><span style="font-weight:bold;color:#000000;">true</span><span style="color:#000000;">;</span>
<span style="color:#000000;">                    </span><span style="font-style:italic;color:#808080;">// define o tipo</span>
<span style="color:#000000;">                    </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type = </span><span style="color:#5555ff;">$type</span><span style="color:#000000;">[</span><span style="color:#dd0000;">'extend'</span><span style="color:#000000;">];</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// caso exista a chave 'type', significa que o tipo</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// da lista foi definida com g::type. Apenas</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// pega o valor de type e seta como padrao para</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// a lista</span>
<span style="color:#000000;">                } </span><span style="color:#a1a100;">else</span><span style="color:#000000;"> </span><span style="color:#a1a100;">if</span><span style="color:#000000;">(</span><span style="color:#000080;">array_key_exists</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'type'</span><span style="color:#000000;">, </span><span style="color:#5555ff;">$type</span><span style="color:#000000;">)) {</span>
<span style="color:#000000;">                    </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type = </span><span style="color:#5555ff;">$type</span><span style="color:#000000;">[</span><span style="color:#dd0000;">'type'</span><span style="color:#000000;">];</span>
<span style="color:#000000;">                }</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// nao deveria chegar aqui</span>
<span style="color:#000000;">                </span><span style="color:#a1a100;">else</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">                    </span><span style="font-weight:bold;color:#000000;">throw</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> InvalidGenericTypeException(</span><span style="color:#dd0000;">'Undefined type'</span><span style="color:#000000;">);</span>
<span style="color:#000000;">                }</span>
<span style="color:#000000;">            }</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// se nao for array, o tipo foi passado diretamente como</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// parametro. Apenas utiliza-o</span>
<span style="color:#000000;">            </span><span style="color:#a1a100;">else</span><span style="color:#000000;"> {</span>
<span style="color:#000000;">                </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type = </span><span style="color:#5555ff;">$type</span><span style="color:#000000;">;</span>
<span style="color:#000000;">            }</span>
<span style="color:#000000;">        }</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Adiciona um valor a lista</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> add(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">)</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// verifica se o tipo sendo adicionado eh um objeto</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// e se o tipo do objeto eh diferente do tipo definido</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// para a lista</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (</span><span style="color:#000080;">is_object</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">) &amp;&amp; </span><span style="color:#000080;">strtolower</span><span style="color:#000000;">(</span><span style="color:#000080;">get_class</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">)) != </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type) {</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// caso o tipo seja diferente, verifica se a lista foi criada</span>
<span style="color:#000000;">            </span><span style="font-style:italic;color:#808080;">// com a opcao de se utilizar subtipos do tipo (extend)</span>
<span style="color:#000000;">            </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (</span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;useExtend != </span><span style="font-weight:bold;color:#000000;">true</span><span style="color:#000000;"> || !(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;"> instanceof </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type)) {</span>
<span style="color:#000000;">                </span><span style="font-style:italic;color:#808080;">// caso nao tenha, gera uma exception</span>
<span style="color:#000000;">                </span><span style="font-weight:bold;color:#000000;">throw</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> InvalidGenericTypeException(</span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'Invalid object type: %s, expected: %s'</span><span style="color:#000000;">, </span><span style="color:#000080;">strtolower</span><span style="color:#000000;">(</span><span style="color:#000080;">get_class</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">)), </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type));</span>
<span style="color:#000000;">            }</span>
<span style="color:#000000;">        }</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// caso o tipo sendo adicionado nao seja um objeto</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// e seja diferente do tipo definido para a lista,</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// gera uma exception (tambem)</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">if</span><span style="color:#000000;"> (!</span><span style="color:#000080;">is_object</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">) &amp;&amp; </span><span style="color:#000080;">gettype</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">) != </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type) {</span>
<span style="color:#000000;">            </span><span style="font-weight:bold;color:#000000;">throw</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">new</span><span style="color:#000000;"> InvalidGenericTypeException(</span><span style="color:#000080;">sprintf</span><span style="color:#000000;">(</span><span style="color:#dd0000;">'Invalid type: %s, expected: %s'</span><span style="color:#000000;">, </span><span style="color:#000080;">get_class</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$val</span><span style="color:#000000;">), </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;type));</span>
<span style="color:#000000;">        }</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// se chegou ate aqui, nao ha erros</span>
<span style="color:#000000;">        </span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;values[] = </span><span style="color:#5555ff;">$val</span><span style="color:#000000;">;</span>
<span style="color:#000000;">        </span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// retorna o valor sendo adicionado a lista</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">return</span><span style="color:#000000;"> </span><span style="color:#5555ff;">$val</span><span style="color:#000000;">;</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">    </span>
<span style="color:#000000;">    </span><span style="font-style:italic;color:#0000ff;">/**</span>
<span style="font-style:italic;color:#0000ff;">    * Retorna o tamanho da lista</span>
<span style="font-style:italic;color:#0000ff;">    */</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">public</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">function</span><span style="color:#000000;"> size()</span>
<span style="color:#000000;">    {</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// exatamente como imaginou no teste,</span>
<span style="color:#000000;">        </span><span style="font-style:italic;color:#808080;">// um simples sizeof</span>
<span style="color:#000000;">        </span><span style="color:#a1a100;">return</span><span style="color:#000000;"> </span><span style="color:#000080;">sizeof</span><span style="color:#000000;">(</span><span style="color:#5555ff;">$this</span><span style="color:#000000;">-&gt;values);</span>
<span style="color:#000000;">    }</span>
<span style="color:#000000;">}</span>
</pre>
<p>5 &#8211; Testando<br />
Depois de termos as implementações, já podemos testar:</p>
<p>$ phpunit TestGenericList.php<br />
PHPUnit 3.0.6 by Sebastian Bergmann.</p>
<p>&#8230;&#8230;&#8230;.</p>
<p>Time: 00:00</p>
<p>OK (10 tests)</p>
<p>E tudo ok. Não é comum passar 100% logo na primeira implementação, mas tudo bem.</p>
<p>6 &#8211; Considerações<br />
Algumas coisas que podemos notar:</p>
<p>- Antes mesmo de escrever a implementação da classe GenericList já tinhamos &#8220;pronto&#8221; nos testes o comportamento que desejavamos<br />
- Todos os testes FALHAVAM antes da implementação da classe. E falhavam de duas formas: Primeiro porque não havia a classe e nem os métodos, então havia a falha de classe não encontrada. Segundo, por mais que tivessemos a classe e os métodos, mas os métodos não tivessem sido implementados, os testes iriam falhar. Este é o comportamento correto de um teste. É comum quando se começa a escrever testes (unitários) fazer com que eles passem antes mesmo de falhar.<br />
- Escreva um teste para falhar e não para passar<br />
- Em PHP não poderemos (não no 5, 6 e nem tão cedo, acredito) utilizar de forma &#8220;elegante&#8221;, como se faz em outras linguagens, a GenericList como parâmetro de um método, mas podemos emular isso:<br />
	java: public void showNomes(GenericList&lt;Pessoa&gt; pessoas)<br />
	c#:   public void ShowNomes(GenericList&lt;Pessoa&gt; pessoas)<br />
	php: um leve &#8220;hack&#8221;<br />
	public function showNomes(GenericList $pessoas)<br />
	{<br />
            $pessoas-&gt;getType() == &#8216;pessoa&#8217; || eval(&#8216;throw new InvalidGenericTypeException(&#8220;Expected GenericList&#8221;);&#8217;);<br />
	}<br />
- Como escrevi ali antes, sabiamos o comportamento que desejamos para a nossa classe. Há um outro método de design que dá mais ênfase nisso. Veja:<br />
<a href="http://behaviour-driven.org/">behavior-driven.org</a><br />
<a href="http://en.wikipedia.org/wiki/Behavior_driven_development">Behavior driven development</a></p>
<p>É isso ai. Mais, em breve.</p>
<p>Arquivos:<br />
<a href='http://phpbr.files.wordpress.com/2007/11/gclass.txt' title='g.class.php'>g.class.php</a><br />
<a href='http://phpbr.files.wordpress.com/2007/11/genericlistclass.txt' title='genericlist.class.php'>genericlist.class.php</a><br />
<a href='http://phpbr.files.wordpress.com/2007/11/invalidgenerictypeexceptionclass.txt' title='invalidgenerictypeexception.class.php'>invalidgenerictypeexception.class.php</a><br />
<a href='http://phpbr.files.wordpress.com/2007/11/testgenericlist.txt' title='TestGenericList.php'>TestGenericList.php</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/106/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/106/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=106&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/11/16/php-tdd-generics/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>1, 2, 3 testando</title>
		<link>http://phpbr.wordpress.com/2007/11/16/1-2-3-testando/</link>
		<comments>http://phpbr.wordpress.com/2007/11/16/1-2-3-testando/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 14:29:40 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Notas]]></category>
		<category><![CDATA[Notícias]]></category>
		<category><![CDATA[Não Categorizado]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/11/16/1-2-3-testando/</guid>
		<description><![CDATA[Muito ocupado nos últimos tempos, por isso a falta de notícias, links, etc&#8230;
Mas voltaremos ao normal.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=104&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Muito ocupado nos últimos tempos, por isso a falta de notícias, links, etc&#8230;</p>
<p>Mas voltaremos ao normal.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/104/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/104/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=104&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/11/16/1-2-3-testando/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP / refactoring: Como ? (Outra vez)</title>
		<link>http://phpbr.wordpress.com/2007/09/22/php-refactoring-como-outra-vez/</link>
		<comments>http://phpbr.wordpress.com/2007/09/22/php-refactoring-como-outra-vez/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 14:23:52 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Notícias]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/09/22/php-refactoring-como-outra-vez/</guid>
		<description><![CDATA[Já havia  comentado aqui alguma coisa. Mas aqui encontramos um artigo muito legal sobre isso.
Apesar de não ser permitido, muitos beta-testers (e desenvolvedores) dessa &#8220;next generation IDE&#8221; tem comentado sobre as features da nova IDE da Zend. Também gostaria de falar sobre profiling, code coverage em testes unitários, debug e blablabla, mas não posso :) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=103&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Já havia  comentado <a href="http://phpbr.wordpress.com/2007/04/15/php-refactoring-como/">aqui</a> alguma coisa. Mas <a href="http://devzone.zend.com/article/2514-Refactoring-PHP-Code">aqui</a> encontramos um artigo muito legal sobre isso.</p>
<p>Apesar de não ser permitido, muitos beta-testers (e desenvolvedores) dessa &#8220;next generation IDE&#8221; tem comentado sobre as features da <a href="http://www.google.com.br/search?q=zend+neon">nova IDE da Zend</a>. Também gostaria de falar sobre profiling, code coverage em testes unitários, debug e blablabla, mas não posso :) .</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/103/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/103/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=103&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/09/22/php-refactoring-como-outra-vez/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>A importância da comunicação</title>
		<link>http://phpbr.wordpress.com/2007/07/27/a-importancia-da-comunicacao/</link>
		<comments>http://phpbr.wordpress.com/2007/07/27/a-importancia-da-comunicacao/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 18:23:17 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Notas]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/07/27/a-importancia-da-comunicacao/</guid>
		<description><![CDATA[Mais um off-topic

Comunicação é uma das premissas do Extreme Programing que acredito ser a mais importante.
Esta imagem é muito utilizada, chega a ser um  chavão para os &#8220;mais andados&#8221;. Vi ela 3 vezes neste mês e aproveitei para compartilhar, sempre tem gente que não a viu.
Aproveitando o off-topic, fica uma sugestão:
Haverá hoje uma apresentação [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=102&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Mais um off-topic</p>
<p><a href="http://phpbr.files.wordpress.com/2007/07/falta_comunicao_desenvolvimento.jpg" title="falta_comunicao_desenvolvimento.jpg"><img src="http://phpbr.files.wordpress.com/2007/07/falta_comunicao_desenvolvimento.thumbnail.jpg" alt="falta_comunicao_desenvolvimento.jpg" /></a></p>
<p>Comunicação é uma das premissas do <a href="http://www.extremeprogramming.org/">Extreme Programing</a> que acredito ser a mais importante.</p>
<p>Esta imagem é muito utilizada, chega a ser um  chavão para os &#8220;mais andados&#8221;. Vi ela 3 vezes neste mês e aproveitei para compartilhar, sempre tem gente que não a viu.<br />
Aproveitando o off-topic, fica uma sugestão:</p>
<p>Haverá hoje uma apresentação sobre Scrum (o título é “Entendendo Scrum Para Gerenciar Projetos Ágeis” ):</p>
<p><a href="http://www.egenial.com.br/betaEventos">http://www.egenial.com.br/betaEventos</a></p>
<p>A primeira apresentação que assisti neste ambiente foi exatamente uma &#8220;introdução&#8221; a XP, excelente por sinal<br />
. É bem provável que a qualidade se mantenha, então fica a sugestão, se não tem alguma coisa suficientemente importante para fazer, vale a pena assistir, hoje, a partir das 20:30. Estarei por lá.</p>
<p>E parabéns aos que vem fazendo com que estas apresentações aconteçam (<a href="http://www.blog.egenial.com.br/">Carlos Eduardo &amp; cia</a>)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/102/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/102/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=102&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/07/27/a-importancia-da-comunicacao/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>

		<media:content url="http://phpbr.files.wordpress.com/2007/07/falta_comunicao_desenvolvimento.thumbnail.jpg" medium="image">
			<media:title type="html">falta_comunicao_desenvolvimento.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Visão Ágil &#8211; Revista Brasileira Sobre Processos Ágeis</title>
		<link>http://phpbr.wordpress.com/2007/07/24/visao-agil-revista-brasileira-sobre-processos-ageis/</link>
		<comments>http://phpbr.wordpress.com/2007/07/24/visao-agil-revista-brasileira-sobre-processos-ageis/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 02:34:04 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Lançamentos]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Não Categorizado]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/07/24/visao-agil-revista-brasileira-sobre-processos-ageis/</guid>
		<description><![CDATA[Visão Ágil é primeira revista brasileira dedicada a processos ágeis, seu principal objetivo, é fornecer um canal único e dinâmico para reunir todas das vertentes ativas no cenário nacional.Este espaço, é aberto a todas as tribos como: Extreme Programming, FDD, Scrum e outras técnicas ágeis correlacionadas.
Portanto, acesse a primeira edição desse projeto  ousado e [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=100&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p>Visão Ágil é primeira revista brasileira dedicada a processos ágeis, seu principal objetivo, é fornecer um canal único e dinâmico para reunir todas das vertentes ativas no cenário nacional.Este espaço, é aberto a todas as tribos como: Extreme Programming, FDD, Scrum e outras técnicas ágeis correlacionadas.</p>
<p>Portanto, acesse a primeira edição desse projeto  ousado e feito com muito carinho para todos os agilistas do Brasil.</p></blockquote>
<p>Conteúdo muito interessante.<br />
Para quem não segue nenhum processo de desenvolvimento de software ou segue algum dito &#8220;burocrático&#8221;, e tem vontade de conhecer algum processo &#8220;ágil&#8221;, vale uma lida.</p>
<p>Entre os artigos, podemos ler sobre XP, SCRUM, um artigo falando sobre &#8220;As Cinco Doenças do Gerenciamento de Projetos&#8221; e um sobre  &#8220;Contrato de Escopo Negociável&#8221;.</p>
<p>Apesar de não se aprofundar muito nos assuntos, todos os artigos tem um conteúdo muito bom.</p>
<p>Veja mais em <a href="http://visaoagil.com">visaoagil.com</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/100/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/100/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=100&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/07/24/visao-agil-revista-brasileira-sobre-processos-ageis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP5: Namespaces</title>
		<link>http://phpbr.wordpress.com/2007/07/21/php5-namespaces/</link>
		<comments>http://phpbr.wordpress.com/2007/07/21/php5-namespaces/#comments</comments>
		<pubDate>Sat, 21 Jul 2007 17:05:12 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[PHP6]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/07/21/php5-namespaces/</guid>
		<description><![CDATA[ [PHP-DEV] Namespaces patch backport
De: &#8220;Timm Friebe&#8221; thekid@thekid.de
Para: &#8220;PHPdev&#8221; internals@lists.php.net
Data: Hoje 06:57:30Hi,
I&#8217;ve backported the namespaces patch to current CVS HEAD. Here it is:http://sitten-polizei.de/php/php5-namespaces.diff
I&#8217;ve tested it with the .phpt-tests Dmitry provided. Enjoy:)
- Timm
&#8211;
PHP Internals &#8211; PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
É certo que o patch não será aplicado ao na versão atual (5.2.3), mas [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=99&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p> [PHP-DEV] Namespaces patch backport<br />
De: &#8220;Timm Friebe&#8221; thekid@thekid.de<br />
Para: &#8220;PHPdev&#8221; internals@lists.php.net<br />
Data: Hoje 06:57:30Hi,<br />
I&#8217;ve backported the namespaces patch to current CVS HEAD. Here it is:<a href="http://sitten-polizei.de/php/php5-namespaces.diff">http://sitten-polizei.de/php/php5-namespaces.diff</a></p>
<p>I&#8217;ve tested it with the .phpt-tests Dmitry provided. Enjoy:)</p>
<p>- Timm</p>
<p>&#8211;<br />
PHP Internals &#8211; PHP Runtime Development Mailing List<br />
To unsubscribe, visit: http://www.php.net/unsub.php</p></blockquote>
<p>É certo que o patch não será aplicado ao na versão atual (5.2.3), mas quem sabe não se aplique em um eventual 5.3 ?</p>
<p>SE isso acontecesse, o que <a href="http://phpbr.wordpress.com/2007/07/17/php5-blah/">disse aqui</a> certamente não teria o teor que teve.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/99/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/99/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=99&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/07/21/php5-namespaces/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP5 ? Blah!!!</title>
		<link>http://phpbr.wordpress.com/2007/07/17/php5-blah/</link>
		<comments>http://phpbr.wordpress.com/2007/07/17/php5-blah/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 00:26:36 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Notas]]></category>
		<category><![CDATA[Opiniões]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/07/17/php5-blah/</guid>
		<description><![CDATA[Alguns dias pra terminar de escrever isso, pode parecer batido:
gophp5.org
Leia.
Leu ? Ótima iniciativa, não ?
Será ?
Vejamos:
- Migrar um servidor de php4 para php5 não é apenas atualizar os pacotes e &#8220;plim&#8221;, esta pronto. Sempre há um custo.
- &#8220;As coisas instaladas&#8221; (softwares de quem contratou o serviço) provavelmente vão quebrar. Ponto!
- Aqueles que ainda não utilizam [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=98&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Alguns dias pra terminar de escrever isso, pode parecer batido:<br />
<a>gophp5.org</a></p>
<p>Leia.</p>
<p>Leu ? Ótima iniciativa, não ?</p>
<p>Será ?</p>
<p>Vejamos:</p>
<p>- Migrar um servidor de php4 para php5 não é apenas atualizar os pacotes e &#8220;plim&#8221;, esta pronto. Sempre há um custo.<br />
- &#8220;As coisas instaladas&#8221; (softwares de quem contratou o serviço) provavelmente vão quebrar. Ponto!<br />
- Aqueles que ainda não utilizam php5 para desenvolver provavelmente vão reclamar de &#8220;suas coisas quebradas&#8221;. Ponto!<br />
- Quem migrou um servidor e teve problemas (não será apenas um, nem dois, nem três)  vai se arrepender da escolha algum tempo depois.</p>
<p>Parece óbvio, ao menos para mim.</p>
<p>E qual o problema nisso tudo ?</p>
<p>PHP6.</p>
<p>Assim que tivermos todo mundo usando PHP5, feliz da vida, após o trauma da transição do PHP4 para o PHP5, com todas as coisas supostamente funcionando, e blablabla, teremos o PHP6, recém saido do forno, com suporte a namespaces, unicode e outras coisas interessantes mais (se não tivesse nada de interessante a mais, seria o PHP5.3, PHP5.4, &#8230;). </p>
<p>E ai, começamos a campanha &#8220;abaixo PHP5, viva PHP6&#8243; ? E os custos ? E as &#8220;coisas quebradas&#8221; da (in)feliz migração PHP4/PHP5 ? E os arrependimentos ? E as reclamações ? E e e ???</p>
<p>Um tiro no pé! É o que acho da iniciativa e das constantes &#8220;pressões&#8221; na adoção do PHP5.</p>
<p>Não que ele seja ruim, longe disso. Mas se coisas não funcionarem, quando tivermos uma boa quantidade de gente desenvolvendo em PHP6, estaremos vendo cada vez mais Aqueles_Nomes_De_Classes_Gigantescos em PHP5 e o PHP6 estará fadado a ser ignorado por empresas de hosting (consequentemente milhares de programadores ?).</p>
<p>Só espero estar errado. E que venha PHP6!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/98/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/98/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=98&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/07/17/php5-blah/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>Annotations (@QualquerCoisa) em PHP</title>
		<link>http://phpbr.wordpress.com/2007/07/15/annotations-qualquercoisa-em-php/</link>
		<comments>http://phpbr.wordpress.com/2007/07/15/annotations-qualquercoisa-em-php/#comments</comments>
		<pubDate>Sun, 15 Jul 2007 20:35:14 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Notas]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/07/15/annotations-qualquercoisa-em-php/</guid>
		<description><![CDATA[Havia lido algum tempo atrás sobre annotations em PHP, mas nada muito concreto.
Vi hoje uma apresentação (antiga, do phpconference) falando mais sobre isso:

Mais, aqui
Muito interessante, bem que poderia fazer parte do core do PHP
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=97&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Havia lido algum tempo atrás sobre <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html">annotations</a> em PHP, mas nada muito concreto.</p>
<p>Vi hoje uma apresentação (antiga, do phpconference) falando mais sobre isso:</p>
<p><object type='application/x-shockwave-flash' wmode='transparent' data='http://static.slideshare.net/swf/ssplayer2.swf?id=53703&#038;doc=declarative-development-using-annotations-in-php-19080' width='425' height='348'><param name='movie' value='http://static.slideshare.net/swf/ssplayer2.swf?id=53703&#038;doc=declarative-development-using-annotations-in-php-19080' /><param name='allowFullScreen' value='true' /><param name='allowScriptAccess' value='always' /></object></p>
<p><a href="http://www.stubbles.org/">Mais, aqui</a><br />
Muito interessante, bem que poderia fazer parte do core do PHP</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/97/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/97/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=97&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/07/15/annotations-qualquercoisa-em-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>xml to mysql: Transformando um arquivo XML em queries SQL (e blablabla)</title>
		<link>http://phpbr.wordpress.com/2007/07/07/xml-to-mysql-transformando-um-arquivo-xml-em-queries-sql-e-blablabla/</link>
		<comments>http://phpbr.wordpress.com/2007/07/07/xml-to-mysql-transformando-um-arquivo-xml-em-queries-sql-e-blablabla/#comments</comments>
		<pubDate>Sat, 07 Jul 2007 00:42:23 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Codes]]></category>
		<category><![CDATA[Dicas]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/07/07/xml-to-mysql-transformando-um-arquivo-xml-em-queries-sql-e-blablabla/</guid>
		<description><![CDATA[xml to mysql: Como fazer o reverso indicado aqui:  mysql to xml: Como transformar um resultado de uma query para XML ( de forma simples ) ( de forma simples )
Sugerido aqui, por Robertson Matos
Para o script, vamos utilizar um banco de dados de exemplo. O banco terá a seguinte estrutura:

-- criamos o banco [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=95&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>xml to mysql: Como fazer o reverso indicado <a href="http://phpbr.wordpress.com/2007/03/07/mysql-to-xml-como-transformar-um-resultado-de-uma-query-para-xml-de-forma-simples/#comment-236">aqui:  mysql to xml: Como transformar um resultado de uma query para XML ( de forma simples )</a> ( de forma simples )</p>
<p>Sugerido <a href="http://phpbr.wordpress.com/2007/03/07/mysql-to-xml-como-transformar-um-resultado-de-uma-query-para-xml-de-forma-simples/#comment-236">aqui</a>, por Robertson Matos</p>
<p>Para o script, vamos utilizar um banco de dados de exemplo. O banco terá a seguinte estrutura:</p>
<pre>
<span style="font-style:italic;color:#808080;">-- criamos o banco de dados, caso ainda nao exista</span>
<span style="font-weight:bold;color:#000000;">CREATE</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">DATABASE</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">IF</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">NOT</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">EXISTS</span><span style="color:#000000;"> XML2MYSQL;</span>

<span style="font-style:italic;color:#808080;">-- selecionamos o banco de dados</span>
<span style="font-weight:bold;color:#000000;">USE</span><span style="color:#000000;"> XML2MYSQL;</span>

<span style="font-style:italic;color:#808080;">-- criamos a tabela se nao existir</span>
<span style="font-weight:bold;color:#000000;">CREATE</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">TABLE</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">IF</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">NOT</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">EXISTS</span><span style="color:#000000;"> exemplo (</span>
<span style="color:#000000;">    id_exemplo </span><span style="color:#800000;">INT</span><span style="color:#000000;">(</span><span style="color:#0000ff;">11</span><span style="color:#000000;">) </span><span style="font-weight:bold;color:#000000;">NOT</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">NULL</span><span style="color:#000000;"> AUTO_INCREMENT,</span>
<span style="color:#000000;">    descricao </span><span style="color:#800000;">VARCHAR</span><span style="color:#000000;">(</span><span style="color:#0000ff;">32</span><span style="color:#000000;">) </span><span style="font-weight:bold;color:#000000;">NOT</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">NULL</span><span style="color:#000000;">,</span>
<span style="color:#000000;">    </span><span style="font-weight:bold;color:#000000;">PRIMARY</span><span style="color:#000000;"> </span><span style="font-weight:bold;color:#000000;">KEY</span><span style="color:#000000;">(id_exemplo)</span>
<span style="color:#000000;">)ENGINE=INNODB;</span>
</pre>
<p>O XML de exemplo é este:<br />
demo.xml</p>
<blockquote><p>
<span style="color:#000000;"><br />
<span style="color:#0000BB;">&lt;?xml&nbsp;version</span><span style="color:#007700;">=</span><span style="color:#DD0000;">&#8220;1.0&#8243;</span><span style="color:#0000BB;">?&gt;<br /></span>&lt;resultset&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;line&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;id_exemplo&gt;1&lt;/id_exemplo&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;descricao&gt;Primeiro&nbsp;exemplo&lt;/descricao&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/line&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;line&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;id_exemplo&gt;2&lt;/id_exemplo&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;descricao&gt;Segundo&nbsp;exemplo&lt;/descricao&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/line&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;line&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;id_exemplo&gt;3&lt;/id_exemplo&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;descricao&gt;Terceiro&nbsp;exemplo&lt;/descricao&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/line&gt;<br />&lt;/resultset&gt;<br /></span>
</p></blockquote>
<p>E o script é este:</p>
<blockquote><p>
<span style="color:#000000;"><br />
<span style="color:#0000BB;">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;arquivo&nbsp;xml2mysql.php</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;definimos&nbsp;informacoes&nbsp;para&nbsp;conexao&nbsp;ao&nbsp;banco&nbsp;de&nbsp;dados:<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$banco&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8216;xml2mysql&#8217;</span><span style="color:#007700;">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;nome&nbsp;do&nbsp;banco<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$host&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8216;localhost&#8217;</span><span style="color:#007700;">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;host<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$usuario&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8216;root&#8217;</span><span style="color:#007700;">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;usuario<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$senha&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8221;</span><span style="color:#007700;">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;senha<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;connectamos&nbsp;ao&nbsp;host&nbsp;e&nbsp;selecionamos&nbsp;o&nbsp;banco<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">mysql_connect</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$host</span><span style="color:#007700;">,&nbsp;</span><span style="color:#0000BB;">$usuario</span><span style="color:#007700;">,&nbsp;</span><span style="color:#0000BB;">$senha</span><span style="color:#007700;">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">mysql_select_db</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$banco</span><span style="color:#007700;">);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;esta&nbsp;variavel&nbsp;sera&nbsp;a&nbsp;query&nbsp;utilizada&nbsp;para&nbsp;insercao&nbsp;dos<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;dados&nbsp;no&nbsp;banco,&nbsp;tendo&nbsp;o&nbsp;%d&nbsp;substituido&nbsp;pelo&nbsp;id_exemplo<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;e&nbsp;o&nbsp;%s&nbsp;substituido&nbsp;pela&nbsp;descricao<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$query&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8216;insert&nbsp;into&nbsp;exemplo&nbsp;(id_exemplo,&nbsp;descricao)&nbsp;values&nbsp;(%d,&nbsp;&#8221;%s&#8221;)&#8217;</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;carregamos&nbsp;o&nbsp;conteudo&nbsp;do&nbsp;arquivo&nbsp;XML<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$xml&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">file_get_contents</span><span style="color:#007700;">(</span><span style="color:#DD0000;">&#8216;demo.xml&#8217;</span><span style="color:#007700;">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;transformamos&nbsp;o&nbsp;XML&nbsp;em&nbsp;um&nbsp;objeto,&nbsp;para&nbsp;que&nbsp;possamos&nbsp;trabalhar<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;de&nbsp;forma&nbsp;mais&nbsp;simples&nbsp;com&nbsp;ele<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$sxml&nbsp;</span><span style="color:#007700;">=&nbsp;new&nbsp;</span><span style="color:#0000BB;">SimpleXMLElement</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$xml</span><span style="color:#007700;">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;aqui&nbsp;iteramos&nbsp;por&nbsp;todo&nbsp;o&nbsp;XML:<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;a&nbsp;cada&nbsp;iteracao,&nbsp;$line&nbsp;ira&nbsp;conter&nbsp;um&nbsp;objeto&nbsp;to&nbsp;tipo<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;SimpleXMLElement,&nbsp;sendo&nbsp;o&nbsp;equivalente&nbsp;a:<br />&nbsp;&nbsp;&nbsp;&nbsp;//<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&lt;line&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;id_exemplo&gt;1&lt;/id_exemplo&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;descricao&gt;Primeiro&nbsp;exemplo&lt;/descricao&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&lt;/line&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;//<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">foreach&nbsp;(</span><span style="color:#0000BB;">$sxml&nbsp;</span><span style="color:#007700;">as&nbsp;</span><span style="color:#0000BB;">$linhaAtual</span><span style="color:#007700;">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;aqui&nbsp;vamos&nbsp;obter&nbsp;cada&nbsp;item&nbsp;do&nbsp;xml&nbsp;que&nbsp;seria&nbsp;referente<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;ao&nbsp;campo&nbsp;da&nbsp;tabela.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Necessario&nbsp;cast&nbsp;pelo&nbsp;fato&nbsp;de&nbsp;que&nbsp;a&nbsp;propriedade&nbsp;do&nbsp;objeto<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;tambem&nbsp;é&nbsp;um&nbsp;objeto&nbsp;do&nbsp;tipo&nbsp;SimpleXMLElement<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;(int)&nbsp;</span><span style="color:#0000BB;">$linhaAtual</span><span style="color:#007700;">-&gt;</span><span style="color:#0000BB;">id_exemplo</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$descricao&nbsp;</span><span style="color:#007700;">=&nbsp;(string)&nbsp;</span><span style="color:#0000BB;">$linhaAtual</span><span style="color:#007700;">-&gt;</span><span style="color:#0000BB;">descricao</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;aqui&nbsp;preparamos&nbsp;a&nbsp;query&nbsp;para&nbsp;ser&nbsp;utilizada<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tmpQuery&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">sprintf</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$query</span><span style="color:#007700;">,&nbsp;</span><span style="color:#0000BB;">$id</span><span style="color:#007700;">,&nbsp;</span><span style="color:#0000BB;">$descricao</span><span style="color:#007700;">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;exibimos&nbsp;a&nbsp;query&nbsp;que&nbsp;será&nbsp;executada<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">echo&nbsp;</span><span style="color:#0000BB;">sprintf</span><span style="color:#007700;">(</span><span style="color:#DD0000;">&#8216;Executando&nbsp;query:&nbsp;%s%s&#8217;</span><span style="color:#007700;">,&nbsp;</span><span style="color:#0000BB;">$tmpQuery</span><span style="color:#007700;">,&nbsp;</span><span style="color:#DD0000;">&#8220;\n&#8221;</span><span style="color:#007700;">);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;e&nbsp;aqui&nbsp;executamos&nbsp;a&nbsp;query<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">mysql_query</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$tmpQuery</span><span style="color:#007700;">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><br />
</span>
</p></blockquote>
<p>Sem controle de erros, prevenção de sql injection, blablabla, apenas para ilustrar, como de costume.<br />
Executando temos:</p>
<blockquote><p>
$ php xml2mysql.php<br />
Executando query: insert into exemplo (id_exemplo, descricao) values (1, &#8220;Primeiro exemplo&#8221;)<br />
Executando query: insert into exemplo (id_exemplo, descricao) values (2, &#8220;Segundo exemplo&#8221;)<br />
Executando query: insert into exemplo (id_exemplo, descricao) values (3, &#8220;Terceiro exemplo&#8221;)
</p></blockquote>
<p>E conferindo no banco:</p>
<blockquote><p>
mysql&gt; select * from exemplo;<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
| id_exemplo | descricao        |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
|          1 | Primeiro exemplo |<br />
|          2 | Segundo exemplo  |<br />
|          3 | Terceiro exemplo |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
3 rows in set (0.00 sec)
</p></blockquote>
<p>É isso ai, valeu pela sugestão Robertson</p>
<p>Arquivos:<br />
<a href='http://phpbr.files.wordpress.com/2007/07/xml2mysql.txt' title='xml2mysql'>xml2mysql.php</a><br />
<a href='http://phpbr.files.wordpress.com/2007/07/xml2mysqlsql.txt' title='xml2mysql.sql'>xml2mysql.sql</a><br />
<a href='http://phpbr.files.wordpress.com/2007/07/demoxml.txt' title='demo.xml'>demo.xml</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/95/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/95/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=95&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/07/07/xml-to-mysql-transformando-um-arquivo-xml-em-queries-sql-e-blablabla/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>PHP / refactoring: Como ? (Parte 2)</title>
		<link>http://phpbr.wordpress.com/2007/05/25/php-refactoring-como-parte-2/</link>
		<comments>http://phpbr.wordpress.com/2007/05/25/php-refactoring-como-parte-2/#comments</comments>
		<pubDate>Fri, 25 May 2007 19:47:30 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Artigos]]></category>
		<category><![CDATA[Codes]]></category>
		<category><![CDATA[Dicas]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/05/25/php-refactoring-como-parte-2/</guid>
		<description><![CDATA[Pois é, eu não sabia que teria parte 2, mas este é para ser uma continuação do post PHP / refactoring: Como ?.
Vejamos agora como modificar o nome de uma função e as chamadas para a mesma. O exemplo anterior com algumas modificações será utilizado:

&#60;?php//&#160;arquivo&#160;sample2.php
$foo&#160;&#160;&#160;=&#160;&#8216;foo&#8217;;$hello&#160;=&#160;&#8220;Ola&#160;$foo\n&#8221;;
//&#160;funcao&#160;foo()&#160;no&#160;comentario&#160;nao&#160;sera&#160;modificada
function&#160;foo(){&#160;&#160;&#160;&#160;//&#160;variavel&#160;$foo&#160;nao&#160;sera&#160;modificada&#160;&#160;&#160;&#160;$foo&#160;=&#160;&#8220;dentro&#160;de&#160;foo()\n&#8221;;&#160;&#160;&#160;&#160;echo&#160;$foo;}
//&#160;exibimos&#160;$helloecho&#160;$hello;
//&#160;observe&#160;que&#160;foo()&#160;e&#160;foo&#160;()&#160;sao&#160;diferentes:&#160;//&#160;foo()&#160;equivale&#160;a://&#160;&#160;&#160;&#160;&#160;&#160;T_STRING&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(foo)//&#160;&#160;&#160;&#160;&#160;&#160;(&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(abre&#160;parenteses)////&#160;enquanto&#160;foo&#160;()&#160;equivale&#160;a://&#160;&#160;&#160;&#160;&#160;&#160;T_STRING&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(foo)//&#160;&#160;&#160;&#160;&#160;&#160;T_WHITESPACE&#160;&#160;&#160;&#160;(&#8216;&#160;&#8217;)//&#160;&#160;&#160;&#160;&#160;&#160;(&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(abre&#160;parenteses)////&#160;e&#160;por&#160;esse&#160;motivo&#160;deve&#160;ser&#160;tratado&#160;como&#160;diferentefoo&#160;(&#160;);?&#62;

E a função com exemplo de uso:

&#60;?php//&#160;arquivo&#160;change_function_name.php
/**&#160;*&#160;Funcao&#160;que&#160;ira&#160;modificar&#160;o&#160;nome&#160;de&#160;uma&#160;funcao&#160;*&#160;*&#160;@param&#160;&#160;array&#160;&#160;$tokens&#160;&#160;Array&#160;com&#160;os&#160;tokens&#160;a&#160;serem&#160;analisados&#160;*&#160;@param&#160;&#160;string&#160;$oldName&#160;Nome&#160;da&#160;funcao&#160;que&#160;sera&#160;modificada&#160;*&#160;@param&#160;&#160;string&#160;$newName&#160;Novo&#160;nome&#160;da&#160;funcao&#160;*&#160;@return&#160;string&#160;Codigo-fonte&#160;referente&#160;aos&#160;tokens&#160;fornecidos,&#160;com&#160;a&#160;&#160;*&#160;funcao&#160;devidamente&#160;modificada&#160;*/function&#160;changeFunctionName($tokens,&#160;$oldName,&#160;$newName){&#160;&#160;&#160;&#160;//&#160;variavel&#160;que&#160;ira&#160;conter&#160;o&#160;codigo-fonte&#160;a&#160;ser&#160;retornado&#160;&#160;&#160;&#160;$ret&#160;=&#160;&#8221;;
&#160;&#160;&#160;&#160;//&#160;contador,&#160;marcara&#160;o&#160;indice&#160;do&#160;token&#160;em&#160;uso&#160;&#160;&#160;&#160;$tokenIndex&#160;=&#160;-1;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;como&#160;$tokens&#160;e&#8217;&#160;um&#160;array,&#160;utilizamos&#160;foreach&#160;para&#160;&#160;&#160;&#160;//&#160;passar&#160;por&#160;todos&#160;os&#160;seus&#160;itens&#160;&#160;&#160;&#160;foreach&#160;($tokens&#160;as&#160;$token)&#160;{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$tokenIndex++;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;quando&#160;se&#160;obtem&#160;os&#160;tokens&#160;de&#160;um&#160;arquivo,&#160;eles&#160;vem&#160;em&#160;um&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;array&#160;contendo&#160;o&#160;numero&#160;do&#160;token&#160;e&#160;o&#160;valor&#160;ou&#160;em&#160;uma&#160;string,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;contendo&#160;apenas&#160;o&#160;valor.&#160;Entao&#160;verificamos&#160;qual&#160;o&#160;caso.&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if&#160;(!is_array($token))&#160;{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$tokenName&#160;&#160;=&#160;false;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$tokenValue&#160;=&#160;$token;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}&#160;else&#160;{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$tokenName&#160;&#160;=&#160;token_name($token[0]);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$tokenValue&#160;=&#160;$token[1];&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;verificamos&#160;se&#160;o&#160;token&#160;atual&#160;pode&#160;ser&#160;considerado&#160;uma&#160;funcao&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if&#160;($tokenName&#160;==&#160;&#8216;T_STRING&#8217;)&#160;{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;obtemos&#160;os&#160;dois&#160;proximos&#160;tokens&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$nextToken&#160;&#160;=&#160;$tokens[$tokenIndex&#160;+&#160;1];&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$nnextToken&#160;=&#160;$tokens[$tokenIndex&#160;+&#160;2];
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;aqui&#160;temos&#160;o&#160;seguinte:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;se&#160;o&#160;proximo&#160;token&#160;for&#160;igual&#160;a&#160;&#8221;(&#8220;&#160;E&#160;se&#160;o&#160;valor&#160;do&#160;token&#160;atual&#160;for&#160;igual&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;ao&#160;nome&#160;da&#160;funcao&#160;que&#160;queremos&#160;modificar&#8230;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$flag&#160;&#160;=&#160;($nextToken[0]&#160;==&#160;&#8216;(&#8216;&#160;&#38;&#38;&#160;$tokenValue&#160;==&#160;$oldName);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;&#8230;&#160;OU&#160;o&#160;proximo&#160;token&#160;for&#160;um&#160;espaco&#160;E&#160;o&#160;token&#160;apos&#160;o&#160;proximo&#160;for&#160;igual&#160;a&#160;&#8221;(&#8220;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;E&#160;o&#160;valor&#160;do&#160;token&#160;atual&#160;for&#160;igual&#160;ao&#160;nome&#160;da&#160;funcao&#160;que&#160;queremos&#160;modificar&#8230;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$flag&#160;&#124;=&#160;(@token_name($nextToken[0])&#160;==&#160;&#8216;T_WHITESPACE&#8217;&#160;&#38;&#38;&#160;$nnextToken[0]&#160;==&#160;&#8216;(&#8216;&#160;&#38;&#38;&#160;$tokenValue&#160;==&#160;$oldName);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;&#8230;&#160;entao&#160;modificamos&#160;o&#160;valor&#160;do&#160;token,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if&#160;($flag)&#160;{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$tokenValue&#160;=&#160;$newName;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$ret&#160;.=&#160;$tokenValue;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;continue;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;se&#160;chegou&#160;ate&#160;aqui,&#160;significa&#160;que&#160;nao&#160;e&#8217;&#160;um&#160;token&#160;que&#160;nos&#160;interessa,&#160;apenas&#160;pegamos&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;o&#160;valor&#160;do&#160;token&#160;e&#160;o&#160;adicionamos&#160;ao&#160;final&#160;do&#160;fonte&#160;a&#160;ser&#160;retornado&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$ret&#160;.=&#160;$tokenValue;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;//&#160;retornamos&#160;o&#160;fonte&#160;&#160;&#160;&#160;return&#160;$ret;}
//&#160;exemplo&#160;de&#160;uso&#160;da&#160;funcao
//&#160;obtemos&#160;o&#160;conteudo&#160;do&#160;arquivo&#160;que&#160;iremos&#160;modificar$arquivo&#160;=&#160;file_get_contents(&#8217;sample2.php&#8217;);
//&#160;e&#160;utilizamos&#160;a&#160;funcao&#160;token_get_all&#160;para&#160;obter&#160;todos//&#160;os&#160;tokens&#160;do&#160;arquivo.&#160;Observe&#160;que&#160;tudo&#160;no&#160;script&#160;e&#8217;//&#160;tratado&#160;como&#160;sendo&#160;um&#160;token$tokens&#160;&#160;=&#160;token_get_all($arquivo);
//&#160;modificamos&#160;foo()&#160;para&#160;bar()$bla&#160;=&#160;changeFunctionName($tokens,&#160;&#8216;foo&#8217;,&#160;&#8216;bar&#8217;);
echo&#160;$bla;
?&#62;
Executando:

$ php change_function_name.php
&#60;?php
// arquivo sample2.php
$foo [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=89&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Pois é, eu não sabia que teria parte 2, mas este é para ser uma continuação do post <a href="http://phpbr.wordpress.com/2007/04/15/php-refactoring-como/">PHP / refactoring: Como ?</a>.</p>
<p>Vejamos agora como modificar o nome de uma função e as chamadas para a mesma. O exemplo anterior com algumas modificações será utilizado:</p>
<p><span style="color:#000000;"><br />
<span style="color:#0000BB;">&lt;?php<br /></span><span style="color:#FF8000;">//&nbsp;arquivo&nbsp;sample2.php</p>
<p></span><span style="color:#0000BB;">$foo&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8216;foo&#8217;</span><span style="color:#007700;">;<br /></span><span style="color:#0000BB;">$hello&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8220;Ola&nbsp;$foo\n&#8221;</span><span style="color:#007700;">;</p>
<p></span><span style="color:#FF8000;">//&nbsp;funcao&nbsp;foo()&nbsp;no&nbsp;comentario&nbsp;nao&nbsp;sera&nbsp;modificada</p>
<p></span><span style="color:#007700;">function&nbsp;</span><span style="color:#0000BB;">foo</span><span style="color:#007700;">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;variavel&nbsp;$foo&nbsp;nao&nbsp;sera&nbsp;modificada<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$foo&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8220;dentro&nbsp;de&nbsp;foo()\n&#8221;</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color:#0000BB;">$foo</span><span style="color:#007700;">;<br />}</p>
<p></span><span style="color:#FF8000;">//&nbsp;exibimos&nbsp;$hello<br /></span><span style="color:#007700;">echo&nbsp;</span><span style="color:#0000BB;">$hello</span><span style="color:#007700;">;</p>
<p></span><span style="color:#FF8000;">//&nbsp;observe&nbsp;que&nbsp;foo()&nbsp;e&nbsp;foo&nbsp;()&nbsp;sao&nbsp;diferentes:&nbsp;<br />//&nbsp;foo()&nbsp;equivale&nbsp;a:<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T_STRING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(foo)<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(abre&nbsp;parenteses)<br />//<br />//&nbsp;enquanto&nbsp;foo&nbsp;()&nbsp;equivale&nbsp;a:<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T_STRING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(foo)<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T_WHITESPACE&nbsp;&nbsp;&nbsp;&nbsp;(&#8216;&nbsp;&#8217;)<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(abre&nbsp;parenteses)<br />//<br />//&nbsp;e&nbsp;por&nbsp;esse&nbsp;motivo&nbsp;deve&nbsp;ser&nbsp;tratado&nbsp;como&nbsp;diferente<br /></span><span style="color:#0000BB;">foo&nbsp;</span><span style="color:#007700;">(&nbsp;);<br /></span><span style="color:#0000BB;">?&gt;<br /></span><br />
</span></p>
<p>E a função com exemplo de uso:</p>
<p><span style="color:#000000;"><br />
<span style="color:#0000BB;">&lt;?php<br /></span><span style="color:#FF8000;">//&nbsp;arquivo&nbsp;change_function_name.php</p>
<p>/**<br />&nbsp;*&nbsp;Funcao&nbsp;que&nbsp;ira&nbsp;modificar&nbsp;o&nbsp;nome&nbsp;de&nbsp;uma&nbsp;funcao<br />&nbsp;*<br />&nbsp;*&nbsp;@param&nbsp;&nbsp;array&nbsp;&nbsp;$tokens&nbsp;&nbsp;Array&nbsp;com&nbsp;os&nbsp;tokens&nbsp;a&nbsp;serem&nbsp;analisados<br />&nbsp;*&nbsp;@param&nbsp;&nbsp;string&nbsp;$oldName&nbsp;Nome&nbsp;da&nbsp;funcao&nbsp;que&nbsp;sera&nbsp;modificada<br />&nbsp;*&nbsp;@param&nbsp;&nbsp;string&nbsp;$newName&nbsp;Novo&nbsp;nome&nbsp;da&nbsp;funcao<br />&nbsp;*&nbsp;@return&nbsp;string&nbsp;Codigo-fonte&nbsp;referente&nbsp;aos&nbsp;tokens&nbsp;fornecidos,&nbsp;com&nbsp;a&nbsp;<br />&nbsp;*&nbsp;funcao&nbsp;devidamente&nbsp;modificada<br />&nbsp;*/<br /></span><span style="color:#007700;">function&nbsp;</span><span style="color:#0000BB;">changeFunctionName</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$tokens</span><span style="color:#007700;">,&nbsp;</span><span style="color:#0000BB;">$oldName</span><span style="color:#007700;">,&nbsp;</span><span style="color:#0000BB;">$newName</span><span style="color:#007700;">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;variavel&nbsp;que&nbsp;ira&nbsp;conter&nbsp;o&nbsp;codigo-fonte&nbsp;a&nbsp;ser&nbsp;retornado<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$ret&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#DD0000;">&#8221;</span><span style="color:#007700;">;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;contador,&nbsp;marcara&nbsp;o&nbsp;indice&nbsp;do&nbsp;token&nbsp;em&nbsp;uso<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tokenIndex&nbsp;</span><span style="color:#007700;">=&nbsp;-</span><span style="color:#0000BB;">1</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;como&nbsp;$tokens&nbsp;e&#8217;&nbsp;um&nbsp;array,&nbsp;utilizamos&nbsp;foreach&nbsp;para<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;passar&nbsp;por&nbsp;todos&nbsp;os&nbsp;seus&nbsp;itens<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">foreach&nbsp;(</span><span style="color:#0000BB;">$tokens&nbsp;</span><span style="color:#007700;">as&nbsp;</span><span style="color:#0000BB;">$token</span><span style="color:#007700;">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tokenIndex</span><span style="color:#007700;">++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;quando&nbsp;se&nbsp;obtem&nbsp;os&nbsp;tokens&nbsp;de&nbsp;um&nbsp;arquivo,&nbsp;eles&nbsp;vem&nbsp;em&nbsp;um&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;array&nbsp;contendo&nbsp;o&nbsp;numero&nbsp;do&nbsp;token&nbsp;e&nbsp;o&nbsp;valor&nbsp;ou&nbsp;em&nbsp;uma&nbsp;string,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;contendo&nbsp;apenas&nbsp;o&nbsp;valor.&nbsp;Entao&nbsp;verificamos&nbsp;qual&nbsp;o&nbsp;caso.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">if&nbsp;(!</span><span style="color:#0000BB;">is_array</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$token</span><span style="color:#007700;">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tokenName&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">false</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tokenValue&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">$token</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tokenName&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">token_name</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$token</span><span style="color:#007700;">[</span><span style="color:#0000BB;">0</span><span style="color:#007700;">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tokenValue&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">$token</span><span style="color:#007700;">[</span><span style="color:#0000BB;">1</span><span style="color:#007700;">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;verificamos&nbsp;se&nbsp;o&nbsp;token&nbsp;atual&nbsp;pode&nbsp;ser&nbsp;considerado&nbsp;uma&nbsp;funcao<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">if&nbsp;(</span><span style="color:#0000BB;">$tokenName&nbsp;</span><span style="color:#007700;">==&nbsp;</span><span style="color:#DD0000;">&#8216;T_STRING&#8217;</span><span style="color:#007700;">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;obtemos&nbsp;os&nbsp;dois&nbsp;proximos&nbsp;tokens<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$nextToken&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">$tokens</span><span style="color:#007700;">[</span><span style="color:#0000BB;">$tokenIndex&nbsp;</span><span style="color:#007700;">+&nbsp;</span><span style="color:#0000BB;">1</span><span style="color:#007700;">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$nnextToken&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">$tokens</span><span style="color:#007700;">[</span><span style="color:#0000BB;">$tokenIndex&nbsp;</span><span style="color:#007700;">+&nbsp;</span><span style="color:#0000BB;">2</span><span style="color:#007700;">];</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;aqui&nbsp;temos&nbsp;o&nbsp;seguinte:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;se&nbsp;o&nbsp;proximo&nbsp;token&nbsp;for&nbsp;igual&nbsp;a&nbsp;&#8221;(&#8220;&nbsp;E&nbsp;se&nbsp;o&nbsp;valor&nbsp;do&nbsp;token&nbsp;atual&nbsp;for&nbsp;igual<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;ao&nbsp;nome&nbsp;da&nbsp;funcao&nbsp;que&nbsp;queremos&nbsp;modificar&#8230;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$flag&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;(</span><span style="color:#0000BB;">$nextToken</span><span style="color:#007700;">[</span><span style="color:#0000BB;">0</span><span style="color:#007700;">]&nbsp;==&nbsp;</span><span style="color:#DD0000;">&#8216;(&#8216;&nbsp;</span><span style="color:#007700;">&amp;&amp;&nbsp;</span><span style="color:#0000BB;">$tokenValue&nbsp;</span><span style="color:#007700;">==&nbsp;</span><span style="color:#0000BB;">$oldName</span><span style="color:#007700;">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;&#8230;&nbsp;OU&nbsp;o&nbsp;proximo&nbsp;token&nbsp;for&nbsp;um&nbsp;espaco&nbsp;E&nbsp;o&nbsp;token&nbsp;apos&nbsp;o&nbsp;proximo&nbsp;for&nbsp;igual&nbsp;a&nbsp;&#8221;(&#8220;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;E&nbsp;o&nbsp;valor&nbsp;do&nbsp;token&nbsp;atual&nbsp;for&nbsp;igual&nbsp;ao&nbsp;nome&nbsp;da&nbsp;funcao&nbsp;que&nbsp;queremos&nbsp;modificar&#8230;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$flag&nbsp;</span><span style="color:#007700;">|=&nbsp;(@</span><span style="color:#0000BB;">token_name</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$nextToken</span><span style="color:#007700;">[</span><span style="color:#0000BB;">0</span><span style="color:#007700;">])&nbsp;==&nbsp;</span><span style="color:#DD0000;">&#8216;T_WHITESPACE&#8217;&nbsp;</span><span style="color:#007700;">&amp;&amp;&nbsp;</span><span style="color:#0000BB;">$nnextToken</span><span style="color:#007700;">[</span><span style="color:#0000BB;">0</span><span style="color:#007700;">]&nbsp;==&nbsp;</span><span style="color:#DD0000;">&#8216;(&#8216;&nbsp;</span><span style="color:#007700;">&amp;&amp;&nbsp;</span><span style="color:#0000BB;">$tokenValue&nbsp;</span><span style="color:#007700;">==&nbsp;</span><span style="color:#0000BB;">$oldName</span><span style="color:#007700;">);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;&#8230;&nbsp;entao&nbsp;modificamos&nbsp;o&nbsp;valor&nbsp;do&nbsp;token,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">if&nbsp;(</span><span style="color:#0000BB;">$flag</span><span style="color:#007700;">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$tokenValue&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">$newName</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$ret&nbsp;</span><span style="color:#007700;">.=&nbsp;</span><span style="color:#0000BB;">$tokenValue</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;se&nbsp;chegou&nbsp;ate&nbsp;aqui,&nbsp;significa&nbsp;que&nbsp;nao&nbsp;e&#8217;&nbsp;um&nbsp;token&nbsp;que&nbsp;nos&nbsp;interessa,&nbsp;apenas&nbsp;pegamos<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;o&nbsp;valor&nbsp;do&nbsp;token&nbsp;e&nbsp;o&nbsp;adicionamos&nbsp;ao&nbsp;final&nbsp;do&nbsp;fonte&nbsp;a&nbsp;ser&nbsp;retornado<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#0000BB;">$ret&nbsp;</span><span style="color:#007700;">.=&nbsp;</span><span style="color:#0000BB;">$tokenValue</span><span style="color:#007700;">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF8000;">//&nbsp;retornamos&nbsp;o&nbsp;fonte<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#007700;">return&nbsp;</span><span style="color:#0000BB;">$ret</span><span style="color:#007700;">;<br />}</p>
<p></span><span style="color:#FF8000;">//&nbsp;exemplo&nbsp;de&nbsp;uso&nbsp;da&nbsp;funcao</p>
<p>//&nbsp;obtemos&nbsp;o&nbsp;conteudo&nbsp;do&nbsp;arquivo&nbsp;que&nbsp;iremos&nbsp;modificar<br /></span><span style="color:#0000BB;">$arquivo&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">file_get_contents</span><span style="color:#007700;">(</span><span style="color:#DD0000;">&#8217;sample2.php&#8217;</span><span style="color:#007700;">);</p>
<p></span><span style="color:#FF8000;">//&nbsp;e&nbsp;utilizamos&nbsp;a&nbsp;funcao&nbsp;token_get_all&nbsp;para&nbsp;obter&nbsp;todos<br />//&nbsp;os&nbsp;tokens&nbsp;do&nbsp;arquivo.&nbsp;Observe&nbsp;que&nbsp;tudo&nbsp;no&nbsp;script&nbsp;e&#8217;<br />//&nbsp;tratado&nbsp;como&nbsp;sendo&nbsp;um&nbsp;token<br /></span><span style="color:#0000BB;">$tokens&nbsp;&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">token_get_all</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$arquivo</span><span style="color:#007700;">);</p>
<p></span><span style="color:#FF8000;">//&nbsp;modificamos&nbsp;foo()&nbsp;para&nbsp;bar()<br /></span><span style="color:#0000BB;">$bla&nbsp;</span><span style="color:#007700;">=&nbsp;</span><span style="color:#0000BB;">changeFunctionName</span><span style="color:#007700;">(</span><span style="color:#0000BB;">$tokens</span><span style="color:#007700;">,&nbsp;</span><span style="color:#DD0000;">&#8216;foo&#8217;</span><span style="color:#007700;">,&nbsp;</span><span style="color:#DD0000;">&#8216;bar&#8217;</span><span style="color:#007700;">);</p>
<p>echo&nbsp;</span><span style="color:#0000BB;">$bla</span><span style="color:#007700;">;<br /></span><br />
<span style="color:#0000BB;">?&gt;<br /></span></span></p>
<p>Executando:</p>
<blockquote><p>
$ php change_function_name.php<br />
&lt;?php<br />
// arquivo sample2.php</p>
<p>$foo   = &#8216;foo&#8217;;<br />
$hello = &quot;Ola $foo\n&quot;;</p>
<p>// funcao foo() no comentario nao sera modificada</p>
<p>function bar()<br />
{<br />
    // variavel $foo nao sera modificada<br />
    $foo = &quot;dentro de foo()\n&quot;;<br />
    echo $foo;<br />
}</p>
<p>// exibimos $hello<br />
echo $hello;</p>
<p>// observe que foo() e foo () sao diferentes:<br />
// foo() equivale a:<br />
//      T_STRING        (foo)<br />
//      (               (abre parenteses)<br />
//<br />
// enquanto foo () equivale a:<br />
//      T_STRING        (foo)<br />
//      T_WHITESPACE    (&#8216; &#8216;)<br />
//      (               (abre parenteses)<br />
//<br />
// e por esse motivo deve ser tratado como diferente<br />
bar ( );<br />
?&gt;
</p></blockquote>
<p>Observe que a declaração da função foi modificada ( function bar ) e a chamada à função também foi modificada (bar ( ); ).<br />
Ótimo, esta pronto ? Não&#8230;</p>
<p>Como bem sabemos, é possível executar funções de outras formas em PHP, como por exemplo, utilizando <a href="http://php.net/call_user_func">call_user_func</a>, <a href="http://php.net/eval">eval</a>, variáveis utilizadas como funções ( $foo(); ), funções utilizadas como <a href="http://php.net/manual/language.pseudo-types.php#language.types.mixed">callback</a>, &#8230;</p>
<p>Então, em uma implementação completa desta função, deveriamos nos atentar a estes fatos.<br />
Para alguns casos, seria relativamente fácil criar uma implementação:<br />
- Em eval, poderiamos utilizar a string que esta sendo executada e, recursivamente, chamar a função changeFunctionName para os tokens obtidos para esta string<br />
- Em call_user_func / call_user_func_array, poderiamos verificar se o token atual é um T_STRING e o valor do token é &#8216;call_user_func&#8217;, desta forma. Se for, analisaria-se os tokens seguintes para ver se não teria relação com a função sendo renomeada;</p>
<p>Já em outros casos, seria necessário um pouco mais de malabarismos:<br />
- Em variáveis utilizadas como funções, provavelmente precisariamos de um trackback das variáveis, para verificar se o valor dela não corresponde ao nome da função que desejamos renomear<br />
- Utilizar um grande switch para verificar todas as funções builtin do PHP que utilizam funções como callback</p>
<p>De qualquer forma, para fontes onde não se utilize a função sendo renomeada de forma mais &#8220;avançada&#8221;, este exemplo deve funcionar.</p>
<p><a href="http://phpbr.files.wordpress.com/2007/05/change_var_name.txt">change_var_name.php (exemplo anterior)</a><br />
<a href="http://phpbr.files.wordpress.com/2007/05/change_function_name.txt">change_function_name.php</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/89/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/89/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=89&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/05/25/php-refactoring-como-parte-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>OFF: Netbeans GUI Builder</title>
		<link>http://phpbr.wordpress.com/2007/05/05/off-netbeans-gui-builder/</link>
		<comments>http://phpbr.wordpress.com/2007/05/05/off-netbeans-gui-builder/#comments</comments>
		<pubDate>Sat, 05 May 2007 02:41:19 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Notas]]></category>
		<category><![CDATA[Opiniões]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/05/05/off-netbeans-gui-builder/</guid>
		<description><![CDATA[Nunca gostei do eclipse.
Quando comecei a programar em java (há um tempo já) comecei com netbeans. Gostava muito dele, bem simples, organizado e vinha &#8220;com tudo&#8221; que eu precisava.
Cheguei a instalar e utilizar o eclipse durante um tempo, mas sempre achando o netbeans melhor. E em algum momento que não lembro quando, deixei de utilizar [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=88&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Nunca gostei do eclipse.<br />
Quando comecei a programar em java (há um tempo já) comecei com netbeans. Gostava muito dele, bem simples, organizado e vinha &#8220;com tudo&#8221; que eu precisava.</p>
<p>Cheguei a instalar e utilizar o eclipse durante um tempo, mas sempre achando o netbeans melhor. E em algum momento que não lembro quando, deixei de utilizar essas IDEs, utilizando editores mais simples e mais leves (sentia dor na alma quando utilizava kde+firebird+tomcat+eclipse/netbeans, por isso &#8220;abandonei&#8221;).</p>
<p>Quando passei a trabalhar mais intensivamente com PHP, voltei a utilizar o eclipse com plugins para habilitar desenvolvimento em PHP, e como trabalhava também com java, acabou que o eclipse voltou a tornar-se meu ambiente de desenvolvimento único. Era java e PHP no mesmo local. Simples assim.<br />
E nesse tempo havia esquecido quase que completamente do netbeans, apenas acompanhando de longe o desenvolvimento do matisse, que era um &#8220;gui builder&#8221; em fase alpha dele.</p>
<p>Hoje vejo o estado que está esse &#8220;gui builder&#8221; e&#8230; Tirem 10 minutos e assistam:</p>
<p><a href="http://www.netbeans.org/download/flash/netbeans_6_gui_builder/netbeans_6_gui_builder.html">netbeans 6 gui builder</a></p>
<p>Tão ou mais simples criar uma aplicação em java para desktop quanto o delphi (não, não o delphi4php :) )</p>
<p>Será que fazem isso no eclipse ?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/88/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/88/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=88&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/05/05/off-netbeans-gui-builder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
		<item>
		<title>Link: Comparação de IDES para desenvolvimento em PHP</title>
		<link>http://phpbr.wordpress.com/2007/05/05/link-comparacao-de-ides-para-desenvolvimento-em-php/</link>
		<comments>http://phpbr.wordpress.com/2007/05/05/link-comparacao-de-ides-para-desenvolvimento-em-php/#comments</comments>
		<pubDate>Sat, 05 May 2007 02:09:07 +0000</pubDate>
		<dc:creator>E Silva</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://phpbr.wordpress.com/2007/05/05/link-comparacao-de-ides-para-desenvolvimento-em-php/</guid>
		<description><![CDATA[É um post antigo, mas bem interessante, onde é feita uma comparação entre Eclipse, Komodo, PHP Designer, PhpED, PHPEdit e Zend Studio:
Seven great PHP IDEs compared
Tinha idéia de escrever um post parecido, comparando também (se é que alguns desses podem ser comparados) o jdeveloper da oracle, com &#8220;Oracle PHP Extension for Oracle JDeveloper 10g&#8221;, o [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=87&subd=phpbr&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>É um post antigo, mas bem interessante, onde é feita uma comparação entre Eclipse, Komodo, PHP Designer, PhpED, PHPEdit e Zend Studio:</p>
<p><a href="http://www-128.ibm.com/developerworks/library/os-php-ide/index.html">Seven great PHP IDEs compared</a></p>
<p>Tinha idéia de escrever um post parecido, comparando também (se é que alguns desses podem ser comparados) o <a href="http://www.oracle.com/technology/products/jdev/index.html">jdeveloper</a> da oracle, com <a href="http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/php/index.html">&#8220;Oracle PHP Extension for Oracle JDeveloper 10g&#8221;</a>, o <a href="http://www.codegear.com/products/delphi/php">delphi4php</a>, o <a href="http://www.zend.com/pdt/">pdt</a>, o <a href="http://quanta.kdewebdev.org/">quanta</a>, o <a href="http://www.kate-editor.org/">kate</a>, o <a href="http://www.kdevelop.org/">kdevelop</a>, o <a href="http://www.adobe.com/products/dreamweaver/">dreamweaver</a>, o <a href="http://www.vim.org/">vim</a> e o <a href="http://www.ibiblio.org/mc/">mcedit</a> (este por ser o editor que uso atualmente   : ) ).</p>
<p>Além desses, há outra dezena que poderia entrar na comparação / descrição, mas por não ter muito tempo pra isso, acho que vale a dica da comparação do link.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/phpbr.wordpress.com/87/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/phpbr.wordpress.com/87/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phpbr.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phpbr.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phpbr.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phpbr.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phpbr.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phpbr.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phpbr.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phpbr.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phpbr.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phpbr.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phpbr.wordpress.com&blog=720219&post=87&subd=phpbr&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://phpbr.wordpress.com/2007/05/05/link-comparacao-de-ides-para-desenvolvimento-em-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f998e345bf02f8f175d1a10ed952f53b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phpbr</media:title>
		</media:content>
	</item>
	</channel>
</rss>