Skip to content

Commit 67eea6b

Browse files
committed
Fixed default value in method parameter when type is NULL, boolean or string
1 parent 7a77b78 commit 67eea6b

File tree

9 files changed

+31
-8
lines changed

9 files changed

+31
-8
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ladybug_dump($var1);
9595

9696
## Helpers
9797

98-
The are 3 helpers:
98+
The are 5 helpers:
9999

100100
`ladybug_dump($var1[, $var2[, ...]])`: Dumps one or more variables
101101

@@ -104,6 +104,10 @@ terminates the current script
104104

105105
`ladybug_dump_return($var1[, $var2[, ...]])`: Dumps one or more variables and
106106
returns the string
107+
108+
`ladybug_dump_ini([$extension])`: Dumps all configuration options
109+
110+
`ladybug_dump_ext()`: Dumps loaded extensions
107111

108112
## Customizable
109113

examples/array.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
$var1[0] = array(
88
'name' => 'Raul',
9-
'age' => 29
9+
'age' => 29,
10+
'url' => 'http://twitter.com/raulfraile'
1011
);
1112

1213
$var1[1] = array(

examples/objects.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Foo {
1212

1313
public function __construct() {$this->a = new Foo2();}
1414
public function getBar() { return $this->bar; }
15-
public function setBar($bar = 1) { $this->bar = $bar; }
15+
public function setBar($bar = 1, $bar2 = TRUE, $bar3 = NULL) { $this->bar = $bar; }
1616
}
1717

1818
$foo = new Foo();

lib/Ladybug/Asset/document.png

-485 Bytes
Binary file not shown.
-401 Bytes
Binary file not shown.

lib/Ladybug/Asset/tree.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ a.doctrine {
8585
background: url(doctrine.png) left center no-repeat;
8686
padding-left: 14px;
8787
margin-left: 3px;
88-
}
88+
}

lib/Ladybug/Processor/StandardObject.php

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class StandardObject {
104104
'RarArchive' => 'class.rararchive.php',
105105
'RarEntry' => 'class.rarentry.php',
106106
'RarException' => 'class.rarexception.php',
107+
108+
// Weakref
109+
'Weakref' => 'class.weakref.php'
107110
);
108111

109112
public function process($str) {

lib/Ladybug/Type/TObject.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct($var, $level, Options $options) {
9090
if ($this->options->getOption('object.show_constants')) {
9191
$this->class_constants = $reflection_class->getConstants();
9292
if (!empty($this->class_constants)) {
93-
foreach ($this->class_constants as $c) {
93+
foreach ($this->class_constants as &$c) {
9494
$c = TFactory::factory($c, $this->level, $options);
9595
}
9696
}
@@ -138,10 +138,14 @@ public function __construct($var, $level, Options $options) {
138138
$default = NULL;
139139
if ($parameter->isDefaultValueAvailable()) {
140140
$default = $parameter->getDefaultValue();
141+
142+
if($default === null) $default = 'NULL';
143+
elseif(is_bool($default)) $default = $default ? 'TRUE' : 'FALSE';
144+
elseif(is_string($default)) $default = '"' . $default . '"';
145+
146+
$parameter_result .= ' = ' . $default;
141147
}
142148

143-
if (!is_null($default)) $parameter_result .= ' = ' . $default;
144-
145149
if ($parameter->isOptional()) $parameter_result .= ']';
146150

147151
$method_parameters_result[] = $parameter_result;

lib/Ladybug/Variable.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ public function render($array_key = NULL, $format = 'html') {
105105
else return NULL;
106106
}
107107

108+
/**
109+
* Renders the variable node in the dump tree using HTML code
110+
*
111+
* @param mixed $array_key if the variable is part of an array, it's value
112+
* @return string Variable representation
113+
*/
108114
protected function _renderHTML($array_key = NULL) {
109115
$html = '<div class="final">';
110116
$html .= $this->renderArrayKey($array_key);
@@ -115,6 +121,12 @@ protected function _renderHTML($array_key = NULL) {
115121
return $html;
116122
}
117123

124+
/**
125+
* Renders the variable node in the dump tree using CLI code
126+
*
127+
* @param mixed $array_key if the variable is part of an array, it's value
128+
* @return string Variable representation
129+
*/
118130
protected function _renderCLI($array_key = NULL) {
119131
$cli = $this->renderArrayKey($array_key) . $this->type . ' ';
120132
$cli .= CLIColors::getColoredString($this->getValue(), $this->getColor('cli'));
@@ -124,7 +136,6 @@ protected function _renderCLI($array_key = NULL) {
124136
}
125137

126138
protected function renderArrayKey($key) {
127-
128139
if (is_null($key)) return NULL;
129140
else return "[$key]: ";
130141
}

0 commit comments

Comments
 (0)