Skip to content

Commit 01f522c

Browse files
committed
Added stub.php;
Made extrasetup.php use installed files as opposed to archived ones; Made packagexmlsetup.php use $oompatible conditionally.
1 parent 84fc3f6 commit 01f522c

File tree

3 files changed

+115
-50
lines changed

3 files changed

+115
-50
lines changed

extrasetup.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
<?php
22
$extrafiles = array();
33

4-
foreach (
5-
array(
6-
dirname(__DIR__) . DIRECTORY_SEPARATOR . 'PEAR2_Cache_SHM.git'
7-
) as $packageRoot
8-
) {
9-
$pkg = new \Pyrus\Package(
10-
$packageRoot . DIRECTORY_SEPARATOR . 'package.xml'
11-
);
12-
foreach (array('tests', 'docs') as $folder) {
4+
$phpDir = Pyrus\Config::current()->php_dir . DIRECTORY_SEPARATOR;
5+
$packages = array('PEAR2/Autoload', 'PEAR2/Cache/SHM');
6+
7+
foreach ($packages as $pkg) {
8+
$prefix = $phpDir . $pkg;
9+
10+
if (is_dir($prefix)) {
1311
foreach (
1412
new RecursiveIteratorIterator(
1513
new RecursiveDirectoryIterator(
16-
$packageRoot . DIRECTORY_SEPARATOR . $folder,
14+
$prefix,
1715
RecursiveDirectoryIterator::UNIX_PATHS
1816
),
1917
RecursiveIteratorIterator::LEAVES_ONLY
2018
) as $path
2119
) {
22-
unset($pkg->files[$path->getPathname()]);
20+
$pathname = $path->getPathname();
21+
$extrafiles['src/' . $pathname] = $pathname;
2322
}
2423
}
25-
$extrafiles[] = $pkg;
24+
25+
if (is_file($prefix . '.php')) {
26+
$extrafiles['src/' . $pkg . '.php'] = $prefix . '.php';
27+
}
2628
}

packagexmlsetup.php

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
)
3939
);
4040

41-
$compatible->license = $package->license;
4241

4342
$package->files['tests/bootstrap.php'] = array_merge_recursive(
4443
$package->files['tests/bootstrap.php']->getArrayCopy(), $srcDirTask
@@ -63,38 +62,43 @@
6362
)
6463
);
6564

66-
//$compatible->files[
67-
// "test/{$package->channel}/{$package->name}/bootstrap.php"
68-
// ] = array_merge_recursive(
69-
// $compatible->files[
70-
// "test/{$package->channel}/{$package->name}/bootstrap.php"
71-
// ]->getArrayCopy(), $srcDirTask
72-
//);
73-
//
74-
//$compatible->files["doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"]
75-
// = array_merge_recursive(
76-
// $compatible->files[
77-
// "doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
78-
// ]->getArrayCopy(), $srcDirTask
79-
//);
80-
//
81-
//$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
82-
// = array_merge_recursive(
83-
// $compatible->files[
84-
// "doc/{$package->channel}/{$package->name}/doxygen.ini"
85-
// ]->getArrayCopy(), $srcDirTask,
86-
// array(
87-
// 'tasks:replace' => array(
88-
// array(
89-
// 'attribs' => array(
90-
// 'from' => 'GIT: $Id$',
91-
// 'to' => 'version',
92-
// 'type' => 'package-info'
93-
// )
94-
// )
95-
// )
96-
// )
97-
//);
65+
$hasCompatible = isset($compatible);
66+
if ($hasCompatible) {
67+
$compatible->license = $package->license;
68+
$compatible->files[
69+
"test/{$package->channel}/{$package->name}/bootstrap.php"
70+
] = array_merge_recursive(
71+
$compatible->files[
72+
"test/{$package->channel}/{$package->name}/bootstrap.php"
73+
]->getArrayCopy(), $srcDirTask
74+
);
75+
76+
$compatible->files[
77+
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
78+
] = array_merge_recursive(
79+
$compatible->files[
80+
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
81+
]->getArrayCopy(), $srcDirTask
82+
);
83+
84+
$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
85+
= array_merge_recursive(
86+
$compatible->files[
87+
"doc/{$package->channel}/{$package->name}/doxygen.ini"
88+
]->getArrayCopy(), $srcDirTask,
89+
array(
90+
'tasks:replace' => array(
91+
array(
92+
'attribs' => array(
93+
'from' => 'GIT: $Id$',
94+
'to' => 'version',
95+
'type' => 'package-info'
96+
)
97+
)
98+
)
99+
)
100+
);
101+
}
98102

99103
$oldCwd = getcwd();
100104
chdir(__DIR__);
@@ -112,10 +116,12 @@
112116
$package->files[$filename]->getArrayCopy(), $srcFileTasks
113117
);
114118

115-
$compatibleFilename = str_replace('src/', 'php/', $filename);
116-
$compatible->files[$compatibleFilename] = array_merge_recursive(
117-
$compatible->files[$compatibleFilename]->getArrayCopy(),
118-
$srcFileTasks
119-
);
119+
if ($hasCompatible) {
120+
$compatibleFilename = str_replace('src/', 'php/', $filename);
121+
$compatible->files[$compatibleFilename] = array_merge_recursive(
122+
$compatible->files[$compatibleFilename]->getArrayCopy(),
123+
$srcFileTasks
124+
);
125+
}
120126
}
121127
chdir($oldCwd);

stub.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
if (count(get_included_files()) > 1) {
3+
Phar::mapPhar();
4+
$autoloder = 'phar://' . __FILE__ . DIRECTORY_SEPARATOR . 'src'
5+
. DIRECTORY_SEPARATOR . 'PEAR2' . DIRECTORY_SEPARATOR . 'Autoload.php';
6+
if (is_file($autoloder)) {
7+
include_once $autoloder;
8+
}
9+
} else {
10+
$isNotCli = PHP_SAPI !== 'cli';
11+
if ($isNotCli) {
12+
header('Content-Type: text/plain;charset=UTF-8');
13+
}
14+
echo "PEAR2_Net_Transmitter @PACKAGE_VERSION@\n";
15+
16+
if (version_compare(phpversion(), '5.3.0', '<')) {
17+
echo "\nThis package requires PHP 5.3.0 or later.";
18+
exit(1);
19+
}
20+
21+
if (extension_loaded('phar')) {
22+
$phar = new Phar(__FILE__);
23+
$sig = $phar->getSignature();
24+
echo "{$sig['hash_type']} hash: {$sig['hash']}\n\n";
25+
}
26+
27+
if (function_exists('stream_socket_client')) {
28+
echo <<<HEREDOC
29+
The stream_socket_client() function is enabled.\n
30+
If you can't connect to a host, this means one
31+
of the following:\n
32+
1. You've mistyped the IP and/or port. Check the IP and port you've specified
33+
are the one you intended.\n
34+
2. The host is not reachable from your web server. Try to reach the host
35+
from the web server by other means (e.g. ping) using the same IP, and if
36+
you're unable to reach it, check your network's settings.\n
37+
2. Your web server is configured to forbid that outgoing connection. If you're
38+
the web server administrator, check your firewall's settings. If you're on a
39+
hosting plan... Typically, shared hosts block all outgoing connections, but it's
40+
also possible that only connections to that port are blocked. If the remote host
41+
is under your control, try to connect to it on a popular port (21, 80, etc.),
42+
and if successful, keep using that port instead. If the connection fails even
43+
then, or if the remote host is not under your control, ask your host to
44+
configure their firewall so as to allow you to make outgoing connections to the
45+
ip:port you need to connect to.
46+
HEREDOC;
47+
} else {
48+
echo <<<HEREDOC
49+
WARNING: stream_socket_client() is disabled. Without it, you won't be able to
50+
connect to any host. Enable it in php.ini, or ask your host to enable it for
51+
you.
52+
HEREDOC;
53+
}
54+
55+
}
56+
57+
__HALT_COMPILER();

0 commit comments

Comments
 (0)