ID:               28158
 Comment by:       ah08010-zend at yahoo dot com
 Reported By:      dcahh at gmx dot de
 Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: XP Pro
 PHP Version:      5CVS-2004-04-26 (dev)
 New Comment:

Interfaces need, at a minimum, the ability to regulate the default
public "interface" of their implementors.

This includes specifically UNpublicizing the "default" public methods: 
__(con|de)struct, __call, __get, __set, etc.

Even if the interface vs. abstract class is valid, it should still be
possible to mark __construct as private for e.g., Singleton behavior.

=Austin


Previous Comments:
------------------------------------------------------------------------

[2004-04-26 17:43:48] dcahh at gmx dot de

Yes, but is it correct that one can not declare a protected function in
an abstract class as long as same implements an interface?

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

[2004-04-26 17:34:41] [EMAIL PROTECTED]

interfaces are, by definition, public.
Abstract classes are not the same as interfaces.

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

[2004-04-26 15:44:22] dcahh at gmx dot de

Description:
------------
I can't have an abstract class provide it's functions protected to it's
child classes, since I'm able to declare only public functions within an
interface.

Reproduce code:
---------------
<?php

        interface AnyClassInterface {

                protected function doSomething ($sTest);

        }

        abstract class AnyClassAbstract {

                protected function doSomething ($sTest) {

                        echo $sTest;

                }

        }

        class AnyClass {

                public funtion __construct() {

                        $this->doSomething ('Hello World');

                }

        }

        $oAnyObject = new AnyClass();

?>

Expected result:
----------------
One should be able to declare a function in an interface to be
protected, so that classes extending the abstract class, which is
implementing the interface is able to provide it's functions only to
child-classes and to protect them from foreign classes.

Actual result:
--------------
Fatal error: Access type for interface method
AnyClassInterface::doSomething() must be omitted or declared public in
D:\apache-webroot\test\testphp\php5.php on line 5


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


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

Reply via email to