switch ref.token to the new structure

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@176286 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Mehdi Achour 2005-01-02 12:20:10 +00:00
parent d82a016858
commit b400f6c6b7
2 changed files with 127 additions and 71 deletions

View file

@ -1,53 +1,78 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<refentry id="function.token-get-all">
<refnamediv>
<refname>token_get_all</refname>
<refpurpose>Split given source into PHP tokens</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>token_get_all</methodname>
<methodparam><type>string</type><parameter>source</parameter></methodparam>
</methodsynopsis>
<simpara>
<function>token_get_all</function> parses the given <parameter>source</parameter>
string into PHP language tokens using the Zend engine&apos;s lexical scanner.
The function returns an array of token identifiers. Each individual token
identifier is either a single character (i.e.: <constant>;</constant>,
<constant>.</constant>, <constant>&gt;</constant>, <constant>!</constant>, etc...),
or a two element array containing the token index in element 0, and the string
content of the original token in element 1.
</simpara>
<simpara>
For a list of parser tokens, see <xref linkend="tokens"/>, or use
<function>token_name</function> to translate a token value into its string
representation.
</simpara>
<example>
<title><function>token_get_all</function> examples</title>
<programlisting role="php">
<!-- $Revision: 1.8 $ -->
<refentry id="function.token-get-all">
<refnamediv>
<refname>token_get_all</refname>
<refpurpose>Split given source into PHP tokens</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>token_get_all</methodname>
<methodparam><type>string</type><parameter>source</parameter></methodparam>
</methodsynopsis>
<para>
<function>token_get_all</function> parses the given <parameter>source</parameter>
string into PHP language tokens using the Zend engine&apos;s lexical scanner.
</para>
<para>
For a list of parser tokens, see <xref linkend="tokens"/>, or use
<function>token_name</function> to translate a token value into its string
representation.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>source</parameter></term>
<listitem>
<para>
The PHP source to parse.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An array of token identifiers. Each individual token identifier is either
a single character (i.e.: <literal>;</literal>, <literal>.</literal>,
<literal>&gt;</literal>, <literal>!</literal>, etc...),
or a two element array containing the token index in element 0, and the string
content of the original token in element 1.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>token_get_all</function> examples</title>
<programlisting role="php">
<![CDATA[
<?php
$tokens = token_get_all('<?php'); // => array(array(T_OPEN_TAG, '<?'));
$tokens = token_get_all('<?php echo; ?>'); /* => array(
array(T_OPEN_TAG, '<?php'),
array(T_ECHO, 'echo'),
';',
array(T_CLOSE_TAG, '?>') ); */
$tokens = token_get_all('<?php'); // => array(array(T_OPEN_TAG, '<?'));
$tokens = token_get_all('<?php echo; ?>'); /* => array(
array(T_OPEN_TAG, '<?php'),
array(T_ECHO, 'echo'),
';',
array(T_CLOSE_TAG, '?>') ); */
/* Note in the following example that the string is parsed as T_INLINE_HTML
rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5).
This is because no open/close tags were used in the "code" provided.
This would be equivalent to putting a comment outside of <?php ?> tags in a normal file. */
$tokens = token_get_all('/* comment */'); // => array(array(T_INLINE_HTML, '/* comment */'));
$tokens = token_get_all('/* comment */'); // => array(array(T_INLINE_HTML, '/* comment */'));
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,40 +1,71 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<refentry id="function.token-name">
<refnamediv>
<refname>token_name</refname>
<refpurpose>Get the symbolic name of a given PHP token</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>token_name</methodname>
<methodparam><type>int</type><parameter>token</parameter></methodparam>
</methodsynopsis>
<para>
<function>token_name</function> returns the symbolic name for a PHP
<parameter>token</parameter> value. The symbolic name
returned matches the name of the matching token constant.
</para>
<example>
<title><function>token_name</function> example</title>
<programlisting role="php">
<!-- $Revision: 1.7 $ -->
<refentry id="function.token-name">
<refnamediv>
<refname>token_name</refname>
<refpurpose>Get the symbolic name of a given PHP token</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>token_name</methodname>
<methodparam><type>int</type><parameter>token</parameter></methodparam>
</methodsynopsis>
<para>
<function>token_name</function> gets the symbolic name for a PHP
<parameter>token</parameter> value.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>token</parameter></term>
<listitem>
<para>
The token value.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The symbolic name of the given <parameter>token</parameter>. The returned
name returned matches the name of the matching token constant.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>token_name</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// 260 is the token value for the T_REQUIRE token
echo token_name(260); // -> "T_REQUIRE"
// 260 is the token value for the T_REQUIRE token
echo token_name(260); // -> "T_REQUIRE"
// a token constant maps to its own name
echo token_name(T_FUNCTION); // -> "T_FUNCTION"
// a token constant maps to its own name
echo token_name(T_FUNCTION); // -> "T_FUNCTION"
?>
]]>
</programlisting>
</example>
<para>
See also <link linkend="tokens">List of Parser Tokens</link>.
</para>
</refsect1>
</refentry>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link linkend="tokens">List of Parser Tokens</link></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables: