zend coding standards

There are two types of cases in php to write compound words.
Writing compound words in which the words are joined without spaces or delimiters.

1. Camelcase: The first letter of a word may or may not be capitalized but inner join words is always start with capital letter follow by
small letters.
Camelcase example : camelCase

2. Pacalcase: Pascal case words always start with a capital letter and inner join words is always start with capital letter follow by small letters.
Pascalcase example : PascalCase , it is also called UpperCamelCase.

PHP Guidelines

Classes – PascalCase (UpperCamelCase)
Interfaces – PascalCase (UpperCamelCase)
Functions and Methods – camelCase
Variables – camelCase
Constants – ALL_CAPS

I follow zend coding standards
Coding standards are important in any development project, but they are particularly important when many developers are working on the same project. Coding standards help ensure that the code is high quality, has fewer bugs, and can be easily maintained.

Indentation
Indentation should consist of 4 spaces. Tabs are not allowed.

Maximum Line Length
The maximum length of any line of PHP code is 120 characters.

Classes
class name is comprised of more than one word, the first letter of each new word must be capitalized. Successive capitalized letters are not allowed, e.g. a class “Zend_PDF” is not allowed while “Zend_Pdf” is acceptable.

Functions
Function names may only contain alphanumeric characters. Underscores are not permitted.Function names must always start with a lowercase letter. When a function name consists of more than one word, the first letter of each new word must be capitalized. This is commonly called “camelCase” formatting.

For Example :getElementById()

Variables
variable names must always start with a lowercase letter and follow the “camelCaps” capitalization convention.

Constants
All letters used in a constant name must be capitalized, while all words in a constant name must be separated by underscore characters.

ex :EMBED_SUPPRESS_EMBED_EXCEPTION

Coding Standard
PHP code must always be delimited by the full-form, standard PHP tags:

<?php

?>

String Literals

$a = 'Example String';

String Literals Containing Apostrophes

$sql = "SELECT `id`, `name` from `people` "
 . "WHERE `name`='Fred' OR `name`='Susan'";

String Concatenation

$company = 'Zend' . ' ' . 'Technologies';

Class Declaration
Class name follow camelcase
The brace should always be written on the line underneath the class name.
Every class must have a documentation block that conforms to the PHPDocumentor standard.
All code in a class must be indented with four spaces.
Only one class is permitted in each PHP file.

Control Statements
If/Else/Elseif
Control statements based on the if and elseif constructs must have a single space before the opening parenthesis of the conditional and a single space after the closing parenthesis.
Within the conditional statements between the parentheses, operators must be separated by spaces for readability. Inner parentheses are encouraged to improve logical grouping for larger conditional expressions.
The opening brace is written on the same line as the conditional statement. The closing brace is always written on its own line. Any content within the braces must be indented using four spaces.

For Ex : if (($a == $b)
 && ($b == $c)
 || (Foo::CONST == $d)
 ) {
 $a = $d;
 }

File Description
Every file that contains PHP code must have a docblock at the top of the file that contains these phpDocumentor tags at a minimum:

/**
* Short description for file
*
* Long description for file (if any)...
*
* LICENSE: Some license information
*
* @category Zend
* @package Zend_Magic
* @subpackage Wand
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license BSD License
* @version $Id:$
* @link http://framework.zend.com/package/PackageName
* @since File available since Release 1.5.0
*/

Class description
Every class must have a docblock that contains these phpDocumentor tags at a minimum:

/**
* Short description for class
*
* Long description for class (if any)...
*
* @category Zend
* @package Zend_Magic
* @subpackage Wand
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license BSD License
* @version Release: @package_version@
* @link http://framework.zend.com/package/PackageName
* @since Class available since Release 1.5.0
* @deprecated Class deprecated in Release 2.0.0
*/

Functions description
Every function, including object methods, must have a docblock that contains at a minimum:
A description of the function
All of the arguments
All of the possible return values

5 thoughts on “zend coding standards”

  1. It’s in point of fact a great and helpful piece of info. I am happy that you simply shared this useful information with us. Please keep us up to date like this. Thank you for sharing.

  2. You’re so cool! I don’t think I have read through a single thing
    like this before. So nice to find another person with original thoughts on this
    topic. Really.. thank you for starting this up. This web site
    is one thing that is required on the web, someone with
    some originality!

  3. Simply want to say your article is as amazing.
    The clarity in your post is just great and i could assume you’re an expert on this subject.
    Well with your permission allow me to grab your RSS feed to keep up to date
    with forthcoming post. Thanks a million and please carry on the gratifying work.

Leave a Reply

Your email address will not be published. Required fields are marked *