X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FSourceDir%2FPecl.php;h=277e122b255c9cd67b140dcde8bf68df412a264b;hb=e44f0adc7b18845a2cd3dc63fdab5d9bcdc10f76;hp=188ea67e98f57097f5e382c2a5734eab52bcf2fe;hpb=e990b6dabecbdaf98b8d8b2173b0d697f9b2b754;p=pharext%2Fpharext diff --git a/src/pharext/SourceDir/Pecl.php b/src/pharext/SourceDir/Pecl.php index 188ea67..277e122 100644 --- a/src/pharext/SourceDir/Pecl.php +++ b/src/pharext/SourceDir/Pecl.php @@ -5,13 +5,15 @@ namespace pharext\SourceDir; 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 @@ -46,7 +48,7 @@ class Pecl implements \IteratorAggregate, SourceDir $sxe->registerXPathNamespace("pecl", $sxe->getDocNamespaces()[""]); $this->sxe = $sxe; - $this->path = $path; + $this->path = realpath($path); } /** @@ -73,6 +75,25 @@ class Pecl implements \IteratorAggregate, SourceDir } } + /** + * @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() @@ -148,7 +169,7 @@ class Pecl implements \IteratorAggregate, SourceDir } /* 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"]); }