cvs: peardoc /en/package/php/php-compatinfo/php-compatinfo parsearray.xml parsedir.xml parsefile.xml parsefolder.xml parsestring.xml

From: Date: Mon, 10 Mar 2008 15:54:39 +0000
Subject: cvs: peardoc /en/package/php/php-compatinfo/php-compatinfo parsearray.xml parsedir.xml parsefile.xml parsefolder.xml parsestring.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-10566@lists.php.net to get a copy of this message
farell Mon Mar 10 15:54:39 2008 UTC Modified files: /peardoc/en/package/php/php-compatinfo/php-compatinfo parsearray.xml parsedir.xml parsefile.xml parsefolder.xml parsestring.xml Log: add return value and example sections for all parsing functions (in reference guide)

http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-compatinfo/php-compatinfo/parsearray.xml?r1=1.3&r2=1.4&diff_format=u Index: peardoc/en/package/php/php-compatinfo/php-compatinfo/parsearray.xml diff -u peardoc/en/package/php/php-compatinfo/php-compatinfo/parsearray.xml:1.3 peardoc/en/package/php/php-compatinfo/php-compatinfo/parsearray.xml:1.4 --- peardoc/en/package/php/php-compatinfo/php-compatinfo/parsearray.xml:1.3 Mon Mar 10 11:04:25 2008 +++ peardoc/en/package/php/php-compatinfo/php-compatinfo/parsearray.xml Mon Mar 10 15:54:38 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.php.php-compatinfo.php-compatinfo.parsearray"> <refnamediv> <refname><function>PHP_CompatInfo::parseArray</function></refname> @@ -132,6 +132,137 @@ &title.note; &note.notstatic; </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsearray.returns"> + &title.returns; + <para> + &type.array; - a hash which contains information keys: + <literal>ignored_functions</literal>, + <literal>ignored_extensions</literal>, + <literal>ignored_constants</literal>, + <literal>max_version</literal>, + <literal>version</literal>, + <literal>extensions</literal>, + <literal>constants</literal>, + <literal>tokens</literal> + </para> + </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsearray.example"> + &title.example; + <para> + <programlisting role="php"> + <![CDATA[ +<?php +require_once 'PHP/CompatInfo.php'; + +$pci = new PHP_CompatInfo(); + +$input = array('/opt/lampp/etc/pear/PEAR.php', + '/opt/lampp/etc/pear/PHP/CompatInfo.php'); + +$res = $pci->parseArray($input); + +var_export($res); +?> + ]]> + </programlisting> + </para> + <para> + We get such result. + <screen> +array ( + 'ignored_files' => + array ( + ), + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '4.3.0', + 'extensions' => + array ( + 0 => 'sapi_cgi', + 1 => 'tokenizer', + 2 => 'pcre', + ), + 'constants' => + array ( + 0 => 'DIRECTORY_SEPARATOR', + ), + 'tokens' => + array ( + ), + '/opt/lampp/etc/pear/PEAR.php' => + array ( + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '4.3.0', + 'extensions' => + array ( + 0 => 'sapi_cgi', + ), + 'constants' => + array ( + ), + 'tokens' => + array ( + ), + ), + '/opt/lampp/etc/pear/PHP/CompatInfo.php' => + array ( + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '4.3.0', + 'extensions' => + array ( + 0 => 'tokenizer', + 1 => 'pcre', + ), + 'constants' => + array ( + 0 => 'DIRECTORY_SEPARATOR', + ), + 'tokens' => + array ( + ), + ), +) + </screen> + As for parseDir() we have global result, follow by each $input entry result in details. + </para> + <para> + <caution> + <simpara> + Either all $input entries are files, or all are string (chunk of php code). + You cannot have both (one or more) string and (one or more) file reference. + </simpara> + </caution> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-compatinfo/php-compatinfo/parsedir.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/php/php-compatinfo/php-compatinfo/parsedir.xml diff -u peardoc/en/package/php/php-compatinfo/php-compatinfo/parsedir.xml:1.2 peardoc/en/package/php/php-compatinfo/php-compatinfo/parsedir.xml:1.3 --- peardoc/en/package/php/php-compatinfo/php-compatinfo/parsedir.xml:1.2 Mon Mar 10 11:04:25 2008 +++ peardoc/en/package/php/php-compatinfo/php-compatinfo/parsedir.xml Mon Mar 10 15:54:38 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.php.php-compatinfo.php-compatinfo.parsedir"> <refnamediv> <refname><function>PHP_CompatInfo::parseDir</function></refname> @@ -149,6 +149,231 @@ &title.note; &note.notstatic; </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsedir.returns"> + &title.returns; + <para> + &type.array; - a hash which contains information keys: + <literal>ignored_functions</literal>, + <literal>ignored_extensions</literal>, + <literal>ignored_constants</literal>, + <literal>max_version</literal>, + <literal>version</literal>, + <literal>extensions</literal>, + <literal>constants</literal>, + <literal>tokens</literal> + </para> + </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsedir.example"> + &title.example; + <para> + Suppose we have these dirs/files to parse : + <screen> +PHP_CompatInfo/tests/parseDir/ + PHP5/tokens.php5 + PHP5/upload_error.php + extensions.php + phpinfo.php + </screen> + See package distribution to know in details content of this scripts. + </para> + <para> + <programlisting role="php"> + <![CDATA[ +<?php +require_once 'PHP/CompatInfo.php'; + +$pci = new PHP_CompatInfo(); + +$input = 'PHP_CompatInfo/tests/parseDir/'; +$options = array('recurse_dir' => true, + 'file_ext' => array('php', 'php5') + ); + +$res = $pci->parseDir($input, $options); + +var_export($res); +?> + ]]> + </programlisting> + </para> + <para> + We get such result. + <screen> +array ( + 'ignored_files' => + array ( + ), + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '5.2.0', + 'extensions' => + array ( + 0 => 'xdebug', + 1 => 'gd', + 2 => 'sapi_apache', + 3 => 'sapi_cgi', + 4 => 'sqlite', + ), + 'constants' => + array ( + 0 => 'UPLOAD_ERR_INI_SIZE', + 1 => 'UPLOAD_ERR_FORM_SIZE', + 2 => 'UPLOAD_ERR_PARTIAL', + 3 => 'UPLOAD_ERR_NO_FILE', + 4 => 'UPLOAD_ERR_NO_TMP_DIR', + 5 => 'UPLOAD_ERR_CANT_WRITE', + 6 => 'UPLOAD_ERR_EXTENSION', + 7 => 'UPLOAD_ERR_OK', + ), + 'tokens' => + array ( + 0 => 'abstract', + 1 => 'protected', + 2 => 'interface', + 3 => 'public', + 4 => 'implements', + 5 => 'private', + 6 => 'clone', + 7 => 'instanceof', + 8 => 'try', + 9 => 'throw', + 10 => 'catch', + 11 => 'final', + ), + 'PHP_CompatInfo/tests/parseDir/extensions.php' => + array ( + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '4.3.2', + 'extensions' => + array ( + 0 => 'xdebug', + 1 => 'gd', + 2 => 'sapi_apache', + 3 => 'sapi_cgi', + 4 => 'sqlite', + ), + 'constants' => + array ( + ), + 'tokens' => + array ( + ), + ), + 'PHP_CompatInfo/tests/parseDir/PHP5/tokens.php5' => + array ( + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '5.0.0', + 'extensions' => + array ( + ), + 'constants' => + array ( + ), + 'tokens' => + array ( + 0 => 'abstract', + 1 => 'protected', + 2 => 'interface', + 3 => 'public', + 4 => 'implements', + 5 => 'private', + 6 => 'clone', + 7 => 'instanceof', + 8 => 'try', + 9 => 'throw', + 10 => 'catch', + 11 => 'final', + ), + ), + 'PHP_CompatInfo/tests/parseDir/PHP5/upload_error.php' => + array ( + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '5.2.0', + 'extensions' => + array ( + ), + 'constants' => + array ( + 0 => 'UPLOAD_ERR_INI_SIZE', + 1 => 'UPLOAD_ERR_FORM_SIZE', + 2 => 'UPLOAD_ERR_PARTIAL', + 3 => 'UPLOAD_ERR_NO_FILE', + 4 => 'UPLOAD_ERR_NO_TMP_DIR', + 5 => 'UPLOAD_ERR_CANT_WRITE', + 6 => 'UPLOAD_ERR_EXTENSION', + 7 => 'UPLOAD_ERR_OK', + ), + 'tokens' => + array ( + 0 => 'throw', + ), + ), + 'PHP_CompatInfo/tests/parseDir/phpinfo.php' => + array ( + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '4.0.0', + 'extensions' => + array ( + ), + 'constants' => + array ( + ), + 'tokens' => + array ( + ), + ), +) + </screen> + We have global result, then follow by each file parsed in sub-directories. + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefile.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefile.xml diff -u peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefile.xml:1.2 peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefile.xml:1.3 --- peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefile.xml:1.2 Mon Mar 10 11:04:25 2008 +++ peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefile.xml Mon Mar 10 15:54:38 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.php.php-compatinfo.php-compatinfo.parsefile"> <refnamediv> <refname><function>PHP_CompatInfo::parseFile</function></refname> @@ -116,6 +116,133 @@ &title.note; &note.notstatic; </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsefile.returns"> + &title.returns; + <para> + &type.array; - a hash which contains information keys: + <literal>ignored_functions</literal>, + <literal>ignored_extensions</literal>, + <literal>ignored_constants</literal>, + <literal>max_version</literal>, + <literal>version</literal>, + <literal>extensions</literal>, + <literal>constants</literal>, + <literal>tokens</literal> + </para> + </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsefile.example"> + &title.example; + <para> + Suppose we have to parse source code like this one, named &quot;conditional.php&quot; : + <programlisting role="php"> + <![CDATA[ +<?php +// PHP 4.0.0 : __FILE__ +// PHP 4.0.6 : DIRECTORY_SEPARATOR +// PHP 4.0.7 : version compare +// PHP 4.3.0 : ob_get_clean +// PHP 4.3.0 : debug_backtrace +// PHP 4.3.10 and 5.0.2 : PHP_EOL +// PHP 5.0.0 : simplexml_load_file +// PHP 5.1.1 : DATE_W3C + +if (!defined('DIRECTORY_SEPARATOR')) { + define('DIRECTORY_SEPARATOR', + strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/' + ); +} + +if (function_exists('debug_backtrace')) { + $backtrace = debug_backtrace(); +} else { + $backtrace = false; +} + +if (function_exists('simplexml_load_file')) { + $xml = simplexml_load_file('C:\php\pear\PHP_CompatInfo\scripts\version.xml'); +} + +if (version_compare(phpversion(), '5.0.0', '<')) { + include_once 'PHP/Compat.php'; + PHP_Compat::loadFunction('ob_get_clean'); + PHP_Compat::loadConstant('PHP_EOL'); +} + +echo "Hello World" . PHP_EOL; + +$ds = DIRECTORY_SEPARATOR; +$fn = dirname(__FILE__) . $ds . basename(__FILE__); +echo "You have run file : $fn at " . date(DATE_W3C) . PHP_EOL; + +?> + ]]> + </programlisting> + </para> + <para> + <programlisting role="php"> + <![CDATA[ +<?php +require_once 'PHP/CompatInfo.php'; + +$pci = new PHP_CompatInfo(); + +$input = 'conditional.php'; +$options = array('ignore_functions' => array('simplexml_load_file'), + 'ignore_constants' => array('DATE_W3C') + ); + +$res = $pci->parseFile($input, $options); + +var_export($res); +?> + ]]> + </programlisting> + </para> + <para> + We get such result. + <screen> +array ( + 'ignored_functions' => + array ( + 0 => 'simplexml_load_file', + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + 0 => 'DATE_W3C', + ), + 'max_version' => '', + 'version' => '4.3.10', + 'extensions' => + array ( + 0 => 'date', + ), + 'constants' => + array ( + 0 => 'PHP_EOL', + 1 => 'DIRECTORY_SEPARATOR', + 2 => '__FILE__', + 3 => 'DATE_W3C', + ), + 'tokens' => + array ( + ), +) + </screen> + That means php simple_load_file() function and constant DATE_W3C + were ignored from scope, and PHP version minimum to run is 4.3.10 (in such condition) + <warning> + <para> + Of course it is impossible to run such script with only PHP 4.3.10 because + usage of DATE_W3C constant is not conditionned. + </para> + </warning> + </para> + </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefolder.xml?r1=1.1&r2=1.2&diff_format=u Index: peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefolder.xml diff -u peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefolder.xml:1.1 peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefolder.xml:1.2 --- peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefolder.xml:1.1 Tue Jan 22 18:50:55 2008 +++ peardoc/en/package/php/php-compatinfo/php-compatinfo/parsefolder.xml Mon Mar 10 15:54:38 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.php.php-compatinfo.php-compatinfo.parsefolder"> <refnamediv> <refname><function>PHP_CompatInfo::parseFolder</function></refname> @@ -84,6 +84,32 @@ &title.note; &note.notstatic; </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsefolder.returns"> + &title.returns; + <para> + &type.array; - a hash which contains information keys: + <literal>ignored_functions</literal>, + <literal>ignored_extensions</literal>, + <literal>ignored_constants</literal>, + <literal>max_version</literal>, + <literal>version</literal>, + <literal>extensions</literal>, + <literal>constants</literal>, + <literal>tokens</literal> + </para> + </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsefolder.example"> + &title.example; + <para> + See + <link linkend="package.php.php-compatinfo.php-compatinfo.parsedir"> + PHP_CompatInfo::parseDir() + </link> example. + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-compatinfo/php-compatinfo/parsestring.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/php/php-compatinfo/php-compatinfo/parsestring.xml diff -u peardoc/en/package/php/php-compatinfo/php-compatinfo/parsestring.xml:1.2 peardoc/en/package/php/php-compatinfo/php-compatinfo/parsestring.xml:1.3 --- peardoc/en/package/php/php-compatinfo/php-compatinfo/parsestring.xml:1.2 Mon Mar 10 11:04:25 2008 +++ peardoc/en/package/php/php-compatinfo/php-compatinfo/parsestring.xml Mon Mar 10 15:54:38 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.php.php-compatinfo.php-compatinfo.parsestring"> <refnamediv> <refname><function>PHP_CompatInfo::parseString</function></refname> @@ -116,6 +116,78 @@ &title.note; &note.notstatic; </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsestring.returns"> + &title.returns; + <para> + &type.array; - a hash which contains information keys: + <literal>ignored_functions</literal>, + <literal>ignored_extensions</literal>, + <literal>ignored_constants</literal>, + <literal>max_version</literal>, + <literal>version</literal>, + <literal>extensions</literal>, + <literal>constants</literal>, + <literal>tokens</literal> + </para> + </refsect1> + + <refsect1 id="package.php.php-compatinfo.php-compatinfo.parsestring.example"> + &title.example; + <para> + <programlisting role="php"> + <![CDATA[ +<?php +require_once 'PHP/CompatInfo.php'; + +$pci = new PHP_CompatInfo(); + +$input = '<?php +$nl = "\n"; +echo "$nl Rfc3339 = " . DATE_RFC3339; +echo "$nl RSS = " . DATE_RSS; +?>'; + +$res = $pci->parseString($input); + +var_export($res); +?> + ]]> + </programlisting> + </para> + <para> + We get such result. + <screen> +array ( + 'ignored_functions' => + array ( + ), + 'ignored_extensions' => + array ( + ), + 'ignored_constants' => + array ( + ), + 'max_version' => '', + 'version' => '5.1.3', + 'extensions' => + array ( + ), + 'constants' => + array ( + 0 => 'DATE_RFC3339', + 1 => 'DATE_RSS', + ), + 'tokens' => + array ( + ), +) + </screen> + That means we need PHP 5.1.3 minimum to run this chunk of code, + due to usage of DATE_RFC3339 constant. + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables:
« previous php.pear.doc (#10566) next »