News Feed
Jobs Feed
Sections




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

OpenSky Blog:
Inheritance in PHP, or why you want to use an Interface or an Abstract class...
November 30, 2010 @ 11:09:17

On the OpenSky blog today there's a new post about object oriented development and class structure. More specifically about how you should use interfaces and abstract classes if you want to truly lock down the methods of your classes.

Every class has an interface, every class can be typehinted as a method argument, typehint lets you specify the collaborator requirements. Not every typehint is the same.

He includes an example of how, despite a "BankAccount" type hint, classes for different types of accounts can be created and methods from the parent can be overwritten. To help remedy the situation, he shows a more structured example that uses interfaces/an abstract class to define the BankAccount structure, setting requirements on the child class functionality.

0 comments voice your opinion now!
typehint interface abstract class example structure


blog comments powered by Disqus

Similar Posts

Developer Tutorials: Debugging PHP code using debug_backtrace

php|architect: Final days of our iPod Training Promo!

OpenSky Blog: Inheritance in PHP, or why you want to use an Interface or an Abstract class...

Tobias Schlitt\'s Blog: A sensible place for a fluent interface

ThinkPHP Blog: Spooky Action at not so much Distance


Community Events











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


application podcast language code symfony2 security release opinion hhvm component overview install facebook hack introduction framework composer example unittest package

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