Skip to content

Instantly share code, notes, and snippets.

@SeanJA
Created May 30, 2011 17:26
Show Gist options
  • Select an option

  • Save SeanJA/999182 to your computer and use it in GitHub Desktop.

Select an option

Save SeanJA/999182 to your computer and use it in GitHub Desktop.
a class with phpdocs
<?php
/**
* @property int $id An identifier
* @property string $name A name
*/
class parent_class{
protected $_data = array();
/**
* magic function __get
*/
public function __get($var){
return $this->_data[$var];
}
/**
* magic function __set
*/
public function __set($var, $value){
return $this->_data[$var] = $value;
}
}
/**
* @property test2 $test2 An object within a class returned by __get()
*/
class test extends parent_class{
public function __construct(){
$this->test2 = new test2();
}
}
/**
* show off @method
* @method int borp() borp(int $int1, int $int2) multiply two integers
*/
class test2 extends parent_class{
/**
* magic method __call
* code stolen from phpdoc.org... not how I would normally write it...
* @link http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.method.pkg.html
*/
function __call($method, $params){
if ($method == 'borp') {
if (count($params) == 2) {
return $params[0] * $params[1];
}
}
}
}
$t = new test();
// autocompletes to $t->test->borp() at the moment in Netbeans
$four = $t->test2->borp(2,2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment