Re: Re: Is there a simple way to enforce a private method in a subclass?
| From: | Richard Quadling | Date: | Wed, 22 Dec 2010 09:26:35 +0000 |
| Subject: | Re: Re: Is there a simple way to enforce a private method in a subclass? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310215@lists.php.net to get a copy of this message | ||
On 21 December 2010 19:12, Carlos Medina <info@simply-networks.de> wrote:
> Am 21.12.2010 17:36, schrieb Richard Quadling:
>>
>> Hi.
>>
>> If I have an abstract class of Task and I want all subclasses of Task
>> to have a private method _runTask, is there a way to enforce this?
>>
>> Currently an abstract private function in an abstract class isn't allowed.
>>
>> Fatal error: Abstract function Task::_runTask() cannot be declared
>> private in D:\PHP\Includes\Task.php on line 91
>>
>> Now I'm pretty sure there are valid reasons for this, but, for me, the
>> key part here is the "abstract" modifier.
>>
>> This should be read first and foremost and simply say that somewhere
>> in the subclasses, this method must defined. And if it must be defined
>> as private, then so be it.
>>
>> Richard.
>>
>
>
> Hi Richard,
> okay you want to use an abstract class (not instantiable) with a private
> abstract method. I think this doesnt make sense. And i think, PHP does not
> allow this because the inheritance constraint will be failed (you can use
> only in the class itself).
>
> Regards
>
> Carlos
Thanks for that. Things were getting too complicated because I had 2
significantly different features in 1 class. Now I've got 2 interfaces
(TaskInterface and TaskControllerInterface), things make more sense to
me.
Richard.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY