From 86f8af038be086bea2f2f2c32a8289dc9494a1b2 Mon Sep 17 00:00:00 2001 From: eater <=@eater.me> Date: Mon, 25 Nov 2019 01:10:51 +0100 Subject: [PATCH] configure php stan --- phpstan.neon | 6 ++++++ src/OpenSSL/Instance.php | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 phpstan.neon diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..4e76a5e --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + universalObjectCratesClasses: + - FFI + - FFI\CData + ignoreErrors: + - '~^Call to an undefined method FFI::~' \ No newline at end of file diff --git a/src/OpenSSL/Instance.php b/src/OpenSSL/Instance.php index 1443110..c40ad00 100644 --- a/src/OpenSSL/Instance.php +++ b/src/OpenSSL/Instance.php @@ -52,9 +52,10 @@ class Instance public function init() { $this->load(); - $this->ffi->ERR_load_crypto_strings(); - $this->ffi->OPENSSL_add_all_algorithms_conf(); - $this->ffi->OPENSSL_config(null); + $ffi = $this->getFFI(); + $ffi->ERR_load_crypto_strings(); + $ffi->OPENSSL_add_all_algorithms_conf(); + $ffi->OPENSSL_config(null); } public function __destruct() @@ -70,6 +71,10 @@ class Instance public function getFFI(): FFI { + if ($this->ffi === null) { + throw new \RuntimeException("Failed to load FFI"); + } + return $this->ffi; } } \ No newline at end of file