summaryrefslogtreecommitdiff
path: root/ext/ffi/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ffi/tests')
-rw-r--r--ext/ffi/tests/002.phpt194
-rw-r--r--ext/ffi/tests/003.phpt12
-rw-r--r--ext/ffi/tests/004.phpt20
-rw-r--r--ext/ffi/tests/008.phpt14
-rw-r--r--ext/ffi/tests/012.phpt4
-rw-r--r--ext/ffi/tests/013.phpt46
-rw-r--r--ext/ffi/tests/015.phpt52
-rw-r--r--ext/ffi/tests/016.phpt20
-rw-r--r--ext/ffi/tests/017.phpt14
-rw-r--r--ext/ffi/tests/018.phpt14
-rw-r--r--ext/ffi/tests/019.phpt12
-rw-r--r--ext/ffi/tests/020.phpt62
-rw-r--r--ext/ffi/tests/021.phpt6
-rw-r--r--ext/ffi/tests/022.phpt16
-rw-r--r--ext/ffi/tests/023.phpt14
-rw-r--r--ext/ffi/tests/024.phpt40
-rw-r--r--ext/ffi/tests/025.phpt28
-rw-r--r--ext/ffi/tests/026.phpt2
-rw-r--r--ext/ffi/tests/027.phpt66
-rw-r--r--ext/ffi/tests/028.phpt42
-rw-r--r--ext/ffi/tests/029.phpt4
-rw-r--r--ext/ffi/tests/031.phpt16
-rw-r--r--ext/ffi/tests/032.phpt24
-rw-r--r--ext/ffi/tests/035.phpt4
-rw-r--r--ext/ffi/tests/036.phpt12
-rw-r--r--ext/ffi/tests/037.phpt8
-rw-r--r--ext/ffi/tests/038.phpt2
-rw-r--r--ext/ffi/tests/039.phpt2
-rw-r--r--ext/ffi/tests/041.phpt48
-rw-r--r--ext/ffi/tests/045.phpt12
-rw-r--r--ext/ffi/tests/100.phpt10
-rw-r--r--ext/ffi/tests/200.phpt15
-rw-r--r--ext/ffi/tests/bug77706.phpt16
-rw-r--r--ext/ffi/tests/bug79096.phpt4
-rw-r--r--ext/ffi/tests/list.phpt134
35 files changed, 494 insertions, 495 deletions
diff --git a/ext/ffi/tests/002.phpt b/ext/ffi/tests/002.phpt
index 62cb9182c4..353f36139c 100644
--- a/ext/ffi/tests/002.phpt
+++ b/ext/ffi/tests/002.phpt
@@ -14,117 +14,117 @@ echo " ok\n";
echo "Various declarations\n";
$ffi = FFI::cdef(<<<EOF
- /* allowed storage classes */
- typedef int type1;
+ /* allowed storage classes */
+ typedef int type1;
// extern int var2;
- static int var3;
- auto int var4;
- register int var5;
+ static int var3;
+ auto int var4;
+ register int var5;
- /* allowed types */
- typedef void type6;
- typedef char type7; /* sint8_t or uint8_t */
- typedef signed char type8; /* sint8_t */
- typedef unsigned char type9; /* uint8_t */
- typedef short type10; /* sint16_t */
- typedef signed short type11; /* sint16_t */
- typedef short int type12; /* sint16_t */
- typedef signed short int type13; /* sint16_t */
- typedef unsigned short type14; /* uint16_t */
- typedef unsigned short int type15; /* uint16_t */
- typedef int type16; /* sint32_t */
- typedef signed type17; /* sint32_t */
- typedef signed int type18; /* sint32_t */
- typedef unsigned type19; /* uint32_t */
- typedef unsigned int type20; /* uint32_t */
- typedef long type21; /* sint32_t or sint64_t */
- typedef signed long type22; /* sint32_t or sint64_t */
- typedef long int type23; /* sint32_t or sint64_t */
- typedef signed long int type24; /* sint32_t or sint64_t */
- typedef unsigned long type25; /* uint32_t or uint64_t */
- typedef unsigned long int type25_2; /* uint32_t or uint64_t */
- typedef long long type26; /* sint64_t */
- typedef signed long long type27; /* sint64_t */
- typedef long long int type28; /* sint64_t */
- typedef signed long long int type29; /* sint64_t */
- typedef unsigned long long type30; /* uint64_t */
- typedef unsigned long long int type31; /* uint64_t */
- typedef float type32;
- typedef double type33;
- typedef long double type34;
- typedef _Bool type35;
+ /* allowed types */
+ typedef void type6;
+ typedef char type7; /* sint8_t or uint8_t */
+ typedef signed char type8; /* sint8_t */
+ typedef unsigned char type9; /* uint8_t */
+ typedef short type10; /* sint16_t */
+ typedef signed short type11; /* sint16_t */
+ typedef short int type12; /* sint16_t */
+ typedef signed short int type13; /* sint16_t */
+ typedef unsigned short type14; /* uint16_t */
+ typedef unsigned short int type15; /* uint16_t */
+ typedef int type16; /* sint32_t */
+ typedef signed type17; /* sint32_t */
+ typedef signed int type18; /* sint32_t */
+ typedef unsigned type19; /* uint32_t */
+ typedef unsigned int type20; /* uint32_t */
+ typedef long type21; /* sint32_t or sint64_t */
+ typedef signed long type22; /* sint32_t or sint64_t */
+ typedef long int type23; /* sint32_t or sint64_t */
+ typedef signed long int type24; /* sint32_t or sint64_t */
+ typedef unsigned long type25; /* uint32_t or uint64_t */
+ typedef unsigned long int type25_2; /* uint32_t or uint64_t */
+ typedef long long type26; /* sint64_t */
+ typedef signed long long type27; /* sint64_t */
+ typedef long long int type28; /* sint64_t */
+ typedef signed long long int type29; /* sint64_t */
+ typedef unsigned long long type30; /* uint64_t */
+ typedef unsigned long long int type31; /* uint64_t */
+ typedef float type32;
+ typedef double type33;
+ typedef long double type34;
+ typedef _Bool type35;
// typedef float _Complex type36;
// typedef double _Complex type36_2;
// typedef long double _Complex type36_3;
- /* struct and union */
- struct tag1;
- union tag2;
- typedef struct tag1 {int x; int y;} type37;
- typedef union tag2 {int x; int y;} type38;
- typedef struct {int x, y; int z;} type39;
- typedef struct {unsigned int x:8, y:8;} type40;
- typedef struct {unsigned int x:8, :8, y:8;} type41;
+ /* struct and union */
+ struct tag1;
+ union tag2;
+ typedef struct tag1 {int x; int y;} type37;
+ typedef union tag2 {int x; int y;} type38;
+ typedef struct {int x, y; int z;} type39;
+ typedef struct {unsigned int x:8, y:8;} type40;
+ typedef struct {unsigned int x:8, :8, y:8;} type41;
- /* enum */
- enum tag3;
- typedef enum tag3 {A,B,C} type42;
- typedef enum {D,E=10,F,} type43;
+ /* enum */
+ enum tag3;
+ typedef enum tag3 {A,B,C} type42;
+ typedef enum {D,E=10,F,} type43;
- /* type qualifiers */
- typedef void* type46;
- typedef const void* type47;
- typedef restrict void* type48;
- typedef volatile void* type49;
- typedef _Atomic void* type50;
- typedef const volatile void* type51;
+ /* type qualifiers */
+ typedef void* type46;
+ typedef const void* type47;
+ typedef restrict void* type48;
+ typedef volatile void* type49;
+ typedef _Atomic void* type50;
+ typedef const volatile void* type51;
- /* function specifiers */
- static void f1();
- static inline void f2();
- static _Noreturn void f3();
+ /* function specifiers */
+ static void f1();
+ static inline void f2();
+ static _Noreturn void f3();
- /* align specifier */
- typedef double _Alignas(char) type52;
- typedef double _Alignas(1) type53;
+ /* align specifier */
+ typedef double _Alignas(char) type52;
+ typedef double _Alignas(1) type53;
- /* pointers */
- typedef void * type54;
- typedef void ** type55;
- typedef const void * const volatile * const type56;
+ /* pointers */
+ typedef void * type54;
+ typedef void ** type55;
+ typedef const void * const volatile * const type56;
- /* arrays */
- typedef char type57[];
- typedef char type58[const];
- typedef char type59[const volatile];
- typedef char type60[10];
- typedef char type61[const 10];
- typedef char type62[static 10];
- typedef char type63[static const volatile 10];
- typedef char type64[const volatile static 10];
- typedef char type65[];
- typedef char type66[const volatile];
- typedef char type67[10][10];
+ /* arrays */
+ typedef char type57[];
+ typedef char type58[const];
+ typedef char type59[const volatile];
+ typedef char type60[10];
+ typedef char type61[const 10];
+ typedef char type62[static 10];
+ typedef char type63[static const volatile 10];
+ typedef char type64[const volatile static 10];
+ typedef char type65[];
+ typedef char type66[const volatile];
+ typedef char type67[10][10];
- /* functions */
- static void f4();
- static void f5(void);
- static void f6(int x);
- static void f7(int x, int y);
- static void f8(int x, int y, ...);
- static void f9(int, int);
- static void f9(int, int, ...);
- static void f10(...);
- static void f11(const char *name);
- static void f12(const char *);
- static void f13(const int a[5]);
- static void f14(const int[5]);
+ /* functions */
+ static void f4();
+ static void f5(void);
+ static void f6(int x);
+ static void f7(int x, int y);
+ static void f8(int x, int y, ...);
+ static void f9(int, int);
+ static void f9(int, int, ...);
+ static void f10(...);
+ static void f11(const char *name);
+ static void f12(const char *);
+ static void f13(const int a[5]);
+ static void f14(const int[5]);
- /* nested */
- typedef int *type69[4];
- typedef int (*type70)[4];
- typedef int (*type71[3])(int *x, int *y);
- typedef int (*type72(int (*)(long), int))(int, ...);
+ /* nested */
+ typedef int *type69[4];
+ typedef int (*type70)[4];
+ typedef int (*type71[3])(int *x, int *y);
+ typedef int (*type72(int (*)(long), int))(int, ...);
EOF
);
echo " ok\n";
diff --git a/ext/ffi/tests/003.phpt b/ext/ffi/tests/003.phpt
index d52e235644..efe88b31f3 100644
--- a/ext/ffi/tests/003.phpt
+++ b/ext/ffi/tests/003.phpt
@@ -30,14 +30,14 @@ var_dump($ffi->new("struct _b"));
var_dump($ffi->new("c"));
var_dump($ffi->new("d"));
try {
- var_dump($ffi->new("struct _e"));
+ var_dump($ffi->new("struct _e"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump($ffi->new("f"));
+ var_dump($ffi->new("f"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
echo "ok\n";
?>
@@ -58,6 +58,6 @@ object(FFI\CData:struct _d)#%d (1) {
["x"]=>
int(0)
}
-FFI\ParserException: incomplete 'struct _e' at line 1
-FFI\ParserException: incomplete 'struct _f' at line 1
+FFI\ParserException: Incomplete 'struct _e' at line 1
+FFI\ParserException: Incomplete 'struct _f' at line 1
ok
diff --git a/ext/ffi/tests/004.phpt b/ext/ffi/tests/004.phpt
index e914b604ac..f5ad02098c 100644
--- a/ext/ffi/tests/004.phpt
+++ b/ext/ffi/tests/004.phpt
@@ -25,10 +25,10 @@ enum _f;
typedef enum _f f;
enum _g {
- _c1,
- _c2,
- _c3 = 1,
- _c4,
+ _c1,
+ _c2,
+ _c3 = 1,
+ _c4,
};
EOF
);
@@ -40,14 +40,14 @@ var_dump($ffi->new("int[_c2]"));
var_dump($ffi->new("int[_c3]"));
var_dump($ffi->new("int[_c4]"));
try {
- var_dump($ffi->new("enum _e"));
+ var_dump($ffi->new("enum _e"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump($ffi->new("f"));
+ var_dump($ffi->new("f"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
echo "ok\n";
?>
@@ -82,6 +82,6 @@ object(FFI\CData:int32_t[2])#%d (2) {
[1]=>
int(0)
}
-FFI\ParserException: incomplete 'enum _e' at line 1
-FFI\ParserException: incomplete 'enum _f' at line 1
+FFI\ParserException: Incomplete 'enum _e' at line 1
+FFI\ParserException: Incomplete 'enum _f' at line 1
ok
diff --git a/ext/ffi/tests/008.phpt b/ext/ffi/tests/008.phpt
index fa3991abee..602468d1e5 100644
--- a/ext/ffi/tests/008.phpt
+++ b/ext/ffi/tests/008.phpt
@@ -11,22 +11,22 @@ $a[1] = 10;
$a[2] = 20;
var_dump(count($a));
foreach ($a as $key => $val) {
- echo "$key => $val\n";
+ echo "$key => $val\n";
}
$a = FFI::new("struct {int x,y;}");
try {
- var_dump(count($a));
+ var_dump(count($a));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- foreach ($a as $key => $val) {
- echo "$key => $val\n";
- }
+ foreach ($a as $key => $val) {
+ echo "$key => $val\n";
+ }
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECT--
diff --git a/ext/ffi/tests/012.phpt b/ext/ffi/tests/012.phpt
index 35686191e1..6623bf7368 100644
--- a/ext/ffi/tests/012.phpt
+++ b/ext/ffi/tests/012.phpt
@@ -7,9 +7,9 @@ ffi.enable=1
--FILE--
<?php
try {
- var_dump(serialize(FFI::new("int[2]")));
+ var_dump(serialize(FFI::new("int[2]")));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECT--
diff --git a/ext/ffi/tests/013.phpt b/ext/ffi/tests/013.phpt
index 3e4c4d6fca..cfc1e85eb0 100644
--- a/ext/ffi/tests/013.phpt
+++ b/ext/ffi/tests/013.phpt
@@ -12,45 +12,45 @@ var_dump(count($a[0]));
var_dump(count($a[0][0]));
try {
- var_dump(FFI::new("void"));
+ var_dump(FFI::new("void"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump(FFI::new("void[1]"));
+ var_dump(FFI::new("void[1]"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("static int foo(int)[5];");
- echo "ok\n";
+ FFI::cdef("static int foo(int)[5];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("static int foo[5](int);");
- echo "ok\n";
+ FFI::cdef("static int foo[5](int);");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("static int foo(int)(int);");
- echo "ok\n";
+ FFI::cdef("static int foo(int)(int);");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("typedef int foo[2][];");
- echo "ok\n";
+ FFI::cdef("typedef int foo[2][];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("typedef int foo[][2];");
- echo "ok\n";
+ FFI::cdef("typedef int foo[][2];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECT--
@@ -59,8 +59,8 @@ int(2)
int(3)
FFI\ParserException: 'void' type is not allowed at line 1
FFI\ParserException: 'void' type is not allowed at line 1
-FFI\ParserException: function returning array is not allowed at line 1
-FFI\ParserException: array of functions is not allowed at line 1
-FFI\ParserException: function returning function is not allowed at line 1
-FFI\ParserException: only the leftmost array can be undimensioned at line 1
+FFI\ParserException: Function returning array is not allowed at line 1
+FFI\ParserException: Array of functions is not allowed at line 1
+FFI\ParserException: Function returning function is not allowed at line 1
+FFI\ParserException: Only the leftmost array can be undimensioned at line 1
ok
diff --git a/ext/ffi/tests/015.phpt b/ext/ffi/tests/015.phpt
index 524ac95030..7b710c1dc0 100644
--- a/ext/ffi/tests/015.phpt
+++ b/ext/ffi/tests/015.phpt
@@ -7,59 +7,59 @@ ffi.enable=1
--FILE--
<?php
try {
- FFI::cdef("struct DIR; static struct DIR dir;");
- echo "ok\n";
+ FFI::cdef("struct DIR; static struct DIR dir;");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct DIR; static struct DIR *ptr;");
- echo "ok\n";
+ FFI::cdef("struct DIR; static struct DIR *ptr;");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR dir;");
- echo "ok\n";
+ FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR dir;");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR *ptr;");
- echo "ok\n";
+ FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR *ptr;");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct DIR; static struct DIR foo();");
- echo "ok\n";
+ FFI::cdef("struct DIR; static struct DIR foo();");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct DIR; static struct DIR* foo();");
- echo "ok\n";
+ FFI::cdef("struct DIR; static struct DIR* foo();");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct DIR; static void foo(struct DIR);");
- echo "ok\n";
+ FFI::cdef("struct DIR; static void foo(struct DIR);");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct DIR; static void foo(struct DIR*);");
- echo "ok\n";
+ FFI::cdef("struct DIR; static void foo(struct DIR*);");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
ok
--EXPECT--
-FFI\ParserException: incomplete 'struct DIR' at line 1
+FFI\ParserException: Incomplete 'struct DIR' at line 1
ok
-FFI\ParserException: incomplete 'struct DIR' at line 1
+FFI\ParserException: Incomplete 'struct DIR' at line 1
ok
ok
ok
diff --git a/ext/ffi/tests/016.phpt b/ext/ffi/tests/016.phpt
index 857780b80c..2ca8363fbd 100644
--- a/ext/ffi/tests/016.phpt
+++ b/ext/ffi/tests/016.phpt
@@ -7,27 +7,27 @@ ffi.enable=1
--FILE--
<?php
try {
- FFI::cdef("struct X {void x();};");
- echo "ok\n";
+ FFI::cdef("struct X {void x();};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct X {struct X x;};");
- echo "ok\n";
+ FFI::cdef("struct X {struct X x;};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct X {struct X *ptr;};");
- echo "ok\n";
+ FFI::cdef("struct X {struct X *ptr;};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
ok
--EXPECT--
FFI\ParserException: 'function' type is not allowed at line 1
-FFI\ParserException: struct/union can't contain an instance of itself at line 1
+FFI\ParserException: Struct/union can't contain an instance of itself at line 1
ok
ok
diff --git a/ext/ffi/tests/017.phpt b/ext/ffi/tests/017.phpt
index 718b078bc7..02b917ff2b 100644
--- a/ext/ffi/tests/017.phpt
+++ b/ext/ffi/tests/017.phpt
@@ -7,25 +7,25 @@ ffi.enable=1
--FILE--
<?php
try {
- var_dump(FFI::new("struct X {void x();}"));
+ var_dump(FFI::new("struct X {void x();}"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump(FFI::new("struct X {struct X x;}"));
+ var_dump(FFI::new("struct X {struct X x;}"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump(FFI::new("struct X {struct X *ptr;}"));
+ var_dump(FFI::new("struct X {struct X *ptr;}"));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
ok
--EXPECTF--
FFI\ParserException: 'function' type is not allowed at line 1
-FFI\ParserException: struct/union can't contain an instance of itself at line 1
+FFI\ParserException: Struct/union can't contain an instance of itself at line 1
object(FFI\CData:struct X)#%d (1) {
["ptr"]=>
NULL
diff --git a/ext/ffi/tests/018.phpt b/ext/ffi/tests/018.phpt
index 9e7c124384..f48367bc71 100644
--- a/ext/ffi/tests/018.phpt
+++ b/ext/ffi/tests/018.phpt
@@ -7,20 +7,20 @@ ffi.enable=1
--FILE--
<?php
try {
- FFI::cdef("struct X {struct X x[2];};");
- echo "ok\n";
+ FFI::cdef("struct X {struct X x[2];};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct X {struct X *ptr[2];};");
- echo "ok\n";
+ FFI::cdef("struct X {struct X *ptr[2];};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
ok
--EXPECT--
-FFI\ParserException: incomplete 'struct X' at line 1
+FFI\ParserException: Incomplete 'struct X' at line 1
ok
ok
diff --git a/ext/ffi/tests/019.phpt b/ext/ffi/tests/019.phpt
index 792db2ef56..80dcfa0ff9 100644
--- a/ext/ffi/tests/019.phpt
+++ b/ext/ffi/tests/019.phpt
@@ -7,16 +7,16 @@ ffi.enable=1
--FILE--
<?php
try {
- FFI::cdef("static int foo(int[]);");
- echo "ok\n";
+ FFI::cdef("static int foo(int[]);");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("static int foo(int bar(int));");
- echo "ok\n";
+ FFI::cdef("static int foo(int bar(int));");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
ok
diff --git a/ext/ffi/tests/020.phpt b/ext/ffi/tests/020.phpt
index 15660250cc..7aca9425a8 100644
--- a/ext/ffi/tests/020.phpt
+++ b/ext/ffi/tests/020.phpt
@@ -7,56 +7,56 @@ ffi.enable=1
--FILE--
<?php
try {
- $p = FFI::new("struct {int x; const int y;}");
- $p->x = 1;
- $p->y = 1;
- echo "ok\n";
+ $p = FFI::new("struct {int x; const int y;}");
+ $p->x = 1;
+ $p->y = 1;
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $p = FFI::new("struct {const int x; int y;}");
- $p->y = 1;
- $p->x = 1;
- echo "ok\n";
+ $p = FFI::new("struct {const int x; int y;}");
+ $p->y = 1;
+ $p->x = 1;
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $p = FFI::new("const struct {int x; int y;}");
- $p->x = 1;
- echo "ok\n";
+ $p = FFI::new("const struct {int x; int y;}");
+ $p->x = 1;
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $p = FFI::new("const int[10]");
- $p[1] = 1;
- echo "ok\n";
+ $p = FFI::new("const int[10]");
+ $p[1] = 1;
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $p = FFI::new("const int * [1]");
- $p[0] = null;
- echo "ok\n";
+ $p = FFI::new("const int * [1]");
+ $p[0] = null;
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $p = FFI::new("int * const [1]");
- $p[0] = null;
- echo "ok\n";
+ $p = FFI::new("int * const [1]");
+ $p[0] = null;
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $f = FFI::cdef("typedef int * const t[1];");
- $p = $f->new("t");
- $p[0] = null;
- echo "ok\n";
+ $f = FFI::cdef("typedef int * const t[1];");
+ $p = $f->new("t");
+ $p[0] = null;
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
ok
diff --git a/ext/ffi/tests/021.phpt b/ext/ffi/tests/021.phpt
index c76a1daf75..d02836c5f4 100644
--- a/ext/ffi/tests/021.phpt
+++ b/ext/ffi/tests/021.phpt
@@ -7,9 +7,9 @@ ffi.enable=1
--FILE--
<?php
function test($size, $type) {
- if (FFI::sizeof(FFI::new($type)) !== $size) {
- echo "FAIL: sizeof($type) != $size\n";
- }
+ if (FFI::sizeof(FFI::new($type)) !== $size) {
+ echo "FAIL: sizeof($type) != $size\n";
+ }
}
test(4, "enum {a1, b1}");
diff --git a/ext/ffi/tests/022.phpt b/ext/ffi/tests/022.phpt
index 3eb28fb214..44ddaeebd2 100644
--- a/ext/ffi/tests/022.phpt
+++ b/ext/ffi/tests/022.phpt
@@ -7,15 +7,15 @@ ffi.enable=1
--FILE--
<?php
function test_size($size, $type) {
- if (FFI::sizeof(FFI::new($type)) !== $size) {
- echo "FAIL: sizeof($type) != $size\n";
- }
+ if (FFI::sizeof(FFI::new($type)) !== $size) {
+ echo "FAIL: sizeof($type) != $size\n";
+ }
}
function test_align($align, $type) {
- if (FFI::alignof(FFI::new($type)) !== $align) {
- echo "FAIL: alignof($type) != $align\n";
- }
+ if (FFI::alignof(FFI::new($type)) !== $align) {
+ echo "FAIL: alignof($type) != $align\n";
+ }
}
test_size(8, "struct {uint32_t a; uint32_t b;}");
@@ -61,8 +61,8 @@ test_size(32, "struct {char a; uint32_t b __attribute__((aligned(16)));}");
test_align(16, "struct {char a; uint32_t b __attribute__((aligned(16)));}");
if (substr(PHP_OS, 0, 3) != 'WIN') {
- test_size(FFI::__BIGGEST_ALIGNMENT__ * 2, "struct {char a; uint32_t b __attribute__((aligned));}");
- test_align(FFI::__BIGGEST_ALIGNMENT__, "struct {char a; uint32_t b __attribute__((aligned));}");
+ test_size(FFI::__BIGGEST_ALIGNMENT__ * 2, "struct {char a; uint32_t b __attribute__((aligned));}");
+ test_align(FFI::__BIGGEST_ALIGNMENT__, "struct {char a; uint32_t b __attribute__((aligned));}");
}
test_size(16, "struct __declspec(align(16)) {char a; uint32_t b;}");
diff --git a/ext/ffi/tests/023.phpt b/ext/ffi/tests/023.phpt
index 920a3bee3e..651713bf2b 100644
--- a/ext/ffi/tests/023.phpt
+++ b/ext/ffi/tests/023.phpt
@@ -6,13 +6,13 @@ FFI 023: GCC struct extensions
ffi.enable=1
--FILE--
<?php
- try {
- var_dump(FFI::sizeof(FFI::new("struct {}")));
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage() . "\n";
- }
- var_dump(FFI::sizeof(FFI::new("struct {int a}")));
- var_dump(FFI::sizeof(FFI::new("struct {int a; int b}")));
+ try {
+ var_dump(FFI::sizeof(FFI::new("struct {}")));
+ } catch (Throwable $e) {
+ echo get_class($e) . ": " . $e->getMessage() . "\n";
+ }
+ var_dump(FFI::sizeof(FFI::new("struct {int a}")));
+ var_dump(FFI::sizeof(FFI::new("struct {int a; int b}")));
?>
ok
--EXPECT--
diff --git a/ext/ffi/tests/024.phpt b/ext/ffi/tests/024.phpt
index 95867b4e45..f1286e49ac 100644
--- a/ext/ffi/tests/024.phpt
+++ b/ext/ffi/tests/024.phpt
@@ -6,26 +6,26 @@ FFI 024: anonymous struct/union
ffi.enable=1
--FILE--
<?php
- $p = FFI::new("
- struct {
- int a;
- struct {
- int b;
- int c;
- };
- union {
- int d;
- uint32_t e;
- };
- int f;
- }");
- var_dump(FFI::sizeof($p));
- $p->a = 1;
- $p->b = 2;
- $p->c = 3;
- $p->d = 4;
- $p->f = 5;
- var_dump($p);
+ $p = FFI::new("
+ struct {
+ int a;
+ struct {
+ int b;
+ int c;
+ };
+ union {
+ int d;
+ uint32_t e;
+ };
+ int f;
+ }");
+ var_dump(FFI::sizeof($p));
+ $p->a = 1;
+ $p->b = 2;
+ $p->c = 3;
+ $p->d = 4;
+ $p->f = 5;
+ var_dump($p);
?>
--EXPECTF--
int(20)
diff --git a/ext/ffi/tests/025.phpt b/ext/ffi/tests/025.phpt
index d1182c4854..0abef88db8 100644
--- a/ext/ffi/tests/025.phpt
+++ b/ext/ffi/tests/025.phpt
@@ -6,21 +6,21 @@ FFI 025: direct work with primitive types
ffi.enable=1
--FILE--
<?php
- $x = FFI::new("int");
- $x->cdata = 5;
- var_dump($x);
- $x->cdata += 2;
- var_dump($x);
- echo "$x\n\n";
- unset($x);
+ $x = FFI::new("int");
+ $x->cdata = 5;
+ var_dump($x);
+ $x->cdata += 2;
+ var_dump($x);
+ echo "$x\n\n";
+ unset($x);
- $x = FFI::new("char");
- $x->cdata = 'a';
- var_dump($x);
- $x->cdata++;
- var_dump($x);
- echo "$x\n\n";
- unset($x);
+ $x = FFI::new("char");
+ $x->cdata = 'a';
+ var_dump($x);
+ $x->cdata++;
+ var_dump($x);
+ echo "$x\n\n";
+ unset($x);
?>
--EXPECTF--
object(FFI\CData:int32_t)#%d (1) {
diff --git a/ext/ffi/tests/026.phpt b/ext/ffi/tests/026.phpt
index 5e4356041f..1c5081c188 100644
--- a/ext/ffi/tests/026.phpt
+++ b/ext/ffi/tests/026.phpt
@@ -11,7 +11,7 @@ $a[1] = 10;
$a[2] = 20;
var_dump($a);
foreach ($a as &$val) {
- $val->cdata += 5;
+ $val->cdata += 5;
}
var_dump($a);
?>
diff --git a/ext/ffi/tests/027.phpt b/ext/ffi/tests/027.phpt
index 6e3e76204b..cc40798478 100644
--- a/ext/ffi/tests/027.phpt
+++ b/ext/ffi/tests/027.phpt
@@ -7,73 +7,73 @@ ffi.enable=1
--FILE--
<?php
try {
- $p = FFI::new("int[*]");
- echo "ok\n";
+ $p = FFI::new("int[*]");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("static int (*foo)[*];");
- echo "ok\n";
+ FFI::cdef("static int (*foo)[*];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("typedef int foo[*];");
- echo "ok\n";
+ FFI::cdef("typedef int foo[*];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("static void foo(int[*][*]);");
- echo "ok\n";
+ FFI::cdef("static void foo(int[*][*]);");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump(FFI::sizeof(FFI::new("int[0]")));
+ var_dump(FFI::sizeof(FFI::new("int[0]")));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump(FFI::sizeof(FFI::new("int[]")));
+ var_dump(FFI::sizeof(FFI::new("int[]")));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump(FFI::sizeof(FFI::cast("int[]", FFI::new("int[2]"))));
+ var_dump(FFI::sizeof(FFI::cast("int[]", FFI::new("int[2]"))));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct _x {int a; int b[];};");
- echo "ok\n";
+ FFI::cdef("struct _x {int a; int b[];};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $f = FFI::cdef("typedef int(*foo)[];");
- echo "ok\n";
+ $f = FFI::cdef("typedef int(*foo)[];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $f = FFI::cdef("typedef int foo[][2];");
- echo "ok\n";
+ $f = FFI::cdef("typedef int foo[][2];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $f = FFI::cdef("typedef int foo[];");
- echo "ok\n";
+ $f = FFI::cdef("typedef int foo[];");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- $f = FFI::cdef("static int foo(int[]);");
- echo "ok\n";
+ $f = FFI::cdef("static int foo(int[]);");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECT--
diff --git a/ext/ffi/tests/028.phpt b/ext/ffi/tests/028.phpt
index ee69d70f68..5d1be7c8dc 100644
--- a/ext/ffi/tests/028.phpt
+++ b/ext/ffi/tests/028.phpt
@@ -7,46 +7,46 @@ ffi.enable=1
--FILE--
<?php
try {
- FFI::cdef("struct _x {int a; int b[0];};");
- echo "ok\n";
+ FFI::cdef("struct _x {int a; int b[0];};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct _x {int a; int b[];};");
- echo "ok\n";
+ FFI::cdef("struct _x {int a; int b[];};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct _x {int a[0]; int b;};");
- echo "ok\n";
+ FFI::cdef("struct _x {int a[0]; int b;};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct _x {int a[]; int b;};");
- echo "ok\n";
+ FFI::cdef("struct _x {int a[]; int b;};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("struct _x { struct {int a; int b[];}; int c;};");
- echo "ok\n";
+ FFI::cdef("struct _x { struct {int a; int b[];}; int c;};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- FFI::cdef("union _x {int a; int b[];};");
- echo "ok\n";
+ FFI::cdef("union _x {int a; int b[];};");
+ echo "ok\n";
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECT--
ok
ok
ok
-FFI\ParserException: flexible array member not at end of struct at line 1
-FFI\ParserException: flexible array member not at end of struct at line 1
-FFI\ParserException: flexible array member in union at line 1
+FFI\ParserException: Flexible array member not at end of struct at line 1
+FFI\ParserException: Flexible array member not at end of struct at line 1
+FFI\ParserException: Flexible array member in union at line 1
diff --git a/ext/ffi/tests/029.phpt b/ext/ffi/tests/029.phpt
index bda59788fb..0951809306 100644
--- a/ext/ffi/tests/029.phpt
+++ b/ext/ffi/tests/029.phpt
@@ -7,8 +7,8 @@ ffi.enable=1
--FILE--
<?php
$ffi = FFI::cdef("
- typedef char t1;
- typedef char _Alignas(int) t2;
+ typedef char t1;
+ typedef char _Alignas(int) t2;
");
var_dump(FFI::sizeof($ffi->new("struct {char a; t1 b;}")));
var_dump(FFI::sizeof($ffi->new("struct {char a; t2 b;}")));
diff --git a/ext/ffi/tests/031.phpt b/ext/ffi/tests/031.phpt
index 3298df4961..c97368a89a 100644
--- a/ext/ffi/tests/031.phpt
+++ b/ext/ffi/tests/031.phpt
@@ -7,14 +7,14 @@ ffi.enable=1
--FILE--
<?php
function test_size($expected_size, $type) {
- try {
- $size = FFI::sizeof(FFI::new($type));
- if ($size !== $expected_size) {
- echo "FAIL: sizeof($type) != $expected_size ($size)\n";
- }
- } catch (Throwable $e) {
- echo $type . "=>" . get_class($e) . ": " . $e->getMessage()."\n";
- }
+ try {
+ $size = FFI::sizeof(FFI::new($type));
+ if ($size !== $expected_size) {
+ echo "FAIL: sizeof($type) != $expected_size ($size)\n";
+ }
+ } catch (Throwable $e) {
+ echo $type . "=>" . get_class($e) . ": " . $e->getMessage()."\n";
+ }
}
test_size( 4, "struct {int a:2; int b:2;}");
diff --git a/ext/ffi/tests/032.phpt b/ext/ffi/tests/032.phpt
index d785d037de..ade848188c 100644
--- a/ext/ffi/tests/032.phpt
+++ b/ext/ffi/tests/032.phpt
@@ -7,20 +7,20 @@ ffi.enable=1
--FILE--
<?php
$p = FFI::new("
- union {
- struct __attribute__((packed)) {
- int a:2;
- unsigned long long b:64;
- int c:3;
- unsigned int d:3;
- } s;
- uint8_t i[9];
+ union {
+ struct __attribute__((packed)) {
+ int a:2;
+ unsigned long long b:64;
+ int c:3;
+ unsigned int d:3;
+ } s;
+ uint8_t i[9];
}");
var_dump(FFI::sizeof($p));
for ($i = -5; $i < 9; $i++) {
- $p->s->c = $i;
- $p->s->d = $i;
- echo "$i => 3-bit int {$p->s->c}, 3-bit uint {$p->s->d}\n";
+ $p->s->c = $i;
+ $p->s->d = $i;
+ echo "$i => 3-bit int {$p->s->c}, 3-bit uint {$p->s->d}\n";
}
$p->s->a = 0;
$p->s->c = 0;
@@ -28,7 +28,7 @@ $p->s->d = 0;
$p->s->b = 0x7fffffff;
echo "0x";
for ($i = 9; $i > 0;) {
- printf("%02x", $p->i[--$i]);
+ printf("%02x", $p->i[--$i]);
}
echo "\n";
?>
diff --git a/ext/ffi/tests/035.phpt b/ext/ffi/tests/035.phpt
index fc42f16e88..ed98839c6e 100644
--- a/ext/ffi/tests/035.phpt
+++ b/ext/ffi/tests/035.phpt
@@ -11,9 +11,9 @@ var_dump($p);
FFI::free($p);
try {
- var_dump($p);
+ var_dump($p);
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECTF--
diff --git a/ext/ffi/tests/036.phpt b/ext/ffi/tests/036.phpt
index 5c4e0600b8..1e989285ff 100644
--- a/ext/ffi/tests/036.phpt
+++ b/ext/ffi/tests/036.phpt
@@ -9,12 +9,12 @@ ffi.enable=1
$type = FFI::type("int*");
function foo($ptr) {
- global $type;
- //$buf = FFI::new("int*[1]"); /* this loses type and crash */
- $buf = FFI::new(FFI::arrayType($type, [1]));
- $buf[0] = $ptr;
- //...
- return $buf[0];
+ global $type;
+ //$buf = FFI::new("int*[1]"); /* this loses type and crash */
+ $buf = FFI::new(FFI::arrayType($type, [1]));
+ $buf[0] = $ptr;
+ //...
+ return $buf[0];
}
$int = FFI::new("int");
diff --git a/ext/ffi/tests/037.phpt b/ext/ffi/tests/037.phpt
index 0b67e4a4da..d8f0a88afa 100644
--- a/ext/ffi/tests/037.phpt
+++ b/ext/ffi/tests/037.phpt
@@ -7,10 +7,10 @@ ffi.enable=1
--FILE--
<?php
function foo($ptr) {
- $buf = FFI::new("int*[1]");
- $buf[0] = $ptr;
- //...
- return $buf[0];
+ $buf = FFI::new("int*[1]");
+ $buf[0] = $ptr;
+ //...
+ return $buf[0];
}
$int = FFI::new("int");
diff --git a/ext/ffi/tests/038.phpt b/ext/ffi/tests/038.phpt
index 89070f31c2..270746a03e 100644
--- a/ext/ffi/tests/038.phpt
+++ b/ext/ffi/tests/038.phpt
@@ -8,7 +8,7 @@ ffi.enable=1
<?php
$a = FFI::new("int[10]");
for ($i = 0; $i < 10; $i++) {
- $a[$i] = $i;
+ $a[$i] = $i;
}
$p = FFI::cast("int*", $a);
var_dump($p[0]);
diff --git a/ext/ffi/tests/039.phpt b/ext/ffi/tests/039.phpt
index 92309d4928..d015a38b95 100644
--- a/ext/ffi/tests/039.phpt
+++ b/ext/ffi/tests/039.phpt
@@ -8,7 +8,7 @@ ffi.enable=1
<?php
$a = FFI::new("int[10]");
for ($i = 0; $i < 10; $i++) {
- $a[$i] = $i;
+ $a[$i] = $i;
}
$p = $a + 0;
var_dump($p[0]);
diff --git a/ext/ffi/tests/041.phpt b/ext/ffi/tests/041.phpt
index 4cb2694dbb..d12a774b21 100644
--- a/ext/ffi/tests/041.phpt
+++ b/ext/ffi/tests/041.phpt
@@ -7,12 +7,12 @@ ffi.enable=1
--FILE--
<?php
function test_new_ownership($str, $transfer) {
- if ($transfer) {
- return FFI::new(FFI::type($str));
- } else {
- $type = FFI::type($str);
- return FFI::new($type);
- }
+ if ($transfer) {
+ return FFI::new(FFI::type($str));
+ } else {
+ $type = FFI::type($str);
+ return FFI::new($type);
+ }
}
var_dump(test_new_ownership("int", 1));
var_dump(test_new_ownership("int[2]", 1));
@@ -20,12 +20,12 @@ var_dump(test_new_ownership("int", 0));
var_dump(test_new_ownership("int[2]", 0));
function test_type_ownership($str, $transfer) {
- if ($transfer) {
- return FFI::typeof(FFI::new($str));
- } else {
- $data = FFI::new($str);
- return FFI::typeof($data);
- }
+ if ($transfer) {
+ return FFI::typeof(FFI::new($str));
+ } else {
+ $data = FFI::new($str);
+ return FFI::typeof($data);
+ }
}
var_dump(test_type_ownership("int", 1));
var_dump(test_type_ownership("int[2]", 1));
@@ -33,12 +33,12 @@ var_dump(test_type_ownership("int", 0));
var_dump(test_type_ownership("int[2]", 0));
function test_cast_ownership($str, $transfer) {
- if ($transfer) {
- return FFI::cast(FFI::type($str), FFI::new($str));
- } else {
- $type = FFI::type($str);
- return FFI::cast($type, FFI::new($str));
- }
+ if ($transfer) {
+ return FFI::cast(FFI::type($str), FFI::new($str));
+ } else {
+ $type = FFI::type($str);
+ return FFI::cast($type, FFI::new($str));
+ }
}
var_dump(test_cast_ownership("int", 1));
var_dump(test_cast_ownership("int[2]", 1));
@@ -46,12 +46,12 @@ var_dump(test_cast_ownership("int", 0));
var_dump(test_cast_ownership("int[2]", 0));
function test_array_ownership($str, $transfer) {
- if ($transfer) {
- return FFI::arrayType(FFI::type($str), [2]);
- } else {
- $type = FFI::type($str);
- return FFI::arrayType($type, [2]);
- }
+ if ($transfer) {
+ return FFI::arrayType(FFI::type($str), [2]);
+ } else {
+ $type = FFI::type($str);
+ return FFI::arrayType($type, [2]);
+ }
}
var_dump(test_array_ownership("int", 1));
var_dump(test_array_ownership("int[2]", 1));
diff --git a/ext/ffi/tests/045.phpt b/ext/ffi/tests/045.phpt
index b73c38aefb..7503fb763b 100644
--- a/ext/ffi/tests/045.phpt
+++ b/ext/ffi/tests/045.phpt
@@ -10,20 +10,18 @@ var_dump(FFI::isNull(FFI::new("int*")));
$i = FFI::new("int");
var_dump(FFI::isNull(FFI::addr($i)));
try {
- var_dump(FFI::isNull(null));
+ var_dump(FFI::isNull(null));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
- var_dump(FFI::isNull(FFI::new("int[0]")));
+ var_dump(FFI::isNull(FFI::new("int[0]")));
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
+ echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECTF--
bool(true)
bool(false)
-
-Warning: FFI::isNull() expects parameter 1 to be FFI\CData, null given in %s045.php on line %d
-NULL
+TypeError: FFI::isNull(): Argument #1 ($ptr) must be of type FFI\CData, null given
FFI\Exception: Cannot instantiate FFI\CData of zero size
diff --git a/ext/ffi/tests/100.phpt b/ext/ffi/tests/100.phpt
index 572052f372..634d8d4436 100644
--- a/ext/ffi/tests/100.phpt
+++ b/ext/ffi/tests/100.phpt
@@ -17,13 +17,13 @@ ffi.enable=1
require_once('utils.inc');
$fastcall = ffi_get_fastcall_specifier();
$zend = ffi_cdef("
- const char *get_zend_version(void);
- //char *get_zend_version(void);
- extern size_t (*zend_printf)(const char *format, ...);
+ const char *get_zend_version(void);
+ //char *get_zend_version(void);
+ extern size_t (*zend_printf)(const char *format, ...);
- unsigned long $fastcall zend_hash_func(const char *str, size_t len);
+ unsigned long $fastcall zend_hash_func(const char *str, size_t len);
- void $fastcall zend_str_tolower(char *str, size_t length);
+ void $fastcall zend_str_tolower(char *str, size_t length);
", ffi_get_php_dll_name());
var_dump(trim(explode("\n",$zend->get_zend_version())[0]));
diff --git a/ext/ffi/tests/200.phpt b/ext/ffi/tests/200.phpt
index 205c0ebab2..39dcbdf71a 100644
--- a/ext/ffi/tests/200.phpt
+++ b/ext/ffi/tests/200.phpt
@@ -12,23 +12,24 @@ try {
?>
--INI--
ffi.enable=1
+opcache.jit=0
--FILE--
<?php
require_once('utils.inc');
$zend = FFI::cdef("
- typedef int (*zend_write_func_t)(const char *str, size_t str_length);
- extern zend_write_func_t zend_write;
+ typedef size_t (*zend_write_func_t)(const char *str, size_t str_length);
+ extern zend_write_func_t zend_write;
", ffi_get_php_dll_name());
echo "Hello World!\n";
$orig_zend_write = clone $zend->zend_write;
$zend->zend_write = function($str, $len) {
- global $orig_zend_write;
- $orig_zend_write("{\n\t", 3);
- $ret = $orig_zend_write($str, $len);
- $orig_zend_write("}\n", 2);
- return $ret;
+ global $orig_zend_write;
+ $orig_zend_write("{\n\t", 3);
+ $ret = $orig_zend_write($str, $len);
+ $orig_zend_write("}\n", 2);
+ return $ret;
};
echo "Hello World!\n";
$zend->zend_write = $orig_zend_write;
diff --git a/ext/ffi/tests/bug77706.phpt b/ext/ffi/tests/bug77706.phpt
index fca6208fe9..87ef584d51 100644
--- a/ext/ffi/tests/bug77706.phpt
+++ b/ext/ffi/tests/bug77706.phpt
@@ -30,27 +30,27 @@ int fprintf(FILE *, const char *, ...);
$ffi = FFI::cdef($header, 'libc.so.6');
try {
- $ffi->time();
+ $ffi->time();
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage() . "\n";
+ echo get_class($e) . ": " . $e->getMessage() . "\n";
}
try {
- $ffi->time(null, null);
+ $ffi->time(null, null);
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage() . "\n";
+ echo get_class($e) . ": " . $e->getMessage() . "\n";
}
try {
- $ffi->fprintf($ffi->stdout);
+ $ffi->fprintf($ffi->stdout);
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage() . "\n";
+ echo get_class($e) . ": " . $e->getMessage() . "\n";
}
try {
- $ffi->fprintf($ffi->stdout, 123, "Hello %s\n", "World");
+ $ffi->fprintf($ffi->stdout, 123, "Hello %s\n", "World");
} catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage() . "\n";
+ echo get_class($e) . ": " . $e->getMessage() . "\n";
}
?>
--EXPECT--
diff --git a/ext/ffi/tests/bug79096.phpt b/ext/ffi/tests/bug79096.phpt
index a45b45646a..d7470eb302 100644
--- a/ext/ffi/tests/bug79096.phpt
+++ b/ext/ffi/tests/bug79096.phpt
@@ -10,8 +10,8 @@ if (!extension_loaded('zend-test')) die('skip zend-test extension not available'
require_once('utils.inc');
$header = <<<HEADER
struct bug79096 {
- uint64_t a;
- uint64_t b;
+ uint64_t a;
+ uint64_t b;
};
struct bug79096 bug79096(void);
diff --git a/ext/ffi/tests/list.phpt b/ext/ffi/tests/list.phpt
index a7696fa091..0cfe4cb7b3 100644
--- a/ext/ffi/tests/list.phpt
+++ b/ext/ffi/tests/list.phpt
@@ -7,78 +7,78 @@ ffi.enable=1
--FILE--
<?php
class DList {
- private static $ffi = null;
- private $root;
+ private static $ffi = null;
+ private $root;
- function __construct() {
- if (is_null(self::$ffi)) {
- self::$ffi =
- FFI::cdef("
- typedef struct _dlist dlist;
- struct _dlist {
- int data;
- dlist *prev;
- dlist *next;
- };
- ");
- }
- $node = FFI::addr(self::$ffi->new("dlist", false));
- $node->data = 0;
- $node->next = $node;
- $node->prev = $node;
- $this->root = $node;
- }
+ function __construct() {
+ if (is_null(self::$ffi)) {
+ self::$ffi =
+ FFI::cdef("
+ typedef struct _dlist dlist;
+ struct _dlist {
+ int data;
+ dlist *prev;
+ dlist *next;
+ };
+ ");
+ }
+ $node = FFI::addr(self::$ffi->new("dlist", false));
+ $node->data = 0;
+ $node->next = $node;
+ $node->prev = $node;
+ $this->root = $node;
+ }
- function __destruct() {
- $root = $this->root;
- $node = $root->next;
- while ($node != $root) {
- $prev = $node;
- $node = $node->next;
- FFI::free($prev);
- }
- FFI::free($root);
- }
+ function __destruct() {
+ $root = $this->root;
+ $node = $root->next;
+ while ($node != $root) {
+ $prev = $node;
+ $node = $node->next;
+ FFI::free($prev);
+ }
+ FFI::free($root);
+ }
- function add(int $data) {
- $node = FFI::addr(self::$ffi->new("dlist", false));
- $node->data = $data;
- $node->next = $this->root;
- $node->prev = $this->root->prev;
- $this->root->prev->next = $node;
- $this->root->prev = $node;
- }
+ function add(int $data) {
+ $node = FFI::addr(self::$ffi->new("dlist", false));
+ $node->data = $data;
+ $node->next = $this->root;
+ $node->prev = $this->root->prev;
+ $this->root->prev->next = $node;
+ $this->root->prev = $node;
+ }
- function del(int $data) {
- $root = $this->root;
- $node = $root->next;
- while ($node != $root) {
- if ($node->data == $data) {
- $node->prev->next = $node->next;
- $node->next->prev = $node->prev;
- FFI::free($node);
- break;
- }
- $node = $node->next;
- }
- }
+ function del(int $data) {
+ $root = $this->root;
+ $node = $root->next;
+ while ($node != $root) {
+ if ($node->data == $data) {
+ $node->prev->next = $node->next;
+ $node->next->prev = $node->prev;
+ FFI::free($node);
+ break;
+ }
+ $node = $node->next;
+ }
+ }
- function print() {
- echo "[";
- $first = true;
- $root = $this->root;
- $node = $root->next;
- while ($node != $root) {
- if (!$first) {
- echo ", ";
- } else {
- $first = false;
- }
- echo $node->data;
- $node = $node->next;
- }
- echo "]\n";
- }
+ function print() {
+ echo "[";
+ $first = true;
+ $root = $this->root;
+ $node = $root->next;
+ while ($node != $root) {
+ if (!$first) {
+ echo ", ";
+ } else {
+ $first = false;
+ }
+ echo $node->data;
+ $node = $node->next;
+ }
+ echo "]\n";
+ }
}
$dlist = new Dlist;