PHP_CompatInfo : The Definitive Guide

PHP_CompatInfo Manual

First Edition

Edited by

Laurent Laville

Copyright © 2006, 2007, 2008 Laurent Laville

This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/.

Revision History
Revision 1.8.0 | August 1, 2008

  • Since release 1.8.0b1, the core of API was rewritten following the MVC pattern. It's allow now to customize more easily the output at end-user convenience. Please read the What is new section to learn more about this major version.

  • There are no Backward Compatibility breaks. You can still continue to run your old scripts with the new API 1.8.0

  • DO NOT forget to read also the FAQ to see if your problem as already found a solution.

Revision 1.7.0 | April 17, 2008

  • Improved detection on conditionnal code: with 3 new options : ignore_functions_match, ignore_extensions_match, ignore_constants_match.

    See the API part, Parser options section of Reference Guide.

    See also new key-information "cond_code" with a level of warning about all functions/extensions/constants conditionned.

Revision 1.6.0 | February 16, 2008

  • loadVersion() may return both function or function+constant list. 2 examples added in Reference Guide.

  • Allow to parse a string without using script tags <?php ... ?> with new -s or --string parameter on CLI

  • Allow to print either an "xml" or "cli" (default) report with new -r | --report on CLI

Revision 1.5.1 | November 19, 2007

  • Manual license Creative Commons upgrade from version 2.0 to 3.0

  • Added new section, about what is new in releases.

Revision 1.5.0 | November 15, 2007

  • Split API note section with related since data, display now release number and date.

  • Version 1.5.0 marked drop down support of PHP3 script detection. If you still used PHP3 scripts, you need to install version 1.4.3 of PHP_CompatInfo.

  • Important reference changes:

    Windows script user "compatinfo.bat" was renamed to "pci.bat"

    *Nix script user "pcicmd" was renamed to "pci" and is located now into PHP_PEAR_INSTALL_DIR

Revision 1.4.1 | February 12, 2007

  • Readability improved with hilighted source code (GESHI) and make html W3C strict compliant (with TIDY).

  • Copyright bumped to 2007

Revision 1.4.0 | September 27, 2006

The first edition of this Guide is now completed. It cover version 1.4.0 (stable) of PHP_CompatInfo.

Table of Contents

Preface
Organization of This Book
Pre-requisites
I. Introduction
1. About PHP_CompatInfo
2. What's New in version ?
3. FAQ - Frequently Asked Questions
4. Installing PHP_CompatInfo
II. Getting Started
5. Overview
6. Basic detection
7. Advanced detection
8. Conditional Code Analysis
9. The Command-Line Parser
10. Outputting Results
III. Reference Guide
11. API - Application Programming Interface
12. PHP version history
13. Observers
14. Parsing data sources
15. Parser infrastructure
16. Renderer infrastructure
17. Array Renderer
18. Csv Renderer
19. Html Renderer
20. Null Renderer
21. Text Renderer
22. Xml Renderer
23. Command-Line version
PHP_CompatInfo : The Definitive Guide v 1.8.0 : August 1, 2008


Preface

Table of Contents

Organization of This Book
Pre-requisites

Organization of This Book

This book is divided into three main parts, they are:

  • Introduction

    This section contains a gentle introduction to what PHP_CompatInfo is and has to offer. Included is general information about installing and using this PEAR package, and answers to frequently asked questions.

  • Getting Started

    This section is intended to provide a quick introduction to get started understanding, installing, and running the bundle examples.

  • Reference Guide

    This section describes every API in the PHP_CompatInfo package. The description of each function may contain some or all of the following parts:

    • Synopsis

      Shows the structure and prototype of the function.

    • Description

      Gives a description about what the function does.

    • Parameter

      Describes each parameter for the function along with the paramater types and names. Both required and optional parameters are listed.

    • Returns

      Describes the returned value, if the function doesn't fail.

    • Throws

      Describes the returned PEAR_Error objects, if the function fails.

    • Note

      Additional notes and information about the function. An example note would be if the function can be called statically.

    • See

      Links to other related functions or manual entries.

    • Example

      An example use of the function or class.


Pre-requisites

It is assumed that you have installed both PHP and PEAR.

It is also assumed that your PHP scripts are correctly interpreted by your web server. In most case it will be probably Apache, but you may also have IIS. PHP_CompatInfo runs both on Windows and *nix.


Part I. Introduction

Table of Contents

1. About PHP_CompatInfo
What is PHP_CompatInfo ?
Intended Audience
Why use PHP_CompatInfo ?
2. What's New in version ?
Version 0.7.x
Version 0.8.x
Version 1.0.x
Version 1.1.x
Version 1.2.x
Version 1.3.x
Version 1.4.x
Version 1.5.x
Version 1.6.x
Version 1.7.x
Version 1.8.x
3. FAQ - Frequently Asked Questions
4. Installing PHP_CompatInfo


Chapter 1. About PHP_CompatInfo

Table of Contents

What is PHP_CompatInfo ?
Intended Audience
Why use PHP_CompatInfo ?
Features
System Requirements

What is PHP_CompatInfo ?

The PHP_CompatInfo package will parse a file/folder/script/array to find out the minimum version and extensions required for it to run. Features advanced debug output which shows which functions require which version and CLI output script.


Intended Audience

This document is written as a guide to and reference for the PHP_CompatInfo package, for both beginner and expert users.


Why use PHP_CompatInfo ?

Features
System Requirements

None other PHP solution exists to find out the minimum version and the extensions required for a piece of code to run.

Features

  • parse a single file
  • parse a folder/directory
  • parse an array (list of file)
  • ability to give a list of functions to ignore when calculating the version needed
  • ability to give a list of directories to ignore when calculating the version needed
  • ability to go recursively or not into folder to find files
  • ability to reduce or extends list of extensions to parse for PHP code
  • ability to give a list of constants to ignore when calculating the version needed. Available since version 1.2.0
  • ability to get list of functions related to a PHP version (or a subset). Available since version 1.2.0
  • ability to give a list of (related functions of) php modules/extensions to ignore when calculating the version needed. Available since version 1.4.0
  • ability to give a list of (related functions of) php versions to ignore when calculating the version needed. Available since version 1.4.0
  • ability to exclude from parsing scope, some functions, extensions, constants, based on conditionnal code. Available since version 1.7.0
  • ability to know conditional code (such as function_exists) used by php scripts. Available since version 1.7.0

System Requirements

Mandatory resources :

  • PHP 4.3.10 or newer.

  • PEAR 1.5.4 or newer.

  • PEAR::Console_Table 1.0.5 or newer.

  • PEAR::Console_GetArgs 1.3.3 or newer.

  • PEAR::File_Find 1.3.0 or newer.

  • PEAR::Event_Dispatcher 1.0.0 or newer.

  • tokenizer extension.

Optional resources:

  • PHPUnit 3.2.0 or newer.

  • PEAR::XML_Util 1.1.4 or newer.

  • PEAR::XML_Beautifier 1.1 or newer.

  • PEAR::Console_ProgressBar 0.5.2beta or newer.

  • PEAR::Var_Dump 1.0.3 or newer.

  • PEAR::HTML_Table 1.8.2 or newer.


Chapter 2. What's New in version ?

Table of Contents

Version 0.7.x
Version 0.8.x
Version 1.0.x
Version 1.1.x
Version 1.2.x
Version 1.3.x
Version 1.4.x
Version 1.5.x
Version 1.6.x
Version 1.7.x
Version 1.8.x

[Warning] Warning
If you need PHP3 detection, DO NOT use version 1.5.0 or greater, but the latest release of 1.4 branch (1.4.3)

Version 0.7.x

  • Initial PEAR public release: occured in March 2003, one month later after package proposal was launched under name PHP_Compatibility

  • Added the ability to ignore files: in PHP_CompatInfo::parseFolder() and PHP_CompatInfo::parseArray()

  • Added the ability to ignore folders: in PHP_CompatInfo::parseFolder()

  • Added the ability to ignore functions: in all public methods.


Version 0.8.x

  • Added a command line interface: with new class PHP_CompatInfo_Cli

  • Added a clone function: to PHP_CompatInfo::parseFolder() named PHP_CompatInfo::parseDir(). parseFolder() became now an alias of parseDir().

  • Added new option file_ext for parseArray: This option contains an array of file extensions to parse for PHP code. Default: php, php4, inc, phtml

  • Fixed integration with PEAR_PackageFileManager: PackageFileManager::detectDependencies() implement call to PHP_CompatInfo and allow to detect easily minimum PHP version needed.


Version 1.0.x

  • Improved PHP5 detection: one year after first PEAR public release, stable version 1.0.0 fixed some bugs and also allow PHP3 script/function detection.


Version 1.1.x

  • Added support for reporting max PHP version: came with user request 6056

  • Improved PECL detection: especially with SAPI extension.


Version 1.2.x

  • Added new option ignore_constants: to
     PHP_CompatInfo::parseArray(),
     PHP_CompatInfo::parseDir(),
     PHP_CompatInfo::parseFolder(),
     PHP_CompatInfo::parseFile(),
     PHP_CompatInfo::parseString(),

  • Load components list for a PHP version or subset: added new function PHP_CompatInfo::loadVersion() to API


Version 1.3.x

  • Improved command line interface: output is limited to 80 columns for a better render. There is also now a windows launcher (named compatinfo.bat).

  • package xml 1.0: was stopped to be generated on version 1.3.2 (september 2006)


Version 1.4.x

  • Inactive leader: Davey Shafik, initial author of this package, became inactive, and I (Laurent Laville) follow his steps as new active package leader.

  • PHP 4.3.0: is now required as a minimum to use both web and cli interfaces.

  • License upgrade: from PHP 3.0 to PHP 3.01

  • Improved PHP5 detection: with some bug fixes


Version 1.5.x

  • Improved PHP5 detection: with new data source version.xml (revision 1.8) and funclist.txt (revision 1.39).

  • Dropped support of PHP3 detection: due to content of new data source version.xml (1.8) and funclist.txt (1.39)

  • Command line interface: under windows (pci.bat) and unix (pci.php) have now unified name. Idea came from PHP_CodeSniffer package that allow to fix lot of errors/warnings of coding standard.

    Debug output of CLI gave now origin of extension (from PECL or not) and minimum extension version (rather than PHP). See example docs/examples/checkExtensions.php


Version 1.6.x

  • Improved PHP5 detection: with data source version.xml (revision 1.9) and funclist.txt (revision 1.39).

    More PHP constant are detected natively:

    • Some Core Predefined Constants ( PHP_EOL, DIRECTORY_SEPARATOR, PATH_SEPARATOR, E_STRICT )

    • Date Predefined Constants ( DATE_* )

    • CLI Specific Constants ( STD* )

    • File Upload Error Specific Constants ( UPLOAD_ERR_* )

  • Command line interface: allow now to detect version of a simple string (code without using script tags <?php ... ?>. Uses new parameter -s or --string.

  • Command line interface: allow now to print either an xml or text report (default). Uses new parameter -r or --report.

  • loadVersion() may return both function or function+constant list.

  • PHP method chaining is implemented on "Davey Shafik" request #13094.


Version 1.7.x

  • Fix CLI output render to 80 columns, on main table :

    • 29 characters for File/Path column
    • 9 characters for Version column
    • 3 characters for C column (conditional code level)
    • 12 characters for Extensions column
    • 20 characters for Constants/Tokens column

  • Fix CLI output render to 80 columns, on additionnal tables :

    • 25 characters for Option column
    • 51 characters for Value column

  • Improved detection on conditionnal code: with new options : ignore_functions_match, ignore_extensions_match, ignore_constants_match.

    That allow to implement request 12857 : add the option to locally mask exceptions.

  • Implement request 13138 : separate constants and tokens in results.

  • Implement request 13147 : add filter file extension option on parsing directory (CLI)

  • On CLI, the XML report generation is now xml compliant with a root tag (pci)

    [Warning] Warning

    XML format is incompatible with version 1.6.x

  • ability to know conditional code (such as function_exists) used by php scripts. A level (and details) of warning about conditional code found during parsing source code is available for all interface (including command line : with new column C)

  • On CLI text report is customizable with new --output-level switch. Path/File+Version are always given on minimum report (0), until full details (max:15 - default).

  • On CLI you may now summarize the result with new --summarize switch. Remove extra lines for all files when parsing a directory.


Version 1.8.x

Rewrites of core API following the MVC pattern came from a user request that wanted to customized its CLI output. Even if output-level switch already exists, there is no easy way with no process-logic dependency.

A word about the new architecture: Parser logic may be found in class PHP_CompatInfo_Parser, while PHP_CompatInfo class is still the main controller, but just a wrapper to parser methods. Each output format (csv, xml, text, html, array, null) is produced by an independant renderer ( PHP_CompatInfo_Renderer_Csv, PHP_CompatInfo_Renderer_Xml, PHP_CompatInfo_Renderer_Text, PHP_CompatInfo_Renderer_Html, PHP_CompatInfo_Renderer_Array, PHP_CompatInfo_Renderer_Null ) with the common interface PHP_CompatInfo_Renderer

To create your own renderer or just customize a bit an exists renderer, please have a look on example named pci180_parsedir_tohtml.php

Here are the list of news and changes since previous API:

  • Always display result on standard output. To disable this feature, see the FAQ entry About new API 1.8.0.

  • 2 news output format. With the new renderer system, the Web SAPI may use the xml render (until now limited to CLI). While there is two news render: csv and html. Default output format (PHP dump array) use the array render while text is for CLI.

  • A common method to parse all data sources. The new method PHP_CompatInfo::parseData allow to parse all data source (array, string, file, directory) with the same interface. All others PHP_CompatInfo::parse* functions become now alias of this new method (to keep backward compatibility).

  • Event-driven architecture allow multiple renderer and extending core API of PHP_CompatInfo.

  • Progress bar for long process. Ability to display simple text wait message or a progress bar when parsing directories (or lot of files) from the command line, and even on web interface.

  • Constant E_RECOVERABLE_ERROR introduced with PHP 5.2.0, is now detected.


Chapter 3. FAQ - Frequently Asked Questions

3.1. General questions
3.1.1. What does it cost ?
3.1.2. Do you offer support ?
3.1.3. I found a bug, what shall i do ?
3.1.4. What is PEAR ?
3.2. How to do
3.2.1. I have a compatible PHP4/5 application with optional PHP5 code. How to ignore only PHP 5 code ?
3.3. About new API 1.8.0
3.3.1. I don't want to have result (PHP array dump) display on the standard output
3.3.2. I want to know what is the status of parsing my data source.

3.1. General questions

3.1.1. What does it cost ?
3.1.2. Do you offer support ?
3.1.3. I found a bug, what shall i do ?
3.1.4. What is PEAR ?
3.1.1.

What does it cost ?

You can download and use it for free. But don't delete the copyright notice. You can read terms of the license

3.1.2.

Do you offer support ?

YES if there is no answer in this Guide and if you are ready to share some informations such as : your configuration (platform Win *nix mac, PHP version, PEAR packages installed) and perharps your script.

3.1.3.

I found a bug, what shall i do ?

You can report it with the bug tracker at PEAR.

3.1.4.

What is PEAR ?

PEAR (an acronym for PHP Extension and Application Repository) is a framework and distribution system for reusable PHP components.

Don't forget to read also the PEAR Manual and PEAR FAQ.

3.2. How to do

3.2.1. I have a compatible PHP4/5 application with optional PHP5 code. How to ignore only PHP 5 code ?
3.2.1.

I have a compatible PHP4/5 application with optional PHP5 code. How to ignore only PHP 5 code ?

If you want to ignore all PHP5 code (functions, constants, extensions), you only need to add a line on your parsing (file, directory, string) options: "ignore_versions". In this example all PHP 5.0.0 to 5.2.0 code will be ignored when parsing current directory.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $dir = dirname(__FILE__);
  5. $options = array('ignore_versions' => array('5.0.0', '5.2.0'));
  6.
  7. $pci = new PHP_CompatInfo();
  8. $res = $pci->parseDir($dir, $options);
  9. var_dump($res);
  10. ?>

3.3. About new API 1.8.0

3.3.1. I don't want to have result (PHP array dump) display on the standard output
3.3.2. I want to know what is the status of parsing my data source.
3.3.1.

I don't want to have result (PHP array dump) display on the standard output

Even if it's the new behavior of API 1.8.0, you can still consumes all output events with the Null renderer. Give the null value (case insensitive), as first parameter to the class constructor.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $pci = new PHP_CompatInfo('null');
  5.
  6. $res = $pci->parseData($datasource);
  7.
  8. // display results is only produced by the line below
  9. var_dump($res);
  10. ?>

3.3.2.

I want to know what is the status of parsing my data source.

For a single file, it's not necessary to have a progress bar or a message wait. But when you parse a directory with many subdirectories and files, it may take some time.

Depending of interface you're running (CLI or Web) you've two ways to display a progress bar or a message wait.

[Warning] Warning

If you specify a progress bar to wait and you don't have PEAR::Console_ProgressBar package installed, default use standard text messages (no error stop the process).

Wait while parsing data source ...
Wait while parsing file "C:\wamp\tmp\Services_W3C_CSSValidator-0.1.0\CSSValidator.php"

On CLI with pci command, give the -p|--progress switch with either bar (for a progress bar), or text (for a simple text message).

pci --summarize --progress bar --dir C:\Temp\beehiveforum082\forum

On CLI without pci command, use the second parameter (driver specific options) of class constructor. Give progress key with bar (for a progress bar), or text (for a simple text message). And don't forget to de-activate silent mode (default is on for behavior backward compatibility).

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $driverType    = 'csv';
  5. $driverOptions = array('silent' => false, 'progress' => 'bar');
  6.
  7. $pci = new PHP_CompatInfo($driverType, $driverOptions);
  8. ?>

It will produce something like:

-  79/419 files [====>-----------------]  18.85% Elapsed Time: 00:28.93

For Web SAPI see the full example available in distribution into examples directory named pci180_parsefolder_tohtml.php. It used the PEAR::HTML_Progress2 package to produce a progress bar with COMET method (not AJAX).


Chapter 4. Installing PHP_CompatInfo

PHP_CompatInfo (alias PCI) should be installed using the PEAR Installer. This installer which provides a distribution system for PHP packages and full application, support channels architecture and custom file tasks. Learn more about new features in PEAR 1.4

Although using the PEAR Installer is the most easy way to install PCI, you can install PCI manually. For manual installation, do the following:

  1. Download the most recent release archive from http://pear.php.net/get/PHP_CompatInfo/ and extract it to a directory that is listed in the include_path of your php.ini configuration file.

  2. Prepare the pci.bat script:

    [Note] Note

    For windows users only

    1. Rename the compatinfo.bat script to pci.bat.

    2. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter. Replace also the @bin_dir@ string in it with the directory where you will put the pci script.

    3. Copy it to a directory that is in your PATH

  3. Prepare the pci script:

    1. Rename the pci.php file to pci.

    2. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).

    3. Copy it to a directory that is in your PATH and make it executable (chmod +x pci), or for windows users copy it to the directory corresponding to @bin_dir@ string (see previous modification).

  4. Prepare the html renderer script (CompatInfo/Renderer/Html.php):

    1. Replace the @data_dir@ string in it with the path where you have extracted the downloaded package.

    2. If you do not move the stylesheet pci.css to another location, remove the line with . '@package_name@' . DIRECTORY_SEPARATOR.

  5. Download also, release archive of PEAR::Console_Table package version 1.0.5 (or better), from http://pear.php.net/package/Console_Table/download and extract it to a directory that is listed in the include_path of your php.ini configuration file.

  6. Download also, release archive of PEAR::Console_GetArgs package version 1.3.3 (or better), from http://pear.php.net/package/Console_GetArgs/download and extract it to a directory that is listed in the include_path of your php.ini configuration file.

  7. Download also, release archive of PEAR::File_Find package version 1.3.0 (or better), from http://pear.php.net/package/File_Find/download and extract it to a directory that is listed in the include_path of your php.ini configuration file.

  8. Download also, release archive of PEAR::Event_Dispatcher package version 1.0.0 (or better), from http://pear.php.net/package/Event_Dispatcher/download and extract it to a directory that is listed in the include_path of your php.ini configuration file.

  9. Depending of what renderer (XML) you will use, you may also need to download release archive of PEAR::XML_Util package version 1.1.4 (or better), from http://pear.php.net/package/XML_Util/download and extract it to a directory that is listed in the include_path of your php.ini configuration file.

  10. Depending of what renderer (HTML) you will use, you may also need to download release archive of PEAR::HTML_Table package version 1.8.2 (or better), from http://pear.php.net/package/HTML_Table/download and extract it to a directory that is listed in the include_path of your php.ini configuration file.


Part II. Getting Started

Table of Contents

5. Overview
In brief
Accuracy of detection
6. Basic detection
Detection of a single file
Detection of a directory
7. Advanced detection
Detection of a single file
Detection of a directory
8. Conditional Code Analysis
Categories
How to catch them with web interface
How to catch them with CLI
9. The Command-Line Parser
10. Outputting Results
Overview
Basic usage
Configuration options
Array renderer options
Csv renderer options
Html renderer options
Text renderer options
Xml renderer options


Chapter 5. Overview

Table of Contents

In brief
Accuracy of detection

The purpose of this tutorial is to give the new users of PHP_CompatInfo an overview of its features and usage patterns.

In brief

There are two types of interface to run a PHP_CompatInfo script detection: CLI and web. All PHP_CompatInfo features (since 1.7.0) are available on both interface.

It's up to you to choose what is the best usage for you.


Accuracy of detection

PHP_CompatInfo may detect without error and with a great precision, any simple PHP scripts that have no switch conditions such as these ones : function_exists or version_compare.

  1. <?php
  2. // ...
  3. if (function_exists('debug_backtrace')) {
  4.     $backtrace = debug_backtrace();
  5. } else {
  6.     $backtrace = false;
  7. }
  8.
  9. if (version_compare(phpversion(), '5.0.0', '<')) {
  10.     include_once 'PHP/Compat.php';
  11.     PHP_Compat::loadFunction('ob_get_clean');
  12.     PHP_Compat::loadConstant('PHP_EOL');
  13. }
  14. // ...
  15. ?>

Don't be afraid, PHP_CompatInfo can still be use, even if your PHP scripts have these conditions or any others, but you should help it, to adjust the parser accuracy with one or more options. See the parser options reference list for details and advanced detection section.


Chapter 6. Basic detection

Table of Contents

Detection of a single file
Detection of a directory

Detection of a single file

In most case, the basic detection is enough. But sometimes, we will need to adjust accuracy of parser to give the best result. It is possible with $option, the second parameter of each parser method. See parser options list for details.

Suppose we have to detect which PHP version we need to run this script named "math.php"

  1. <?php
  2. $nb = bcsub(1.234, 5, 4);
  3. if (preg_match('/^-/', $nb)) {
  4.     echo 'minus';
  5. }
  6. ?>

We will use this very simple detection script.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $source = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'math.php';
  5.
  6. $info = new PHP_CompatInfo();
  7. $info->parseFile($source);
  8. // you may also use unified method:  $info->parseData($source);
  9. ?>

Default output used the Array renderer (we will talk about it and other renderers later; don't be afraid if you don't know what is it yet). Here are the raw results we got on standard output :

array (
  'ignored_files' =>
  array (
  ),
  'ignored_functions' =>
  array (
  ),
  'ignored_extensions' =>
  array (
  ),
  'ignored_constants' =>
  array (
  ),
  'max_version' => '',
  'version' => '4.0.0',
  'extensions' =>
  array (
    0 => 'bcmath',
    1 => 'pcre',
  ),
  'constants' =>
  array (
  ),
  'tokens' =>
  array (
  ),
  'cond_code' =>
  array (
    0 => 0,
  ),
)

It means that we need at least PHP 4.0.0 to run the "math.php" script. with two PHP extensions bcmath, pcre loaded.


Detection of a directory

Rather than parsing file after file of an application, you may give the root of your application path as the main directory to parse. Default is recursive parsing: that mean each directory children will be also parsed. And only files with extension php, php4, inc, phtml will be proceed.

Suppose we have to detect which PHP version we need to run the PEAR::File_Find package release 1.3.0

First begin to download the archive from http://pear.php.net/package/File_Find/download/1.3.0 and extract the full contents to a temporary directory (in our example its '/tmp')

We will use this very simple detection script.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $source = '/tmp/File_Find-1.3.0';
  5.
  6. $info = new PHP_CompatInfo();
  7. $info->parseDir($source);
  8. // you may also use unified method:  $info->parseData($source);
  9. ?>

Results displayed:

array (
  'ignored_files' =>
  array (
    0 => '/tmp/File_Find-1.3.0/package.xml',
    1 => '/tmp/File_Find-1.3.0/tests/01glob.phpt',
    2 => '/tmp/File_Find-1.3.0/tests/02maptree.phpt',
    3 => '/tmp/File_Find-1.3.0/tests/03maptreemultiple.phpt',
    4 => '/tmp/File_Find-1.3.0/tests/04search.phpt',
    5 => '/tmp/File_Find-1.3.0/tests/05search_inside.phpt',
    6 => '/tmp/File_Find-1.3.0/tests/06match_shell.phpt',
    7 => '/tmp/File_Find-1.3.0/tests/bug2773.phpt',
  ),
  'ignored_functions' =>
  array (
  ),
  'ignored_extensions' =>
  array (
  ),
  'ignored_constants' =>
  array (
  ),
  'max_version' => '',
  'version' => '4.3.0',
  'extensions' =>
  array (
    0 => 'pcre',
  ),
  'constants' =>
  array (
    0 => '__FILE__',
  ),
  'tokens' =>
  array (
  ),
  'cond_code' =>
  array (
    0 => 4,
  ),
  '/tmp/File_Find-1.3.0/Find.php' =>
  array (
    'ignored_functions' =>
    array (
    ),
    'ignored_extensions' =>
    array (
    ),
    'ignored_constants' =>
    array (
    ),
    'max_version' => '',
    'version' => '4.3.0',
    'extensions' =>
    array (
      0 => 'pcre',
    ),
    'constants' =>
    array (
    ),
    'tokens' =>
    array (
    ),
    'cond_code' =>
    array (
      0 => 4,
    ),
  ),
  '/tmp/File_Find-1.3.0/tests/setup.php' =>
  array (
    'ignored_functions' =>
    array (
    ),
    'ignored_extensions' =>
    array (
    ),
    'ignored_constants' =>
    array (
    ),
    'max_version' => '',
    'version' => '4.0.0',
    'extensions' =>
    array (
    ),
    'constants' =>
    array (
      0 => '__FILE__',
    ),
    'tokens' =>
    array (
    ),
    'cond_code' =>
    array (
      0 => 0,
    ),
  ),
)

means that package PEAR::File_Find 1.3.0 need at least PHP 4.3.0 with extension pcre.

[Caution] Caution

cond_cond offset 0 is set to 4. That means there are conditional code (constant condition) implemented in source code (with php defined function).

If you have a look on source code, you will see that all conditions referred to private package constant FILE_FIND_DEBUG

[Tip] Tip

You may avoid to read the source code to know the constant name, if you specify the debug option when parsing the directory.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $source = '/tmp/File_Find-1.3.0';
  5.
  6. $info = new PHP_CompatInfo();
  7. $info->parseDir($source, array('debug' => true));
  8. ?>

And you will see in displayed results, something like :

  'cond_code' =>
  array (
    0 => 4,
    1 =>
    array (
      0 =>
      array (
      ),
      1 =>
      array (
      ),
      2 =>
      array (
        0 => 'FILE_FIND_DEBUG',
      ),
    ),

cond_code offset 1 is an array available only when debug mode is set to true. In this array :

  • offset 0, give name of function conditions

  • offset 1, give name of extension conditions

  • offset 2, give name of constant conditions


Chapter 7. Advanced detection

Table of Contents

Detection of a single file
Detection of a directory

Detection of a single file

If your file implement code condition that is optional and don't break main goal, such as, for example : if function_exists then I do something, else I do something else.

Solution is very easy: You have to specify what function required should be considered as optional.

Suppose we have to detect which PHP version we need to run this chunk of script named "errorHandler.php". With standard behavior, PCI returns PHP 4.3.0 (because debug_backtrace came with version 4.3.0). So, if we ignore function debug_backtrace to find out the minimum version, we will get the real and true result.

  1. <?php
  2. // ...
  3. if (function_exists('debug_backtrace')) {
  4.     $backtrace = debug_backtrace();
  5. } else {
  6.     $backtrace = false;
  7. }
  8. // ...
  9. ?>

We will use another very simple detection script. Have a look on options array given as second parameter (here is the magic).

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $source  = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'errorHandler.php';
  5. $options = array('ignore_functions' => array('debug_backtrace'));
  6.
  7. $info = new PHP_CompatInfo();
  8. $info->parseFile($source, $options);
  9. // you may also use unified method:  $info->parseData($source, $options);
  10. ?>

And displayed results are :

array (
  'ignored_files' =>
  array (
  ),
  'ignored_functions' =>
  array (
    0 => 'debug_backtrace',
  ),
  'ignored_extensions' =>
  array (
  ),
  'ignored_constants' =>
  array (
  ),
  'max_version' => '',
  'version' => '4.0.0',
  'extensions' =>
  array (
  ),
  'constants' =>
  array (
  ),
  'tokens' =>
  array (
  ),
  'cond_code' =>
  array (
    0 => 1,
  ),
)

that means chunk of script named "errorHandler.php" need PHP 4.0.0, have condition code (function condition : cond_code = 1), and php debug_backtrace function was excluded from scope.

[Note] Note

Since version 1.7.0, you may catch this situation (more easily), and exclude from scope all functions that are conditionned by a function_exists. See example that follow.

Other alternative is to use ignore_functions_match option.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $source  = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'errorHandler.php';
  5. $options = array('ignore_functions_match' => array('function_exists', array('/.*/')));
  6.
  7. $info = new PHP_CompatInfo();
  8. $info->parseFile($source, $options);
  9. // you may also use unified method:  $info->parseData($source, $options);
  10. ?>

The string function_exists as first parameter, tell to ignore function(s) that match only conditionnal code with php function_exists().

The other possibility is string preg_match, that give more freedom, and catch function that match the pattern (without condition).

While array as second parameter, gave a list of pattern (function name) that must be catch and ignored.


Detection of a directory

Parsing a full directory, recursively or not, is no more difficult than detect PHP version of a single file.

This new example is based on auto detection of HTML_CSS 1.5.1 distribution. As we will see, basic detection is not accurate as it should be. But with an option we can get the real result (PHP minimum = 4.3.0).

First begin to download the archive from http://pear.php.net/package/HTML_CSS/download/1.5.1 and extract the full contents to a temporary directory (in our example its '/tmp')

We will focus on two important files: CSS.php and CSS/Error.php. So we will indicate to PCI to ignore examples/, and tests/ directories.

Here is the detection script:

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $source  = '/tmp/HTML_CSS-1.5.1';
  5. $options = array('ignore_dirs' => array('examples', 'tests'));
  6.
  7. $info = new PHP_CompatInfo();
  8. $info->parseDir($source, $options);
  9. // you may also use unified method:  $info->parseData($source, $options);
  10. ?>

And displayed results are :

array (
  'ignored_files' =>
  array (
    0 => '/tmp/HTML_CSS-1.5.1/ChangeLog',
    1 => '/tmp/HTML_CSS-1.5.1/package.xml',
    2 => '/tmp/HTML_CSS-1.5.1/tests/AllTests.php',
    3 => '/tmp/HTML_CSS-1.5.1/tests/HTML_CSS_TestSuite_Bugs.php',
    4 => '/tmp/HTML_CSS-1.5.1/tests/HTML_CSS_TestSuite_Standard.php',
    5 => '/tmp/HTML_CSS-1.5.1/tests/stylesheet.css',
    6 => '/tmp/HTML_CSS-1.5.1/examples/CSS_Advanced.php',
    7 => '/tmp/HTML_CSS-1.5.1/examples/CSS_DisplayOnline.php',
    8 => '/tmp/HTML_CSS-1.5.1/examples/css_errorstack_custom.php',
    9 => '/tmp/HTML_CSS-1.5.1/examples/css_errorstack_logger.php',
    10 => '/tmp/HTML_CSS-1.5.1/examples/css_error_custom.php',
    11 => '/tmp/HTML_CSS-1.5.1/examples/css_error_ignore.php',
    12 => '/tmp/HTML_CSS-1.5.1/examples/css_error_logger.php',
    13 => '/tmp/HTML_CSS-1.5.1/examples/CSS_grepStyles.php',
    14 => '/tmp/HTML_CSS-1.5.1/examples/CSS_InHeader.php',
    15 => '/tmp/HTML_CSS-1.5.1/examples/CSS_Inline.php',
    16 => '/tmp/HTML_CSS-1.5.1/examples/CSS_Logger.php',
    17 => '/tmp/HTML_CSS-1.5.1/examples/CSS_parseData.php',
    18 => '/tmp/HTML_CSS-1.5.1/examples/CSS_req12194_atrule_api.php',
    19 => '/tmp/HTML_CSS-1.5.1/examples/CSS_req12194_atrule_parser.php',
    20 => '/tmp/HTML_CSS-1.5.1/examples/CSS_Stylesheet.php',
    21 => '/tmp/HTML_CSS-1.5.1/examples/CSS_validate.php',
  ),
  'ignored_functions' =>
  array (
  ),
  'ignored_extensions' =>
  array (
  ),
  'ignored_constants' =>
  array (
  ),
  'max_version' => '',
  'version' => '5.0.0',
  'extensions' =>
  array (
    0 => 'date',
    1 => 'pcre',
  ),
  'constants' =>
  array (
  ),
  'tokens' =>
  array (
  ),
  'cond_code' =>
  array (
    0 => 1,
  ),
  '/tmp/HTML_CSS-1.5.1/CSS.php' =>
  array (
    'ignored_functions' =>
    array (
    ),
    'ignored_extensions' =>
    array (
    ),
    'ignored_constants' =>
    array (
    ),
    'max_version' => '',
    'version' => '5.0.0',
    'extensions' =>
    array (
      0 => 'date',
      1 => 'pcre',
    ),
    'constants' =>
    array (
    ),
    'tokens' =>
    array (
    ),
    'cond_code' =>
    array (
      0 => 1,
    ),
  ),
  '/tmp/HTML_CSS-1.5.1/CSS/Error.php' =>
  array (
    'ignored_functions' =>
    array (
    ),
    'ignored_extensions' =>
    array (
    ),
    'ignored_constants' =>
    array (
    ),
    'max_version' => '',
    'version' => '4.3.0',
    'extensions' =>
    array (
      0 => 'date',
    ),
    'constants' =>
    array (
    ),
    'tokens' =>
    array (
    ),
    'cond_code' =>
    array (
      0 => 0,
    ),
  ),
)

As we can read, PHP 5.0.0 is required to run the package.

Yes, but its the wrong result. HTML_CSS 1.5.1 require only PHP 4.3.0 to run.

[Tip] Tip

If you have cond_code offset with a value different than zero, you are almost sure that the version given is wrong.

So why we get such result ?

Package PEAR::HTML_CSS 1.5.1 as many application/extension use conditional code to emulate function that are unavailable for previous PHP versions. Its means that HTML_CSS use the php function function_exists() to implement such alternative.

To illustrate our purpose, we can find in source code (CSS.php) :

  1. <?php
  2. // ...
  3.     if (function_exists('file_put_contents')) {
  4.         file_put_contents($filename, $this->toString());
  5.     } else {
  6.         $file = fopen($filename, 'wb');
  7.         fwrite($file, $this->toString());
  8.         fclose($file);
  9.     }
  10. // ...
  11. ?>

PHP function file_put_contents() came with version 5.0.0; That is the reason of wrong parsing result. But we can catch such conditional code.

Let's see now how to set the good accuracy with conditional code analysis.


Chapter 8. Conditional Code Analysis

Table of Contents

Categories
How to catch them with web interface
How to catch them with CLI

Categories

As briefly introduced at end of Advanced detection chapter, we will learn now that there are 3 categories of conditional code that could give wrong result, if there are not catched properly.

These categories are :

  • function (cond_code = 1)

    A quick example:

    1. <?php
    2. if (function_exists('debug_backtrace')) {
    3.     $backtrace = debug_backtrace();
    4. } else {
    5.     $backtrace = false;
    6. }
    7. ?>

  • extension (cond_code = 2)

    A quick example:

    1. <?php
    2. if (extension_loaded('sqlite') == false) {
    3.     $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
    4.     dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
    5.     echo 'SQLite version : ' . sqlite_libversion();
    6. }
    7. ?>

  • constant (cond_code = 4)

    A quick example:

    1. <?php
    2. if (defined('DATE_RSS') {
    3.     $date_format = DATE_RSS;
    4. } else {
    5.     $date_format = 'D, j M Y H:i:s O';
    6. }
    7. // will display something like "Sat, 26 Jul 2008 16:56:24 +0200"
    8. echo date($date_format, mktime(0, 0, 0, 7, 26, 2008));
    9. ?>


How to catch them with web interface

At the beginning of first version that catch conditional code, there were only 3 options: ignore_functions, ignore_extensions and ignore_constants.

Incovenient with these options, is that you should know the source code to parse, and identify whose functions, extensions or constants to avoid.

Version 1.7.0 of API has introduced the ability to add name patterns to identify all or part of functions, extensions, constants to ignore from parsing. You should use now these options: ignore_functions_match, ignore_extensions_match or ignore_constants_match.

Let's take a look with an example, how it's easy to catch whatever you want to exclude from parsing. We will take again example of PEAR::HTML_CSS 1.5.1 package already seen in advanced directory detection.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $datasource = '/tmp/HTML_CSS-1.5.1';
  5. $options    = array(
  6.     'ignore_dirs' => array('examples', 'tests'),
  7.     'ignore_functions_match' => array('function_exists', array('/.*/')),
  8.     'ignore_extensions_match' => array('extension_loaded', array('/.*/')),
  9.     'ignore_constants_match' => array('defined', array('/.*/')),
  10.     );
  11.
  12. $pci = new PHP_CompatInfo();
  13. $pci->parseData($datasource, $options);
  14. ?>

Here we catch all standard conditional code (function_exists, extension_loaded, defined) what match all names (regular expression given by array('/.*/')).

[Tip] Tip

To catch what ever function you want, use preg_match rather than function_exists.

It's also true for extension_loaded and defined

With preg_match you are really free to ignore a single function, a group set or all functions, only by giving the good name pattern.

Example to ignore all functions prefixed by xdebug_ :

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $datasource = '/tmp/HTML_CSS-1.5.1';
  5. $options    = array(
  6.     'ignore_functions_match' => array('preg_match', array('/^xdebug_/')),
  7.     );
  8.
  9. $pci = new PHP_CompatInfo();
  10. $pci->parseData($datasource, $options);
  11. ?>


How to catch them with CLI

If you use the command-line parser with pci script, the solution is a bit different.

To catch cond_code = 1 (function), you must run the command

pci [-inm functions-match.txt]

where functions-match.txt is a text file, that identify on each line a new condition.

Each blank line or beginning with ; will be skipped (proceed as comment line like in php.ini)

If first non blank character is an equal sign (=), then you can catch what ever function you want with a preg_match condition (see xdebug example in previous section (web interface)

Example of text file contents

;=^xdebug_
;=alias$
.*
;file_put_contents

[Caution] Caution

Do not confuse a regular expression beginning with equal sign (=), and the same line without =.

In first case you will catch all functions that match the name pattern given found in all source code, while second case try to catch only matches found with if function_exists('') condition.

It's also true for extensions and constants, we will see them now.

To catch cond_code = 2 (extension), you must run the command

pci [-iem extensions-match.txt]

where extensions-match.txt is a text file, that identify on each line a new condition.

Each blank line or beginning with ; will be skipped (proceed as comment line like in php.ini)

If first non blank character is an equal sign (=), then you can catch what ever extension you want with a preg_match condition.

Example of text file contents

;=xdebug
;sqlite
=gd
;=sapi_apache

To catch cond_code = 4 (constant), you must run the command

pci [-icm constants-match.txt]

where constants-match.txt is a text file, that identify on each line a new condition.

Each blank line or beginning with ; will be skipped (proceed as comment line like in php.ini)

If first non blank character is an equal sign (=), then you can catch what ever constant you want with a preg_match condition.

Example of text file contents

=PHP_EOL
=DATE_RSS
;FILE_FIND_VERSION


Chapter 9. The Command-Line Parser

The Command-Line Parser can be invoked through the pci command.

Let's take a look at the command-line parser switches:

Usage: pci [options]

  -d   --dir (optional)value                      Parse DIR to get its
                                                  compatibility info ()
  -f   --file (optional)value                     Parse FILE to get its
                                                  compatibility info ()
  -s   --string (optional)value                   Parse STRING to get its
                                                  compatibility info ()
  -v   --verbose (optional)value                  Set the verbose level (1)
  -n   --no-recurse                               Do not recursively parse files

                                                  when using --dir
  -if  --ignore-files (optional)value             Data file name which contains
                                                  a list of file to ignore
                                                  (files.txt)
  -id  --ignore-dirs (optional)value              Data file name which contains
                                                  a list of directory to ignore
                                                  (dirs.txt)
  -in  --ignore-functions (optional)value         Data file name which contains
                                                  a list of php function to
                                                  ignore (functions.txt)
  -ic  --ignore-constants (optional)value         Data file name which contains
                                                  a list of php constant to
                                                  ignore (constants.txt)
  -ie  --ignore-extensions (optional)value        Data file name which contains
                                                  a list of php extension to
                                                  ignore (extensions.txt)
  -iv  --ignore-versions values(optional)         PHP versions - functions to
                                                  exclude when parsing source
                                                  code (5.0.0)
  -inm --ignore-functions-match (optional)value   Data file name which contains
                                                  a list of php function pattern

                                                  to ignore
                                                  (functions-match.txt)
  -iem --ignore-extensions-match (optional)value  Data file name which contains
                                                  a list of php extension
                                                  pattern to ignore
                                                  (extensions-match.txt)
  -icm --ignore-constants-match (optional)value   Data file name which contains
                                                  a list of php constant pattern

                                                  to ignore
                                                  (constants-match.txt)
  -fe  --file-ext (optional)value                 A comma separated list of file

                                                  extensions to parse (only
                                                  valid if parsing a directory)
                                                  (php, php4, inc, phtml)
  -r   --report (optional)value                   Print either "xml" or "csv"
                                                  report (text)
  -o   --output-level (optional)value             Print Path/File + Version with

                                                  additional data (31)
  -t   --tab (optional)value                      Columns width (29,12,20)
  -p   --progress (optional)value                 Show a wait message [text] or
                                                  a progress bar [bar] (bar)
  -S   --summarize                                Print only summary when
                                                  parsing directory
  -V   --version                                  Print version information
  -h   --help                                     Show this help

-d | --dir

pci [-d directory]

Runs the parser with all default options, and try to analyze content of files into directory identified by switch -d or --dir

-f | --file

pci [-f file]

Runs the parser with all default options, and try to analyze content of a single file identified by switch -f or --file

-s | --string

pci [-s string]

Runs the parser with all default options, and try to analyze content of a chunk of code (string) designed by switch -s or --string

-v | --verbose

pci [-v number] [-d directory]

Runs the parser with all default options, and try to analyze content of files into directory identified by switch -d or --dir with the level of detail given by number and switch -v or --verbose

Verbose level goes from 0 (no extra information) to 7 (full extra details).

  • Level 0 give only parsing results of data source (directory, file, string).

    For example: pci -v 0 -d /tmp/Services_W3C_CSSValidator-0.1.0 give

    +-----------------------------+---------+---+------------+--------------------+
| Files                       | Version | C | Extensions | Constants/Tokens   |
+-----------------------------+---------+---+------------+--------------------+
| ...W3C_CSSValidator-0.1.0/* | 5.1.0   | 4 | pecl_http  | ...CTORY_SEPARATOR |
|                             |         |   |            | __FILE__           |
|                             |         |   |            | instanceof         |
|                             |         |   |            | protected          |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...r-0.1.0/CSSValidator.php | 5.1.0   | 0 | pecl_http  | protected          |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...0.1.0/tests/AllTests.php | 5.0.0   | 4 |            | __FILE__           |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...W3C_CSSValidatorTest.php | 5.0.0   | 4 |            | ...CTORY_SEPARATOR |
|                             |         |   |            | __FILE__           |
|                             |         |   |            | protected          |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...les/validate_atrules.php | 4.0.0   | 0 |            |                    |
+-----------------------------+---------+---+------------+--------------------+
| ...ples/validate_byfile.php | 4.0.0   | 0 |            |                    |
+-----------------------------+---------+---+------------+--------------------+
| ...mples/validate_byuri.php | 4.0.0   | 0 |            |                    |
+-----------------------------+---------+---+------------+--------------------+
| ...es/validate_fragment.php | 4.0.0   | 0 |            |                    |
+-----------------------------+---------+---+------------+--------------------+
| ...0/CSSValidator/Error.php | 5.0.0   | 0 |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...CSSValidator/Message.php | 5.0.0   | 0 |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...SSValidator/Response.php | 5.0.0   | 0 |            | instanceof         |
|                             |         |   |            | public             |
+-----------------------------+---------+---+------------+--------------------+
| ...CSSValidator/Warning.php | 4.0.0   | 0 |            |                    |
+-----------------------------+---------+---+------------+--------------------+

  • Level 1 give same details as level 0, plus command line resume.

    For example: pci -v 1 -d /tmp/Services_W3C_CSSValidator-0.1.0 give

    Command Line resume :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+
| summarize               | FALSE                                             |
| output-level            | 31                                                |
| verbose                 | 1                                                 |
| dir                     | /tmp/Services_W3C_CSSValidator-0.1.0              |
+-------------------------+---------------------------------------------------+

  • Level 2 give same details as level 0, plus parser options used.

    For example: pci -v 2 -d /tmp/Services_W3C_CSSValidator-0.1.0 give

    Parser options :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+
| file_ext                | php                                               |
|                         | php4                                              |
|                         | inc                                               |
|                         | phtml                                             |
| recurse_dir             | TRUE                                              |
| debug                   | FALSE                                             |
| is_string               | FALSE                                             |
| ignore_files            |                                                   |
| ignore_dirs             |                                                   |
+-------------------------+---------------------------------------------------+

  • Level 3 is equivalent to level 2 + level 1 + level 0.

  • Level 4 give same details as level 0, plus list of php functions used with their version and source (extension PECL or standard).

    For example: pci -v 4 -d /tmp/Services_W3C_CSSValidator-0.1.0 give

    Debug:

+---------+-----------------+-----------+------+
| Version | Function        | Extension | PECL |
+---------+-----------------+-----------+------+
| 1.0.0   | http_request    | pecl_http | yes  |
| 4.0.0   | in_array        |           | no   |
| 4.0.0   | file_exists     |           | no   |
| 4.0.0   | is_bool         |           | no   |
| 4.0.0   | intval          |           | no   |
| 4.0.0   | defined         |           | no   |
| 4.0.0   | define          |           | no   |
| 4.0.0   | chdir           |           | no   |
| 4.0.0   | dirname         |           | no   |
| 4.0.0   | realpath        |           | no   |
| 4.0.0   | error_reporting |           | no   |
| 4.0.0   | ini_set         |           | no   |
| 4.0.0   | var_dump        |           | no   |
| 4.0.0   | get_object_vars |           | no   |
| 5.1.0   | property_exists |           | no   |
+---------+-----------------+-----------+------+

  • Level 5 is equivalent to level 4 + level 1 + level 0.

  • Level 6 is equivalent to level 4 + level 2.

  • Level 7 is equivalent to level 4 + level 2 + level 1.

-n | --no-recurse

pci [-n] [-d directory]

Runs the parser and analyze only files in directory identified by -d or --dir. Default behavior will parse all directory childs recursively.

-if | --ignore-files

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

Default value used files.txt file in the same directory as pci script.

-id | --ignore-dirs

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

Default value used dirs.txt file in the same directory as pci script.

-in | --ignore-functions

Identify the parameter text file that contains on each line the name of each PHP function to ignore when parsing the data source.

Default value used functions.txt file in the same directory as pci script.

-ic | --ignore-constants

Identify the parameter text file that contains on each line the name of each PHP constant to ignore when parsing the data source

Default value used constants.txt file in the same directory as pci script.

-ie | --ignore-extensions

Identify the parameter text file that contains on each line the name of each PHP extension to ignore (all extension.functions) when parsing the data source

-iv | --ignore-versions

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

[Tip] Tip

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

pci [-f file] [-iv 5.0.0 5.2.0]

pci [-d directory] [-iv 5.0.0]

-inm | --ignore-functions-match

Identify the parameter text file that contains on each line a pattern (match a regular expression) of PHP function to ignore when parsing the data source.

Default value used functions-match.txt file in the same directory as pci script.

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 parameter text file that contains on each line a pattern (match a regular expression) of PHP extension to ignore when parsing the data source.

Default value used extensions-match.txt file in the same directory as pci script.

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 parameter 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.

Default value used constants-match.txt file in the same directory as pci script.

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.

-fe | --file-ext

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

-r | --report

Print either a text report (default), or any others render available (csv, xml, ...)

For example:

pci [-r xml] [-f /tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php]

give these results (when package XML_Beautifier is available)

<?xml version="1.0" encoding="UTF-8"?>
<pci version="1.8.0">
    <file name="/tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php">
    <version>5.1.2</version>
    <conditions level="0" />
    <extensions count="5">
        <extension>date</extension>
        <extension>pcre</extension>
        <extension>spl</extension>
        <extension>tokenizer</extension>
        <extension>xml</extension>
    </extensions>
    <constants count="3">
        <constant>DIRECTORY_SEPARATOR</constant>
        <constant>PHP_EOL</constant>
        <constant>__FILE__</constant>
    </constants>
    <tokens count="5">
        <token>catch</token>
        <token>protected</token>
        <token>public</token>
        <token>throw</token>
        <token>try</token>
    </tokens>
    <ignored>
        <files count="0" />
        <functions count="0" />
        <extensions count="0" />
        <constants count="0" />
    </ignored>
</pci>

And with little debug option ( verbose level 4 )

pci [-r xml] [-v 4] [-f /tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php]

results became

<?xml version="1.0" encoding="UTF-8"?>
<pci version="1.8.0">
    <file>/tmp/PHP_CodeSniffer-1.1.0/CodeSniffer.php</file>
    <version>5.1.2</version>
    <conditions count="0" level="0" />
    <extensions count="5">
        <extension>date</extension>
        <extension>pcre</extension>
        <extension>spl</extension>
        <extension>tokenizer</extension>
        <extension>xml</extension>
    </extensions>
    <constants count="3">
        <constant>DIRECTORY_SEPARATOR</constant>
        <constant>PHP_EOL</constant>
        <constant>__FILE__</constant>
    </constants>
    <tokens count="5">
        <token>catch</token>
        <token>protected</token>
        <token>public</token>
        <token>throw</token>
        <token>try</token>
    </tokens>
    <ignored>
        <files count="0" />
        <functions count="0" />
        <extensions count="0" />
        <constants count="0" />
    </ignored>
    <functions count="41">
        <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">count</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">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">is_null</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>
</pci>

-o | --output-level

Allow to filter data type (column) you want on standard output (console). From all details (31=default) to only file name (=0)

  • 0: file name

  • 1: conditional code

  • 2: extensions

  • 4: constants

  • 8: tokens

  • 16: version

output_level is binary value. So to have, for example, only file name (always mandatory) with version and extensions, you have to give value 18 (16 + 2).

-t | --tab

Sets the Files, Etensions and Constants/Tokens columns width. Default values are: 29 char. for Files colum, 12 char. for Extentions column, and 20 char. for Constants/Tokens column.

Here are the best values optimized by output-level for a 80 columns screen width, to almost always see extensions and constants/tokens without name truncated: first value is always for Files column (f), second value is always for Extensions column (e), and third value is always for Constants/Tokens column (c)

[Note] Note

If a (f,e,c) value is missing then the corresponding default value (f=29,e=12,c=20) is used.

For example: 56,,20 is equivalent to 56,12,20

  • output-level 0: 77

  • output-level 1: 73

  • output-level 2: 59,17

  • output-level 3: 55,17

  • output-level 4, 8, 12: 55,,21

  • output-level 5, 9, 13: 51,,21

  • output-level 6, 10, 14: 37,17,21

  • output-level 7, 11, 15: 33,17,21

  • output-level 16: 67

  • output-level 17: 63

  • output-level 18: 49,17

  • output-level 19: 45,17

  • output-level 20, 24: 45,,21

  • output-level 21, 25, 29: 41,,21

  • output-level 22, 26, 30: 27,17,21

  • output-level 23, 27, 31: 23,17,21

  • output-level 24, 28: 45,17,21

-p | --progress [ bar | text ]

Show a progress bar (if PEAR::Console_ProgressBar is installed) or a simple text wait message when parsing a directory.

[Note] Note

If you specify --progress bar and PEAR::Console_ProgressBar is not available, then default display will be text wait message (without giving an error), as if you have specified --progress text instead

-S | --summarize

Print only the summary of parsing result for a directory, rather than full details file by file (default).

-V | --version

Print only the current version information

-h | --help

Show help panel (as described in beginning of this section)

Let's take a look now at the result displayed : the main table

+-----------------------------+---------+---+------------+--------------------+
| Files                       | Version | C | Extensions | Constants/Tokens   |
+-----------------------------+---------+---+------------+--------------------+

+-----------------------------+---------+---+------------+--------------------+

We have, by default (output-level = 31) 5 columns

[Note] Note

For Files, Extensions, Constants/Tokens columns, if content is larger than cell width, then the content if truncated by left, and replaced by ...

  • Files Identify each file of data source parsed.

  • Version Give the minimum version to run the file. And if there is a second number, give the max version to run source file.

  • C Show the level of conditional code found in your source file(s). From 0=none, 1=function_exists, 2=extension_loaded, 4=defined and more (its binary value). This C column is the same information given by cond_code in final hash result of Array Renderer.

  • Extensions List the PHP standard or PECL extensions required to run the source file.

  • Constants/Tokens List the PHP standard or user defined constants and PHP5+ tokens (such as: private, public, final, ...)

When verbose mode is set to level 1, you have an additional table displayed, that resume the command line arguments

Command Line resume :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+

+-------------------------+---------------------------------------------------+

When verbose mode is set to level 2, you have an additional table displayed, that resume the parser options used

Parser options :

+-------------------------+---------------------------------------------------+
| Option                  | Value                                             |
+-------------------------+---------------------------------------------------+

+-------------------------+---------------------------------------------------+

When verbose mode is set to level 4, you have an additional table displayed, that show each PHP standard or PECL functions with their version

Debug:

+---------+-----------------+-----------+------+
| Version | Function        | Extension | PECL |
+---------+-----------------+-----------+------+

+---------+-----------------+-----------+------+


Chapter 10. Outputting Results

Table of Contents

Overview
Basic usage
Configuration options
Array renderer options
Csv renderer options
Html renderer options
Text renderer options
Xml renderer options

Overview

PHP_CompatInfo can use different kind of renderers and provides a default one (Array) which print a complete parsable string representation of results.

There are 6 renderers available with PHP_CompatInfo 1.8.0

  • Array, PHP_CompatInfo_Renderer_Array. It is similar to PHP var_export May be beautify if PEAR::Var_Dump is installed on your system.

  • Csv, PHP_CompatInfo_Renderer_Csv. Print a comma separate values of results.

  • Html, PHP_CompatInfo_Renderer_Html. Print a pretty nice table with a customizable style sheet (inline or to a separate file)

  • Null, PHP_CompatInfo_Renderer_Null. The solution to suppress display on standard output.

  • Text, PHP_CompatInfo_Renderer_Text. This renderer is usefull only with the command-line parser mode (CLI).

  • Xml, PHP_CompatInfo_Renderer_Xml. Print an XML representation of results. May be beautify if PEAR::XML_Beautifier is installed on your system.

If none of them match your need, you can also write your own renderers.


Basic usage

The main steps of using any available renderer are quite similar:

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. // data source to parse: file, directory, string, ...
  5. $datasource = '/tmp/HTML_CSS-1.5.1';
  6.
  7. // parser options depending of data source
  8. $options    = array();
  9.
  10. // kind of renderer: array, csv, html, null, text, xml, ...
  11. $driverType    = 'array';  // case insensitive
  12.
  13. // specific renderer hash options
  14. $driverOptions = array();
  15.
  16. $pci = new PHP_CompatInfo($driverType, $driverOptions);
  17. $r = $pci->parseData($datasource, $options);
  18. ?>

[Note] Note

To keep compatibility with previous versions, you can find the result similar to var_export (Array renderer) in $r (in our example). All parse functions (parseDir, parseFile, parseArray, parseString) have the same behavior.

PHP_CompatInfo class constructor expect to receive two parameters: first one identify the kind of renderer (array, csv, html, null, text, xml), while second is private and specific to each renderer. Allows to customize a bit the renderer without to rewrite a new one (explore all options before beginning to write your own version).


Configuration options

Before to have a look on each driver specific options, take a short pause on common options of all renderers.

  • silent mode : When parsing more than one source file, PHP_CompatInfo can display status of long process. With simple wait text messages, or a progress bar if PEAR::Console_ProgressBar is available (installed on your system).

    The default mode silent On, is turn off when you specify a progress bar or a progress text with --progress or -p switches on CLI with the pci script.

    If you run the web interface, you have to turn it on manually. For example:

    1. <?php
    2. require_once 'PHP/CompatInfo.php';
    3.
    4. // data source to parse: file, directory, string, ...
    5. $datasource = '/tmp/HTML_CSS-1.5.1';
    6.
    7. // parser options depending of data source
    8. $options    = array();
    9.
    10. // kind of renderer: array, csv, html, null, text, xml, ...
    11. $driverType    = 'array';  // case insensitive
    12.
    13. // Turn Off the silent mode, and display simple wait text messages
    14. $driverOptions = array('silent' => false, 'progress' => 'text');
    15.
    16. $pci = new PHP_CompatInfo($driverType, $driverOptions);
    17. $r = $pci->parseData($datasource, $options);
    18. ?>

    See also the docs/examples/parseDir_withCustomProgressBar.php example in the package distribution, to customize a progress bar for the CLI and pci script usage.

  • output-level allow to choose what information (condition code level, extensions, constants, tokens, version) will be shown or hidden.

    Default value is 31: that means we show all details. See the Command-Line Parser section, and -o | --output-level switch to learn more about values and corresponding behaviors.

  • summarize mode, is usefull when you parse more than one file, and don't want to see intermediate result of each file, but only the final one.

    Default is turn off.

  • verbose level, give details deep you want to have: from 0 (no extra information) to 7 (full details).

    Default level is 0. See the Command-Line Parser section, and -v | --verbose switch to learn more about values and corresponding behaviors.

[Important] Important

All renderers can be run in both interfaces (web and cli), this is why we can find a hash named args in the driver array options (second parameter of PHP_CompatInfo class constructor). This hash replace corresponding arguments you should have (otherwise) to specify on the Command-Line.


Array renderer options

Array renderer used two drivers to show dump of results. Default is PHP (var_export function). The other one is PEAR::Var_Dump. You can use this last one only if package is installed on your system.

While there are no specific options for PHP driver, you can use all options of PEAR::Var_Dump to beautify the dump of results. See example docs/examples/pci180_parsefile.php in the package distribution.

First key of hash (options) allow to choose the Var_Dump renderer (display_mode) you want.

[Caution] Caution

Only display_mode = Text is allowed if you run PHP_CompatInfo on CLI.

Second key of hash (rendererOptions) allow to give specific options to the Var_Dump renderer identified by display_mode directive.

[Note] Note

Var_Dump package exists for two major versions of PHP.

Var_Dump PHP 4 on default PEAR channel (branch 1.0)

Var_Dump PHP 5 on PEAR channel Toolbox (branch 1.2)


Csv renderer options

Csv renderer can be customized only in one way: change delimiters characters

  • fields-values-separated-by identify the delimiter of values when there is a list given (extensions, constants, tokens). Default is ,

  • fields-terminated-by identify the delimiter of fields (those given by the output-level directive). Default is ;

  • fields-enclosed-by identify the protect field character if content have one or more restrictive character as given by previous options. Default is "

  • lines-terminated-by identify the end-of-line character. Usefull if you want to generate a file for another platform than those who have produced the results. Default is PHP_EOL constant


Html renderer options

Html renderer have only one specific option :

  • tdwidth that give size of each column (in em css unit), even if there are not shown (see output-level value). Default is 18,4,2,7,13

    That means: File is 18 em width, Version is 4 em width, C (cond_code) is 2 em width, Extensions is 7 em width, and Constants/Tokens is 13 em width.

See also the docs/examples/pci180_parsedir_tohtml.php example in the package distribution, howto define your own html renderer.


Text renderer options

Text renderer have only one specific option :

  • colwidth that give size of file (f), extensions (e), and constants/tokens (c) column (in character unit), even if there are not shown (see output-level value). Default is f = 29, e = 12, c = 20)

See the Command-Line Parser section, and -t | --tab switch to learn more about optimized values depending of output-level


Xml renderer options

Xml renderer have only two specific options :

  • use-beautifier tell if we use the PEAR::XML_Beautifier package to beautify XML output. Default is auto (use only if available)

  • beautifier is a hash for the PEAR::XML_Beautifier package options. Default is empty array (use all XML_Beautifier package default options).

[Tip] Tip

Use no value if you have PEAR::XML_Beautifier installed, and you don't want to have XML beautified.

See also the docs/examples/pci180_parsedata_toxml.php, and docs/examples/pci180_parsestring_toxml.php examples in the package distribution.


Part III. Reference Guide

Table of Contents

11. API - Application Programming Interface
Parsing data sources
Parser options
12. PHP version history
PHP_CompatInfo::loadVersion - Load components list
13. Observers
PHP_CompatInfo::addListener - Registers a new listener
PHP_CompatInfo::removeListener - Removes a registered listener
14. Parsing data sources
PHP_CompatInfo::loadVersion - Load components list
PHP_CompatInfo::parseArray - Parse an Array of Files
PHP_CompatInfo::parseDir - Parse a directory
PHP_CompatInfo::parseFolder - Alias of parseDir
PHP_CompatInfo::parseFile - Parse a single file
PHP_CompatInfo::parseString - Parse a string
PHP_CompatInfo::parseData - Parse a data source
15. Parser infrastructure
constructor PHP_CompatInfo_Parser::PHP_CompatInfo_Parser - Parser Class constructor
PHP_CompatInfo_Parser::setOutputDriver - Set up driver to be used
PHP_CompatInfo_Parser::addListener - Registers a new listener
PHP_CompatInfo_Parser::removeListener - Removes a registered listener
PHP_CompatInfo_Parser::notifyListeners - Post a new notification to all listeners registered
PHP_CompatInfo_Parser::loadVersion - Load components list
PHP_CompatInfo_Parser::getDirlist - Returns list of directory parsed
PHP_CompatInfo_Parser::getFilelist - Returns list of files parsed
PHP_CompatInfo_Parser::getIgnoredFiles - Returns list of files ignored
PHP_CompatInfo_Parser::parseData - Parse a data source
16. Renderer infrastructure
constructor PHP_CompatInfo_Renderer::PHP_CompatInfo_Renderer - Base Renderer Class constructor
PHP_CompatInfo_Renderer::factory - Create required instance of the Output 'driver'
PHP_CompatInfo_Renderer::update - Update the current view
PHP_CompatInfo_Renderer::startWaitProgress - Initialize the wait process
PHP_CompatInfo_Renderer::stillWaitProgress - Update the wait message
PHP_CompatInfo_Renderer::endWaitProgress - Finish the wait process
PHP_CompatInfo_Renderer::isIncludable - Checks if in the include path
17. Array Renderer
constructor PHP_CompatInfo_Renderer_Array::PHP_CompatInfo_Renderer_Array - Array Renderer Class constructor
PHP_CompatInfo_Renderer_Array::display - Display final results
18. Csv Renderer
constructor PHP_CompatInfo_Renderer_Csv::PHP_CompatInfo_Renderer_Csv - Csv Renderer Class constructor
PHP_CompatInfo_Renderer_Csv::display - Display final results
19. Html Renderer
constructor PHP_CompatInfo_Renderer_Html::PHP_CompatInfo_Renderer_Html - Html Renderer Class constructor
PHP_CompatInfo_Renderer_Html::display - Display final results
PHP_CompatInfo_Renderer_Html::getStyleSheet - Returns the custom style sheet
PHP_CompatInfo_Renderer_Html::setStyleSheet - Set a custom style sheet
PHP_CompatInfo_Renderer_Html::toHtml - Returns HTML code
20. Null Renderer
constructor PHP_CompatInfo_Renderer_Null::PHP_CompatInfo_Renderer_Null - Null Renderer Class constructor
PHP_CompatInfo_Renderer_Null::display - Consumes output events
21. Text Renderer
constructor PHP_CompatInfo_Renderer_Text::PHP_CompatInfo_Renderer_Text - Text Renderer Class constructor
PHP_CompatInfo_Renderer_Text::display - Display final results
22. Xml Renderer
constructor PHP_CompatInfo_Renderer_Xml::PHP_CompatInfo_Renderer_Xml - Xml Renderer Class constructor
PHP_CompatInfo_Renderer_Xml::display - Display final results
23. Command-Line version
constructor PHP_CompatInfo_Cli::PHP_CompatInfo_Cli - Command-Line Class constructor
PHP_CompatInfo_Cli::run - Run the CLI version


Chapter 11. API - Application Programming Interface

Table of Contents

Parsing data sources
Parser options

Parsing data sources

You can parse multiple data sources :

  • A single file with PHP_CompatInfo::parseFile() .

  • A chunk of code into a string with PHP_CompatInfo::parseString() .

  • A full directory (with or without sub dir) with PHP_CompatInfo::parseDir() , or its alias PHP_CompatInfo::parseFolder() .

  • A mix of files and strings with PHP_CompatInfo::parseArray() .

[Note] Note

API 1.8.0 introduces a common interface to parse all data sources (array, file, directory, chunk of code) with source auto detection. See PHP_CompatInfo::parseData() .

Call one of these five functions, with or without options, and you will retrieve a hash which contains information:

  • ignored_functions, PHP functions list that were ignored during source code parsing.

  • ignored_extensions, PHP extensions list that were ignored during source code parsing.

  • ignored_constants, PHP constants list that were ignored during source code parsing.

  • max_version, maximum PHP version to run source code.

  • version, minimum PHP version to run source code.

  • functions, PHP standard and user functions found in source code.

  • extensions, PHP modules/extensions functions found in source code.

  • constants, PHP constants found in source code.

  • tokens, PHP5 tokens (public, final, abstract, etc )

  • cond_code, A level (and details) of warning about conditional code found during parsing source code: from 0=none, 1=function_exists, 2=extension_loaded, 4=defined

    Its binary value, so 5 means defined+function_exists, and so on ...


Parser options

Each of five parsing functions support common and specifics options :

Common options

debug

Contains a boolean to control whether extra ouput is shown.

ignore_functions

Contains an array of functions to ignore when calculating the version needed.

ignore_constants

Contains an array of constants to ignore when calculating the version needed.

ignore_extensions

Contains an array of php extensions to ignore when calculating the version needed.

ignore_versions

Contains an array of php versions to ignore when calculating the version needed.

ignore_functions_match

Excludes from scope all functions that match (full or partially) the pattern(s).

ignore_extensions_match

Excludes from scope all extensions that match (full or partially) the pattern(s).

ignore_constants_match

Excludes from scope all constants that match (full or partially) the pattern(s).

parseArray, parseDir|parseFolder, specific options

file_ext

Contains an array of file extensions to parse for PHP code. Default: php, php4, inc, phtml

ignore_files

Contains an array of files to ignore. File names are case insensitive.

parseArray specific options

is_string

Contains a boolean which says if the array values are strings or file names.

parseDir|parseFolder specific options

recurse_dir

Boolean on whether to recursively find files.

ignore_dirs

Contains an array of directories to ignore. Directory names are case insensitive.


Chapter 12. PHP version history

Table of Contents

PHP_CompatInfo::loadVersion - Load components list


PHP_CompatInfo::loadVersion

Name

PHP_CompatInfo::loadVersion — Load components list

Synopsis

    require_once 'PHP/CompatInfo.php';

array PHP_CompatInfo::loadVersion( | $min,
 | $max = FALSE,
 | $include_const = FALSE,
 | $groupby_vers = FALSE);
string | $min;
string|boolean | $max = FALSE;
boolean | $include_const = FALSE;
boolean | $groupby_vers = FALSE;

Description

Load components list for a PHP version or subset

Parameter

string $min

PHP minimal version

string|boolean $max

(optional) PHP maximal version

boolean $include_const

(optional) include constants list in final result

boolean $groupby_vers

(optional) give initial php version of function or constant

Return value

returns An array of php function available in version(s) given

returns A mixed array of php function + php constants available in version(s) given. Available with parameter #3 ($include_const) since API 1.6.0

Throws

throws no exceptions thrown

Since

since version 1.2.0 (2006-08-23)

Note

This function can not be called statically.

Example

What's new with PHP version 4.3.10 ?

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $pci = new PHP_CompatInfo();
  5. $res = $pci->loadVersion('4.3.10', '4.3.10', true);
  6. var_export($res);
  7. ?>

Result give: 0 function and 2 constants

array (
  'functions' =>
  array (
  ),
  'constants' =>
  array (
    0 => 'PHP_EOL',
    1 => 'UPLOAD_ERR_NO_TMP_DIR',
  ),
)

What's new since PHP version 5.2.1 ?

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $pci = new PHP_CompatInfo();
  5. $res = $pci->loadVersion('5.2.1');
  6. var_export($res);
  7. ?>

Result give 24 functions

array (
  0 => 'cachingiterator::count',
  1 => 'directoryiterator::getbasename',
  2 => 'imagegrabscreen',
  3 => 'imagegrabwindow',
  4 => 'ming_setswfcompression',
  5 => 'mysql_set_charset',
  6 => 'openssl_pkcs12_export',
  7 => 'openssl_pkcs12_export_to_file',
  8 => 'openssl_pkcs12_read',
  9 => 'php_ini_loaded_file',
  10 => 'reflectionextension::info',
  11 => 'regexiterator::setpregflags',
  12 => 'splfileinfo::getbasename',
  13 => 'splfileinfo::getlinktarget',
  14 => 'splfileinfo::getrealpath',
  15 => 'splobjectstorage::serialize',
  16 => 'splobjectstorage::unserialize',
  17 => 'stream_is_local',
  18 => 'stream_socket_shutdown',
  19 => 'swfmovie::namedanchor',
  20 => 'swfmovie::protect',
  21 => 'swfmovie::remove',
  22 => 'sys_get_temp_dir',
  23 => 'tidynode::getparent',
)


Chapter 13. Observers

Table of Contents

PHP_CompatInfo::addListener - Registers a new listener
PHP_CompatInfo::removeListener - Removes a registered listener


PHP_CompatInfo::addListener

Name

PHP_CompatInfo::addListener — Registers a new listener

Synopsis

    require_once 'PHP/CompatInfo.php';

void PHP_CompatInfo::addListener ( | $callback,
 | $nName = EVENT_DISPATCHER_GLOBAL );
mixed | $callback ;
string | $nName = EVENT_DISPATCHER_GLOBAL ;

Description

Registers a new listener with the given criteria

Parameter

mixed $callback

A PHP callback

string $nName

(optional) Expected notification name

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b3 (2008-06-07)

Note

This function can not be called statically.

Example

Attach a simple function that will listen all PHP_CompatInfo events, which write start and end audit results in a flat file defined by a php constant.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. define('DEST_PCI_LOG', '/var/log/pciEvents.log');
  5.
  6. function debugNotify(&$auditEvent)
  7. {
  8.     $notifyName = $auditEvent->getNotificationName();
  9.     $notifyInfo = $auditEvent->getNotificationInfo();
  10.
  11.     if ($notifyName == PHP_COMPATINFO_EVENT_AUDITSTARTED) {
  12.         error_log($notifyName.':'. PHP_EOL .
  13.                   var_export($notifyInfo, true) . PHP_EOL,
  14.                   3, DEST_PCI_LOG);
  15.
  16.     } elseif ($notifyName == PHP_COMPATINFO_EVENT_AUDITFINISHED) {
  17.         error_log($notifyName.':'. PHP_EOL .
  18.                   var_export($notifyInfo, true) . PHP_EOL,
  19.                   3, DEST_PCI_LOG);
  20.     }
  21. }
  22.
  23. $cbObserver = 'debugNotify';
  24.
  25. $pci = new PHP_CompatInfo();
  26. $pci->addListener($cbObserver);
  27. // ...
  28. $source  = '';      // <- identify the date source to parse
  29. $options = array(); // <- some parser options
  30.
  31. $pci->parseData($source, $options);
  32.
  33. $pci->removeListener($cbObserver);
  34. ?>


PHP_CompatInfo::removeListener

Name

PHP_CompatInfo::removeListener — Removes a registered listener

Synopsis

    require_once 'PHP/CompatInfo.php';

bool PHP_CompatInfo::removeListener ( | $callback,
 | $nName = EVENT_DISPATCHER_GLOBAL );
mixed | $callback ;
string | $nName = EVENT_DISPATCHER_GLOBAL ;

Description

Removes a registered listener that correspond to the given criteria.

Parameter

mixed $callback

A PHP callback

string $nName

(optional) Expected notification name

Return value

returns True if listener was removed, false otherwise.

Throws

throws no exceptions thrown

Since

since version 1.8.0b3 (2008-06-07)

Note

This function can not be called statically.

Example

see PHP_CompatInfo::addListener example


Chapter 14. Parsing data sources

Table of Contents

PHP_CompatInfo::loadVersion - Load components list
PHP_CompatInfo::parseArray - Parse an Array of Files
PHP_CompatInfo::parseDir - Parse a directory
PHP_CompatInfo::parseFolder - Alias of parseDir
PHP_CompatInfo::parseFile - Parse a single file
PHP_CompatInfo::parseString - Parse a string
PHP_CompatInfo::parseData - Parse a data source


PHP_CompatInfo::parseArray

Name

PHP_CompatInfo::parseArray — Parse an Array of Files

Synopsis

    require_once 'PHP/CompatInfo.php';

array|false PHP_CompatInfo::parseArray( | $files,
 | $options = array());
array | $files;
array | $options = array();

Description

You can parse an array of Files or Strings. To parse strings, $options['is_string'] must be set to true

Parameter

array $files

Array of file names or code strings

array $options

An array of options where:

  • file_ext Contains an array of file extensions to parse for PHP code. Default: php, php4, inc, phtml

  • debug Contains a boolean to control whether extra ouput is shown.

  • ignore_functions Contains an array of functions to ignore when calculating the version needed.

  • ignore_constants Contains an array of constants to ignore when calculating the version needed.

  • ignore_files Contains an array of files to ignore. File names are case insensitive.

  • is_string Contains a boolean which says if the array values are strings or file names.

  • ignore_extensions Contains an array of php extensions to ignore when calculating the version needed.

  • ignore_versions Contains an array of php versions to ignore when calculating the version needed.

  • ignore_functions_match Contains an array of function patterns to ignore when calculating the version needed.

  • ignore_extensions_match Contains an array of extension patterns to ignore when calculating the version needed.

  • ignore_constants_match Contains an array of constant patterns to ignore when calculating the version needed.

Throws

throws no exceptions thrown

See

see PHP_CompatInfo::parseData

Since

since version 0.7.0 (2004-03-09)

Note

This function can not be called statically.

Return value

array - a hash which contains information keys: ignored_functions, ignored_extensions, ignored_constants, max_version, version, extensions, constants, tokens, cond_code

Example

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $pci = new PHP_CompatInfo();
  5.
  6. $input = array('/opt/lampp/etc/pear/PEAR.php',
  7.                '/opt/lampp/etc/pear/PHP/CompatInfo.php');
  8.
  9. $res = $pci->parseArray($input);
  10.
  11. var_export($res);
  12. ?>

We get such result.

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 => 'pcre',
    2 => 'tokenizer',
  ),
  'constants' =>
  array (
  ),
  'tokens' =>
  array (
  ),
  'cond_code' =>
  array (
    0 => 7,
    1 =>
    array (
      0 =>
      array (
      ),
      1 =>
      array (
      ),
      2 =>
      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 (
    ),
    'cond_code' =>
    array (
      0 => 7,
      1 =>
      array (
        0 =>
        array (
        ),
        1 =>
        array (
        ),
        2 =>
        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 => 'pcre',
      1 => 'tokenizer',
    ),
    'constants' =>
    array (
    ),
    'tokens' =>
    array (
    ),
    'cond_code' =>
    array (
      0 => 0,
      1 =>
      array (
        0 =>
        array (
        ),
        1 =>
        array (
        ),
        2 =>
        array (
        ),
      ),
    ),
  ),
)

As for parseDir() we have global result, follow by each $input entry result in details.

[Caution] Caution

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.


PHP_CompatInfo::parseDir

Name

PHP_CompatInfo::parseDir — Parse a directory

Synopsis

    require_once 'PHP/CompatInfo.php';

array PHP_CompatInfo::parseDir( | $dir,
 | $options = array());
string | $dir;
array | $options = array();

Description

Parse a directory recursively for its compatibility info

Parameter

string $dir

Path of folder to parse

array $options

An array of options where:

  • file_ext Contains an array of file extensions to parse for PHP code. Default: php, php4, inc, phtml

  • recurse_dir Boolean on whether to recursively find files

  • debug Contains a boolean to control whether extra ouput is shown.

  • ignore_functions Contains an array of functions to ignore when calculating the version needed.

  • ignore_constants Contains an array of constants to ignore when calculating the version needed.

  • ignore_files Contains an array of files to ignore. File names are case insensitive.

  • ignore_dirs Contains an array of directories to ignore. Directory names are case insensitive.

  • ignore_extensions Contains an array of php extensions to ignore when calculating the version needed.

  • ignore_versions Contains an array of php versions to ignore when calculating the version needed.

  • ignore_functions_match Contains an array of function patterns to ignore when calculating the version needed.

  • ignore_extensions_match Contains an array of extension patterns to ignore when calculating the version needed.

  • ignore_constants_match Contains an array of constant patterns to ignore when calculating the version needed.

Throws

throws no exceptions thrown

See

see PHP_CompatInfo::parseFolder , PHP_CompatInfo::parseData

Since

since version 0.8.0 (2004-04-22)

Note

This function can not be called statically.

Return value

array - a hash which contains information keys: ignored_functions, ignored_extensions, ignored_constants, max_version, version, extensions, constants, tokens, cond_code

Example

Suppose we have these dirs/files to parse :

PHP_CompatInfo/tests/parseDir/
  PHP5/tokens.php5
  PHP5/upload_error.php
  extensions.php
  phpinfo.php

See package distribution to know in details content of this scripts.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $pci = new PHP_CompatInfo();
  5.
  6. $input   = 'PHP_CompatInfo/tests/parseDir/';
  7. $options = array('recurse_dir' => true,
  8.                  'file_ext'    => array('php', 'php5')
  9.                 );
  10.
  11. $res = $pci->parseDir($input, $options);
  12.
  13. var_export($res);
  14. ?>

We get such result.

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',
  ),
  'cond_code' =>
  array (
    0 => 2,
    1 =>
    array (
      0 =>
      array (
      ),
      1 =>
      array (
      ),
      2 =>
      array (
      ),
    ),
  ),
  '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 (
    ),
    'cond_code' =>
    array (
      0 => 2,
      1 =>
      array (
        0 =>
        array (
        ),
        1 =>
        array (
        ),
        2 =>
        array (
        ),
      ),
    ),
  ),
  '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 (
    ),
    'cond_code' =>
    array (
      0 => 0,
      1 =>
      array (
        0 =>
        array (
        ),
        1 =>
        array (
        ),
        2 =>
        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',
    ),
    'cond_code' =>
    array (
      0 => 0,
      1 =>
      array (
        0 =>
        array (
        ),
        1 =>
        array (
        ),
        2 =>
        array (
        ),
      ),
    ),
  ),
  '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',
    ),
    'cond_code' =>
    array (
      0 => 0,
      1 =>
      array (
        0 =>
        array (
        ),
        1 =>
        array (
        ),
        2 =>
        array (
        ),
      ),
    ),
  ),
)

We have global result, then follow by each file parsed in sub-directories.


PHP_CompatInfo::parseFolder

Name

PHP_CompatInfo::parseFolder — Alias of parseDir

Synopsis

    require_once 'PHP/CompatInfo.php';

void PHP_CompatInfo::parseFolder( | $folder,
 | $options = array());
string | $folder;
array | $options = array();

Description

Alias of parseDir function

Parameter

string $folder

Path of folder to parse

array $options

An array of options

Throws

throws no exceptions thrown

See

see PHP_CompatInfo::parseDir , PHP_CompatInfo::parseData

Since

since version 0.7.0 (2004-03-09)

Note

This function can not be called statically.

Return value

array - a hash which contains information keys: ignored_functions, ignored_extensions, ignored_constants, max_version, version, extensions, constants, tokens, cond_code

Example

See PHP_CompatInfo::parseDir() example.


PHP_CompatInfo::parseFile

Name

PHP_CompatInfo::parseFile — Parse a single file

Synopsis

    require_once 'PHP/CompatInfo.php';

Array PHP_CompatInfo::parseFile( | $file,
 | $options = array());
string | $file;
array | $options = array();

Description

Parse a file for its compatibility info

Parameter

string $file

Path of File to parse

array $options

An array of options where:

  • debug Contains a boolean to control whether extra ouput is shown.

  • ignore_functions Contains an array of functions to ignore when calculating the version needed.

  • ignore_constants Contains an array of constants to ignore when calculating the version needed.

  • ignore_extensions Contains an array of php extensions to ignore when calculating the version needed.

  • ignore_versions Contains an array of php versions to ignore when calculating the version needed.

  • ignore_functions_match Contains an array of function patterns to ignore when calculating the version needed.

  • ignore_extensions_match Contains an array of extension patterns to ignore when calculating the version needed.

  • ignore_constants_match Contains an array of constant patterns to ignore when calculating the version needed.

Throws

throws no exceptions thrown

See

see PHP_CompatInfo::parseData

Since

since version 0.7.0 (2004-03-09)

Note

This function can not be called statically.

Return value

array - a hash which contains information keys: ignored_functions, ignored_extensions, ignored_constants, max_version, version, extensions, constants, tokens, cond_code

Example

Suppose we have to parse source code like this one, named "conditional.php" :

  1. <?php
  2. // PHP 4.0.0 : __FILE__
  3. // PHP 4.0.6 : DIRECTORY_SEPARATOR
  4. // PHP 4.0.7 : version compare
  5. // PHP 4.3.0 : ob_get_clean
  6. // PHP 4.3.0 : debug_backtrace
  7. // PHP 4.3.10 and 5.0.2 : PHP_EOL
  8. // PHP 5.0.0 : simplexml_load_file
  9. // PHP 5.1.1 : DATE_W3C
  10.
  11. if (!defined('DIRECTORY_SEPARATOR')) {
  12.     define('DIRECTORY_SEPARATOR',
  13.         strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/'
  14.     );
  15. }
  16.
  17. if (function_exists('debug_backtrace')) {
  18.     $backtrace = debug_backtrace();
  19. } else {
  20.     $backtrace = false;
  21. }
  22.
  23. if (function_exists('simplexml_load_file')) {
  24.     $xml = simplexml_load_file('C:\php\pear\PHP_CompatInfo\scripts\version.xml');
  25. }
  26.
  27. if (version_compare(phpversion(), '5.0.0', '<')) {
  28.     include_once 'PHP/Compat.php';
  29.     PHP_Compat::loadFunction('ob_get_clean');
  30.     PHP_Compat::loadConstant('PHP_EOL');
  31. }
  32.
  33. echo "Hello World" . PHP_EOL;
  34.
  35. $ds  = DIRECTORY_SEPARATOR;
  36. $fn  = dirname(__FILE__) . $ds . basename(__FILE__);
  37. echo "You have run file : $fn at " . date(DATE_W3C) . PHP_EOL;
  38.
  39. ?>

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $pci = new PHP_CompatInfo();
  5.
  6. $input   = 'conditional.php';
  7. $options = array('ignore_functions' => array('simplexml_load_file'),
  8.                  'ignore_constants' => array('DATE_W3C')
  9.                 );
  10.
  11. $res = $pci->parseFile($input, $options);
  12.
  13. var_export($res);
  14. ?>

We get such result.

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 (
  ),
  'cond_code' =>
  array (
    0 => 5,
    1 =>
    array (
    ),
  ),
)

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] Warning

Of course it is impossible to run such script with only PHP 4.3.10 because usage of DATE_W3C constant is not conditionned.


PHP_CompatInfo::parseString

Name

PHP_CompatInfo::parseString — Parse a string

Synopsis

    require_once 'PHP/CompatInfo.php';

Array PHP_CompatInfo::parseString( | $string,
 | $options = array());
string | $string;
array | $options = array();

Description

Parse a string for its compatibility info

Parameter

string $string

PHP Code to parses

array $options

An array of options where:

  • debug Contains a boolean to control whether extra ouput is shown.

  • ignore_functions Contains an array of functions to ignore when calculating the version needed.

  • ignore_constants Contains an array of constants to ignore when calculating the version needed.

  • ignore_extensions Contains an array of php extensions to ignore when calculating the version needed.

  • ignore_versions Contains an array of php versions to ignore when calculating the version needed.

  • ignore_functions_match Contains an array of function patterns to ignore when calculating the version needed.

  • ignore_extensions_match Contains an array of extension patterns to ignore when calculating the version needed.

  • ignore_constants_match Contains an array of constant patterns to ignore when calculating the version needed.

Throws

throws no exceptions thrown

See

see PHP_CompatInfo::parseData

Since

since version 0.7.0 (2004-03-09)

Note

This function can not be called statically.

Return value

array - a hash which contains information keys: ignored_functions, ignored_extensions, ignored_constants, max_version, version, extensions, constants, tokens, cond_code

Example

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $pci = new PHP_CompatInfo();
  5.
  6. $input = '<?php
  7. $nl = "\n";
  8. echo "$nl Rfc3339 = " . DATE_RFC3339;
  9. echo "$nl RSS     = " . DATE_RSS;
  10. ?>';
  11.
  12. $res = $pci->parseString($input);
  13.
  14. var_export($res);
  15. ?>

We get such result.

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 (
  ),
  'cond_code' =>
  array (
    0 => 0,
    1 =>
    array (
      0 =>
      array (
      ),
      1 =>
      array (
      ),
      2 =>
      array (
      ),
    ),
  ),
)

That means we need PHP 5.1.3 minimum to run this chunk of code, due to usage of DATE_RFC3339 constant.


PHP_CompatInfo::parseData

Name

PHP_CompatInfo::parseData — Parse a data source

Synopsis

    require_once 'PHP/CompatInfo.php';

Array PHP_CompatInfo::parseData( | $dataSource,
 | $options = array());
mixed | $dataSource;
array | $options = array();

Description

Parse a data source with auto detect ability. This data source, may be one of these follows: a directory, a file, a string (chunk of code), an array of multiple origin.

Parameter

mixed $dataSource

Identify the data source(s)

array $options

An array of common options where:

  • debug Contains a boolean to control whether extra ouput is shown.

  • ignore_functions Contains an array of functions to ignore when calculating the version needed.

  • ignore_constants Contains an array of constants to ignore when calculating the version needed.

  • ignore_extensions Contains an array of php extensions to ignore when calculating the version needed.

  • ignore_versions Contains an array of php versions to ignore when calculating the version needed.

  • ignore_functions_match Contains an array of function patterns to ignore when calculating the version needed.

  • ignore_extensions_match Contains an array of extension patterns to ignore when calculating the version needed.

  • ignore_constants_match Contains an array of constant patterns to ignore when calculating the version needed.

An array of specific options, for parseArray parseDir or parseFolder, where:

  • file_ext Contains an array of file extensions to parse for PHP code. Default: php, php4, inc, phtml

  • ignore_files Contains an array of files to ignore. File names are case insensitive.

An array of specific options, for parseArray, where:

  • is_string Contains a boolean which says if the array values are strings or file names.

An array of specific options, for parseDir or parseFolder, where:

  • recurse_dir Boolean on whether to recursively find files

  • ignore_dirs Contains an array of directories to ignore. Directory names are case insensitive.

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.

Return value

array - a hash which contains information keys: ignored_files, ignored_functions, ignored_extensions, ignored_constants, max_version, version, extensions, constants, tokens, cond_code or FALSE on error.

Example

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.
  4. $source  = '/tmp/File_Find-1.3.0/Find.php';
  5. $options = array('debug' => true);
  6.
  7. $pci = new PHP_CompatInfo();
  8. $pci->parseData($source, $options);
  9. ?>


Chapter 15. Parser infrastructure

Table of Contents

constructor PHP_CompatInfo_Parser::PHP_CompatInfo_Parser - Parser Class constructor
PHP_CompatInfo_Parser::setOutputDriver - Set up driver to be used
PHP_CompatInfo_Parser::addListener - Registers a new listener
PHP_CompatInfo_Parser::removeListener - Removes a registered listener
PHP_CompatInfo_Parser::notifyListeners - Post a new notification to all listeners registered
PHP_CompatInfo_Parser::loadVersion - Load components list
PHP_CompatInfo_Parser::getDirlist - Returns list of directory parsed
PHP_CompatInfo_Parser::getFilelist - Returns list of files parsed
PHP_CompatInfo_Parser::getIgnoredFiles - Returns list of files ignored
PHP_CompatInfo_Parser::parseData - Parse a data source


constructor PHP_CompatInfo_Parser::PHP_CompatInfo_Parser

Name

constructor PHP_CompatInfo_Parser::PHP_CompatInfo_Parser — Parser Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';
void constructor PHP_CompatInfo_Parser::PHP_CompatInfo_Parser ( );
;

Description

Parser Class constructor

Return value

returns instance of object PHP_CompatInfo_Parser

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Parser::setOutputDriver

Name

PHP_CompatInfo_Parser::setOutputDriver — Set up driver to be used

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

void PHP_CompatInfo_Parser::setOutputDriver ( | $type,
 | $conf = array() );
string | $type ;
array | $conf = array() ;

Description

Set up driver to be used, dependant on specified type.

Parameter

string $type

Name the type of driver (html, text...)

array $conf

A hash containing any additional configuration

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Parser::addListener

Name

PHP_CompatInfo_Parser::addListener — Registers a new listener

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

void PHP_CompatInfo_Parser::addListener ( | $callback,
 | $nName = EVENT_DISPATCHER_GLOBAL );
mixed | $callback ;
string | $nName = EVENT_DISPATCHER_GLOBAL ;

Description

Registers a new listener with the given criteria.

Parameter

mixed $callback

A PHP callback

string $nName

(optional) Expected notification name

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.

Example

see PHP_CompatInfo::addListener example


PHP_CompatInfo_Parser::removeListener

Name

PHP_CompatInfo_Parser::removeListener — Removes a registered listener

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

bool PHP_CompatInfo_Parser::removeListener ( | $callback,
 | $nName = EVENT_DISPATCHER_GLOBAL );
mixed | $callback ;
string | $nName = EVENT_DISPATCHER_GLOBAL ;

Description

Removes a registered listener that correspond to the given criteria.

Parameter

mixed $callback

A PHP callback

string $nName

(optional) Expected notification name

Return value

returns True if listener was removed, false otherwise.

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.

Example

see PHP_CompatInfo::addListener example


PHP_CompatInfo_Parser::notifyListeners

Name

PHP_CompatInfo_Parser::notifyListeners — Post a new notification to all listeners registered

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

void PHP_CompatInfo_Parser::notifyListeners ( | $event,
 | $info = array() );
string | $event ;
array | $info = array() ;

Description

This notification occured only if a dispatcher exists. That means if at least one listener was registered.

Parameter

string $event

Name of the notification handler

array $info

(optional) Additional information about the notification

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Parser::loadVersion

Name

PHP_CompatInfo_Parser::loadVersion — Load components list

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

array PHP_CompatInfo_Parser::loadVersion ( | $min,
 | $max = FALSE ,
 | $include_const = FALSE ,
 | $groupby_vers = FALSE );
string | $min ;
string|boolean | $max = FALSE ;
boolean | $include_const = FALSE ;
boolean | $groupby_vers = FALSE ;

Description

Load components list for a PHP version or subset

Parameter

string $min

PHP minimal version

string|boolean $max

(optional) PHP maximal version

boolean $include_const

(optional) include constants list in final result

boolean $groupby_vers

(optional) give initial php version of function or constant

Return value

returns An array of php function/constant names history

Throws

throws no exceptions thrown

Since

since version 1.2.0 (2006-08-23)

Note

This function can not be called statically.


PHP_CompatInfo_Parser::getDirlist

Name

PHP_CompatInfo_Parser::getDirlist — Returns list of directory parsed

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

array PHP_CompatInfo_Parser::getDirlist ( | $dir,
 | $options);
mixed | $dir ;
array | $options ;

Description

Returns list of directory parsed, depending of restrictive parser options.

Parameter

mixed $dir

The directory name

array $options

An array of parser options. See parseData() method.

Return value

returns array - list of directories that should be parsed

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Parser::getFilelist

Name

PHP_CompatInfo_Parser::getFilelist — Returns list of files parsed

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

array PHP_CompatInfo_Parser::getFilelist ( | $dir,
 | $options);
mixed | $dir ;
array | $options ;

Description

Returns list of files parsed, depending of restrictive parser options.

Parameter

mixed $dir

The directory name where to look files

array $options

An array of parser options. See parseData() method.

Return value

returns array - list of files that should be parsed

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Parser::getIgnoredFiles

Name

PHP_CompatInfo_Parser::getIgnoredFiles — Returns list of files ignored

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';
array PHP_CompatInfo_Parser::getIgnoredFiles ( );
;

Description

Returns list of files ignored while parsing directories

Return value

returns array or false on error

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Parser::parseData

Name

PHP_CompatInfo_Parser::parseData — Parse a data source

Synopsis

    require_once 'PHP/CompatInfo/Parser.php';

array PHP_CompatInfo_Parser::parseData ( | $dataSource,
 | $options = array() );
mixed | $dataSource ;
array | $options = array() ;

Description

Parse a data source with auto detect ability. This data source, may be one of these follows: a directory, a file, a string (chunk of code), an array of multiple origin.

Each of five parsing functions support common and specifics options.

* Common options :

  • 'debug' Contains a boolean to control whether extra ouput is shown.

  • 'ignore_functions' Contains an array of functions to ignore when calculating the version needed.

  • 'ignore_constants' Contains an array of constants to ignore when calculating the version needed.

  • 'ignore_extensions' Contains an array of php extensions to ignore when calculating the version needed.

  • 'ignore_versions' Contains an array of php versions to ignore when calculating the version needed.

  • 'ignore_functions_match' Contains an array of function patterns to ignore when calculating the version needed.

  • 'ignore_extensions_match' Contains an array of extension patterns to ignore when calculating the version needed.

  • 'ignore_constants_match' Contains an array of constant patterns to ignore when calculating the version needed.

* parseArray, parseDir|parseFolder, specific options :

  • 'file_ext' Contains an array of file extensions to parse for PHP code. Default: php, php4, inc, phtml

  • 'ignore_files' Contains an array of files to ignore. File names are case insensitive.

* parseArray specific options :

  • 'is_string' Contains a boolean which says if the array values are strings or file names.

* parseDir|parseFolder specific options :

  • 'recurse_dir' Boolean on whether to recursively find files

  • 'ignore_dirs' Contains an array of directories to ignore. Directory names are case insensitive.

Parameter

mixed $dataSource

The data source (may be file, dir, string, or array)

array $options

An array of options. See above.

Return value

returns array or false on error

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.

Example

see PHP_CompatInfo::parseData example


Chapter 16. Renderer infrastructure

Table of Contents

constructor PHP_CompatInfo_Renderer::PHP_CompatInfo_Renderer - Base Renderer Class constructor
PHP_CompatInfo_Renderer::factory - Create required instance of the Output 'driver'
PHP_CompatInfo_Renderer::update - Update the current view
PHP_CompatInfo_Renderer::startWaitProgress - Initialize the wait process
PHP_CompatInfo_Renderer::stillWaitProgress - Update the wait message
PHP_CompatInfo_Renderer::endWaitProgress - Finish the wait process
PHP_CompatInfo_Renderer::isIncludable - Checks if in the include path


constructor PHP_CompatInfo_Renderer::PHP_CompatInfo_Renderer

Name

constructor PHP_CompatInfo_Renderer::PHP_CompatInfo_Renderer — Base Renderer Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Renderer.php';

void constructor PHP_CompatInfo_Renderer::PHP_CompatInfo_Renderer ( | &$parser,
 | $conf);
object | &$parser ;
array | $conf ;

Description

Base Renderer Class constructor

Parameter

object &$parser

Instance of the parser (model of MVC pattern)

array $conf

A hash containing any additional configuration

Return value

returns instance of object PHP_CompatInfo_Renderer

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer::factory

Name

PHP_CompatInfo_Renderer::factory — Create required instance of the Output 'driver'

Synopsis

    require_once 'PHP/CompatInfo/Renderer.php';

object PHP_CompatInfo_Renderer & PHP_CompatInfo_Renderer::factory ( | &$parser,
 | $type = 'array' ,
 | $conf = array() );
object | &$parser ;
string | $type = 'array' ;
array | $conf = array() ;

Description

Creates a concrete instance of the renderer depending of $type

Parameter

object &$parser

A concrete instance of the parser

string $type

(optional) Type of instance required, case insensitive

array $conf

(optional) A hash containing any additional configuration information that a subclass might need.

Return value

returns A concrete PHP_CompatInfo_Renderer instance, or null on error.

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer::update

Name

PHP_CompatInfo_Renderer::update — Update the current view

Synopsis

    require_once 'PHP/CompatInfo/Renderer.php';
void PHP_CompatInfo_Renderer::update ( &$auditEvent);
object &$auditEvent ;

Description

Interface to update the view with current information. Listen events produced by Event_Dispatcher and the PHP_CompatInfo_Parser

Parameter

object &$auditEvent

Instance of Event_Dispatcher

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer::startWaitProgress

Name

PHP_CompatInfo_Renderer::startWaitProgress — Initialize the wait process

Synopsis

    require_once 'PHP/CompatInfo/Renderer.php';
void PHP_CompatInfo_Renderer::startWaitProgress ( $maxEntries);
integer $maxEntries ;

Description

Initialize the wait process, with a simple message or a progress bar.

Parameter

integer $maxEntries

Number of source to parse

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer::stillWaitProgress

Name

PHP_CompatInfo_Renderer::stillWaitProgress — Update the wait message

Synopsis

    require_once 'PHP/CompatInfo/Renderer.php';

void PHP_CompatInfo_Renderer::stillWaitProgress ( | $source,
 | $index);
string | $source ;
string | $index ;

Description

Update the wait message, or status of the progress bar

Parameter

string $source

Source (file, string) currently parsing

string $index

Position of the $source in the data source list to parse

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer::endWaitProgress

Name

PHP_CompatInfo_Renderer::endWaitProgress — Finish the wait process

Synopsis

    require_once 'PHP/CompatInfo/Renderer.php';
void PHP_CompatInfo_Renderer::endWaitProgress ( );
;

Description

Finish the wait process, by erasing the progress bar

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer::isIncludable

Name

PHP_CompatInfo_Renderer::isIncludable — Checks if in the include path

Synopsis

    require_once 'PHP/CompatInfo/Renderer.php';
boolean PHP_CompatInfo_Renderer::isIncludable ( $file);
string $file ;

Description

Returns whether or not a file is in the include path

Parameter

string $file

Path to filename to check if includable

Return value

returns True if the file is in the include path, false otherwise

Throws

throws no exceptions thrown

Since

since version 1.7.0b4 (2008-04-03)

Note

This function can not be called statically.


Chapter 17. Array Renderer

Table of Contents

constructor PHP_CompatInfo_Renderer_Array::PHP_CompatInfo_Renderer_Array - Array Renderer Class constructor
PHP_CompatInfo_Renderer_Array::display - Display final results


constructor PHP_CompatInfo_Renderer_Array::PHP_CompatInfo_Renderer_Array

Name

constructor PHP_CompatInfo_Renderer_Array::PHP_CompatInfo_Renderer_Array — Array Renderer Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Array.php';

void constructor PHP_CompatInfo_Renderer_Array::PHP_CompatInfo_Renderer_Array ( | &$parser,
 | $conf);
object | &$parser ;
array | $conf ;

Description

Array Renderer Class constructor

Parameter

object &$parser

Instance of the parser (model of MVC pattern)

array $conf

A hash containing any additional configuration

Return value

returns instance of object PHP_CompatInfo_Renderer_Array

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Array::display

Name

PHP_CompatInfo_Renderer_Array::display — Display final results

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Array.php';
void PHP_CompatInfo_Renderer_Array::display ( );
;

Description

Display final results, when data source parsing is over.

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


Chapter 18. Csv Renderer

Table of Contents

constructor PHP_CompatInfo_Renderer_Csv::PHP_CompatInfo_Renderer_Csv - Csv Renderer Class constructor
PHP_CompatInfo_Renderer_Csv::display - Display final results


constructor PHP_CompatInfo_Renderer_Csv::PHP_CompatInfo_Renderer_Csv

Name

constructor PHP_CompatInfo_Renderer_Csv::PHP_CompatInfo_Renderer_Csv — Csv Renderer Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Csv.php';

void constructor PHP_CompatInfo_Renderer_Csv::PHP_CompatInfo_Renderer_Csv ( | &$parser,
 | $conf);
object | &$parser ;
array | $conf ;

Description

Csv Renderer Class constructor

Parameter

object &$parser

Instance of the parser (model of MVC pattern)

array $conf

A hash containing any additional configuration

Return value

returns instance of object PHP_CompatInfo_Renderer_Csv

Throws

throws no exceptions thrown

Since

since version 1.8.0b4 (2008-06-18)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Csv::display

Name

PHP_CompatInfo_Renderer_Csv::display — Display final results

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Csv.php';
void PHP_CompatInfo_Renderer_Csv::display ( );
;

Description

Display final results, when data source parsing is over.

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b4 (2008-06-18)

Note

This function can not be called statically.


Chapter 19. Html Renderer

Table of Contents

constructor PHP_CompatInfo_Renderer_Html::PHP_CompatInfo_Renderer_Html - Html Renderer Class constructor
PHP_CompatInfo_Renderer_Html::display - Display final results
PHP_CompatInfo_Renderer_Html::getStyleSheet - Returns the custom style sheet
PHP_CompatInfo_Renderer_Html::setStyleSheet - Set a custom style sheet
PHP_CompatInfo_Renderer_Html::toHtml - Returns HTML code


constructor PHP_CompatInfo_Renderer_Html::PHP_CompatInfo_Renderer_Html

Name

constructor PHP_CompatInfo_Renderer_Html::PHP_CompatInfo_Renderer_Html — Html Renderer Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Html.php';

void constructor PHP_CompatInfo_Renderer_Html::PHP_CompatInfo_Renderer_Html ( | &$parser,
 | $conf);
object | &$parser ;
array | $conf ;

Description

Html Renderer Class constructor

Parameter

object &$parser

Instance of the parser (model of MVC pattern)

array $conf

A hash containing any additional configuration

Return value

returns instance of object PHP_CompatInfo_Renderer_Html

Throws

throws no exceptions thrown

Since

since version 1.8.0b4 (2008-06-18)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Html::display

Name

PHP_CompatInfo_Renderer_Html::display — Display final results

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Html.php';
void PHP_CompatInfo_Renderer_Html::display ( );
;

Description

Display final results, when data source parsing is over.

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b4 (2008-06-18)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Html::getStyleSheet

Name

PHP_CompatInfo_Renderer_Html::getStyleSheet — Returns the custom style sheet

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Html.php';

mixed PHP_CompatInfo_Renderer_Html::getStyleSheet ( | $destination = 1 ,
 | $extra = NULL );
int | $destination = 1 ;
mixed | $extra = NULL ;

Description

Returns the custom style sheet to use for layout

Parameter

integer $destination

(optional) Destination of css content

mixed $extra

(optional) Additional data depending of destination

Return value

returns mixed

Throws

throws no exceptions thrown

Since

since version 1.8.0b4 (2008-06-18)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Html::setStyleSheet

Name

PHP_CompatInfo_Renderer_Html::setStyleSheet — Set a custom style sheet

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Html.php';
bool PHP_CompatInfo_Renderer_Html::setStyleSheet ( $css = NULL );
string $css = NULL ;

Description

Set a custom style sheet to use your own styles

Parameter

string $css

(optional) File to read user-defined styles from

Return value

returns True if custom styles, false if default styles applied

Throws

throws no exceptions thrown

Since

since version 1.8.0b4 (2008-06-18)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Html::toHtml

Name

PHP_CompatInfo_Renderer_Html::toHtml — Returns HTML code

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Html.php';
string PHP_CompatInfo_Renderer_Html::toHtml ( $obj);
object $obj ;

Description

Returns HTML code of parsing result

Parameter

object $obj

instance of HTML_Table

Return value

returns string - html code

Throws

throws no exceptions thrown

Since

since version 1.8.0b4 (2008-06-18)

Note

This function can not be called statically.


Chapter 20. Null Renderer

Table of Contents

constructor PHP_CompatInfo_Renderer_Null::PHP_CompatInfo_Renderer_Null - Null Renderer Class constructor
PHP_CompatInfo_Renderer_Null::display - Consumes output events


constructor PHP_CompatInfo_Renderer_Null::PHP_CompatInfo_Renderer_Null

Name

constructor PHP_CompatInfo_Renderer_Null::PHP_CompatInfo_Renderer_Null — Null Renderer Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Null.php';

void constructor PHP_CompatInfo_Renderer_Null::PHP_CompatInfo_Renderer_Null ( | &$parser,
 | $conf);
object | &$parser ;
array | $conf ;

Description

Null Renderer Class constructor

Parameter

object &$parser

Instance of the parser (model of MVC pattern)

array $conf

A hash containing any additional configuration

Return value

returns instance of object PHP_CompatInfo_Renderer_Null

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Null::display

Name

PHP_CompatInfo_Renderer_Null::display — Consumes output events

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Null.php';
void PHP_CompatInfo_Renderer_Null::display ( );
;

Description

Consumes all output events

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0RC1 (2008-07-01)

Note

This function can not be called statically.


Chapter 21. Text Renderer

Table of Contents

constructor PHP_CompatInfo_Renderer_Text::PHP_CompatInfo_Renderer_Text - Text Renderer Class constructor
PHP_CompatInfo_Renderer_Text::display - Display final results


constructor PHP_CompatInfo_Renderer_Text::PHP_CompatInfo_Renderer_Text

Name

constructor PHP_CompatInfo_Renderer_Text::PHP_CompatInfo_Renderer_Text — Text Renderer Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Text.php';

void constructor PHP_CompatInfo_Renderer_Text::PHP_CompatInfo_Renderer_Text ( | &$parser,
 | $conf);
object | &$parser ;
array | $conf ;

Description

Text Renderer Class constructor

Parameter

object &$parser

Instance of the parser (model of MVC pattern)

array $conf

A hash containing any additional configuration

Return value

returns instance of object PHP_CompatInfo_Renderer_Text

Throws

throws no exceptions thrown

Since

since version 1.8.0b3 (2008-06-07)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Text::display

Name

PHP_CompatInfo_Renderer_Text::display — Display final results

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Text.php';
void PHP_CompatInfo_Renderer_Text::display ( );
;

Description

Display final results, when data source parsing is over.

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b3 (2008-06-07)

Note

This function can not be called statically.


Chapter 22. Xml Renderer

Table of Contents

constructor PHP_CompatInfo_Renderer_Xml::PHP_CompatInfo_Renderer_Xml - Xml Renderer Class constructor
PHP_CompatInfo_Renderer_Xml::display - Display final results


constructor PHP_CompatInfo_Renderer_Xml::PHP_CompatInfo_Renderer_Xml

Name

constructor PHP_CompatInfo_Renderer_Xml::PHP_CompatInfo_Renderer_Xml — Xml Renderer Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Xml.php';

void constructor PHP_CompatInfo_Renderer_Xml::PHP_CompatInfo_Renderer_Xml ( | &$parser,
 | $conf);
object | &$parser ;
array | $conf ;

Description

Xml Renderer Class constructor

Parameter

object &$parser

Instance of the parser (model of MVC pattern)

array $conf

A hash containing any additional configuration

Return value

returns instance of object PHP_CompatInfo_Renderer_Xml

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


PHP_CompatInfo_Renderer_Xml::display

Name

PHP_CompatInfo_Renderer_Xml::display — Display final results

Synopsis

    require_once 'PHP/CompatInfo/Renderer/Xml.php';
void PHP_CompatInfo_Renderer_Xml::display ( );
;

Description

Display final results, when data source parsing is over.

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 1.8.0b2 (2008-06-03)

Note

This function can not be called statically.


Chapter 23. Command-Line version

Table of Contents

constructor PHP_CompatInfo_Cli::PHP_CompatInfo_Cli - Command-Line Class constructor
PHP_CompatInfo_Cli::run - Run the CLI version


constructor PHP_CompatInfo_Cli::PHP_CompatInfo_Cli

Name

constructor PHP_CompatInfo_Cli::PHP_CompatInfo_Cli — Command-Line Class constructor

Synopsis

    require_once 'PHP/CompatInfo/Cli.php';
void constructor PHP_CompatInfo_Cli::PHP_CompatInfo_Cli ( );
;

Description

Command-Line Class constructor

Return value

returns instance of object PHP_CompatInfo_Cli

Throws

throws no exceptions thrown

Since

since version 0.8.0 (2004-04-22)

Note

This function can not be called statically.


PHP_CompatInfo_Cli::run

Name

PHP_CompatInfo_Cli::run — Run the CLI version

Synopsis

    require_once 'PHP/CompatInfo/Cli.php';
void PHP_CompatInfo_Cli::run ( );
;

Description

Run the CLI version of PHP_CompatInfo

Return value

returns void

Throws

throws no exceptions thrown

Since

since version 0.8.0 (2004-04-22)

Note

This function can not be called statically.