Eusebius
Eusebius

Reputation: 531

How to interpret PSR-1 rule about method naming in the case of PHP constructors

I'm trying to take into consideration the PSR-0 and PSR-1 recommendations made by my IDE (Netbeans here). PSR-1 says both:

Class names MUST be declared in StudlyCaps.

and :

Method names MUST be declared in camelCase.

That's of course very fine, but how are we supposed to comply in the case of constructors named like the class? Is it somehow implied that the first rule must take precedence in this case (and in that kind of document, I really really don't think anything should be implied)? I can't seem to make the warnings disappear without disabling the PSR-1 recommendations. Is Netbean's checker just a bit too psychorigid?

Upvotes: 0

Views: 389

Answers (1)

samuel
samuel

Reputation: 351

Don't use constructors named like the class, use __contruct() instead.

As noted in PHP constructors documentation, PHP seems to search for class-named-constructors only for backwards compatibility.

Upvotes: 3

Related Questions