0

There are contradictions between PSR-2 and Codeigniter Style Guidelines:

Allman style indenting in CI which is discouraged in PSR-2 elseifs on new line in allman

private methods in classes prefixed with underscore in CI and NOT in PSR-2.

TRUE, FALSE, NULL caps in Codeigniter and lowercase in PSR-2.

Tab in Codeigniter VS 4 spaces for indenting in PSR

Some more occurences like this but you get the point.

I am thinking of favoring PSR-2 over Codeigniter Style guidelines.

Thoughts?

  • 1
    Do as you will, it's your code. But CI does have a few conventions that are required, like capitalize the Class name, etc. – ourmandave Jan 17 '18 at 21:43
  • CodeIgniter method names best to have underscores for spaces that get converted to dashes from the config file setting... I will favor PSR-2 but in instances like the above camelCase methods don't make sense and will go with CodeIgniter – ponytails_soda Jan 17 '18 at 21:55
  • 1
    Adherence to the CI style guide is only relevant if you intend to contribute code to the project. Otherwise, do what you will. As other comments point out you still have to conform to the file naming and class definition requirements. – DFriend Jan 17 '18 at 23:32
  • I think it's a great approach the "do what you will" but when you're working in a team, there's must be an agreement, and I think the best approach imho is to configure the linter to follow CI patterns, otherwise, if you have legacy code, would be an unnecessary waste of time just to convert the coding style. – Bruno de Oliveira May 02 '18 at 13:55

0 Answers0