forked from vim-php/phpctags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildPHAR.php
56 lines (48 loc) · 1.58 KB
/
buildPHAR.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
$phar = new Phar('build/phpctags.phar', 0, 'phpctags.phar');
if (version_compare(PHP_VERSION, '5.4.0') < 0) {
class RecursiveCallbackFilterIterator extends RecursiveFilterIterator {
public function __construct ( RecursiveIterator $iterator, $callback ) {
$this->callback = $callback;
parent::__construct($iterator);
}
public function accept () {
$callback = $this->callback;
return $callback(parent::current(), parent::key(), parent::getInnerIterator());
}
public function getChildren () {
return new self($this->getInnerIterator()->getChildren(), $this->callback);
}
}
}
$phar->buildFromIterator(
new RecursiveIteratorIterator(
new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator(
getcwd(),
FilesystemIterator::SKIP_DOTS
),
function ($current) {
$excludes = array(
'.*',
'tags',
'build/*',
'tests/*',
'Makefile',
'bin/phpctags',
'buildPHAR.php',
);
foreach($excludes as $exclude) {
if (fnmatch(getcwd().'/'.$exclude, $current->getPathName())) {
return false;
}
}
return true;
}
)
),
getcwd()
);
$phar->setStub(
"#!/usr/bin/env php\n".$phar->createDefaultStub('bootstrap.php')
);