xref: /PHP-5.6/ext/phar/build_precommand.php (revision 4e5280a7)
1#!/usr/bin/php
2<?php echo '<'.'?php';?>
3
4/** @file phar.php
5 * @ingroup Phar
6 * @brief class Phar Pre Command
7 * @author  Marcus Boerger
8 * @date    2007 - 2008
9 *
10 * Phar Command
11 */
12foreach(array("SPL", "Reflection", "Phar") as $ext) {
13	if (!extension_loaded($ext)) {
14		echo "$argv[0] requires PHP extension $ext.\n";
15		exit(1);
16	}
17}
18
19<?php
20
21$classes = array(
22	'DirectoryTreeIterator',
23	'DirectoryGraphIterator',
24	'InvertedRegexIterator',
25	'CLICommand',
26	'PharCommand',
27	);
28
29foreach($classes as $name) {
30	echo "if (!class_exists('$name', 0))\n{\n";
31	$f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc');
32	unset($f[0]);
33	$c = count($f);
34	while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
35		unset($f[$c--]);
36	}
37	if (substr($f[$c], -2) == "\r\n") {
38		$f[$c] = substr($f[$c], 0, -2);
39	}
40	if (substr($f[$c], -1) == "\n") {
41		$f[$c] = substr($f[$c], 0, -1);
42	}
43	if (substr($f[$c], -2) == '?>') {
44		$f[$c] = substr($f[$c], 0,-2);
45	}
46	while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
47		unset($f[$c--]);
48	}
49	echo join('', $f);
50	echo "\n}\n\n";
51}
52
53echo 'new PharCommand($argc, $argv);'."\n";
54
55?>
56