<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sat, 18 May 2013 21:09:41 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Chris Hartjes' Blog: Metatesting: Extending Your Testing Tools]]></title>
      <guid>http://www.phpdeveloper.org/news/17851</guid>
      <link>http://www.phpdeveloper.org/news/17851</link>
      <description><![CDATA[<p>
<i>Chris Hartjes</i> has had a few posts about "metatesting" already and in <a href="http://www.littlehart.net/atthekeyboard/2012/04/19/metatesting-extending-your-testing-tools/">this latest article</a> he takes the series one more step. He looks at moving outside of the current toolset and expanding on them to meet your testing needs.
</p>
<blockquote>
While <a href="http://phpunit.de/">PHPUnit</a> is awesome out of the box, it still lacks some tools that are required to do things like test protected class methods or assign values to protected class attributes. Lucky for me we have an awesome testing engineer at Kaplan named <a href="https://twitter.com/FreshWillisms">Will Parker</a> who has shown me some ways that they have extended PHPUnit itself to make testing certain things easier.
</blockquote>
<p>
<i>Chris</i> talks about things like testing protected methods (easy thanks to a helper) and checking the value of a class property. The key to both of them lies in using PHP's own <a href="http://php.net/reflection">Reflection</a> functionality to alter properties on the class objects themselves.
</p>]]></description>
      <pubDate>Mon, 23 Apr 2012 11:27:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Volker Dusch's Blog: An introduction to PHPUnits @covers annotation]]></title>
      <guid>http://www.phpdeveloper.org/news/17085</guid>
      <link>http://www.phpdeveloper.org/news/17085</link>
      <description><![CDATA[<p>
<a href="http://phpunit.de">PHPUnit</a> is one of the most widely used unit testing tools for PHP applications. It comes packed with features, some that are commonly used and some not so much. In <a href="http://edorian.posterous.com/an-introduction-to-phpunits-covers-annotation">a new post to his blog</a> today <i>Volker Dusch</i> looks at one specific feature - the "@covers" annotation you can use in your tests' comments to specify which functionality you're actually testing.
</p>
<blockquote>
One of the goals of your test suite and the coverage report is to make you trust in your code base and to remove the fear of changing something that needs to be changed. [...] You shouldn't think "Well yes that a 100% but a lot of that just comes from that big integration test and I don't know if the class is really tested!". [...] Thankfully PHPUnit offers a way to drastically increase your confidence in what you actually have tested.
</blockquote>
<p>
Using the "@covers" annotation on your test method docblocks gives you one more level of confidence in what's being tested and can help make for clearer updating down the road. He also mentions using them to provide extra insight into protected methods in your code and where the test coverage for them really lies.
</p>]]></description>
      <pubDate>Fri, 04 Nov 2011 09:55:32 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Till Klampaeckel's Blog: RFC: Mocking protected methods]]></title>
      <guid>http://www.phpdeveloper.org/news/16481</guid>
      <link>http://www.phpdeveloper.org/news/16481</link>
      <description><![CDATA[<p>
<i>Till Klampaeckel</i> has <a href="http://till.klampaeckel.de/blog/archives/158-RFC-Mocking-protected-methods.html">a new post</a> to his blog today looking at the method he's found (through some help from others) to be able to mock out protected methods in his unit tests.
</p>
<blockquote>
I wrote a couple tests for a small CouchDB access wrapper today. But when I wrote the implementation itself, I realized that my class setup depends on an actual CouchDB server being available and here my journey began.
</blockquote>
<p>
It was his first experience trying to mock out parts of a class, and he found it a bit difficult to use even after reading <a href="http://sebastian-bergmann.de/archives/881-Testing-Your-Privates.html">this article</a> from <i>Sebastian Bergmann</i>. He ended up, as a first solution, making a "fake" (a term from Ruby testing) that just returned the basic JSON string of an error. Thanks to comments on the post, though, he was able to come up with a more correct solution using getMock() to create a stub and apply an expects() to his "makeRequest" method.
</p>]]></description>
      <pubDate>Thu, 16 Jun 2011 13:48:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[RubySource.com: Confessions of a Converted PHP Developer: On Visibility and Privates]]></title>
      <guid>http://www.phpdeveloper.org/news/16331</guid>
      <link>http://www.phpdeveloper.org/news/16331</link>
      <description><![CDATA[<p>
From RubySource.com there's a new post from a confessed developer who moved from PHP to Ruby about <a href="http://rubysource.com/php-developer-on-visibility-and-privates/">PHP's private visibility rules</a> and how they compare to Ruby's.
</p>
<blockquote>
Alright class - today I'm here to talk about the differences and similarities that PHP and Ruby have when it comes to object properties, methods, and their visibility - how you create variables inside classes, and how you can interact with them.
</blockquote>
<p>
He compares the private properties in PHP classes to the corresponding handling in Ruby, including the getters and setters to go with them. There's also a look at class visibility settings in Ruby.
</p>]]></description>
      <pubDate>Thu, 12 May 2011 10:49:52 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Invalid Protected Resource URL in pecl_oauth]]></title>
      <guid>http://www.phpdeveloper.org/news/16180</guid>
      <link>http://www.phpdeveloper.org/news/16180</link>
      <description><![CDATA[<p>
In a quick post to her blog today, <i>Lorna Mitchell</i> talks about <a href="http://www.lornajane.net/posts/2011/Invalid-Protected-Resource-URL-in-Pecl_Oauth">an issue with pecl_outh</a> tat came up during her development of a new API. A strange fatal error message was breaking her connection.
</p>
<blockquote>
I'd gone through all the handshaking steps, got the acces token and was ready to start talking to the service itself. However when I tried to call OAuth::fetch, I got an error message: Fatal error: Uncaught exception 'OAuthException' with message 'Invalid protected resource url, unable to generate signature base string'
</blockquote>
<p>
As it turns out, the issue was obscure - the address she was connecting to was missing a training slash (http://api.localhost versus http://api.localhost/) and it was causing the OAuth fetch to fail (apparently undocumented). If you're interested in some of the other things that have come up in her work with OAuth on the project, <a href="http://www.lornajane.net/plugin/tag/oauth">see here</a>.
</p>]]></description>
      <pubDate>Tue, 12 Apr 2011 10:16:03 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Vance Lucas' Blog: Protected vs Private Scope: Arrogance, Fear and Handcuffs]]></title>
      <guid>http://www.phpdeveloper.org/news/16148</guid>
      <link>http://www.phpdeveloper.org/news/16148</link>
      <description><![CDATA[<p>
<i>Vance Lucas</i> has tossed his hat into the ring in the debate about private versus protected scope in PHP projects with <a href="http://www.vancelucas.com/blog/protected-vs-private-scope-arrogance-fear-and-handcuffs/">this new post</a> to his blog.
</p>
<blockquote>
The age old private vs protected debate has been re-ignited in the PHP community recently following the decision of Doctrine2 and Symfony2 to make all class methods private until there is a very clear and proven reason to change them to protected or public. The intention is a good one - to ensure they are providing a clear and stable API through intentional and known extension points that they can better test and support. [...] The problem is that this kind of thinking is a slippery slope that kills the spirit of programming.
</blockquote>
<p>
He suggests that, by limiting the scoping down to private, you're taking away the very thing that gets most people excited about third-party tools - the extensibility. In his opinion, it sends a strong message to other developers that they're "not welcome" to make suggestions or updates to the application/tool. 
</p>]]></description>
      <pubDate>Tue, 05 Apr 2011 10:45:53 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Stefan Koopmanschap's Blog: My privates are not public, they are protected ]]></title>
      <guid>http://www.phpdeveloper.org/news/14814</guid>
      <link>http://www.phpdeveloper.org/news/14814</link>
      <description><![CDATA[<p>
<i>Stefan Koopmanschap</i> has <a href="http://www.leftontheweb.com/message/My_privates_are_not_public_they_are_protected">spoken up in response</a> to some of the comments about OOP design, specifically in using the private scope in your applications. Overall, <i>Stefan</i> agrees and thinks that this access prevents possible extension which goes against the whole point of writing open source software.
</p>
<blockquote>
I agree with pro-private people that it is important to have a good API design and to use that to protect less experienced developers from making mistakes, however one should never assume that the developers using your libraries, especially Open Source libraries, are less than yourself. [...] I definitely am not in favor of simply opening up the complete library to every developer though. By making a clear decision on which methods are public and which methods are protected you will ensure that people simply implementing your library will use the API that you have taken the time designing.
</blockquote>
<p>
His <a href="http://www.leftontheweb.com/message/My_privates_are_not_public_they_are_protected">does note</a>, however, that there are cases when a private scope is valid - usually when it involves a planned, architected product where it is someone's responsibility to have that access controlled.
</p>]]></description>
      <pubDate>Mon, 19 Jul 2010 13:58:12 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ivo Jansch's Blog: Good use of public, private and protected in OO class design]]></title>
      <guid>http://www.phpdeveloper.org/news/14811</guid>
      <link>http://www.phpdeveloper.org/news/14811</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Ivo Jansch</i> responds to some of the recent comments about scoping in PHP applications with some <a href="http://www.jansch.nl/2010/07/19/good-use-of-public-private-and-protected-in-oo-class-design/">thoughts of his own</a> (someone spurred on by the <a href="http://symfony-project.org">Symfony</a> project saying that "private is evil").
</p>
<blockquote>
I don't care much about Symfony as I'm not a user, but it turned to a discussion on OO theory when Stefan <A href="http://www.leftontheweb.com/message/My_privates_are_not_public_they_are_protected">defended the position</a> by claiming that you 'should have the right to extend a class's methods if it doesn't support the use case you have'.
</blockquote>
<p>
He also mentions the agreeing opinions of <a href="http://twitter.com/mtabini/status/18867470296">Marco Tabini</a> and <a href="http://twitter.com/tswicegood/status/18864493405">Travis Swicegood</a>. <i>Ivo</i> gives an example of a piece of code that uses all three states - public, protected and private - as a use case for his later statements. In his opinion, removing the private/protected scoping from the picture only helps those looking to make it easier to derive information from the class rather than fine-tuning what can be called.
</p>
<p>
Be sure to <a href="http://www.jansch.nl/2010/07/19/good-use-of-public-private-and-protected-in-oo-class-design/#comments">read the comments</a> on this one - there's lots of great thoughts from community members in there.
</p>]]></description>
      <pubDate>Mon, 19 Jul 2010 10:57:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint PHP Blog: How to Expose PHP's Private Parts]]></title>
      <guid>http://www.phpdeveloper.org/news/11385</guid>
      <link>http://www.phpdeveloper.org/news/11385</link>
      <description><![CDATA[<p>
On the SitePoint PHP Blog <i>Troels Knak-Nielsen</i> has <A href="http://www.sitepoint.com/blogs/2008/11/11/how-to-expose-phps-private-parts/">worked up a way</a> to "expose PHP's private parts" when it comes to finding out more about the object/variable he's working with (without a usual <a href="http://www.php.net/print_r">print_r</a> or <a href="http://www.php.net/var_dump">var_dump</a>).
</p>
<blockquote>
I've been tinkering with dumping PHP objects, and have found myself constantly running into a brick wall. The output from <a href="http://docs.php.net/manual/en/function.print-r.php">print_r</a> and friends is fine in some contexts, but for larger structures, it would be nice to tidy the output up a bit and wrap it in some HTML.
</blockquote>
<p>
His solution is to serialize the object into a string (keeping all related meta information) that can be passed around and parsed back into its original form for debugging. He's included the script that works bye taking in the string and manually parsing it back out into its parts into a useful array.
</p>]]></description>
      <pubDate>Tue, 11 Nov 2008 09:32:14 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Debuggable Blog: Programming Psychology II: Private methods ]]></title>
      <guid>http://www.phpdeveloper.org/news/10560</guid>
      <link>http://www.phpdeveloper.org/news/10560</link>
      <description><![CDATA[<p>
According to <i>Felix Geisendorfer</i>'s <a href="http://www.debuggable.com/posts/programming-psychology-ii-private-methods:481ed862-b0d8-4a0e-9247-165c4834cda3">newest post</a> on the Debuggable blog, he thinks that "private and protected methods and properties are one of the most stupid concepts of OOP."
</p>
<blockquote>
This is a thought I first shared at <a href="http://debuggable.com/posts/cakefest-orlando-2008-summary:480f4dd6-6404-4774-a771-4e8fcbdd56cb">CakeFest Orlando</a> this year, but could not explain properly at the time.
</blockquote>
<p>
He illustrates with an example of a protected "balance" variable in a BankAccount class. Sure, it's marked as private but less skilled programmers might not use it that way. He recommends a method without the getters/setters to help make the usage of the variable a bit simpler. He also suggests that using protected/private scoping helps to promote "crappy code" - using them to provide a sort of protection for code that you either don't want getting used or hiding it away so the API can't get at it.
</p>]]></description>
      <pubDate>Tue, 08 Jul 2008 08:44:58 -0500</pubDate>
    </item>
  </channel>
</rss>
