# Protected methods in interfaces

- Thread: https://externals.io/message/11941
- Original archive: https://news-web.php.net/php.internals/11941
- Started by Ferdinand Beyer on 2004-08-05T15:01:42+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #11941 — Ferdinand Beyer — 2004-08-05T15:01:42+00:00

URL: https://externals.io/message/11941#11941

Trying to write a singleton interface:

interface Singleton {
    // Disallow public construction
    protected function __construct();

    public static function getInstance();
}

I got an error saying I was not allowed to declare the constructor 
protected - I should either use public or omit it.

Why can't I instruct Singleton-classes to use protected constructors? 
Is this expected behavior or may I file a bug report?

-- 
Ferdinand Beyer
<fb@fbeyer.com

---

## #11943 — Marcus Boerger — 2004-08-05T17:32:05+00:00

URL: https://externals.io/message/11941#11943 · In reply to: #11941

Hello Ferdinand,

Thursday, August 5, 2004, 5:01:42 PM, you wrote:

> Trying to write a singleton interface:

> interface Singleton {
>     // Disallow public construction
>     protected function __construct();

>     public static function getInstance();
> }

> I got an error saying I was not allowed to declare the constructor 
> protected - I should either use public or omit it.

> Why can't I instruct Singleton-classes to use protected constructors? 
> Is this expected behavior or may I file a bug report?

All interface methods must be public - that's the point behind interfaces.

regards
marcus

---

## #11944 — Jason Garber — 2004-08-05T17:51:01+00:00

URL: https://externals.io/message/11941#11944 · In reply to: #11943

Hello Marcus,

  Can abstract methods be protected?

-- 
Best regards,
 Jason                            mailto:jason@ionzoft.com

Thursday, August 5, 2004, 1:32:05 PM, you wrote:

MB> Hello Ferdinand,

MB> Thursday, August 5, 2004, 5:01:42 PM, you wrote:

> > […]

> > […]

> > […]

> > […]

> > […]

MB> All interface methods must be public - that's the point behind interfaces.

MB> regards
MB> marcus

---

## #11945 — George Schlossnagle — 2004-08-05T17:59:14+00:00

URL: https://externals.io/message/11941#11945 · In reply to: #11944

> Hello Marcus,
>
>   Can abstract methods be protected?

No.

George
