Skip to content

Commit 679a7fb

Browse files
committed
Add more details about WeakReferences (#3976)の取り込み
php/doc-en@cd391e6
1 parent a1b7749 commit 679a7fb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

language/predefined/weakreference.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 14767af0f05dffa6fdb9b49e1a1f4e9ca7022a60 Maintainer: mumumu Status: ready -->
3+
<!-- EN-Revision: cd391e65a613a729f9bbded2b1249e2d7143400c Maintainer: mumumu Status: ready -->
44
<reference xml:id="class.weakreference" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
55

66
<title>WeakReference クラス</title>
@@ -14,6 +14,10 @@
1414
<para>
1515
弱い参照により、オブジェクトが破棄されるのを妨げないオブジェクトへの参照を保持することが可能です。
1616
この機能は、キャッシュのようなデータ構造を実装するのに役立ちます。
17+
元のオブジェクトが破棄されている場合、<methodname>WeakReference::get</methodname>
18+
メソッドを呼び出すと &null; を返します。
19+
元のオブジェクトは、<link linkend="features.gc.refcounting-basics">refcount</link> が 0 になると破棄されます。
20+
弱い参照を作成しても、参照されているオブジェクトの <literal>refcount</literal> は増加しません。
1721
</para>
1822
<para>
1923
<classname>WeakReference</classname> クラスはシリアライズできません。
@@ -51,11 +55,16 @@
5155
<programlisting role="php">
5256
<![CDATA[
5357
<?php
58+
5459
$obj = new stdClass;
5560
$weakref = WeakReference::create($obj);
61+
5662
var_dump($weakref->get());
63+
5764
unset($obj);
65+
5866
var_dump($weakref->get());
67+
5968
?>
6069
]]>
6170
</programlisting>

0 commit comments

Comments
 (0)