svn: /phpdoc/en/trunk/reference/tokenizer/functions/ token-get-all.xml

From: Date: Thu, 24 Dec 2015 10:23:32 +0000
Subject: svn: /phpdoc/en/trunk/reference/tokenizer/functions/ token-get-all.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13932@lists.php.net to get a copy of this message
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>

« previous php.doc.cvs (#13932) next »