svn: /phpdoc/en/trunk/language/ functions.xml
| From: | Pasindu De Silva | Date: | Sat, 18 Jul 2015 16:40:30 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/ functions.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-13470@lists.php.net to get a copy of this message | ||
pasindu Sat, 18 Jul 2015 16:40:30 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=337189
Log:
Added Intial Return TypeError Doc & fix typo
Changed paths:
U phpdoc/en/trunk/language/functions.xml
Modified: phpdoc/en/trunk/language/functions.xml
===================================================================
--- phpdoc/en/trunk/language/functions.xml 2015-07-18 12:58:28 UTC (rev 337188)
+++ phpdoc/en/trunk/language/functions.xml 2015-07-18 16:40:30 UTC (rev 337189)
@@ -937,7 +937,7 @@
</para>
<para>
<example>
- <title>Return a class;</title>
+ <title>Return a class</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -955,6 +955,30 @@
</programlisting>
</example>
</para>
+ <para>
+ <example>
+ <title>TypeError</title>
+ <para>Incorrect return type will result in a TypeError</para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+declare(strict_types=1);
+
+function show(): int{
+ return "1";
+}
+
+try {
+ show();
+} catch (TypeError $e) {
+ var_dump($e->getMessage()); // string(121) "Return value of show() must be of the type
integer,
+ // string returned in %s on line 5"
+}
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
</sect2>
</sect1>