mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 07:02:08 +01:00
179 lines
4.6 KiB
XML
179 lines
4.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: f5a677b8fdc3f7f72f2225f906cac0e466d4558d Maintainer: takagi Status: ready -->
|
|
<refentry xml:id="function.class-alias" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>class_alias</refname>
|
|
<refpurpose>クラスのエイリアスを作成する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>class_alias</methodname>
|
|
<methodparam><type>string</type><parameter>class</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>alias</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>autoload</parameter><initializer>&true;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<parameter>alias</parameter> という名前のエイリアスを、
|
|
ユーザー定義のクラス <parameter>class</parameter> に対して作成します。
|
|
エイリアスは、元のクラスとまったく同一のものとなります。
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
PHP 8.3.0 以降では、<function>class_alias</function>
|
|
は PHP の内部クラスのエイリアスを作る機能もサポートしています。
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>class</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
元となるクラス。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>alias</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
クラスのエイリアス名。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>autoload</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
元のクラスが見つからない場合に <link linkend="language.oop5.autoload">オートロード</link> するかどうか。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.3.0</entry>
|
|
<entry>
|
|
<function>class_alias</function> は、内部クラスのエイリアスを作る機能をサポートしました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>class_alias</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
class Foo { }
|
|
|
|
class_alias('Foo', 'Bar');
|
|
|
|
$a = new Foo;
|
|
$b = new Bar;
|
|
|
|
// オブジェクトは同一となります
|
|
var_dump($a == $b, $a === $b);
|
|
var_dump($a instanceof $b);
|
|
|
|
// クラスは同一となります
|
|
var_dump($a instanceof Foo);
|
|
var_dump($a instanceof Bar);
|
|
|
|
var_dump($b instanceof Foo);
|
|
var_dump($b instanceof Bar);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
bool(true)
|
|
bool(false)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
クラス名は、大文字小文字を区別しません。
|
|
また、その振る舞いはこの関数にも反映されています。
|
|
<function>class_alias</function> によって作られたエイリアスは、
|
|
小文字で宣言されます。
|
|
たとえばクラス <literal>MyClass</literal> について、
|
|
<code>class_alias('MyClass', 'MyClassAlias')</code>
|
|
を実行すると、<literal>myclassalias</literal>
|
|
という名前の新しいクラスエイリアスが宣言されます。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>get_parent_class</function></member>
|
|
<member><function>is_subclass_of</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
|
|
-->
|