Permalink
Browse files

can load extensions dyn. and optional args fix

  • Loading branch information...
1 parent 934df8a commit 54fb4db8dbf8a997064691483b1f91e2aa5b489d @iampradip committed Mar 20, 2013
Showing with 90 additions and 25 deletions.
  1. +29 −0 README.md
  2. +4 −2 class.php
  3. +15 −6 code_functions.php
  4. +4 −2 constants.php
  5. +5 −2 extension.php
  6. +14 −3 extensions_list.php
  7. +1 −2 functions.php
  8. +1 −1 highlight_hash.js
  9. +1 −1 index.html
  10. +4 −2 ini_entries.php
  11. +7 −1 style.css
  12. +4 −2 variables.php
  13. +1 −1 visibility.js
View
29 README.md
@@ -4,3 +4,32 @@ php-doc-gen
===========
This script will generate PHP code for defined classes, functions, constants, etc. from extensions or included files. Interface is somewhat similar to javadocs.
+
+An example
+
+```php
+class PDOException extends RuntimeException {
+
+ /* Properties */
+ protected $message ;
+ protected $code ;
+ protected $file ;
+ protected $line ;
+ public $errorInfo ;
+
+ /* Methods */
+ private function __clone() {}
+ public function __construct($message = '<internal-value>', $code = '<internal-value>', $previous = '<internal-value>') {
+ /* Constructor Implementation */
+ }
+ public function getMessage() {}
+ public function getCode() {}
+ public function getFile() {}
+ public function getLine() {}
+ public function getTrace() {}
+ public function getPrevious() {}
+ public function getTraceAsString() {}
+ public function __toString() {}
+
+}
+```
View
6 class.php
@@ -1,5 +1,4 @@
-<!-- Author: Pradip Vadher. -->
-<html>
+<!-- Author: Pradip Vadher --><html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="highlight_hash.js"></script>
@@ -15,6 +14,9 @@
<?php
require "code_functions.php";
if(isset($_GET['extension'], $_GET['class'])){
+ if(isset($_GET['dl'])){
+ dl($_GET['dl']);
+ }
add_included_files();
if($_GET['extension'] === ""){
$class = new ReflectionClass($_GET['class']);
View
21 code_functions.php
@@ -1,6 +1,5 @@
<?php
-// Author: Pradip Vadher.
-
+// Author: Pradip Vadher
function add_included_files(){
if(isset($_GET['include_files']) && !empty($_GET['include_files'])){
$include_files = explode(";", $_GET['include_files']);
@@ -34,7 +33,7 @@ function value($value, $add_space = TRUE){
//ob_start();
//var_dump($value);
//echo trim(ob_get_clean());
- echo var_export($value, TRUE);
+ echo htmlentities(var_export($value, TRUE));
echo "</span>";
}
function ini_value($value, $add_space = TRUE){
@@ -177,15 +176,25 @@ function display_function($method, $indent = 1){
} else {
bracket("(", FALSE);
}
+ $required_arguments = $method->getNumberOfRequiredParameters();
for($i = 0; $i < $count; $i++){
$parameter = $parameters[$i];
if($parameter->isPassedByReference()){
operator("&", FALSE);
}
- identifier($parameter->getName(), TRUE, $parameter->isDefaultValueAvailable());
- if($parameter->isDefaultValueAvailable()){
+ $is_optional = $parameter->isDefaultValueAvailable() || $i >= $required_arguments;
+ identifier($parameter->getName(), TRUE, $is_optional);
+ if($is_optional){
operator("=");
- value($parameter->getDefaultValue(), FALSE);
+ try{
+ value($parameter->getDefaultValue(), FALSE);
+ }catch(ReflectionException $e){
+ if(strpos($e->getMessage(), "Cannot determine default value for internal functions") !== FALSE){
+ value("<internal-value>", FALSE);
+ } else {
+ value("<?>", FALSE);
+ }
+ }
}
if($i !== $count - 1)
comma();
View
6 constants.php
@@ -1,5 +1,4 @@
-<!-- Author: Pradip Vadher. -->
-<html>
+<!-- Author: Pradip Vadher --><html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="highlight_hash.js"></script>
@@ -8,6 +7,9 @@
<h2>Constants</h2>
<?php
if(isset($_GET['extension'])){
+ if(isset($_GET['dl'])){
+ dl($_GET['dl']);
+ }
$constants = 0;
if($_GET['extension'] === ""){
$constants = get_defined_constants(FALSE);
View
7 extension.php
@@ -1,5 +1,4 @@
-<!-- Author: Pradip Vadher. -->
-<html>
+<!-- Author: Pradip Vadher --><html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
@@ -10,6 +9,10 @@
$extension = $_GET['extension'];
}
output_add_rewrite_var("extension", $extension);
+ if(isset($_GET['dl'])){
+ dl($_GET['dl']);
+ output_add_rewrite_var("dl", $_GET['dl']);
+ }
$classes = 0;
$interfaces = 0;
$constants = 0;
View
17 extensions_list.php
@@ -1,12 +1,23 @@
-<!-- Author: Pradip Vadher. -->
-<html>
+<!-- Author: Pradip Vadher --><html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<h2>PHP</h2>
<a class="extension" target="extension" href="extension.php?extension=">Everything</a>
- <form class="extension_add" target="extension" action="extension.php"><input type="text" name="include_files" value="file1;file2;file3" /><input type="submit" value="Include Files" /></form>
+ <form class="extension_add" target="extension" action="extension.php">
+ <input type="text" name="include_files" value="file1;file2;file3" />
+ <input type="submit" value="Include Files" />
+ </form>
+ <?php if(function_exists("dl")) { ?>
+ <form class="extension_add" target="extension" action="extension.php">
+ <input type="text" name="dl" value="extension.dll" />
+ <input type="text" name="extension" value="name" />
+ <input type="submit" value="Load Extension" />
+ </form>
+ <?php } else { ?>
+ <small>Cannot load extensions dynamically.</small>
+ <?php } ?>
<h3>Extensions</h3>
<?php
$extensions = get_loaded_extensions();
View
3 functions.php
@@ -1,5 +1,4 @@
-<!-- Author: Pradip Vadher. -->
-<html>
+<!-- Author: Pradip Vadher --><html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="highlight_hash.js"></script>
View
2 highlight_hash.js
@@ -1,4 +1,4 @@
-// Author: Pradip Vadher.
+// Author: Pradip Vadher
var last_hash = "";
setInterval(function (){
var hash = location.hash;
View
2 index.html
@@ -1 +1 @@
-<!-- Author: Pradip Vadher. -->
+<!-- Author: Pradip Vadher --><html>
View
6 ini_entries.php
@@ -1,5 +1,4 @@
-<!-- Author: Pradip Vadher. -->
-<html>
+<!-- Author: Pradip Vadher --><html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="highlight_hash.js"></script>
@@ -8,6 +7,9 @@
<h2>INI Entries</h2>
<?php
if(isset($_GET['extension'])){
+ if(isset($_GET['dl'])){
+ dl($_GET['dl']);
+ }
$ini_entries = 0;
if($_GET['extension'] === ""){
$ini_entries = ini_get_all(NULL, FALSE);
View
8 style.css
@@ -1,7 +1,13 @@
/*
- Author: Pradip Vadher.
+ Author: Pradip Vadher
+
There are more classes than defined in this stylesheet.
*/
+form.extension_add {
+ border: 1px solid #ddd;
+ padding: 2px;
+ margin: 2px;
+}
.extension,
.ini_entry,
.interface,
View
6 variables.php
@@ -1,5 +1,4 @@
-<!-- Author: Pradip Vadher. -->
-<html>
+<!-- Author: Pradip Vadher --><html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="highlight_hash.js"></script>
@@ -8,6 +7,9 @@
<h2>Variables</h2>
<?php
if(isset($_GET['extension'])){
+ if(isset($_GET['dl'])){
+ dl($_GET['dl']);
+ }
$variables = 0;
if($_GET['extension'] === ""){
$variables = get_defined_vars();
View
2 visibility.js
@@ -1,4 +1,4 @@
-// Author: Pradip Vadher.
+// Author: Pradip Vadher
var change_visibility = function (className, value){
var elements = document.getElementsByClassName(className);
for(var i = 0; i < elements.length; i++){

0 comments on commit 54fb4db

Please sign in to comment.