Skip to content

Commit 60fd3f8

Browse files
minor #61372 chore: PHP CS Fixer - update heredoc handling (keradus)
This PR was merged into the 7.4 branch. Discussion ---------- chore: PHP CS Fixer - update heredoc handling | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix CS <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT Inspired while #61371 , but can be merged separately. ``@PHPxMigration`` and ``@Symfony`` ruleset have different config for those rules. I assume the difference is coming from supporting pre-7.2 PHP version earlier in the codebase, where heredoc closure and trailing comma had to be on separated lines - but it's no longer the case. Can we benefit from newer PHP syntax and incorporate those changes? (yes, `trailing_comma_in_multiline`, part of ``@Symfony``, is already having this enabled!) if so, i will also merge them into ``@Symfony`` ruleset itself afterwards. with love by [PHP Coding Standards Fixer](https://cs.symfony.com/) Commits ------- f9956227bb6 chore: PHP CS Fixer - update heredoc handling
2 parents 6451093 + b53ffd5 commit 60fd3f8

14 files changed

+214
-135
lines changed

Tests/Caster/CasterTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public function testAnonymousClass()
159159
stdClass@anonymous {
160160
-foo: "foo"
161161
}
162-
EOTXT
163-
, $c
162+
EOTXT,
163+
$c
164164
);
165165

166166
$c = eval('return new class implements \Countable { private $foo = "foo"; public function count(): int { return 0; } };');
@@ -170,8 +170,8 @@ public function testAnonymousClass()
170170
Countable@anonymous {
171171
-foo: "foo"
172172
}
173-
EOTXT
174-
, $c
173+
EOTXT,
174+
$c
175175
);
176176
}
177177

@@ -196,7 +196,9 @@ public function testClassHierarchy()
196196
#e: "e"
197197
-f: "f"
198198
}
199-
DUMP, new B());
199+
DUMP,
200+
new B()
201+
);
200202
}
201203
}
202204

Tests/Caster/CurlCasterTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function testCastCurl()
3434
http_code: %d
3535
%A
3636
}
37-
EODUMP, $ch);
37+
EODUMP,
38+
$ch
39+
);
3840
}
3941
}

Tests/Caster/FFICasterTest.php

Lines changed: 79 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public function testCastAnonymousStruct()
4646
FFI\CData<struct <anonymous>> size 4 align 4 {
4747
uint32_t x: 0
4848
}
49-
PHP, \FFI::cdef()->new('struct { uint32_t x; }'));
49+
PHP,
50+
\FFI::cdef()->new('struct { uint32_t x; }')
51+
);
5052
}
5153

5254
public function testCastNamedStruct()
@@ -55,7 +57,9 @@ public function testCastNamedStruct()
5557
FFI\CData<struct Example> size 4 align 4 {
5658
uint32_t x: 0
5759
}
58-
PHP, \FFI::cdef()->new('struct Example { uint32_t x; }'));
60+
PHP,
61+
\FFI::cdef()->new('struct Example { uint32_t x; }')
62+
);
5963
}
6064

6165
public function testCastAnonymousUnion()
@@ -65,7 +69,9 @@ public function testCastAnonymousUnion()
6569
uint32_t x: 0
6670
uint32_t y: 0
6771
}
68-
PHP, \FFI::cdef()->new('union { uint32_t x; uint32_t y; }'));
72+
PHP,
73+
\FFI::cdef()->new('union { uint32_t x; uint32_t y; }')
74+
);
6975
}
7076

7177
public function testCastNamedUnion()
@@ -75,7 +81,9 @@ public function testCastNamedUnion()
7581
uint32_t x: 0
7682
uint32_t y: 0
7783
}
78-
PHP, \FFI::cdef()->new('union Example { uint32_t x; uint32_t y; }'));
84+
PHP,
85+
\FFI::cdef()->new('union Example { uint32_t x; uint32_t y; }')
86+
);
7987
}
8088

8189
public function testCastAnonymousEnum()
@@ -84,7 +92,9 @@ public function testCastAnonymousEnum()
8492
FFI\CData<enum <anonymous>> size 4 align 4 {
8593
cdata: 0
8694
}
87-
PHP, \FFI::cdef()->new('enum { a, b }'));
95+
PHP,
96+
\FFI::cdef()->new('enum { a, b }')
97+
);
8898
}
8999

90100
public function testCastNamedEnum()
@@ -93,7 +103,9 @@ public function testCastNamedEnum()
93103
FFI\CData<enum Example> size 4 align 4 {
94104
cdata: 0
95105
}
96-
PHP, \FFI::cdef()->new('enum Example { a, b }'));
106+
PHP,
107+
\FFI::cdef()->new('enum Example { a, b }')
108+
);
97109
}
98110

99111
public static function scalarsDataProvider(): array
@@ -122,7 +134,9 @@ public function testCastScalar(string $type, string $value, int $size, int $alig
122134
FFI\CData<$type> size $size align $align {
123135
cdata: $value
124136
}
125-
PHP, \FFI::cdef()->new($type));
137+
PHP,
138+
\FFI::cdef()->new($type)
139+
);
126140
}
127141

128142
public function testCastVoidFunction()
@@ -133,7 +147,9 @@ public function testCastVoidFunction()
133147
$abi callable(): void {
134148
returnType: FFI\CType<void> size 1 align 1 {}
135149
}
136-
PHP, \FFI::cdef()->new('void (*)(void)'));
150+
PHP,
151+
\FFI::cdef()->new('void (*)(void)')
152+
);
137153
}
138154

139155
public function testCastIntFunction()
@@ -144,7 +160,9 @@ public function testCastIntFunction()
144160
$abi callable(): uint64_t {
145161
returnType: FFI\CType<uint64_t> size 8 align 8 {}
146162
}
147-
PHP, \FFI::cdef()->new('unsigned long long (*)(void)'));
163+
PHP,
164+
\FFI::cdef()->new('unsigned long long (*)(void)')
165+
);
148166
}
149167

150168
public function testCastFunctionWithArguments()
@@ -155,7 +173,9 @@ public function testCastFunctionWithArguments()
155173
$abi callable(int32_t, char*): void {
156174
returnType: FFI\CType<void> size 1 align 1 {}
157175
}
158-
PHP, \FFI::cdef()->new('void (*)(int a, const char* b)'));
176+
PHP,
177+
\FFI::cdef()->new('void (*)(int a, const char* b)')
178+
);
159179
}
160180

161181
public function testCastNonCuttedPointerToChar()
@@ -170,7 +190,9 @@ public function testCastNonCuttedPointerToChar()
170190
FFI\CData<char*> size 8 align 8 {
171191
cdata: "Hello World!\x00"
172192
}
173-
PHP, $pointer);
193+
PHP,
194+
$pointer
195+
);
174196
}
175197

176198
public function testCastCuttedPointerToChar()
@@ -188,7 +210,8 @@ public function testCastCuttedPointerToChar()
188210
// allowed by pages size of the current system
189211
$ffi = \FFI::cdef(<<<C
190212
size_t zend_get_page_size(void);
191-
C);
213+
C
214+
);
192215

193216
$pageSize = $ffi->zend_get_page_size();
194217
$start = $ffi->cast('uintptr_t', $ffi->cast('char*', $pointer))->cdata;
@@ -199,7 +222,9 @@ public function testCastCuttedPointerToChar()
199222
FFI\CData<char*> size 8 align 8 {
200223
cdata: "$expectedMessage"…
201224
}
202-
PHP, $pointer);
225+
PHP,
226+
$pointer
227+
);
203228
}
204229

205230
public function testCastNonTrailingCharPointer()
@@ -218,7 +243,9 @@ public function testCastNonTrailingCharPointer()
218243
FFI\CData<char*> size 8 align 8 {
219244
cdata: %A"$actualMessage%s"
220245
}
221-
PHP, $pointer);
246+
PHP,
247+
$pointer
248+
);
222249
}
223250

224251
public function testCastUnionWithDirectReferencedFields()
@@ -228,14 +255,17 @@ public function testCastUnionWithDirectReferencedFields()
228255
int32_t x;
229256
float y;
230257
} Event;
231-
CPP);
258+
CPP
259+
);
232260

233261
$this->assertDumpEquals(<<<'OUTPUT'
234262
FFI\CData<union Event> size 4 align 4 {
235263
int32_t x: 0
236264
float y: 0.0
237265
}
238-
OUTPUT, $ffi->new('Event'));
266+
OUTPUT,
267+
$ffi->new('Event')
268+
);
239269
}
240270

241271
public function testCastUnionWithPointerReferencedFields()
@@ -245,7 +275,8 @@ public function testCastUnionWithPointerReferencedFields()
245275
void* something;
246276
char* string;
247277
} Event;
248-
CPP);
278+
CPP
279+
);
249280

250281
$this->assertDumpEquals(<<<'OUTPUT'
251282
FFI\CData<union Event> size 8 align 8 {
@@ -256,7 +287,9 @@ public function testCastUnionWithPointerReferencedFields()
256287
0: FFI\CType<char> size 1 align 1 {}
257288
}
258289
}
259-
OUTPUT, $ffi->new('Event'));
290+
OUTPUT,
291+
$ffi->new('Event')
292+
);
260293
}
261294

262295
public function testCastUnionWithMixedFields()
@@ -268,7 +301,8 @@ public function testCastUnionWithMixedFields()
268301
char* c;
269302
ptrdiff_t d;
270303
} Event;
271-
CPP);
304+
CPP
305+
);
272306

273307
$this->assertDumpEquals(<<<'OUTPUT'
274308
FFI\CData<union Event> size 8 align 8 {
@@ -281,7 +315,9 @@ public function testCastUnionWithMixedFields()
281315
}
282316
int64_t d: 0
283317
}
284-
OUTPUT, $ffi->new('Event'));
318+
OUTPUT,
319+
$ffi->new('Event')
320+
);
285321
}
286322

287323
public function testCastPointerToEmptyScalars()
@@ -296,7 +332,8 @@ public function testCastPointerToEmptyScalars()
296332
double *f;
297333
bool *g;
298334
} Example;
299-
CPP);
335+
CPP
336+
);
300337

301338
$this->assertDumpEquals(<<<'OUTPUT'
302339
FFI\CData<struct <anonymous>> size 56 align 8 {
@@ -308,7 +345,9 @@ public function testCastPointerToEmptyScalars()
308345
double* f: null
309346
bool* g: null
310347
}
311-
OUTPUT, $ffi->new('Example'));
348+
OUTPUT,
349+
$ffi->new('Example')
350+
);
312351
}
313352

314353
public function testCastPointerToNonEmptyScalars()
@@ -323,7 +362,8 @@ public function testCastPointerToNonEmptyScalars()
323362
double *f;
324363
bool *g;
325364
} Example;
326-
CPP);
365+
CPP
366+
);
327367

328368
// Create values
329369
$int = \FFI::cdef()->new('int64_t');
@@ -369,7 +409,9 @@ public function testCastPointerToNonEmptyScalars()
369409
cdata: true
370410
}
371411
}
372-
OUTPUT, $struct);
412+
OUTPUT,
413+
$struct
414+
);
373415
}
374416

375417
public function testCastPointerToStruct()
@@ -378,7 +420,8 @@ public function testCastPointerToStruct()
378420
typedef struct {
379421
int8_t a;
380422
} Example;
381-
CPP);
423+
CPP
424+
);
382425

383426
$struct = $ffi->new('Example', false);
384427

@@ -388,7 +431,9 @@ public function testCastPointerToStruct()
388431
int8_t a: 0
389432
}
390433
}
391-
OUTPUT, \FFI::addr($struct));
434+
OUTPUT,
435+
\FFI::addr($struct)
436+
);
392437

393438
// Save the pointer as variable so that
394439
// it is not cleaned up by the GC
@@ -402,7 +447,9 @@ public function testCastPointerToStruct()
402447
}
403448
}
404449
}
405-
OUTPUT, \FFI::addr($pointer));
450+
OUTPUT,
451+
\FFI::addr($pointer)
452+
);
406453

407454
\FFI::free($struct);
408455
}
@@ -433,7 +480,8 @@ public function testCastComplexType()
433480
struct __sub *h
434481
);
435482
} Example;
436-
CPP);
483+
CPP
484+
);
437485

438486
$var = $ffi->new('Example');
439487
$var->func = (static fn (object $p) => 42);
@@ -460,6 +508,8 @@ public function testCastComplexType()
460508
returnType: FFI\CType<int32_t> size 4 align 4 {}
461509
}
462510
}
463-
OUTPUT, $var);
511+
OUTPUT,
512+
$var
513+
);
464514
}
465515
}

Tests/Caster/OpenSSLCasterTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public function testAsymmetricKey()
4545
"""
4646
type: 0
4747
}
48-
EODUMP, $key);
48+
EODUMP,
49+
$key
50+
);
4951
}
5052

5153
public function testOpensslCsr()
@@ -77,6 +79,8 @@ public function testOpensslCsr()
7779
commonName: "symfony.com"
7880
emailAddress: "[email protected]"
7981
}
80-
EODUMP, $csr);
82+
EODUMP,
83+
$csr
84+
);
8185
}
8286
}

0 commit comments

Comments
 (0)