ZendFramework Coding Standards On On

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Zend Framework coding standards on one page http://raphaelstolt.blogspot.

com

<?php
/**
* 'File-level' PHPDoc Block
*/
<< line length 80 characters, max. 120 characters >>
/**
* 'Class-level' PHPDoc Block
*/
class Cs_Example_Xyz
{
....const SAMPLE_FLAG = 'ab';
/**
* @var datatype [description]
*/
camelCaps
public $variableName = null;
private $_listOfElements = null;
protected $_instance = null;

/**
* A description of the method
*
* @param 1..n datatype $parametername [description]
* @return datatype
* @throws exceptionClass [description]
*/
private|protected function _exampleMethod(array $list, $two, $three)
{
....if.(count($list) > 0).{
........// do something
}.else.{
// do something
}
switch.($two).{
case self::SAMPLE_FLAG:
// do something
break;
case 'dc':
// break intentionally omitted
default:
// do something
break;
}
foreach.($list as $elementOfList).{
// do something
}
}

/**
* 'Method-level' PHPDoc Block
*/
public function bundle($name = ‘John Doe’)
{
$greeting = "Hello $name, welcome back!";
$greeting = "Hello {$name}, welcome back!";
$greetingConcatenation = $greeting . ' ' . 'Nice to see you.';

$sql = "SELECT `id`, `name` FROM `people` "


. "WHERE `name` = 'John Doe'";

$indexed = array(1, 2, 3, 4);


$indexedMultiline = array(1, 2, 3, 4,
'John', 'Doe');
$associative = array('first’ => 'ab',
'second' => 'cd');
try.{
$this->_exampleMethod($indexed, 'ab', 3);
}.catch.(Exception $e).{
throw new Exception($e->getMessage());
}
}

/**
* 'Method-level' PHPDoc Block accessors/mutators
*/
public function get|setListOfElements(|array $list)
{
// access/mutate
}
// Class Filename: Cs/Example/Xyz.php
// Interface Filename: Cs/Example/Interface.php

You might also like