use pharext\Cli\Args;
use pharext\Exception;
use pharext\SourceDir;
-use pharext\Tempfile;
+use pharext\License;
/**
* A PECL extension source directory containing a v2 package.xml
*/
class Pecl implements \IteratorAggregate, SourceDir
{
+ use License;
+
/**
* The package.xml
* @var SimpleXmlElement
$sxe->registerXPathNamespace("pecl", $sxe->getDocNamespaces()[""]);
$this->sxe = $sxe;
- $this->path = $path;
+ $this->path = realpath($path);
}
/**
}
}
+ /**
+ * @inheritdoc
+ * @return string
+ */
+ public function getLicense() {
+ if (($license = $this->sxe->xpath("/pecl:package/pecl:license"))) {
+ if (($file = $this->findLicense($this->getBaseDir(), $license[0]["filesource"]))) {
+ return $this->readLicense($file);
+ }
+ }
+ if (($file = $this->findLicense($this->getBaseDir()))) {
+ return $this->readLicense($file);
+ }
+ if ($license) {
+ return $license[0] ." ". $license[0]["uri"];
+ }
+ return "UNKNOWN";
+ }
+
/**
* @inheritdoc
* @see \pharext\SourceDir::getArgs()
}
/* files */
- yield $this->file;
+ yield realpath($this->file);
foreach ($this->sxe->xpath("//pecl:file") as $file) {
yield realpath($this->path ."/". $this->dirOf($file) ."/". $file["name"]);
}