|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-05-14 17:15 UTC] 1000235409 at smail dot shnu dot edu dot cn
Description:
------------
A fatal error generates when a class extends from an abstract class and implements
from an interface both with a same named abstract (all methods defined inside
interfaces are abstract) method inside.
Test script:
---------------
<?php
abstract class TAbstractParam {
public abstract function getType(); //getType
}
interface IParam {
public function getType(); //getType again.
}
class TPrimativeParam extends TAbstractParam implements IParam {
public function getType() {return 'VARCHAR'; } //another getType, the fatal error goes here.
}
Expected result:
----------------
[just nothing...]
Actual result:
--------------
Fatal error: Can't inherit abstract function IParam::getType() (previously
declared abstract in TAbstractParam) in E:\foo.php on line 10
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
I have adapted those code(see it below) into delphi(object pascal, on Delphi2010), however, nothing wrong at all. so i think it should be a wrong oop logic in php5(5.2 included also, since i've tested then...) Type TAbstractParam = Class(TInterfacedObject) Procedure getType(); Virtual; Abstract; End; IParam = Interface Procedure getType(); End; TPrimativeParam = Class(TAbstractParam, IParam) Procedure getType(); End; //Other code omitted...<?php abstract class TAbstractParam { protected $FValue = null; public abstract function getType(); //getType public function Dump() { return "TYPE=" . $this->getType() . " VALUE=" . $this->FValue; } } interface IParam { public function getType(); //getType again. } class TStringParam extends TAbstractParam implements IParam { public function getType() {return 'VARCHAR'; } //another getType, the fatal error goes here. } see this example, please...