From:             
Operating system: Windows XP SP3
PHP version:      5.2SVN-2010-03-29 (snap)
Package:          Class/Object related
Bug Type:         Bug
Bug description:Abstract __construct constructor argument list not enforced

Description:
------------
PHP Version = 5.2.6.6



I cannot seem to enforce a class's __construct argument list by defining an
abstract constructor in the base class. This can, however, be achieved as
expected by using an object interface.



This was mistakenly reported as not working for interfaces either in bug
#43557 (closed).

Test script:
---------------
class Type1 {} //for demo purposes

class Type2 {} //for demo purposes



abstract class BaseClass {

   abstract public function __construct(Type1 $foo, Type2 $bar);

}



class ExtendedClass extends BaseClass {

   public function __construct() {

      //expected - fatal error as argument list doesn't match

      //actually happens - nothing, script continues as normal

   }

}



interface SomeInterface {

   public function __construct(Type1 $foo, Type2 $bar);

}



class InterfacedClass implements SomeInterface {

   public function __construct() {

      //generates fatal error as expected

   }

}

Expected result:
----------------
Fatal error when declaring ExtendedClass and InterfacedClass as abstract
and concrete method signatures are different.

Actual result:
--------------
Only a fatal error when declaring InterfacedClass, no error when declaring
ExtendedClass.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51421&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51421&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51421&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51421&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51421&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51421&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51421&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51421&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51421&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51421&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51421&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51421&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51421&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51421&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51421&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51421&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51421&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51421&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51421&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51421&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51421&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51421&r=mysqlcfg

Reply via email to