[geeklog-devel] GL2: abstract classes in PHP?

Tony Bibbs tony at tonybibbs.com
Mon Mar 10 09:39:41 EST 2003


Yeah, this is interesting and requires a look.  I think in most cases I 
was just counting on the developers to read the code for the comments 
which state roughly "hey, this is an abstract class, don't instantiate 
this directly..."

I have been religiously entering PHPDoc comments so when an alpha of the 
GL2 engine is ready I can distribute the docs with it.

--Tony

 On Fri, 7 Mar 
2003, Chris Franklin wrote:

> 
> I'm not sure if this would add value to GL2 (i haven't thoroughly reviewed tony's OO code yet) but this is an interesting article on how to implement the notion of abstract classes on php. I could see if being applied to represent the top-level abstract class for something like the item db table.
> Anyway, it's basically just a snippet that goes in the constructor:
> 
> class Control
> {
>     function Control()
>   {
>     /*
>      * Do not allow instantiation of Control class.
>      * Prevent non subclass from calling constructor.
>      */
>     if ( !is_subclass_of($this, "Control") ) {
>       trigger_error("Control instantiation from non subclass.", E_USER_ERROR);
>       return NULL;
>     }
>   }
>   
>   function on() {}         // Turn on a device.
>   function off() {}        // Turn off a device.
>   function getStatus() {}  // Get the status of a device.
> }
> ?>
> 
> Here's full article:
> http://www.phpbuilder.com/columns/griffin20030207.php3?page=1
> 
> -C
> 
> 
> 

-- 
Tony Bibbs          "I guess you have to remember that those who don't
tony at tonybibbs.com  hunt or fish often see those of us who do as      
                    harmlessly strange and sort of amusing. When you  
                    think about it, that might be a fair assessment." 
                    --Unknown





More information about the geeklog-devel mailing list