Skip to content
Advertisement

PHP naming conventions about abstract classes and interfaces

Should an abstract class always be prefixed with Abstract and suffixed with Interface (when it’s an interface)? Is there any standard naming convention, similar to PSR-0 for folder structure/namespaces, but for classes?

It seems redundant as the language has literal keywords for this very purpose.

abstract class AbstractFoo {}

interface InterfaceFoo {}

trait TraitFoo {}

Advertisement

Answer

There isn’t a convention for this; especially in PHP. This can all be organized however you’d like.

With the additions of namespaces in PHP 5.3, I don’t see the need to add Abstract or Interface prefixes/suffixes to the actual class names.

Just name things as they are!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement