PDA

View Full Version : استاندار نوشتن کلاس ها؟؟



realman
سه شنبه 28 اسفند 1386, 11:19 صبح
با سلام.
من وقتی کلاس های معتبری که برای PHP نوشته شدن رو بررسی می کردم ،دیدم همشون از یک حالت مشابه و استانداردی برای نوشتن کامنت ها و کد نویسی استفاده می کنند.مثل این حالت:




<?php
//================================================== ==========+
// File name : TMXResourceBundle.php
// Begin : 2004-10-19
// Last Update : 2005-03-18
//
// Description : TMX-PHP Bridge Class
// Platform : PHP 5
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Tecnick.com S.r.l.
// Via Ugo Foscolo n.19
// 09045 Quartu Sant'Elena (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//================================================== ==========+

/**
* TMX-PHP Bridge Class (TMXResourceBundle).
* @package com.tecnick.tmxphpbridge
*/

/**
* This PHP Class reads resource text data directly from a TMX (XML) file.
* First, the XMLTMXResourceBundle class instantiates itself with two parameters:
* a TMX file name and a target language name. Then, using an XML parser, it
* reads all of a translation unit's properties for the key information and
* specified language data and populates the resource array with them (key -&gt; value).
*
* @name TMXResourceBundle
* @package com.tecnick.tmxphpbridge
* @abstract TMX-PHP Bridge Class
* @link http://tmxphpbridge.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @author Nicola Asuni [www.tecnick.com]
* @copyright Copyright (c) 2004-2005 - Tecnick.com S.r.l (www.tecnick.com) - Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @version 1.1.001
*/
class TMXResourceBundle {

/**
* @var Array used to contain key-translation couples.
* @access private
*/
private $resource = array();

/**
* @var Current tu -&gt; tuid value.
* @access private
*/
private $current_key = "";


* Class constructor.
* @param string $tmxfile TMX (XML) file name
* @param string $language ISO language identifier (a two- or three-letter code)
*/
public function __construct($tmxfile, $language) {
// reset array
$this-&gt;resource = array();
// set selecteed language
$this-&gt;language = strtoupper($language);
// creates a new XML parser to be used by the other XML functions
$this-&gt;parser = xml_parser_create();
// the following function allows to use parser inside object
xml_set_object($this-&gt;parser, $this);
// disable case-folding for this XML parser
xml_parser_set_option($this-&gt;parser, XML_OPTION_CASE_FOLDING, 0);
// sets the element handler functions for the XML parser
xml_set_element_handler($this-&gt;parser, "startElementHandler", "endElementHandler");
// sets the character data handler function for the XML parser
xml_set_character_data_handler($this-&gt;parser, "segContentHandler");
// start parsing an XML document
if(!xml_parse($this-&gt;parser, file_get_contents($tmxfile))) {
die(sprintf("ERROR TMXResourceBundle :: XML error: %s at line %d",
xml_error_string(xml_get_error_code($this-&gt;parser)),
xml_get_current_line_number($this-&gt;parser)));
}
// free this XML parser
xml_parser_free($this-&gt;parser);
}

/**
* Class destructor; resets $resource array.
*/
public function __destruct() {
$resource = array(); // reset resource array
}

/**
* Sets the start element handler function for the XML parser parser.start_element_handler.
* @param resource $parser The first parameter, parser, is a reference to the XML parser calling the handler.
* @param string $name The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.
* @param array $attribs The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on.
* @access private
*/
private function startElementHandler($parser, $name, $attribs) {
switch(strtolower($name)) {... }



من می خوام بدونم استانداردی وجود داره که همه بر اون مبنا کار می کنن؟آیا جایی هست که من هم بتونم با مطالعه اون کلاس هام رو به این شکل اصولی و با این نوع کامنت گزاری بنویسم؟

hidensoft
سه شنبه 28 اسفند 1386, 12:14 عصر
بطور معمول این نوع کامنت توی اکثر کلاس ها هست

* @name TMXResourceBundle
* @package com.tecnick.tmxphpbridge
* @abstract TMX-PHP Bridge Class
* @link http://tmxphpbridge.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @author Nicola Asuni [www.tecnick.com]
* @copyright Copyright (c) 2004-2005 - Tecnick.com S.r.l (www.tecnick.com) - Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @version 1.1.001


اما من ندیدم تاحالا جایی ازش به عنوان یک استاندارد یاد شده باشه .

vahid4134
سه شنبه 28 اسفند 1386, 12:18 عصر
search in google for phpdocumentor