svn: /phpdoc/fr/trunk/reference/reflection/reflectionparameter/ gettype.xml
| From: | George Peter Banyard | Date: | Sun, 17 Feb 2019 13:14:17 +0000 |
| Subject: | svn: /phpdoc/fr/trunk/reference/reflection/reflectionparameter/ gettype.xml | ||
| Groups: | php.doc.fr | ||
| Request: | Send a blank email to doc-fr+get-12820@lists.php.net to get a copy of this message | ||
girgias Sun, 17 Feb 2019 13:14:17 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=346843
Log:
Updated French doc for ReflectionParameter.
Changed paths:
U phpdoc/fr/trunk/reference/reflection/reflectionparameter/gettype.xml
Modified: phpdoc/fr/trunk/reference/reflection/reflectionparameter/gettype.xml
===================================================================
--- phpdoc/fr/trunk/reference/reflection/reflectionparameter/gettype.xml 2019-02-17 13:13:07 UTC
(rev 346842)
+++ phpdoc/fr/trunk/reference/reflection/reflectionparameter/gettype.xml 2019-02-17 13:14:17 UTC
(rev 346843)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 346835 Maintainer: girgias Status: ready -->
+<!-- EN-Revision: 346839 Maintainer: girgias Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="reflectionparameter.gettype" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
@@ -12,7 +12,7 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
- <modifier>public</modifier>
<type>ReflectionNamedType</type><methodname>ReflectionParameter::getType</methodname>
+ <modifier>public</modifier>
<type>ReflectionType</type><methodname>ReflectionParameter::getType</methodname>
<void />
</methodsynopsis>
<para>
@@ -28,7 +28,7 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
- Retourne un objet <classname>ReflectionNamedType</classname> si un type de
+ Retourne un objet <classname>ReflectionType</classname> si un type de
paramètre est spécifié, &null; sinon.
</para>
</refsect1>
@@ -37,7 +37,13 @@
&reftitle.examples;
<para>
<example>
- <title>Exemple avec
<methodname>ReflectionParameter::getType</methodname></title>
+ <title>Utilisation de <methodname>ReflectionParameter::getType</methodname>
à partir de PHP 7.1.0</title>
+ <simpara>
+ À partir de PHP 7.1.0, <methodname>ReflectionType::__toString</methodname> est
obsolète, et
+ <methodname>ReflectionParamater::getType</methodname>
<emphasis>peut</emphasis> retourner une
+ instance de <classname>ReflectionNamedType</classname>. Pour récupérer le nom du
type de paramètre,
+ <methodname>ReflectionNamedType</methodname> est disponible dans ce cas.
+ </simpara>
<programlisting role="php">
<![CDATA[
<?php
@@ -48,19 +54,48 @@
$reflectionType1 = $reflectionParams[0]->getType();
$reflectionType2 = $reflectionParams[1]->getType();
-echo $reflectionType1;
+assert($reflectionType1 instanceof ReflectionNamedType);
+echo $reflectionType1->getName(), PHP_EOL;
var_dump($reflectionType2);
+?>
]]>
</programlisting>
- &example.outputs.similar;
+ &example.outputs;
<screen>
<![CDATA[
int
-null
+NULL
]]>
</screen>
</example>
</para>
+ <para>
+ <example>
+ <title>Utilisation de <methodname>ReflectionParameter::getType</methodname>
antérieur à PHP 7.1.0</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+function someFunction(int $param, $param2) {}
+
+$reflectionFunc = new ReflectionFunction('someFunction');
+$reflectionParams = $reflectionFunc->getParameters();
+$reflectionType1 = $reflectionParams[0]->getType();
+$reflectionType2 = $reflectionParams[1]->getType();
+
+echo $reflectionType1, PHP_EOL;
+var_dump($reflectionType2);
+?>
+]]>
+ </programlisting>
+ &example.outputs.70;
+ <screen>
+<![CDATA[
+int
+NULL
+]]>
+ </screen>
+ </example>
+ </para>
</refsect1>
<refsect1 role="seealso">
@@ -68,7 +103,7 @@
<para>
<simplelist>
<member><methodname>ReflectionParameter::hasType</methodname></member>
- <member><methodname>ReflectionNamedType::getName</methodname></member>
+ <member><methodname>ReflectionType::__toString</methodname></member>
</simplelist>
</para>
</refsect1>