#!/usr/bin/php
<?php
/**
*+-----------------------------------------------------------------------+
*| GenDummyClass - 02 Jul 2006 |
*+-----------------------------------------------------------------------+
*| Diego do Nascimento Feitosa |
*| diego@dnfeitosa.com |
*| www.dnfeitosa.com |
*| São Paulo/SP - Brasil |
*+-----------------------------------------------------------------------+
*| GenDummyClass is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published by |
*| the Free Software Foundation; either version 2 of the License, or |
*| (at your option) any later version. |
*| |
*| GenDummyClass is distributed in the hope that it will be useful, but |
*| WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
*| General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with GenDummyClass; if not, write to the Free Software |
*| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
*| 02111-1307 USA |
*+-----------------------------------------------------------------------+
**/
/*
Exemplo de uso:
# ./genDummyClass.php -c ArrayIterator -e php -r
Irá retornar aum arquivo da classe ArrayIterator e cada uma das interfaces
ArrayAccess
ArrayIterator
Countable
Iterator
SeekableIterator
Traversable
Ou para usar a classe de teste:
# ./genDummyClass.php -c TestClass -e php -r
*/
class TestParent {
private function parentMethod($param = "aaaaa") {
// do something
}
}
interface TestInterface {
function method($param1);
}
class TestClass extends TestParent implements TestInterface {
const CONST_STRING = "String";
const CONST_INTEGER = 1;
const CONST_FLOAT = 0.3;
const CONST_BOOL = true;
static public $property2;
private $property3;
protected $property4;
public function __construct($param1, $param2 = false) {
if ($param2) {
// do something
}
$this->method($param1);
}
public function method($param1) {
// do something
}
static public function staticMethod($param) {
// do something
}
protected function protectedMethod() {
// do something
}
}
require_once("GenDummyClassFile.inc");
$argv = $_SERVER["argv"];
$output = null;
$classname = null;
$extension = null;
$recursive = null;
foreach ($argv as $key => $value) {
if ($key == 0 || !($key % 2))
continue;
switch ($value) {
case "-o":
$value = $argv[++$key];
$output = $value;
break;
case "-c":
$value = $argv[++$key];
$classname = $value;
break;
case "-e":
$value = $argv[++$key];
$extension = $value;
break;
case "-r":
$recursive = true;
break;
case "-h":
case "-help":
case "--help":
echo "Usage: genDummyClass [options] -c className\n";
echo " Options:\n";
echo " -o\tOutput Directory\n";
echo " -e\tOutput File Extension\n";
echo " -h,-H\tThis help message\n\n";
exit;
default:
echo "Unknown option \"$value\" \n";
echo "Usage: genDummyClass [options] -c className\n";
echo " Options:\n";
echo " -o\tOutput Directory\n";
echo " -e\tOutput File Extension\n";
echo " -h,-H\tThis help message\n\n";
exit;
}
}
if (!$classname) {
echo "Usage: genDummyClass [options] -c className\n";
echo " Options:\n";
echo " -o\tOutput Directory\n";
echo " -e\tOutput File Extension\n";
echo " -r\tRecursive (Generate all Classes and Interfaces)\n";
echo " -h,-H\tThis help message\n\n";
exit;
}
if ($output || $extension) {
$gen = new GenDummyClassFile($classname, $extension, $recursive);
$gen->generate($output);
} else {
$gen = new GenDummyClassRecursive($classname);
print_r($gen->generate());
}
?>
|