100% found this document useful (1 vote)
68 views

ZendFramework Coding Standards On On

This document provides coding standards for Zend Framework in 3 sentences or less: The standards specify formatting for file-level and class-level PHPDoc blocks, as well as formatting for method definitions including parameter and return types. It also outlines conventions for variable and constant naming, whitespace, line lengths, and syntax for control structures like if/else, switch, foreach, and try/catch blocks. The document gives an example class definition following the described standards.

Uploaded by

anon-642812
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
68 views

ZendFramework Coding Standards On On

This document provides coding standards for Zend Framework in 3 sentences or less: The standards specify formatting for file-level and class-level PHPDoc blocks, as well as formatting for method definitions including parameter and return types. It also outlines conventions for variable and constant naming, whitespace, line lengths, and syntax for control structures like if/else, switch, foreach, and try/catch blocks. The document gives an example class definition following the described standards.

Uploaded by

anon-642812
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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