projects
/
pharext
/
pharext
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
ca052b5
)
fix metadata retrieval when not running as phar
author
Michael Wallner
<mike@php.net>
Tue, 9 Apr 2019 06:45:44 +0000
(08:45 +0200)
committer
Michael Wallner
<mike@php.net>
Wed, 4 Sep 2019 07:27:08 +0000
(09:27 +0200)
src/pharext/Cli/Command.php
patch
|
blob
|
history
diff --git
a/src/pharext/Cli/Command.php
b/src/pharext/Cli/Command.php
index 01c50c4f3feb1393a45d1979250e138738804956..6b91aeb41a4235731efaed9e60dbb2be053023c6 100644
(file)
--- a/
src/pharext/Cli/Command.php
+++ b/
src/pharext/Cli/Command.php
@@
-3,6
+3,7
@@
namespace pharext\Cli;
use pharext\Archive;
namespace pharext\Cli;
use pharext\Archive;
+use pharext\Metadata;
use Phar;
use Phar;
@@
-10,7
+11,7
@@
trait Command
{
/**
* Command line arguments
{
/**
* Command line arguments
- * @var
pharext\Cli\
Args
+ * @var Args
*/
private $args;
*/
private $args;
@@
-28,21
+29,25
@@
trait Command
* @return mixed
*/
public function metadata($key = null) {
* @return mixed
*/
public function metadata($key = null) {
- if (extension_loaded("Phar")) {
- $running = new Phar(Phar::running(false));
- } else {
- $running = new Archive(PHAREXT_PHAR);
- }
+ try {
+ if (extension_loaded("Phar")) {
+ $running = new Phar(Phar::running(false));
+ } else {
+ $running = new Archive(PHAREXT_PHAR);
+ }
- if ($key === "signature") {
- $sig = $running->getSignature();
- return sprintf("%s signature of %s\n%s",
- $sig["hash_type"],
- $this->metadata("name"),
- chunk_split($sig["hash"], 64, "\n"));
- }
+
if ($key === "signature") {
+
$sig = $running->getSignature();
+ return sprintf("%s signature of %s\n%s",
+
$sig["hash_type"],
+
$this->metadata("name"),
+
chunk_split($sig["hash"], 64, "\n"));
+
}
- $metadata = $running->getMetadata();
+ $metadata = $running->getMetadata();
+ } catch (\Exception $e) {
+ $metadata = Metadata::all();
+ }
if (isset($key)) {
return $metadata[$key];
}
if (isset($key)) {
return $metadata[$key];
}