From 95ccc64c86fc7a5d2c4de4b9ce6744ec4378b78a Mon Sep 17 00:00:00 2001 From: Milad Rahimi Date: Sat, 1 Jun 2024 12:18:52 +0200 Subject: [PATCH] use realpath to check files --- src/Cryptography/Keys/EcdsaPrivateKey.php | 6 +++--- src/Cryptography/Keys/EcdsaPublicKey.php | 6 +++--- src/Cryptography/Keys/RsaPrivateKey.php | 6 +++--- src/Cryptography/Keys/RsaPublicKey.php | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Cryptography/Keys/EcdsaPrivateKey.php b/src/Cryptography/Keys/EcdsaPrivateKey.php index 0f81da7..146f4ff 100644 --- a/src/Cryptography/Keys/EcdsaPrivateKey.php +++ b/src/Cryptography/Keys/EcdsaPrivateKey.php @@ -9,7 +9,7 @@ class EcdsaPrivateKey { /** - * @var resource Key resource handler + * @var mixed Key resource handler */ protected $resource; @@ -24,7 +24,7 @@ class EcdsaPrivateKey */ public function __construct(string $key, string $passphrase = '', ?string $id = null) { - $content = file_exists($key) ? file_get_contents(realpath($key)) : $key; + $content = realpath($key) ? file_get_contents(realpath($key)) : $key; $this->resource = openssl_pkey_get_private($content, $passphrase); if ($this->resource === false) { @@ -35,7 +35,7 @@ public function __construct(string $key, string $passphrase = '', ?string $id = } /** - * @return resource + * @return mixed */ public function getResource() { diff --git a/src/Cryptography/Keys/EcdsaPublicKey.php b/src/Cryptography/Keys/EcdsaPublicKey.php index c2b21ff..381955a 100644 --- a/src/Cryptography/Keys/EcdsaPublicKey.php +++ b/src/Cryptography/Keys/EcdsaPublicKey.php @@ -9,7 +9,7 @@ class EcdsaPublicKey { /** - * @var resource Key resource handler + * @var mixed Key resource handler */ protected $resource; @@ -23,7 +23,7 @@ class EcdsaPublicKey */ public function __construct(string $key, ?string $id = null) { - $content = file_exists($key) ? file_get_contents(realpath($key)) : $key; + $content = realpath($key) ? file_get_contents(realpath($key)) : $key; $this->resource = openssl_pkey_get_public($content); if ($this->resource === false) { @@ -34,7 +34,7 @@ public function __construct(string $key, ?string $id = null) } /** - * @return resource + * @return mixed */ public function getResource() { diff --git a/src/Cryptography/Keys/RsaPrivateKey.php b/src/Cryptography/Keys/RsaPrivateKey.php index 48a2af9..2125ba8 100644 --- a/src/Cryptography/Keys/RsaPrivateKey.php +++ b/src/Cryptography/Keys/RsaPrivateKey.php @@ -9,7 +9,7 @@ class RsaPrivateKey { /** - * @var resource Key resource handler + * @var mixed Key resource handler */ protected $resource; @@ -24,7 +24,7 @@ class RsaPrivateKey */ public function __construct(string $key, string $passphrase = '', ?string $id = null) { - $content = file_exists($key) ? file_get_contents(realpath($key)) : $key; + $content = realpath($key) ? file_get_contents(realpath($key)) : $key; $this->resource = openssl_pkey_get_private($content, $passphrase); if ($this->resource === false) { @@ -35,7 +35,7 @@ public function __construct(string $key, string $passphrase = '', ?string $id = } /** - * @return resource + * @return mixed */ public function getResource() { diff --git a/src/Cryptography/Keys/RsaPublicKey.php b/src/Cryptography/Keys/RsaPublicKey.php index 0b9602a..51d34d9 100644 --- a/src/Cryptography/Keys/RsaPublicKey.php +++ b/src/Cryptography/Keys/RsaPublicKey.php @@ -9,7 +9,7 @@ class RsaPublicKey { /** - * @var resource Key resource handler + * @var mixed Key resource handler */ protected $resource; @@ -23,7 +23,7 @@ class RsaPublicKey */ public function __construct(string $key, ?string $id = null) { - $content = file_exists($key) ? file_get_contents(realpath($key)) : $key; + $content = realpath($key) ? file_get_contents(realpath($key)) : $key; $this->resource = openssl_pkey_get_public($content); if ($this->resource === false) { @@ -34,7 +34,7 @@ public function __construct(string $key, ?string $id = null) } /** - * @return resource + * @return mixed */ public function getResource() {