[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/reference/tokenizer/functions/_token-get-all.xml?=
From: Thomas_Punt <tpunt () php ! net>
Date: 2015-12-24 10:23:32
Message-ID: svn-tpunt-1450952612-338345-1328149587 () svn ! php ! net
[Download RAW message or body]
tpunt Thu, 24 Dec 2015 10:23:32 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=338345
Log:
Resolve doc bug #71207
Bug: https://bugs.php.net/71207 (Assigned) token_get_all does not recognize \
context-sensitive keywords
Changed paths:
U phpdoc/en/trunk/reference/tokenizer/functions/token-get-all.xml
Modified: phpdoc/en/trunk/reference/tokenizer/functions/token-get-all.xml
===================================================================
--- phpdoc/en/trunk/reference/tokenizer/functions/token-get-all.xml 2015-12-24 \
00:04:56 UTC (rev 338344)
+++ phpdoc/en/trunk/reference/tokenizer/functions/token-get-all.xml 2015-12-24 \
10:23:32 UTC (rev 338345) @@ -10,6 +10,7 @@
<methodsynopsis>
<type>array</type><methodname>token_get_all</methodname>
<methodparam><type>string</type><parameter>source</parameter></methodparam>
+ <methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
<function>token_get_all</function> parses the given <parameter>source</parameter>
@@ -33,6 +34,22 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><parameter>flags</parameter></term>
+ <listitem>
+ <para>
+ Valid flags:
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ <constant>TOKEN_PARSE</constant> - Recognises the ability to use
+ reserved words in specific contexts.
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect1>
@@ -70,6 +87,53 @@
</programlisting>
</example>
</para>
+ <para>
+ <example>
+ <title>
+ <function>token_get_all</function> on class using a reserved word
+ </title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$source = <<<'code'
+<?php
+
+class A
+{
+ const PUBLIC = 1;
+}
+code;
+
+$tokens = token_get_all($source, TOKEN_PARSE);
+
+foreach ($tokens as $token) {
+ if (is_array($token)) {
+ echo token_name($token[0]) , PHP_EOL;
+ }
+}
+?>
+]]>
+ </programlisting>
+ &example.outputs.similar;
+ <screen>
+<![CDATA[
+T_OPEN_TAG
+T_WHITESPACE
+T_CLASS
+T_WHITESPACE
+T_STRING
+T_CONST
+T_WHITESPACE
+T_STRING
+T_LNUMBER
+]]>
+ </screen>
+ </example>
+ Without the <constant>TOKEN_PARSE</constant> flag, the penultimate
+ token (<constant>T_STRING</constant>) would have been
+ <constant>T_PUBLIC</constant>.
+ </para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
@@ -84,8 +148,16 @@
</thead>
<tbody>
<row>
+ <entry>7.0.0</entry>
+ <entry>
+ Added the optional <parameter>flags</parameter> parameter along with
+ the <constant>TOKEN_PARSE</constant> flag.
+ </entry>
+ </row>
+ <row>
<entry>5.2.2</entry>
- <entry>Line numbers are returned in element 2
+ <entry>
+ Line numbers are returned in element 2
</entry>
</row>
</tbody>
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic