PHP Interface: Specify ANY visibility PHP Interface: Specify ANY visibility php php

PHP Interface: Specify ANY visibility


Methods you declare in Interfaces should be public. You define a contract with an interface. Any non-public methods would be implementation details and those do not belong into an Interface. As the name implies implementation details should go into the concrete classes implementing the interface.

From Wikipedia:

Programming to the interface

The use of interfaces allows a programming style called programming to the interface. The idea behind this is to base programming logic on the interfaces of the objects used rather than on internal implementation details. Programming to the interface reduces dependency on implementation specifics and makes code more reusable.[7] It gives the programmer the ability to later change the behavior of the system by simply swapping the object used with another implementing the same interface.


A interface is a contract between 2 parties, a agreement how they communicate.

It makes no sense to make methods protected or private, because the other party will not see those.


The devs disabled the visibility for more fluid reusage. Through the keyword implements you already bind an interface to a class. You cannot access an interface without having it implemented anyways.