array PHP_CompatInfo::parseDir (
string $dir
, array $options = array()
)
ディレクトリを再帰的にパースして互換性情報を取得します。
$dir
パースするフォルダのパス。
$options
以下のオプションを指定する配列。
file_ext には PHP コードとみなるファイル拡張子の配列を指定します。 デフォルトは php, php4, inc, phtml です。
recurse_dir には、ファイルを再帰的に探すかどうかを boolean 値で指定します。
debug には、追加の出力を行うかどうかを boolean 値で指定します。
ignore_functions には、バージョンを算出する際に無視させたい関数の配列を指定します。
ignore_constants には、バージョンを算出する際に無視させたい定数の配列を指定します。
ignore_files には、無視させたいファイルの配列を指定します。 ファイル名の大文字小文字は区別しません。
ignore_dirs には、無視させたいディレクトリの配列を指定します。 ディレクトリ名の大文字小文字は区別しません。
ignore_extensions には、バージョンを算出する際に無視させたい PHP 拡張モジュールの配列を指定します。
ignore_versions には、バージョンを算出する際に無視させたい PHP のバージョンの配列を指定します。
ignore_functions_match には、バージョンを算出する際に無視させたい関数名のパターンの配列を指定します。
ignore_extensions_match には、バージョンを算出する際に無視させたい拡張モジュール名のパターンの配列を指定します。
ignore_constants_match には、バージョンを算出する際に無視させたい定数名のパターンの配列を指定します。
例外はスローされません。
PHP_CompatInfo::parseFolder() 、 PHP_CompatInfo::parseData() も参照ください。
バージョン 0.8.0 (2004-04-22) 以降
This function can not be called statically.
array - 以下のキーを含むハッシュを返します。
ignored_functions
,
ignored_extensions
,
ignored_constants
,
max_version
,
version
,
extensions
,
constants
,
tokens
,
cond_code
これらのディレクトリ/ファイルをパースするものとします。
PHP_CompatInfo/tests/parseDir/ PHP5/tokens.php5 PHP5/upload_error.php extensions.php phpinfo.php
このスクリプトの中身については配布パッケージを参照ください。
<?php
require_once 'PHP/CompatInfo.php';
$pci = new PHP_CompatInfo();
$input = 'PHP_CompatInfo/tests/parseDir/';
$options = array('recurse_dir' => true,
'file_ext' => array('php', 'php5')
);
$res = $pci->parseDir($input, $options);
var_export($res);
?>
結果はこのようになります。
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 ( ), ), ), ), )
まず全体的な結果を出力し、 続けてサブディレクトリ内の各ファイルの情報を出力します。