We are gonna be using php5.5 , so upgrade your systems to that.
-
http://laravel.com/docs/contributing#coding-guidelines , we follow these, along with PSR-0 and PSR-1.
-
use Foo
(aliasing) etc statements should start from the 3rd line. Each class that needs to be used in a namespace has to be aliased in a separate line. -
Aliasing is important. You shouldn't be using more than two Namespace Separators
(\)
in the code that you right in your classes. Try to restrict the count of those namespace separators to one. -
No accessing global namespace (ie,
\Foo
is not allowed, you need to alias the classFoo
viause Foo
). The only exception for this is php spl exception classes. -
Tabs of size 4 are to be used for indentation, spaces can be used to align things that span multiple lines properly.
-
Do not make global helper functions.
-
Do not use
&&
and||
for boolean operations, useand
andor
. -
Maintain type coherence of methods. Always look at returned values as filled-up or empty. So if a method returns an object, it should always return an object or a null. If it returns an array, boolean, string or number, it should always return an array, boolean, string, or number correspondingly (no null allowed). If you wan't to handle edge cases, or break flow of the method, use exceptions. But do not break type coherence.