PHP_CompatInfo::parseArray

PHP_CompatInfo::parseArray() – Parse an Array of Files

Synopsis

require_once 'PHP/CompatInfo.php';

array|false PHP_CompatInfo::parseArray ( 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

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

<?php
require_once 'PHP/CompatInfo.php';

$pci = new PHP_CompatInfo();

$input = array('/opt/lampp/etc/pear/PEAR.php',
               
'/opt/lampp/etc/pear/PHP/CompatInfo.php');

$res $pci->parseArray($input);

#var_export($res); // no need since PCI 1.8.0
?>

We get such result.

array (
  'ignored_files' =>
  array (
  ),
  'ignored_functions' =>
  array (
  ),
  'ignored_extensions' =>
  array (
  ),
  'ignored_constants' =>
  array (
  ),
  'max_version' => '',
  'version' => '4.3.0',
  'classes' =>
  array (
    0 => 'PHP_CompatInfo_Parser',
  ),
  'extensions' =>
  array (
    0 => 'pcre',
    1 => 'tokenizer',
  ),
  'constants' =>
  array (
    0 => 'E_USER_ERROR',
    1 => 'E_USER_NOTICE',
    2 => 'E_USER_WARNING',
    3 => 'FALSE',
    4 => 'NULL',
    5 => 'PHP_OS',
    6 => 'PHP_VERSION',
    7 => 'TRUE',
  ),
  'tokens' =>
  array (
  ),
  'cond_code' =>
  array (
    0 => 5,
  ),
  '/opt/lampp/etc/pear/PEAR.php' =>
  array (
    'ignored_functions' =>
    array (
    ),
    'ignored_extensions' =>
    array (
    ),
    'ignored_constants' =>
    array (
    ),
    'max_version' => '',
    'version' => '4.3.0',
    'classes' =>
    array (
    ),
    'extensions' =>
    array (
    ),
    'constants' =>
    array (
      0 => 'E_USER_ERROR',
      1 => 'E_USER_NOTICE',
      2 => 'E_USER_WARNING',
      3 => 'FALSE',
      4 => 'NULL',
      5 => 'PHP_OS',
      6 => 'PHP_VERSION',
      7 => 'TRUE',
    ),
    'tokens' =>
    array (
    ),
    'cond_code' =>
    array (
      0 => 5,
    ),
  ),
  '/opt/lampp/etc/pear/PHP/CompatInfo.php' =>
  array (
    'ignored_functions' =>
    array (
    ),
    'ignored_extensions' =>
    array (
    ),
    'ignored_constants' =>
    array (
    ),
    'max_version' => '',
    'version' => '4.3.0',
    'classes' =>
    array (
      0 => 'PHP_CompatInfo_Parser',
    ),
    'extensions' =>
    array (
      0 => 'pcre',
      1 => 'tokenizer',
    ),
    'constants' =>
    array (
      0 => 'FALSE',
    ),
    'tokens' =>
    array (
    ),
    'cond_code' =>
    array (
      0 => 0,
    ),
  ),
)
   

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

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.