As was said earlier by Guilherme: there is no correct one. There is indeed a recommendation, which is well demonstrated in PSR-2 - a coding style.
I agree with the part that Guilherme explains about "if you start with a pattern, continue with it to the end". But it is important to note here that there are standards that are used by most PHP libraries.
If we have to address this issue of library development, I strongly recommend that you use the PSR-2 standards.
It is easy to see that most libraries (% with%,% with%,% with%,% with%) use the default Zend
(it deals with other subjects, and not only from the nomenclature of methods).
I'm not saying that you should do everything the same as these libraries do, but it is important, in developing libraries, to maintain a standard, to facilitate users accustomed to the standards employed in libraries to use yours.
If you think about how PHP's standard classes or interfaces are written, for example, you can use common sense and do something similar, so you can present a code closer to the "reality" of the language.
Note, for example, the summary of the Laravel
interface:
interface ArrayAccess {
/* Métodos */
abstract public boolean offsetExists ( mixed $offset )
abstract public mixed offsetGet ( mixed $offset )
abstract public void offsetSet ( mixed $offset , mixed $value )
abstract public void offsetUnset ( mixed $offset )
}
Note that the method names are in CamelCase (as explained by Guilherme).
PSR Summary (for your case)
As a Summary of the PSR-2 (which I remember head), I can state that the standards are:
-
Use camelCase to name the methods of a class.
-
The words Guzzle
or Gregwar
should come before the visibility ( PSR-2
, ArrayAccess
or final
) of the methods.
-
Use snake_case for functions.
-
Function keys or methods should contain a line break.
Again stressing that this is a recommendation, it is not required.