File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,16 @@ stan: image
1919psalm : image
2020 ${RUN_PHP_CMD} ./vendor/bin/psalm --show-info=true
2121
22+ test-ffi-scope : image
23+ ${RUN_PHP_CMD} -d ffi.preload=./src/pcap.h -d memory_limit=-1 ./vendor/bin/phpunit --debug
24+
2225buster :
2326 docker build -t ${REPOSITORY} :buster -f Dockerfile.buster .
2427
2528buster-test : buster
2629 ${RUN_CMD} :buster php -d memory_limit=-1 -d memory_limit=-1 ./vendor/bin/phpunit --debug
2730
28- ci : stan psalm test buster-test
31+ ci : stan psalm test-ffi-scope test buster-test
2932
3033clean :
3134 rm -rf ` cat .gitignore`
Original file line number Diff line number Diff line change 66
77use FFI ;
88use FFI \CData ;
9- use FFI \Exception ;
9+ use FFI \Exception as FFIException ;
1010
1111/**
1212 * FFI/libpcap class
@@ -15,13 +15,13 @@ class PcapFFI
1515{
1616 public const LIBPCAP_NAME = 'libpcap.so.1 ' ;
1717
18- static private $ ffi = NULL ;
18+ static private FFI $ ffi ;
1919
2020 private ?string $ error = null ;
2121
2222 public function __construct ()
2323 {
24- if (self ::$ ffi ) {
24+ if (isset ( self ::$ ffi) ) {
2525 return ;
2626 }
2727
@@ -31,21 +31,18 @@ public function __construct()
3131 $ code = file_get_contents (__DIR__ . '/pcap.h ' );
3232
3333 if ($ code === false ) {
34- throw new Exception ('Cannot load pcap C definitions ' );
34+ throw new FFIException ('Cannot load pcap C definitions ' );
3535 }
3636 self ::$ ffi = FFI ::cdef ($ code , $ lib );
3737 } else {
3838 try {
3939 // Try preload
40- self ::$ ffi = \ FFI ::scope ("_RTCKIT_PCAP_FFI_ " );
41- } catch (\ FFI \ Exception $ e ) {
40+ self ::$ ffi = FFI ::scope ("_RTCKIT_PCAP_FFI_ " );
41+ } catch (FFIException $ e ) {
4242 // Try direct load
43- self ::$ ffi = \ FFI ::load (__DIR__ . '/pcap.h ' );
43+ self ::$ ffi = FFI ::load (__DIR__ . '/pcap.h ' );
4444 }
4545 }
46- if (!self ::$ ffi ) {
47- throw new \RuntimeException ("FFI parse fails " );
48- }
4946 }
5047
5148 public function lib_version (): string
You can’t perform that action at this time.
0 commit comments