==== Code Formatting ==== Για τη μορφοποίηση του κώδικα PHP του Open eClass ακολουθούμε τους προκαθορισμένους κανόνες του Netbeans για τον κώδικα PHP: * Το indenting γίνεται μόνο με κενά, όχι με tab. * Το βασικό indenting είναι 4 στήλες. * Σε όλες τις δομές ελέγχου που περιέχουν μπλοκ, τα μπλοκ θα βρίσκονται μέσα σε άγκιστρα ακόμα κι αν περιέχουν μια μόνο εντολή. Δηλαδή: if ($flag) { do_this(); } else { do_that(); do_something_else(); } * Τα άγκιστρα των δομών ελέγχου ανοίγουν στο τέλος της αρχικής γραμμής και κλείνουν στην επόμενη γραμμή μετά την τελευταία εντολή κώδικα. Αυτό ισχύει και για τους ορισμούς συναρτήσεων και κλάσεων. Πχ: function do_this($arg1, $arg2) { ... } Ειδικότερα, όλοι οι κανόνες είναι οι εξης: h3. Indentation * Expand tabs to spaces * “tab” size: 4 spaces * no initial indentation * continuation indentation of 8 spaces * array declaration indentation of 4 spaces h3. Braces on the same line * class declaration * method declaration * if * else * elseif * for * foreach * while * do * switch * try * catch * use trait body * ... all other h3. One blank line * before namespace * after namespace * before use * after use * before class * after class * before fields * between fields * after fields * before function * after function * after open tag * before use trait h3. No blank line * after class header * before class end * before function end * before close tag h3. Blank spaces before keywords * while * else * elseif * catch before parentheses * if * elseif * for * foreach * while * catch * switch around operators * binary * ternary * string concatenation * key => value pairs * assignment operators before left braces * class declaration * method declaration * if * elseif * else * while * for * foreach * do * switch * try * catch * use trait body after comma after semicolon after type cast after keyword after short PHP tag before close PHP tag h3. Wrapping always * for * foreach * if * while * do never * extends / implements * method parameters * method call arguments * chained method calls * array initializer * binary operators * ternary operators * assignment operators