mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
150 lines
3.9 KiB
XML
150 lines
3.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="reflectionparameter.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ReflectionParameter::__construct</refname>
|
|
<refpurpose>Construct</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<constructorsynopsis>
|
|
<modifier>public</modifier> <methodname>ReflectionParameter::__construct</methodname>
|
|
<methodparam><type class="union"><type>string</type><type>array</type><type>object</type></type><parameter>function</parameter></methodparam>
|
|
<methodparam><type class="union"><type>int</type><type>string</type></type><parameter>param</parameter></methodparam>
|
|
</constructorsynopsis>
|
|
<para>
|
|
Constructs a <classname>ReflectionParameter</classname> instance.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>function</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The function to reflect parameters from.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>param</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Either an &integer; specifying the position of the parameter (starting with
|
|
zero), or the parameter name as &string;.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Using the <classname>ReflectionParameter</classname> class</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function foo($a, $b, $c) { }
|
|
function bar(Exception $a, &$b, $c) { }
|
|
function baz(ReflectionFunction $a, $b = 1, $c = null) { }
|
|
function abc() { }
|
|
|
|
$reflect = new ReflectionFunction('foo');
|
|
|
|
echo $reflect;
|
|
|
|
foreach ($reflect->getParameters() as $i => $param) {
|
|
printf(
|
|
"-- Parameter #%d: %s {\n".
|
|
" Class: %s\n".
|
|
" Allows NULL: %s\n".
|
|
" Passed to by reference: %s\n".
|
|
" Is optional?: %s\n".
|
|
"}\n",
|
|
$i, // $param->getPosition() can be used
|
|
$param->getName(),
|
|
var_export($param->getClass(), 1),
|
|
var_export($param->allowsNull(), 1),
|
|
var_export($param->isPassedByReference(), 1),
|
|
$param->isOptional() ? 'yes' : 'no'
|
|
);
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
Function [ <user> function foo ] {
|
|
@@ /Users/philip/cvs/phpdoc/a 2 - 2
|
|
|
|
- Parameters [3] {
|
|
Parameter #0 [ <required> $a ]
|
|
Parameter #1 [ <required> $b ]
|
|
Parameter #2 [ <required> $c ]
|
|
}
|
|
}
|
|
-- Parameter #0: a {
|
|
Class: NULL
|
|
Allows NULL: true
|
|
Passed to by reference: false
|
|
Is optional?: no
|
|
}
|
|
-- Parameter #1: b {
|
|
Class: NULL
|
|
Allows NULL: true
|
|
Passed to by reference: false
|
|
Is optional?: no
|
|
}
|
|
-- Parameter #2: c {
|
|
Class: NULL
|
|
Allows NULL: true
|
|
Passed to by reference: false
|
|
Is optional?: no
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>ReflectionFunctionAbstract::getParameters</methodname></member>
|
|
<member><methodname>ReflectionFunction::__construct</methodname></member>
|
|
<member><methodname>ReflectionMethod::__construct</methodname></member>
|
|
<member><link linkend="language.oop5.decon.constructor">Constructors</link></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|