svn: /phpdoc/zh/trunk/ language/oop5/typehinting.xml reference/curl/curlfile/wakeup.xml reference/oci8/functions/oci-internal-debug.xml
[email protected] (Bole Chen) Mon, 30 Nov 2020 09:24:18 +0000
| Newsgroups | php.doc.zh |
|---|---|
| Message-ID | <[email protected]> |
avenger Mon, 30 Nov 2020 09:24:18 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=351782
Log:
sync to en.
Changed paths:
D phpdoc/zh/trunk/language/oop5/typehinting.xml
D phpdoc/zh/trunk/reference/curl/curlfile/wakeup.xml
D phpdoc/zh/trunk/reference/oci8/functions/oci-internal-debug.xml
svn-diffs-351782.txt
(text/x-diff, 8 KB)
Deleted: phpdoc/zh/trunk/language/oop5/typehinting.xml
===================================================================
--- phpdoc/zh/trunk/language/oop5/typehinting.xml 2020-11-30 09:07:01 UTC (rev 351781)
+++ phpdoc/zh/trunk/language/oop5/typehinting.xml 2020-11-30 09:24:18 UTC (rev 351782)
@@ -1,171 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- $Revision$ -->
-<!-- EN-Revision: 324171 Maintainer: Haohappy Status: ready -->
- <sect1 xml:id="language.oop5.typehinting" xmlns="http://docbook.org/ns/docbook">
- <title>类型约束</title>
- <para>
- PHP 5 可以使用类型约束。函数的参数可以指定必须为对象(在函数原型里面指定类的名字),接口,数组(PHP
- 5.1 起)或者 <type>callable</type>(PHP 5.4 起)。不过如果使用 <type>NULL</type>
- 作为参数的默认值,那么在调用函数的时候依然可以使用 <type>NULL</type> 作为实参。
- </para>
-
- <para>
- 如果一个类或接口指定了类型约束,则其所有的子类或实现也都如此。
- </para>
-
- <para>
- 类型约束不能用于标量类型如 <type>int</type> 或
- <type>string</type>。<link linkend="language.oop5.traits">Traits</link> 也不允许。
- </para>
-
- <example>
- <title>类型约束示例</title>
- <programlisting role="php">
-<![CDATA[
-<?php
-//如下面的类
-class MyClass
-{
- /**
- * 测试函数
- * 第一个参数必须为 OtherClass 类的一个对象
- */
- public function test(OtherClass $otherclass) {
- echo $otherclass->var;
- }
-
-
- /**
- * 另一个测试函数
- * 第一个参数必须为数组
- */
- public function test_array(array $input_array) {
- print_r($input_array);
- }
-}
-
- /**
- * 第一个参数必须为递归类型
- */
- public function test_interface(Traversable $iterator) {
- echo get_class($iterator);
- }
-
- /**
- * 第一个参数必须为回调类型
- */
- public function test_callable(callable $callback, $data) {
- call_user_func($callback, $data);
- }
-}
-
-// OtherClass 类定义
-class OtherClass {
- public $var = 'Hello World';
-}
-?>
-]]>
- </programlisting>
- <para>
- 函数调用的参数与定义的参数类型不一致时,会抛出一个可捕获的致命错误。
- </para>
- <programlisting role="php">
-<![CDATA[
-<?php
-// 两个类的对象
-$myclass = new MyClass;
-$otherclass = new OtherClass;
-
-// 致命错误:第一个参数必须是 OtherClass 类的一个对象
-$myclass->test('hello');
-
-// 致命错误:第一个参数必须为 OtherClass 类的一个实例
-$foo = new stdClass;
-$myclass->test($foo);
-
-// 致命错误:第一个参数不能为 null
-$myclass->test(null);
-
-// 正确:输出 Hello World
-$myclass->test($otherclass);
-
-// 致命错误:第一个参数必须为数组
-$myclass->test_array('a string');
-
-// 正确:输出数组
-$myclass->test_array(array('a', 'b', 'c'));
-
-// 正确:输出 ArrayObject
-$myclass->test_interface(new ArrayObject(array()));
-
-// 正确:输出 int(1)
-$myclass->test_callable('var_dump', 1);
-?>
-]]>
- </programlisting>
- <para>
- 类型约束不只是用在类的成员函数里,也能使用在函数里:
- </para>
- <programlisting role="php">
-<![CDATA[
-<?php
-// 如下面的类
-class MyClass {
- public $var = 'Hello World';
-}
-
-/**
- * 测试函数
- * 第一个参数必须是 MyClass 类的一个对象
- */
-function MyFunction (MyClass $foo) {
- echo $foo->var;
-}
-
-// 正确
-$myclass = new MyClass;
-MyFunction($myclass);
-?>
-]]>
- </programlisting>
- <para>
- 类型约束允许 NULL 值:
- </para>
- <programlisting role="php">
-<![CDATA[
-<?php
-
-/* 接受 NULL 值 */
-function test(stdClass $obj = NULL) {
-
-}
-
-test(NULL);
-test(new stdClass);
-
-?>
-]]>
- </programlisting>
- </example>
- </sect1>
-
-<!-- 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
--->
Deleted: phpdoc/zh/trunk/reference/curl/curlfile/wakeup.xml
===================================================================
--- phpdoc/zh/trunk/reference/curl/curlfile/wakeup.xml 2020-11-30 09:07:01 UTC (rev 351781)
+++ phpdoc/zh/trunk/reference/curl/curlfile/wakeup.xml 2020-11-30 09:24:18 UTC (rev 351782)
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- $Revision$ -->
-<!-- EN-Revision: 330234 Maintainer: 徐骁 Status: ready -->
-<!-- Reviewed: no -->
-
-<refentry xml:id="curlfile.wakeup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
- <refnamediv>
- <refname>CURLFile::__wakeup</refname>
- <refpurpose>反序列化句柄</refpurpose>
- </refnamediv>
-
- <refsect1 role="description">
- &reftitle.description;
- <methodsynopsis>
- <modifier>public</modifier> <type>void</type><methodname>CURLFile::__wakeup</methodname>
- <void />
- </methodsynopsis>
- <para>
-
- </para>
-
- </refsect1>
-
- <refsect1 role="parameters">
- &reftitle.parameters;
- &no.function.parameters;
- </refsect1>
-
- <refsect1 role="returnvalues">
- &reftitle.returnvalues;
- <para>
- &return.void;
- </para>
- </refsect1>
-
- <refsect1 role="errors">
- &reftitle.errors;
- <para>
- CURLFile 对象不是从序列化数据重建的。
- </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
--->
Deleted: phpdoc/zh/trunk/reference/oci8/functions/oci-internal-debug.xml
===================================================================
--- phpdoc/zh/trunk/reference/oci8/functions/oci-internal-debug.xml 2020-11-30 09:07:01 UTC (rev 351781)
+++ phpdoc/zh/trunk/reference/oci8/functions/oci-internal-debug.xml 2020-11-30 09:24:18 UTC (rev 351782)
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- $Revision$ -->
-<!-- $Author$ -->
-<!-- EN-Revision: n/a Maintainer: yincheng Status: ready -->
-<!-- CREDITS: dallas -->
-<refentry xml:id="function.oci-internal-debug" xmlns="http://docbook.org/ns/docbook">
- <refnamediv>
- <refname>oci_internal_debug</refname>
- <refpurpose>打开或关闭内部调试输出</refpurpose>
- </refnamediv>
- <refsect1>
- <title>说明</title>
- <methodsynopsis>
- <type>void</type><methodname>oci_internal_debug</methodname>
- <methodparam><type>int</type><parameter>onoff</parameter></methodparam>
- </methodsynopsis>
- <para>
- <function>oci_internal_debug</function>
- 打开或关闭内部调试输出。设置 <parameter>onoff</parameter>
- 为 0 关闭调试输出,为 1 则打开。
- </para>
- <note>
- <para>
- 在 PHP 5.0.0 之前的版本必须使用 <function>ociinternaldebug</function>
- 替代本函数。该函数名仍然可用,为向下兼容作为
- <function>oci_internal_debug</function> 的别名。不过其已被废弃,不推荐使用。
- </para>
- </note>
- </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
--->