File tree 2 files changed +11
-11
lines changed
2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,16 @@ stan: image
19
19
psalm : image
20
20
${RUN_PHP_CMD} ./vendor/bin/psalm --show-info=true
21
21
22
+ test-ffi-scope : image
23
+ ${RUN_PHP_CMD} -d ffi.preload=./src/pcap.h -d memory_limit=-1 ./vendor/bin/phpunit --debug
24
+
22
25
buster :
23
26
docker build -t ${REPOSITORY} :buster -f Dockerfile.buster .
24
27
25
28
buster-test : buster
26
29
${RUN_CMD} :buster php -d memory_limit=-1 -d memory_limit=-1 ./vendor/bin/phpunit --debug
27
30
28
- ci : stan psalm test buster-test
31
+ ci : stan psalm test-ffi-scope test buster-test
29
32
30
33
clean :
31
34
rm -rf ` cat .gitignore`
Original file line number Diff line number Diff line change 6
6
7
7
use FFI ;
8
8
use FFI \CData ;
9
- use FFI \Exception ;
9
+ use FFI \Exception as FFIException ;
10
10
11
11
/**
12
12
* FFI/libpcap class
@@ -15,13 +15,13 @@ class PcapFFI
15
15
{
16
16
public const LIBPCAP_NAME = 'libpcap.so.1 ' ;
17
17
18
- static private $ ffi = NULL ;
18
+ static private FFI $ ffi ;
19
19
20
20
private ?string $ error = null ;
21
21
22
22
public function __construct ()
23
23
{
24
- if (self ::$ ffi ) {
24
+ if (isset ( self ::$ ffi) ) {
25
25
return ;
26
26
}
27
27
@@ -31,21 +31,18 @@ public function __construct()
31
31
$ code = file_get_contents (__DIR__ . '/pcap.h ' );
32
32
33
33
if ($ code === false ) {
34
- throw new Exception ('Cannot load pcap C definitions ' );
34
+ throw new FFIException ('Cannot load pcap C definitions ' );
35
35
}
36
36
self ::$ ffi = FFI ::cdef ($ code , $ lib );
37
37
} else {
38
38
try {
39
39
// 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 ) {
42
42
// Try direct load
43
- self ::$ ffi = \ FFI ::load (__DIR__ . '/pcap.h ' );
43
+ self ::$ ffi = FFI ::load (__DIR__ . '/pcap.h ' );
44
44
}
45
45
}
46
- if (!self ::$ ffi ) {
47
- throw new \RuntimeException ("FFI parse fails " );
48
- }
49
46
}
50
47
51
48
public function lib_version (): string
You can’t perform that action at this time.
0 commit comments