Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chopins committed Jun 6, 2020
1 parent 4bce957 commit 29e88d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/FFIExtend.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class FFIExtend

public function __construct()
{
defined('PHP_DLL_FILE_PATH') || define('PHP_DLL_FILE_PATH', false);
if(self::$ffi === null) {
$this->versionMacro();
$this->initPhpApi();
Expand Down Expand Up @@ -136,7 +137,7 @@ private function initPhpApi()
self::$ffi = FFI::cdef($code, $phpDll);
} else {
$code = str_replace('ZEND_FASTCALL', '__attribute__((fastcall))', $code);
if(defined('PHP_DLL_FILE_PATH')) {
if(PHP_DLL_FILE_PATH) {
self::$ffi = FFI::cdef($code, PHP_DLL_FILE_PATH);
} else {
self::$ffi = FFI::cdef($code);
Expand All @@ -148,7 +149,7 @@ private function initPhpApi()

protected function findPhpDll()
{
if(defined('PHP_DLL_FILE_PATH')) {
if(PHP_DLL_FILE_PATH) {
return PHP_DLL_FILE_PATH;
}
$f = '/php7' . (PHP_ZTS ? 'ts' : '') . '.dll';
Expand Down
4 changes: 3 additions & 1 deletion src/ReflectionCFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class ReflectionCFunction extends FFIExtend implements Reflector
private $name = '';
private $ffi = null;
private $type = null;
private static $preName;

public function __construct(FFI $ffi, $name)
{
parent::__construct();
$this->ffi = $ffi;
$this->name = $name;
self::$preName = $name;
$sym = $this->findSymobl($ffi, $name, self::ZEND_FFI_SYM_FUNC);
if(!$this->isNull($sym)) {
$this->type = $this->ZEND_FFI_TYPE($sym[0]->type)[0];
Expand All @@ -42,7 +44,7 @@ public function getName()

public static function export()
{
return $this->name;
return self::$preName;
}

public function getClosure()
Expand Down

0 comments on commit 29e88d2

Please sign in to comment.