/** * Execute the PhpCompatibility plugin */ protected function _execute() { $options = array('recursive' => true, 'report' => 'summary'); $min = 0; $minReadable = 0; $max = INF; $maxReadable = 'latest'; try { $phpci = new \PHP_CompatInfo($options); $phpci->parse($this->_extensionPath); $allResultsAtOnce = $phpci->toArray(); foreach ($phpci->toArray() as $file => $result) { if ($file == 'versions') { $currentMin = $this->_getVersionInt($result[0]); $currentMax = $this->_getVersionInt($result[1]); if (false == is_null($currentMin) && $min < $currentMin) { $min = $currentMin; $minReadable = $result[0]; } if (false == is_null($currentMax) && $currentMax < $max) { $max = $currentMax; $maxReadable = $result[1]; } } } } catch (\PHP_CompatInfo_Exception $e) { die('PHP_CompatInfo Exception : ' . $e->getMessage() . PHP_EOL); } if ($min <= $this->_getVersionInt($this->_settings->min) && $maxReadable == 'latest') { IssueHandler::addIssue(new Issue(array("extension" => $this->_extensionPath, "checkname" => $this->_pluginName, "type" => 'php_compatibility', "comment" => vsprintf('Extension is compatible to PHP from version %s up to latest versions', array($minReadable)), "failed" => false))); return; } IssueHandler::addIssue(new Issue(array("extension" => $this->_extensionPath, "checkname" => $this->_pluginName, "type" => 'php_compatibility', "comment" => vsprintf('Extension is compatible to PHP from version %s (instead of required %s) up to %s', array($minReadable, $this->_settings->min, $maxReadable)), "failed" => true))); }
/** * Class constructor for full/combined report * * @param string $source Data source * @param array $options Options for parser * @param array $warnings List of warning messages already produced * @param array $reportChilds List of reports to print */ public function __construct($source, $options, $warnings, $reportChilds) { $pci = new PHP_CompatInfo($options); if ($pci->parse($source) === false) { return; } $reportResults = $pci->toArray(); $masterResults = $reportResults[0]; if ($options['verbose'] < 3) { $reportResults = $reportResults[0]; } else { unset($reportResults[0]); } $base = realpath($source); if (is_file($base)) { $base = dirname($base); } $allWarnings = array_unique(array_merge($warnings, $pci->getWarnings())); $options = $pci->getOptions(); if (empty($reportChilds)) { $reportChilds = array('summary', 'extension', 'interface', 'trait', 'class', 'function', 'constant', 'global', 'token', 'condition'); } foreach ($reportChilds as $report) { $classReport = 'PHP_CompatInfo_Report_' . ucfirst($report); new $classReport($source, $options, $allWarnings, $reportResults); } echo PHP_EOL; if (count($allWarnings) > 0 && $options['verbose'] > 0) { echo 'Warning messages : (' . count($allWarnings) . ')' . PHP_EOL; echo PHP_EOL; foreach ($allWarnings as $warn) { if (in_array($warn, $warnings)) { // other listeners need to be notifed about console warnings $pci->addWarning($warn); } echo ' ' . $warn . PHP_EOL; } echo PHP_EOL; } if (class_exists('PHP_Timer', true) === true) { echo PHP_Timer::resourceUsage() . PHP_EOL; echo PHP_EOL; } echo 'Required PHP ' . $masterResults['versions'][0] . ' (min)'; if (!empty($masterResults['versions'][1])) { echo ', ' . $masterResults['versions'][1] . ' (max)'; } echo PHP_EOL; }
You should have received a copy of the GNU General Public License along with Beehive; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ======================================================================*/ require 'Bartlett/PHP/CompatInfo/Autoload.php'; require 'Bartlett/PHP/CompatInfo.php'; set_time_limit(0); header('Content-Type: text/plain'); echo "Please wait checking Minimum PHP Version...\n\n"; $pci = new PHP_CompatInfo(); $minimum_version = "0"; $versions_array = array(); $extensions_array = array(); $ignore_result_keys = array('ignored_files', 'ignored_functions', 'ignored_extensions', 'ignored_constants', 'max_version', 'version', 'classes', 'functions', 'extensions', 'constants', 'tokens', 'cond_code'); if (isset($_SERVER['argc']) && $_SERVER['argc'] > 1) { $pci->parse(array_splice($_SERVER['argv'], 1)); } else { $options = array('debug' => false, 'recurse_dir' => true, 'ignore_dirs' => array('forum/ckeditor', 'forum/include/htmlpurifier', 'forum/include/locale', 'forum/include/swift')); $pci->parse('forum'); } $results = $pci->toArray(); foreach ($results[0]['extensions'] as $extension_name => $extension_info) { if (in_array($extension_name, array('Core', 'standard'))) { continue; } $extensions_array[] = $extension_name; } $minimum_version = $results[0]['versions'][0]; sort($extensions_array); printf("PHP Minimum Version = %s\nExtensions required : %s\n\n", $minimum_version, implode(", ", $extensions_array));