News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Weier O'Phinney's Blog:
On Visibility in OOP
June 29, 2012 @ 09:52:03

Matthew Weier O'Phinney has a new post to his blog today looking at visibility in OOP in PHP - less about the features the language offers and more about the theory of their use.

I'm a big proponent of object oriented programming. OOP done right helps ease code maintenance and enables code re-use. Starting in PHP, OOP enthusiasts got a whole bunch of new tools, and new tools keep coming into the language for us with each minor release. One feature that has had a huge impact on frameworks and libraries has been available since the earliest PHP 5 versions: visibility.

He covers a bit of the syntax and features of public, private and protected and mentions a keyword not often seen in PHP applications - final. The reason all of this came up was work on annotation support in Zend Framework 2 and some difficulty in integrating it with Doctrine support. The "final" status of the class was part of the problem, and after a a lot of copy & pasting he decided on a different tactic - using its public API to try to work around the problem.

In sum: because the class in question was marked final and had private members, I found myself forced to think critically about what I wanted to accomplish, and then thoroughly understand the public API to see how I might accomplish that task without the ability to extend.
0 comments voice your opinion now!
visibility oop final annotation doctrine


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: Three Advanced Object-Oriented PHP Features You Need to Know

Leaseweb Labs Blog: Tuning Zend framework and Doctrine

Job Posting: Senior OO/PHP 5.0 Architect (Boston, MA)

Vexxhost.com: Top 5 new (and cool!) features in PHP5 that you probably haven't heard of

CodeBetter.com: Is PHP the new VB6?


Community Events





Don't see your event here?
Let us know!


developer series language laravel tips zendserver framework application deployment list code release community development conference interview podcast introduction threedevsandamaybe api

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework