Edit report at https://bugs.php.net/bug.php?id=54003&edit=1

 ID:                 54003
 Comment by:         dagguh at gmail dot com
 Reported by:        giorgio dot liscio at email dot it
 Summary:            re-enable abstract static methods
 Status:             Open
 Type:               Feature/Change Request
 Package:            Class/Object related
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

1. Don't use LSB next time.
2. Use normal inheritance instead.
3. WONTFIX


Previous Comments:
------------------------------------------------------------------------
[2012-03-06 04:19:14] cgili at yahoo dot com

Inheritance and method override is something really important on PHP, it's 
important to redefine not only the methods but also the parameters they take, 
for instance, you have a class Rectangle with a method called Area that 
calculates the area in m2 by requiring the height and width, now you want to 
create a Cube class extending the Rectangle class, and override the function 
Area to calculate the area in cubic meters, the formula is different and the 
parameters are 3, height, width and deep. It's the very "BASIC" definition of 
Class inheritance and Method Overriding.

------------------------------------------------------------------------
[2011-02-13 00:14:32] giorgio dot liscio at email dot it

Description:
------------
hi, please read carefully my request before trash this

since static inheritance is now implemented in php, enabling this again can 
provide an awesome natural feature of the language

I talked with some php hackers, and they agree with me, but in past, I did not 
have good news about this:

I'm sure my example makes totally sense, and this should stay disabled only if 
there are technical limitations that do not matter with the good logic of my 
example

in practice, I can understand WONT FIX, but not BOGUS

abstract class AFileSystemItem
{
     public static function                getIfValid   ($fullPath)
     {
          // i use static::isValid to get the method defined in the called class
          if(static::isValid($fullPath)) return new static($fullPath);
     }
     protected function                    __construct  ($fp){}

     // i want to force real classes to implement a way to check a path before 
instance an object
     protected abstract static function    isValid      ($fullPath); // 
abstract declaration
}

class Dir extends AFileSystemItem
{
     protected static function             isValid      ($fullPath)  // 
implementation
     {
         return is_dir($fullPath);
     }
}

class File extends AFileSystemItem
{
     protected static function             isValid      ($fullPath)  // 
implementation
     {
         return is_file($fullPath);
     }
}

class Image extends File
{
     protected static function             isValid      ($fullPath)  // 
implementation with override
     {
         if(parent::isValid($fullPath) AND (bool)getimagesize($fullPath)) 
return true; return false;
     }
}



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=54003&edit=1

Reply via email to