PHP_CompatInfo
[ class tree: PHP_CompatInfo ] [ index: PHP_CompatInfo ] [ all elements ]

Source for file configure.php

Documentation is available at configure.php

  1. #!@php_bin@
  2. <?php
  3. /**
  4.  * The Predefined Classes/Constants array script generator.
  5.  *
  6.  * PHP version 5
  7.  *
  8.  * @category PHP
  9.  * @package  PHP_CompatInfo
  10.  * @author   Laurent Laville <pear@laurent-laville.org>
  11.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  12.  * @version  CVS: $Id: configure.php,v 1.2 2008/11/30 21:05:43 farell Exp $
  13.  * @link     http://pear.php.net/package/PHP_CompatInfo
  14.  * @since    File available since Release 1.9.0b1
  15.  */
  16.  
  17. require_once 'Console/Getargs.php';
  18.  
  19. $ds = DIRECTORY_SEPARATOR;
  20.  
  21. $opts = array('enable' =>
  22.                   array('short'   => 'e',
  23.                         'desc'    => 'A comma separated list of extensions '
  24.                                    . 'you want only',
  25.                         'default' => '',
  26.                         'min'     => 0 'max' => 1),
  27.               'disable' =>
  28.                   array('short'   => 'd',
  29.                         'desc'    => 'A comma separated list of extensions '
  30.                                    . 'you want to disable',
  31.                         'default' => '',
  32.                         'min'     => 0 'max' => 1),
  33.               'exceptions' =>
  34.                   array('short'   => 'x',
  35.                         'desc'    => 'File that provides exceptions results',
  36.                         'default' => 'exceptions.conf.php',
  37.                         'min'     => 0 'max' => 1),
  38.               'output' =>
  39.                   array('short'   => 'o',
  40.                         'desc'    => 'Target directory where to write results',
  41.                         'default' => './',
  42.                         'min'     => 0 'max' => 1),
  43.               'verbose' =>
  44.                   array('short'   => 'v',
  45.                         'desc'    => 'Set the verbose level',
  46.                         'default' => 1,
  47.                         'min'     => 0 'max' => 1),
  48.               'version' =>
  49.                   array('short' => 'V',
  50.                         'desc'  => 'Print version information',
  51.                         'max'   => 0),
  52.               'help' =>
  53.                   array('short' => 'h',
  54.                         'desc'  => 'Show this help',
  55.                         'max'   => 0)
  56.               );
  57.  
  58. $args = Console_Getargs::factory($opts);
  59.  
  60. if (PEAR::isError($args)) {
  61.     $header "PHP_CompatInfo build system \n".
  62.               'Usage: '.basename($_SERVER['SCRIPT_NAME'])." [options]\n\n";
  63.     if ($args->getCode(=== CONSOLE_GETARGS_ERROR_USER{
  64.         echo Console_Getargs::getHelp($opts$header$args->getMessage())."\n";
  65.     else if ($args->getCode(=== CONSOLE_GETARGS_HELP{
  66.         echo Console_Getargs::getHelp($opts$header)."\n";
  67.     }
  68.     exit(1);
  69. }
  70.  
  71. // version
  72. if ($args->isDefined('V')) {
  73.     echo 'PHP_CompatInfo build system version 1.9.0b1';
  74.     exit(0);
  75. }
  76.  
  77. // verbose
  78. if ($args->isDefined('v')) {
  79.     $verbose $args->getValue('v');
  80. else {
  81.     $verbose = 1;
  82. }
  83.  
  84. // output
  85. if ($args->isDefined('o')) {
  86.     $o $args->getValue('o');
  87.     if (is_dir($o&& (is_writable($o))) {
  88.         /* Directory where to write
  89.            all "*_const_array.php" and "*_class_array.php" files
  90.            Must ended with a trailing directory separator */
  91.         if (substr($o-11!== $ds{
  92.             $o .= $ds;
  93.         }
  94.         $target_directory $o;
  95.     else {
  96.         echo 'Invalid (or not writable) target directory';
  97.         exit(1);
  98.     }
  99. else {
  100.     $target_directory dirname(__FILE__$ds;
  101. }
  102.  
  103. // enable
  104. if ($args->isDefined('e')) {
  105.     $extensions explode(','$args->getValue('e'));
  106. else {
  107.     $extensions get_loaded_extensions();
  108. }
  109.  
  110. // disable
  111. if ($args->isDefined('d')) {
  112.     $d          explode(','$args->getValue('d'));
  113.     $extensions array_diff($extensions$d);
  114. }
  115.  
  116. // exceptions
  117. if ($args->isDefined('x')) {
  118.     $x $args->getValue('x');
  119.     if (file_exists($x)) {
  120.         include_once $x;
  121.         if (!function_exists('getExceptions')) {
  122.             echo 'getExceptions() function does not exists';
  123.             exit(1);
  124.         }
  125.     else {
  126.         echo 'Exceptions file does not exists';
  127.         exit(1);
  128.     }
  129. else {
  130.     include_once dirname(__FILE__$ds 'scripts' $ds 'exceptions.conf.php';
  131. }
  132.  
  133. $const_glob_list = array();
  134. $class_glob_list = array();
  135.  
  136. foreach ($extensions as $extension{
  137.  
  138.     if (!extension_loaded($extension)) {
  139.         continue;  // skip this extension if not loaded : prevent error
  140.     }
  141.  
  142.     $ext = new ReflectionExtension($extension);
  143.  
  144.     // name of the current Extension
  145.     $extName $ext->getName();
  146.  
  147.     // version of the current Extension
  148.     $extVers $ext->getVersion();
  149.  
  150.     if ($verbose > 0{
  151.         print 'Found '$extName;
  152.         if ($extVers{
  153.             print ' version '$extVers;
  154.         }
  155.         print PHP_EOL;
  156.     }
  157.  
  158.     // default version to apply to each constant and class predefined
  159.     $ver getExceptions($extName'version');
  160.     if ($ver === false{
  161.         $ver '5.0.0';
  162.     }
  163.  
  164.     // constants described by the Extension interface
  165.     $extConstants $ext->getConstants();
  166.     if (count($extConstants> 0{
  167.         $const_glob_list[$extName;
  168.  
  169.         $constants = array();
  170.         foreach ($extConstants as $cst => $val{
  171.             $constants[$cst]['init'$ver;
  172.             $constants[$cst]['name'$cst;
  173.         }
  174.  
  175.         $exceptions getExceptions($extName'constant');
  176.         if ($exceptions === false{
  177.             // no constant exceptions for this extension
  178.         else {
  179.             // apply exceptions to give final constant results
  180.             $constants array_merge($constants$exceptions);
  181.         }
  182.         ksort($constants);
  183.  
  184.         file_put_contents($target_directory $extName '_const_array.php',
  185.                           "<?php
  186. /**
  187.  * $extName extension Constant dictionary for PHP_CompatInfo 1.9.0a1 or better
  188.  *
  189.  * PHP versions 4 and 5
  190.  *
  191.  * @category PHP
  192.  * @package  PHP_CompatInfo
  193.  * @author   Davey Shafik <davey@php.net>
  194.  * @author   Laurent Laville <pear@laurent-laville.org>
  195.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  196.  * @version  CVS: \$Id: configure.php,v 1.2 2008/11/30 21:05:43 farell Exp $
  197.  * @link     http://pear.php.net/package/PHP_CompatInfo
  198.  * @since    version 1.9.0a1 (2008-11-23)
  199.  * @ignore
  200.  */
  201.  
  202. \$GLOBALS['_PHP_COMPATINFO_CONST_" . strtoupper($extName"'] = " .
  203.         var_export($constantstrue";
  204. ?>");
  205.  
  206.     }
  207.  
  208.     // classes described by the Extension interface
  209.     $extClasses $ext->getClassNames();
  210.     if (count($extClasses> 0{
  211.         $class_glob_list[$extName;
  212.  
  213.         $classes = array();
  214.         foreach ($extClasses as $i => $cls{
  215.             $classes[$cls]['init'$ver;
  216.             $classes[$cls]['name'$cls;
  217.             $classes[$cls]['ext']  $extName;
  218.             $classes[$cls]['pecl'= false;
  219.         }
  220.  
  221.         $exceptions getExceptions($extName'class');
  222.         if ($exceptions === false{
  223.             // no class exceptions for this extension
  224.         else {
  225.             // apply exceptions to give final class results
  226.             $classes array_merge($classes$exceptions);
  227.         }
  228.         ksort($classes);
  229.  
  230.         file_put_contents($target_directory $extName '_class_array.php',
  231.                           "<?php
  232. /**
  233.  * $extName extension Class dictionary for PHP_CompatInfo 1.9.0a1 or better
  234.  *
  235.  * PHP versions 4 and 5
  236.  *
  237.  * @category PHP
  238.  * @package  PHP_CompatInfo
  239.  * @author   Davey Shafik <davey@php.net>
  240.  * @author   Laurent Laville <pear@laurent-laville.org>
  241.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  242.  * @version  CVS: \$Id: configure.php,v 1.2 2008/11/30 21:05:43 farell Exp $
  243.  * @link     http://pear.php.net/package/PHP_CompatInfo
  244.  * @since    version 1.9.0a1 (2008-11-23)
  245.  * @ignore
  246.  */
  247.  
  248. \$GLOBALS['_PHP_COMPATINFO_CLASS_" . strtoupper($extName"'] = " .
  249.         var_export($classestrue";
  250. ?>");
  251.  
  252.     }
  253. }
  254.  
  255. $const_glob_list array_unique($const_glob_list);
  256. sort($const_glob_list);
  257.  
  258. $requires '';
  259. $globals  '';
  260. foreach ($const_glob_list as $cstExt{
  261.     $requires .= "require_once 'PHP/CompatInfo/" $cstExt "_const_array.php';"
  262.               . PHP_EOL;
  263.     $globals  .= "    \$GLOBALS['_PHP_COMPATINFO_CONST_" strtoupper($cstExt)
  264.               . "'], " . PHP_EOL;
  265. }
  266. $globals  rtrim($globals", ".PHP_EOL);
  267. $globals .= PHP_EOL;
  268.  
  269. file_put_contents($target_directory 'const_array.php',
  270.  
  271. "<?php
  272. /**
  273.  * Constant dictionary for PHP_CompatInfo 1.1.1 or better
  274.  *
  275.  * PHP versions 4 and 5
  276.  *
  277.  * @category PHP
  278.  * @package  PHP_CompatInfo
  279.  * @author   Davey Shafik <davey@php.net>
  280.  * @author   Laurent Laville <pear@laurent-laville.org>
  281.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  282.  * @version  CVS: \$Id: configure.php,v 1.2 2008/11/30 21:05:43 farell Exp $
  283.  * @link     http://pear.php.net/package/PHP_CompatInfo
  284.  * @since    version 1.1.1 (2006-07-27)
  285.  * @ignore
  286.  */
  287.  
  288. "$requires .
  289. "
  290. /**
  291.  * Predefined Constants
  292.  *
  293.  * @link http://www.php.net/manual/en/reserved.constants.php
  294.  * @global array \$GLOBALS['_PHP_COMPATINFO_CONST']
  295.  */
  296.  
  297. \$GLOBALS['_PHP_COMPATINFO_CONST'] = array_merge(
  298. "$globals .
  299. "    );
  300. ?>");
  301.  
  302.  
  303. $class_glob_list array_unique($class_glob_list);
  304. sort($class_glob_list);
  305.  
  306. $requires '';
  307. $globals  '';
  308. foreach ($class_glob_list as $clsExt{
  309.     $requires .= "require_once 'PHP/CompatInfo/" $clsExt "_class_array.php';"
  310.               . PHP_EOL;
  311.     $globals  .= "    \$GLOBALS['_PHP_COMPATINFO_CLASS_" strtoupper($clsExt)
  312.               . "'], " . PHP_EOL;
  313. }
  314. $globals  rtrim($globals", ".PHP_EOL);
  315. $globals .= PHP_EOL;
  316.  
  317. file_put_contents($target_directory 'class_array.php',
  318.  
  319. "<?php
  320. /**
  321.  * Class dictionary for PHP_CompatInfo 1.9.0a1 or better
  322.  *
  323.  * PHP versions 4 and 5
  324.  *
  325.  * @category PHP
  326.  * @package  PHP_CompatInfo
  327.  * @author   Davey Shafik <davey@php.net>
  328.  * @author   Laurent Laville <pear@laurent-laville.org>
  329.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  330.  * @version  CVS: \$Id: configure.php,v 1.2 2008/11/30 21:05:43 farell Exp $
  331.  * @link     http://pear.php.net/package/PHP_CompatInfo
  332.  * @since    version 1.9.0a1 (2008-11-23)
  333.  * @ignore
  334.  */
  335.  
  336. "$requires .
  337. "
  338. /**
  339.  * Predefined Classes
  340.  *
  341.  * > Standard Defined Classes
  342.  *   These classes are defined in the standard set of functions included in
  343.  *   the PHP build.
  344.  * - Directory
  345.  * - stdClass
  346.  * -  __PHP_Incomplete_Class
  347.  *
  348.  * > Predefined classes as of PHP 5
  349.  *   These additional predefined classes were introduced in PHP 5.0.0
  350.  * - Exception
  351.  * - php_user_filter
  352.  *
  353.  * > Miscellaneous extensions
  354.  *   define other classes which are described in their reference.
  355.  *
  356.  * @link http://www.php.net/manual/en/function.get-declared-classes.php
  357.  * @link http://www.php.net/manual/en/reserved.classes.php
  358.  * @global array \$GLOBALS['_PHP_COMPATINFO_CLASS']
  359.  */
  360.  
  361. \$GLOBALS['_PHP_COMPATINFO_CLASS'] = array_merge(
  362. "$globals .
  363. "    );
  364. ?>");
  365. ?>

Documentation generated on Sun, 30 Nov 2008 16:30:26 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.