|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- $Revision$ --> |
| 3 | +<!-- EN-Revision: 527e9b11ab0c1f678743a76773bbc795f9f6f05f Maintainer: mumumu Status: ready --> |
| 4 | +<refentry xml:id="countable.count" xmlns="http://docbook.org/ns/docbook"> |
| 5 | + <refnamediv> |
| 6 | + <refname>Countable::count</refname> |
| 7 | + <refpurpose>オブジェクトの要素の数を数える</refpurpose> |
| 8 | + </refnamediv> |
| 9 | + |
| 10 | + <refsect1 role="description"> |
| 11 | + &reftitle.description; |
| 12 | + <methodsynopsis role="Countable"> |
| 13 | + <modifier>public</modifier> <type>int</type><methodname>Countable::count</methodname> |
| 14 | + <void/> |
| 15 | + </methodsynopsis> |
| 16 | + <simpara> |
| 17 | + このメソッドは、 |
| 18 | + <function>count</function> 関数の |
| 19 | + <parameter>value</parameter> パラメーターが |
| 20 | + <classname>Countable</classname> を実装している場合に実行されます。 |
| 21 | + </simpara> |
| 22 | + </refsect1> |
| 23 | + |
| 24 | + <refsect1 role="parameters"> |
| 25 | + &reftitle.parameters; |
| 26 | + &no.function.parameters; |
| 27 | + </refsect1> |
| 28 | + |
| 29 | + <refsect1 role="returnvalues"> |
| 30 | + &reftitle.returnvalues; |
| 31 | + <simpara> |
| 32 | + 数えたカスタムの結果を整数値として返します。 |
| 33 | + </simpara> |
| 34 | + </refsect1> |
| 35 | + |
| 36 | + <refsect1 role="examples"> |
| 37 | + &reftitle.examples; |
| 38 | + <example> |
| 39 | + <title><function>Countable::count</function> の例</title> |
| 40 | + <programlisting role="php"> |
| 41 | +<![CDATA[ |
| 42 | +<?php |
| 43 | +
|
| 44 | +class Counter implements Countable |
| 45 | +{ |
| 46 | + private $count = 0; |
| 47 | +
|
| 48 | + public function count(): int |
| 49 | + { |
| 50 | + return ++$this->count; |
| 51 | + } |
| 52 | +} |
| 53 | +
|
| 54 | +$counter = new Counter; |
| 55 | +
|
| 56 | +for ($i = 0; $i < 10; ++$i) { |
| 57 | + echo "I have been count()ed " . count($counter) . " times\n"; |
| 58 | +} |
| 59 | +
|
| 60 | +?> |
| 61 | +]]> |
| 62 | + </programlisting> |
| 63 | + &example.outputs.similar; |
| 64 | + <screen> |
| 65 | +<![CDATA[ |
| 66 | +I have been count()ed 1 times |
| 67 | +I have been count()ed 2 times |
| 68 | +I have been count()ed 3 times |
| 69 | +I have been count()ed 4 times |
| 70 | +I have been count()ed 5 times |
| 71 | +I have been count()ed 6 times |
| 72 | +I have been count()ed 7 times |
| 73 | +I have been count()ed 8 times |
| 74 | +I have been count()ed 9 times |
| 75 | +I have been count()ed 10 times |
| 76 | +]]> |
| 77 | + </screen> |
| 78 | + </example> |
| 79 | + </refsect1> |
| 80 | + |
| 81 | +</refentry> |
| 82 | +<!-- Keep this comment at the end of the file |
| 83 | +Local variables: |
| 84 | +mode: sgml |
| 85 | +sgml-omittag:t |
| 86 | +sgml-shorttag:t |
| 87 | +sgml-minimize-attributes:nil |
| 88 | +sgml-always-quote-attributes:t |
| 89 | +sgml-indent-step:1 |
| 90 | +sgml-indent-data:t |
| 91 | +indent-tabs-mode:nil |
| 92 | +sgml-parent-document:nil |
| 93 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 94 | +sgml-exposed-tags:nil |
| 95 | +sgml-local-catalogs:nil |
| 96 | +sgml-local-ecat-files:nil |
| 97 | +End: |
| 98 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 99 | +vim: et tw=78 syn=sgml |
| 100 | +vi: ts=1 sw=1 |
| 101 | +--> |
0 commit comments