Req #53081 [Com]: why you should bring back abstract static methods

From: Date: Wed, 20 Oct 2010 14:47:43 +0000
Subject: Req #53081 [Com]: why you should bring back abstract static methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155370@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53081&edit=1

 ID:                 53081
 Comment by:         giorgio dot liscio at email dot it
 Reported by:        giorgio dot liscio at email dot it
 Summary:            why you should bring back abstract static methods
 Status:             Bogus
 Type:               Feature/Change Request
 Package:            Class/Object related
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

i know... could someone analyze my request please? i know that a lot of
bug reports are bogus, but not all


Previous Comments:
------------------------------------------------------------------------
[2010-10-17 13:59:48] cmanley at xs4all dot nl

Georgio,
Your example makes perfect sense. I just wish the bug handlers wouldn't
be so rude 
as to flag valid reports as bogus when users spend effort to report
these bugs 
with examples.

There's nothing bad about having abstract static methods in a language
that 
finally supports static inheritance (since PHP 5.3). This is normal
practice in 
other languages too so E_STRICT shouldn't be emitted.

------------------------------------------------------------------------
[2010-10-17 02:56:08] giorgio dot liscio at email dot it

simplified case

abstract class AFSItem
{
     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 File extends AFSItem
{
     protected static function             isValid      ($fullPath)  //
implementation
     {
         return is_file($fullPath);
     }
}

class Dir extends AFSItem
{
     protected static function             isValid      ($fullPath)  //
implementation
     {
         return is_dir($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;
     }
}

------------------------------------------------------------------------
[2010-10-17 02:03:36] cmanley at xs4all dot nl

This bug (emitting E_STRICT for abstract static methods in PHP 5.3 while
static 
inheritance has finally been implemented) leads to another bug that I
recently 
submitted: http://bugs.php.net/bug.php?id=53086
These are definately different bugs, but this bug spawns the other one
which is 
more catestrophic.

If you don't see the bug, then add E_STRICT to your error reporting:
error_reporting(E_ALL | E_STRICT);

------------------------------------------------------------------------
[2010-10-16 20:23:31] giorgio dot liscio at email dot it

Strict Standards: Static function cA::B() should not be abstract in
..\www\index.php on line 6

5.3.3

------------------------------------------------------------------------
[2010-10-16 19:42:48] rasmus@php.net

Which strict warning do you get?  I don't see one.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=53081


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


Thread (25 messages)

« previous php.bugs (#155370) next »