/usr/share/php/TheSeer/Autoload/CollectorResult.php is in phpab 1.16.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | <?php
namespace TheSeer\Autoload {
class CollectorResult {
/**
* @var array
*/
private $whitelist;
/**
* @var array
*/
private $blacklist;
/**
* @var array
*/
private $units = array();
/**
* @var array
*/
private $dependencies = array();
public function __construct(array $whitelist, array $blacklist) {
$this->whitelist = $whitelist;
$this->blacklist = $blacklist;
}
public function addParseResult(\SplFileInfo $file, ParseResult $result) {
if (!$result->hasUnits()) {
return;
}
$filename = $file->getRealPath();
foreach($result->getUnits() as $unit) {
if (!$this->accept($unit)) {
continue;
}
if (isset($this->units[$unit])) {
throw new CollectorResultException(
sprintf(
"Redeclaration of trait, interface or class found:\n\n\tUnit name: %s\n\tFirst occurance: %s\n\tRedeclaration: %s",
$unit,
$this->units[$unit],
$filename
),
CollectorResultException::DuplicateUnitName
);
}
$this->units[$unit] = $filename;
$this->dependencies[$unit] = $result->getDependenciesForUnit($unit);
}
}
public function hasUnits() {
return count($this->units) > 0;
}
/**
* @return array
*/
public function getDependencies() {
return $this->dependencies;
}
/**
* @return array
*/
public function getUnits() {
return $this->units;
}
/**
* @param string $unit
*
* @return bool
*/
private function accept($unit) {
foreach($this->blacklist as $entry) {
if (fnmatch($entry, $unit)) {
return false;
}
}
foreach($this->whitelist as $entry) {
if (fnmatch($entry, $unit)) {
return true;
}
}
return false;
}
}
class CollectorResultException extends \Exception {
const DuplicateUnitName = 1;
}
}
|