svn: /phpdoc/en/trunk/language/ functions.xml
| From: | Pasindu De Silva | Date: | Thu, 09 Jul 2015 21:50:51 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/ functions.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-13448@lists.php.net to get a copy of this message | ||
pasindu Thu, 09 Jul 2015 21:50:51 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=337132
Log:
Added Type Declaration Type Error
Changed paths:
U phpdoc/en/trunk/language/functions.xml
Modified: phpdoc/en/trunk/language/functions.xml
===================================================================
--- phpdoc/en/trunk/language/functions.xml 2015-07-09 18:48:03 UTC (rev 337131)
+++ phpdoc/en/trunk/language/functions.xml 2015-07-09 21:50:51 UTC (rev 337132)
@@ -518,6 +518,51 @@
</example>
</para>
</sect3>
+ <sect3 xml:id="functions.scalar-type-declaration-error">
+ <title>Type Error</title>
+ <para>Absences of a &try; &catch; block will result in a
<constant>E_ERROR</constant></para>
+ <example>
+ <title>Type Error with try catch</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+declare(strict_types=1);
+
+function show(int $intNum)
+{
+ return $a;
+}
+
+
+try {
+
+ show("1");
+
+} catch (TypeError $e) {
+
+ var_dump($e->getmessage()); // "Argument 1 passed to show() must be of the type
+ // integer, string given, called in %s on line %d"
+}
+?>
+]]>
+ </programlisting>
+ <programlisting role="php">
+<![CDATA[
+<?php
+declare(strict_types=1);
+
+function show(int $intNum)
+{
+ return $a;
+}
+
+ show("1"); // Fatal Error
+
+?>
+]]>
+ </programlisting>
+ </example>
+ </sect3>
</sect2>
<sect2 xml:id="functions.variable-arg-list">
<title>Variable-length argument lists</title>