PEAR logo

PHP_CompatInfo : The Definitive Guide

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 : The Definitive Guide v 1.8.0 : August 1, 2008