mirror of
https://github.com/php/doc-ja.git
synced 2026-03-27 08:32:09 +01:00
231 lines
6.9 KiB
XML
231 lines
6.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: bbd4f6a100b48cd3390590037088fe7c5c5cc0e7 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: takagi,mumumu -->
|
|
<refentry xml:id="function.assert-options" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>assert_options</refname>
|
|
<refpurpose>様々な assert フラグを設定/取得する</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>assert_options</methodname>
|
|
<methodparam><type>int</type><parameter>what</parameter></methodparam>
|
|
<methodparam choice="opt"><type>mixed</type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
種々の <function>assert</function> 制御オプションを設定したり、
|
|
単に現在の設定を調べたりします。
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
PHP 7.0.0 以降では、
|
|
<function>assert_options</function> を使うことはお勧めできません。
|
|
&php.ini; のディレクティブ
|
|
<link linkend="ini.zend.assertions">zend.assertions</link> と
|
|
<link linkend="ini.assert.exception">assert.exception</link> を
|
|
<function>ini_set</function> や <function>ini_get</function>
|
|
で取得したり設定したりする方が望ましいです。
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>what</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<table>
|
|
<title>assert オプション</title>
|
|
<tgroup cols="4">
|
|
<thead>
|
|
<row>
|
|
<entry>オプション</entry>
|
|
<entry>INI 設定</entry>
|
|
<entry>デフォルト値</entry>
|
|
<entry>説明</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>ASSERT_ACTIVE</entry>
|
|
<entry>assert.active</entry>
|
|
<entry>1</entry>
|
|
<entry><function>assert</function> による評価を有効にする</entry>
|
|
</row>
|
|
<row>
|
|
<entry>ASSERT_WARNING</entry>
|
|
<entry>assert.warning</entry>
|
|
<entry>1</entry>
|
|
<entry>assersion に失敗した場合に PHP 警告を発生する</entry>
|
|
</row>
|
|
<row>
|
|
<entry>ASSERT_BAIL</entry>
|
|
<entry>assert.bail</entry>
|
|
<entry>0</entry>
|
|
<entry>assersion に失敗した場合に実行を終了する</entry>
|
|
</row>
|
|
<row>
|
|
<entry>ASSERT_QUIET_EVAL</entry>
|
|
<entry>assert.quiet_eval</entry>
|
|
<entry>0</entry>
|
|
<entry>
|
|
assersion 式については error_reporting を無効にする
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>ASSERT_CALLBACK</entry>
|
|
<entry>assert.callback</entry>
|
|
<entry>(&null;)</entry>
|
|
<entry>assertion に失敗した場合にコールされるコールバック</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
オプションに指定する新しい値。
|
|
</para>
|
|
<para>
|
|
<constant>ASSERT_CALLBACK</constant> 定数または assert.callback
|
|
に設定するコールバック関数は、次のようなシグネチャを持つべきです:
|
|
<methodsynopsis role="procedural">
|
|
<type>void</type><methodname>assert_callback</methodname>
|
|
<methodparam><type>string</type><parameter>file</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>line</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>assertion</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>description</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>file</parameter></term>
|
|
<listitem>
|
|
<simpara>
|
|
<function>assert</function> 関数がコールされたファイル名
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>line</parameter></term>
|
|
<listitem>
|
|
<simpara>
|
|
<function>assert</function> 関数がコールされた行番号
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>assertion</parameter></term>
|
|
<listitem>
|
|
<simpara>
|
|
<function>assert</function> 関数に渡した assertion
|
|
を文字列に変換したもの
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>description</parameter></term>
|
|
<listitem>
|
|
<simpara>
|
|
<function>assert</function> 関数に渡された説明
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
<parameter>value</parameter>
|
|
に空文字列を渡すと、assertコールバックはリセットされます。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
そのオプションの元の値、あるいはエラー時に &false; を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>assert_options</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// これは、assert に失敗した際の
|
|
// 処理を行う関数です
|
|
function assert_failure($file, $line, $assertion, $message)
|
|
{
|
|
echo "The assertion $assertion in $file on line $line has failed: $message";
|
|
}
|
|
|
|
// これがテスト関数です
|
|
function test_assert($parameter)
|
|
{
|
|
assert(is_bool($parameter));
|
|
}
|
|
|
|
// assert オプションを設定します
|
|
assert_options(ASSERT_ACTIVE, true);
|
|
assert_options(ASSERT_BAIL, true);
|
|
assert_options(ASSERT_WARNING, false);
|
|
assert_options(ASSERT_CALLBACK, 'assert_failure');
|
|
|
|
// 失敗する assert です
|
|
test_assert(1);
|
|
|
|
// ASSERT_BAIL が true なので
|
|
// 決してここには到達しません
|
|
echo 'Never reached';
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>assert</function></member>
|
|
</simplelist>
|
|
</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
|
|
-->
|