Skip to content

Commit 1944d07

Browse files
Merge branch '5.4' into 6.2
* 5.4: Fix deprecations on PHP 8.3 [WebProfilerBundle] Fix error in case of 'Content-Type' set null in dev environment with no debug [Routing] Use vsprintf instead of sprintf + unpacking
2 parents 6fd823b + e706c99 commit 1944d07

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

Tests/Caster/FFICasterTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testCastAnonymousStruct()
4040
FFI\CData<struct <anonymous>> size 4 align 4 {
4141
uint32_t x: 0
4242
}
43-
PHP, \FFI::new('struct { uint32_t x; }'));
43+
PHP, \FFI::cdef()->new('struct { uint32_t x; }'));
4444
}
4545

4646
public function testCastNamedStruct()
@@ -49,7 +49,7 @@ public function testCastNamedStruct()
4949
FFI\CData<struct Example> size 4 align 4 {
5050
uint32_t x: 0
5151
}
52-
PHP, \FFI::new('struct Example { uint32_t x; }'));
52+
PHP, \FFI::cdef()->new('struct Example { uint32_t x; }'));
5353
}
5454

5555
public function testCastAnonymousUnion()
@@ -59,7 +59,7 @@ public function testCastAnonymousUnion()
5959
uint32_t x: 0
6060
uint32_t y: 0
6161
}
62-
PHP, \FFI::new('union { uint32_t x; uint32_t y; }'));
62+
PHP, \FFI::cdef()->new('union { uint32_t x; uint32_t y; }'));
6363
}
6464

6565
public function testCastNamedUnion()
@@ -69,7 +69,7 @@ public function testCastNamedUnion()
6969
uint32_t x: 0
7070
uint32_t y: 0
7171
}
72-
PHP, \FFI::new('union Example { uint32_t x; uint32_t y; }'));
72+
PHP, \FFI::cdef()->new('union Example { uint32_t x; uint32_t y; }'));
7373
}
7474

7575
public function testCastAnonymousEnum()
@@ -78,7 +78,7 @@ public function testCastAnonymousEnum()
7878
FFI\CData<enum <anonymous>> size 4 align 4 {
7979
cdata: 0
8080
}
81-
PHP, \FFI::new('enum { a, b }'));
81+
PHP, \FFI::cdef()->new('enum { a, b }'));
8282
}
8383

8484
public function testCastNamedEnum()
@@ -87,7 +87,7 @@ public function testCastNamedEnum()
8787
FFI\CData<enum Example> size 4 align 4 {
8888
cdata: 0
8989
}
90-
PHP, \FFI::new('enum Example { a, b }'));
90+
PHP, \FFI::cdef()->new('enum Example { a, b }'));
9191
}
9292

9393
public static function scalarsDataProvider(): array
@@ -118,7 +118,7 @@ public function testCastScalar(string $type, string $value, int $size, int $alig
118118
FFI\CData<$type> size $size align $align {
119119
cdata: $value
120120
}
121-
PHP, \FFI::new($type));
121+
PHP, \FFI::cdef()->new($type));
122122
}
123123

124124
public function testCastVoidFunction()
@@ -129,7 +129,7 @@ public function testCastVoidFunction()
129129
$abi callable(): void {
130130
returnType: FFI\CType<void> size 1 align 1 {}
131131
}
132-
PHP, \FFI::new('void (*)(void)'));
132+
PHP, \FFI::cdef()->new('void (*)(void)'));
133133
}
134134

135135
public function testCastIntFunction()
@@ -140,7 +140,7 @@ public function testCastIntFunction()
140140
$abi callable(): uint64_t {
141141
returnType: FFI\CType<uint64_t> size 8 align 8 {}
142142
}
143-
PHP, \FFI::new('unsigned long long (*)(void)'));
143+
PHP, \FFI::cdef()->new('unsigned long long (*)(void)'));
144144
}
145145

146146
public function testCastFunctionWithArguments()
@@ -151,14 +151,14 @@ public function testCastFunctionWithArguments()
151151
$abi callable(int32_t, char*): void {
152152
returnType: FFI\CType<void> size 1 align 1 {}
153153
}
154-
PHP, \FFI::new('void (*)(int a, const char* b)'));
154+
PHP, \FFI::cdef()->new('void (*)(int a, const char* b)'));
155155
}
156156

157157
public function testCastNonCuttedPointerToChar()
158158
{
159159
$actualMessage = "Hello World!\0";
160160

161-
$string = \FFI::new('char[100]');
161+
$string = \FFI::cdef()->new('char[100]');
162162
$pointer = \FFI::addr($string[0]);
163163
\FFI::memcpy($pointer, $actualMessage, \strlen($actualMessage));
164164

@@ -180,7 +180,7 @@ public function testCastCuttedPointerToChar()
180180
.'World!Hello World!Hello World!Hello World!Hello World!Hello Wor'
181181
.'ld!Hello World!Hel';
182182

183-
$string = \FFI::new('char['.$actualLength.']');
183+
$string = \FFI::cdef()->new('char['.$actualLength.']');
184184
$pointer = \FFI::addr($string[0]);
185185
\FFI::memcpy($pointer, $actualMessage, $actualLength);
186186

@@ -207,13 +207,13 @@ public function testCastNonTrailingCharPointer()
207207
$actualMessage = 'Hello World!';
208208
$actualLength = \strlen($actualMessage);
209209

210-
$string = \FFI::new('char['.$actualLength.']');
210+
$string = \FFI::cdef()->new('char['.$actualLength.']');
211211
$pointer = \FFI::addr($string[0]);
212212

213213
\FFI::memcpy($pointer, $actualMessage, $actualLength);
214214

215215
// Remove automatically addition of the trailing "\0" and remove trailing "\0"
216-
$pointer = \FFI::cast('char*', \FFI::cast('void*', $pointer));
216+
$pointer = \FFI::cdef()->cast('char*', \FFI::cast('void*', $pointer));
217217
$pointer[$actualLength] = "\x01";
218218

219219
$this->assertDumpMatchesFormat(<<<PHP
@@ -328,24 +328,24 @@ public function testCastPointerToNonEmptyScalars()
328328
CPP);
329329

330330
// Create values
331-
$int = \FFI::new('int64_t');
331+
$int = \FFI::cdef()->new('int64_t');
332332
$int->cdata = 42;
333-
$float = \FFI::new('float');
333+
$float = \FFI::cdef()->new('float');
334334
$float->cdata = 42.0;
335-
$double = \FFI::new('double');
335+
$double = \FFI::cdef()->new('double');
336336
$double->cdata = 42.2;
337-
$bool = \FFI::new('bool');
337+
$bool = \FFI::cdef()->new('bool');
338338
$bool->cdata = true;
339339

340340
// Fill struct
341341
$struct = $ffi->new('Example');
342-
$struct->a = \FFI::addr(\FFI::cast('int8_t', $int));
343-
$struct->b = \FFI::addr(\FFI::cast('uint8_t', $int));
344-
$struct->c = \FFI::addr(\FFI::cast('int64_t', $int));
345-
$struct->d = \FFI::addr(\FFI::cast('uint64_t', $int));
346-
$struct->e = \FFI::addr(\FFI::cast('float', $float));
347-
$struct->f = \FFI::addr(\FFI::cast('double', $double));
348-
$struct->g = \FFI::addr(\FFI::cast('bool', $bool));
342+
$struct->a = \FFI::addr(\FFI::cdef()->cast('int8_t', $int));
343+
$struct->b = \FFI::addr(\FFI::cdef()->cast('uint8_t', $int));
344+
$struct->c = \FFI::addr(\FFI::cdef()->cast('int64_t', $int));
345+
$struct->d = \FFI::addr(\FFI::cdef()->cast('uint64_t', $int));
346+
$struct->e = \FFI::addr(\FFI::cdef()->cast('float', $float));
347+
$struct->f = \FFI::addr(\FFI::cdef()->cast('double', $double));
348+
$struct->g = \FFI::addr(\FFI::cdef()->cast('bool', $bool));
349349

350350
$this->assertDumpEquals(<<<'OUTPUT'
351351
FFI\CData<struct <anonymous>> size 56 align 8 {
@@ -441,7 +441,7 @@ public function testCastComplexType()
441441
$var->func = (static fn (object $p) => 42);
442442

443443
$abi = \PHP_OS_FAMILY === 'Windows' ? '[cdecl]' : '[fastcall]';
444-
$longSize = \FFI::type('long')->getSize();
444+
$longSize = \FFI::cdef()->type('long')->getSize();
445445
$longType = 8 === $longSize ? 'int64_t' : 'int32_t';
446446
$structSize = 56 + $longSize * 2;
447447

0 commit comments

Comments
 (0)