PHP_Compat::loadVersion

PEAR Manual


CLI

CLI -- The console command

Switchs

The PHP_CompatInfo_Cli class, also known under it's wrapper name "pci", get the compatibility info from PHP Command Line Interpreter, on existing script or folder.

Overview

pci [options]  -f FILE | -d DIR | -s STRING
     
Usage is to run pci with at least the -s (--string), -f (--file) or -d (--dir) switch and perharps some additional and optional options.

Reference

-d | --dir

Identify the directory to parse to get compatibility info of its files contents.

-f | --file

Identify the file name (path) to parse to get compatibility info.

-s | --string

Content of a simple php code string without script tags <?php ... ?>

-n | --no-recurse

Do not recursively parse files into subdirectories when using --dir .

-v | --verbose

Set the verbose level. From 0 (no extra information) to 7 (full extra details).

In level 0, pci give only results related to -d or -f. See first line of the console table. If there are more than one line, next ones are details for each file of a directory/branch.

+-----------------------------+---------+---+------------+--------------------+
| Path                        | Version | C | Extensions | Constants/Tokens   |
+-----------------------------+---------+---+------------+--------------------+
| ...amp\tmp\HTML_CSS-1.5.1\* | 5.0.0   | 5 | pcre       | __FILE__           |
|                             |         |   | date       | ...CTORY_SEPARATOR |
|                             |         |   |            | PHP_EOL            |
|                             |         |   |            | public             |
|                             |         |   |            | protected          |
+-----------------------------+---------+---+------------+--------------------+
| ...p\HTML_CSS-1.5.1\CSS.php | 5.0.0   | 1 | pcre       |                    |
|                             |         |   | date       |                    |
+-----------------------------+---------+---+------------+--------------------+
| ...1.5.1\tests\AllTests.php | 5.0.0   | 4 |            | __FILE__           |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...L_CSS_TestSuite_Bugs.php | 5.0.0   | 4 |            | protected          |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...S_TestSuite_Standard.php | 5.0.0   | 4 |            | __FILE__           |
|                             |         |   |            | ...CTORY_SEPARATOR |
|                             |         |   |            | protected          |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...xamples\CSS_Advanced.php | 3.0.0   | 0 |            |                    |
+-----------------------------+---------+---+------------+--------------------+
         

In level 1, pci give results of level 0 with a summary of command line arguments. For example

pci -v 1 -d C:\wamp\tmp\HTML_CSS-1.5.1
         
give table of level 0 (see previous), plus :
Command Line resume :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+
| verbose                 | 1                                                 |
| dir                     | C:\wamp\tmp\HTML_CSS-1.5.1                        |
+-------------------------+---------------------------------------------------+
         

In level 2, pci give results of level 0 with the list of options used to parse file or directory. For example

pci -v 2 -d C:\wamp\tmp\HTML_CSS-1.5.1
         
give table of level 0 (see previous), plus :
Parser options :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+
| debug                   | FALSE                                             |
+-------------------------+---------------------------------------------------+
         

Note: Even when none option are used, the summary table is displayed.

In level 3, pci give results of level 0, 1 and 2. For example

pci -v 3 -n -d C:\wamp\tmp\HTML_CSS-1.5.1
         
give table of level 0 (see previous), plus :
Command Line resume :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+
| verbose                 | 3                                                 |
| no-recurse              | 1                                                 |
| dir                     | C:\wamp\tmp\HTML_CSS-1.5.1                        |
+-------------------------+---------------------------------------------------+

Parser options :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+
| debug                   | FALSE                                             |
| recurse_dir             | FALSE                                             |
+-------------------------+---------------------------------------------------+
         

In level 4, useless when using --dir , pci give results of level 0 with a list of functions implemented and their versions. For example

pci -v 4 -f C:\wamp\tmp\HTML_CSS-1.5.1\CSS.php
         
give :
+-----------------------------+---------+---+------------+--------------------+
| File                        | Version | C | Extensions | Constants/Tokens   |
+-----------------------------+---------+---+------------+--------------------+
| ...p\HTML_CSS-1.5.1\CSS.php | 5.0.0   | 1 | pcre       |                    |
|                             |         |   | date       |                    |
+-----------------------------+---------+---+------------+--------------------+

Debug:

+---------+----------------------+-----------+------+
| Version | Function             | Extension | PECL |
+---------+----------------------+-----------+------+
| 4.0.0   | define               |           | no   |
| 4.0.0   | is_array             |           | no   |
| 4.0.0   | strtolower           |           | no   |
| 4.0.0   | substr               |           | no   |
... (more lines not displayed here) ...
| 4.0.0   | func_get_args        |           | no   |
| 4.0.4   | call_user_func_array |           | no   |
| 4.0.6   | is_callable          |           | no   |
| 4.0.7   | version_compare      |           | no   |
| 4.3.0   | debug_backtrace      |           | no   |
| 5.0.0   | file_put_contents    |           | no   |
+---------+----------------------+-----------+------+
         

Level 5 is equivalent to level 4 + level 1.

Level 6 is equivalent to level 4 + level 2.

And finally, level 7 is equivalent to level 4 + level 2 + level 1.

-if | --ignore-files

Identify the file name (path) to a text file that contains on each line the name of each file to ignore when parsing a directory/branch.

-id | --ignore-dirs

Identify the file name (path) to a text file that contains on each line the name of each sub-directory to ignore when parsing a directory/branch.

-in | --ignore-functions

Identify the file name (path) to a text file that contains on each line the name of each PHP function to ignore when parsing a directory or a single file.

-ic | --ignore-constants

Identify the file name (path) to a text file that contains on each line the name of each PHP constant to ignore when parsing a directory or a single file.

-ie | --ignore-extensions

Identify the file name (path) to a text file that contains on each line the name of each PHP extension to ignore (all extension.functions) when parsing a directory or a single file.

-iv | --ignore-versions

Expect one or two values that identify which PHP version (and all its related functions) to ignore.

Tip

For example: ignore all PHP 5 functions (minor releases 0 thru 2), or only PHP 5.0.0 functions.

pci -f FILE | -d DIR  -iv 5.0.0 5.2.0
pci -f FILE | -d DIR  -iv 5.0.0
          

-inm | --ignore-functions-match

Identify the file name (path) to a text file that contains on each line a pattern (match a regular expression) of PHP function to ignore when parsing a directory, a single file, or a string.

Comments start with ";", as in php.ini, and blank lines are allowed.

If you want to use the preg_match compare function, put a "=", to start the line, follow by a regular expression.

-iem | --ignore-extensions-match

Identify the file name (path) to a text file that contains on each line a pattern (match a regular expression) of PHP extension to ignore when parsing a directory, a single file, or a string.

Comments start with ";", as in php.ini, and blank lines are allowed.

If you want to use the preg_match compare function, put a "=", to start the line, follow by a regular expression.

-icm | --ignore-constants-match

Identify the file name (path) to a text file that contains on each line a pattern (match a regular expression) of PHP constant to ignore when parsing a directory, a single file, or a string.

Comments start with ";", as in php.ini, and blank lines are allowed.

If you want to use the preg_match compare function, put a "=", to start the line, follow by a regular expression.

-h | --help

Show full help usage with all switchs explained.

-r | --report

Print either an xml or text report (default).

For example:

pci -r xml -f C:\wamp\tmp\PHP_CodeSniffer-1.0.1\CodeSniffer.php
         
give these results (when package XML_Beautifier is available)
          
<?xml version="1.0" encoding="UTF-8"?>
<pci version="1.7.0">
 <files count="1">
  <file name="C:\wamp\tmp\PHP_CodeSniffer-1.0.1\CodeSniffer.php">
   <version>5.1.2</version>
   <conditions level="0" />
   <extensions count="5">
    <extension>spl</extension>
    <extension>pcre</extension>
    <extension>date</extension>
    <extension>xml</extension>
    <extension>tokenizer</extension>
   </extensions>
   <constants count="3">
    __FILE__
    PHP_EOL
    DIRECTORY_SEPARATOR
   </constants>
   <tokens count="3">
    <token>throw</token>
    <token>protected</token>
    <token>public</token>
   </tokens>
   <ignored>
    <functions count="0" />
    <extensions count="0" />
    <constants count="0" />
   </ignored>
  </file>
 </files>
</pci>
          
And with little debug option ( -v4 )
pci -r xml -v4 -f C:\wamp\php\PEAR\PHP\CodeSniffer.php
         
results became
          
<?xml version="1.0" encoding="UTF-8"?>
<pci version="1.7.0">
 <files count="1">
  <file name="C:\wamp\tmp\PHP_CodeSniffer-1.0.1\CodeSniffer.php">
   <version>5.1.2</version>
   <conditions count="0" level="0" />
   <extensions count="5">
    <extension>spl</extension>
    <extension>pcre</extension>
    <extension>date</extension>
    <extension>xml</extension>
    <extension>tokenizer</extension>
   </extensions>
   <constants count="3">
    __FILE__
    PHP_EOL
    DIRECTORY_SEPARATOR
   </constants>
   <tokens count="3">
    <token>throw</token>
    <token>protected</token>
    <token>public</token>
   </tokens>
   <ignored>
    <functions count="0" />
    <extensions count="0" />
    <constants count="0" />
   </ignored>
   <functions count="40">
    <function version="4.0.0">class_exists</function>
    <function version="4.0.0">define</function>
    <function version="4.0.0">chdir</function>
    <function version="4.0.0">dirname</function>
    <function version="4.0.0">substr</function>
    <function version="4.0.0">str_replace</function>
    <function version="4.0.0">is_file</function>
    <function version="4.0.0">is_array</function>
    <function version="4.0.0">is_string</function>
    <function version="4.0.0">is_dir</function>
    <function version="4.0.0">basename</function>
    <function version="4.0.0">realpath</function>
    <function version="4.0.0">count</function>
    <function version="4.0.0">strtolower</function>
    <function version="4.0.0">strrpos</function>
    <function version="4.0.0">in_array</function>
    <function version="4.0.0">explode</function>
    <function version="4.0.0">array_pop</function>
    <function version="4.0.0">array_merge</function>
    <function version="4.0.0">file_exists</function>
    <function version="4.0.0">strtr</function>
    <function extension="pcre" pecl="false" version="4.0.0">preg_match</function>
    <function extension="date" pecl="false" version="4.0.0">time</function>
    <function version="4.0.0">ksort</function>
    <function version="4.0.0">htmlspecialchars</function>
    <function extension="xml" pecl="false" version="4.0.0">utf8_encode</function>
    <function version="4.0.0">strlen</function>
    <function version="4.0.0">str_repeat</function>
    <function version="4.0.0">ord</function>
    <function version="4.0.0">strtoupper</function>
    <function version="4.0.0">strpos</function>
    <function version="4.0.0">rtrim</function>
    <function version="4.0.0">is_writable</function>
    <function version="4.0.2">wordwrap</function>
    <function version="4.0.4">constant</function>
    <function extension="tokenizer" pecl="false" version="4.2.0">token_name</function>
    <function version="4.2.0">var_export</function>
    <function version="5.0.0">file_put_contents</function>
    <function version="5.0.2">interface_exists</function>
    <function extension="spl" pecl="false" version="5.1.2">spl_autoload_register</function>
   </functions>
  </file>
 </files>
</pci>
          

-fe | --file-ext

A comma separated list of file extensions to parse (only valid if parsing a directory). Default is: php, php4, inc, phtml




PHP_Compat::loadVersion

PEAR Manual