reference/reflection/reflectionparameter/getdefaultvalueconstantname.xml
ec2fe9a592f794978114ef5021db9f1d00c2e05d
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="reflectionparameter.getdefaultvalueconstantname" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>ReflectionParameter::getDefaultValueConstantName</refname>
...
...
@@ -9,16 +8,16 @@
9
8

10
9
<refsect1 role="description">
11
10
&reftitle.description;
12
-
<methodsynopsis>
13
-
<modifier>public</modifier> <type>string</type><methodname>ReflectionParameter::getDefaultValueConstantName</methodname>
14
-
<void />
11
+
<methodsynopsis role="ReflectionParameter">
12
+
<modifier>public</modifier> <type class="union"><type>string</type><type>null</type></type><methodname>ReflectionParameter::getDefaultValueConstantName</methodname>
13
+
<void/>
15
14
</methodsynopsis>
16
15
<para>
17
-

16
+
Returns the default value's constant name of the parameter of any user-defined
17
+
or internal function or method, if default value is constant or null.
18
+
If the parameter is not optional a <classname>ReflectionException</classname>
19
+
will be thrown.
18
20
</para>
19
-

20
-
&warn.undocumented.func;
21
-

22
21
</refsect1>
23
22

24
23
<refsect1 role="parameters">
...
...
@@ -33,9 +32,81 @@
33
32
</para>
34
33
</refsect1>
35
34

35
+
<refsect1 role="changelog">
36
+
&reftitle.changelog;
37
+
<para>
38
+
<informaltable>
39
+
<tgroup cols="2">
40
+
<thead>
41
+
<row>
42
+
<entry>&Version;</entry>
43
+
<entry>&Description;</entry>
44
+
</row>
45
+
</thead>
46
+
<tbody>
47
+
<row>
48
+
<entry>8.0.0</entry>
49
+
<entry>
50
+
This method now allows getting the default values' constant names of built-in functions and
51
+
built-in class methods. Previously, a <classname>ReflectionException</classname> was thrown.
52
+
</entry>
53
+
</row>
54
+
</tbody>
55
+
</tgroup>
56
+
</informaltable>
57
+
</para>
58
+
</refsect1>
59
+

60
+
<refsect1 role="examples">
61
+
&reftitle.examples;
62
+
<para>
63
+
<example>
64
+
<title>Getting default values' constant names of function parameters</title>
65
+
<programlisting role="php">
66
+
<![CDATA[
67
+
<?php
68
+
function foo($test, $bar = PHP_INT_MIN)
69
+
{
70
+
echo $test . $bar;
71
+
}
36
72

37
-
</refentry>
73
+
$function = new ReflectionFunction('foo');
38
74

75
+
foreach ($function->getParameters() as $param) {
76
+
echo 'Name: ' . $param->getName() . PHP_EOL;
77
+
if ($param->isOptional()) {
78
+
echo 'Default value: ' . $param->getDefaultValueConstantName() . PHP_EOL;
79
+
}
80
+
echo PHP_EOL;
81
+
}
82
+
?>
83
+
]]>
84
+
</programlisting>
85
+
&example.outputs;
86
+
<screen>
87
+
<![CDATA[
88
+
Name: test
89
+

90
+
Name: bar
91
+
Default value: PHP_INT_MIN
92
+
]]>
93
+
</screen>
94
+
</example>
95
+
</para>
96
+
</refsect1>
97
+
98
+
<refsect1 role="seealso">
99
+
&reftitle.seealso;
100
+
<para>
101
+
<simplelist>
102
+
<member><methodname>ReflectionParameter::isOptional</methodname></member>
103
+
<member><methodname>ReflectionParameter::isDefaultValueConstant</methodname></member>
104
+
<member><methodname>ReflectionParameter::getDefaultValue</methodname></member>
105
+
</simplelist>
106
+
</para>
107
+
</refsect1>
108
+

109
+
</refentry>
39
110
<!-- Keep this comment at the end of the file
40
111
Local variables:
41
112
mode: sgml
42
113