Skip to content

Commit cbcc638

Browse files
committed
Test more return constant expressions
1 parent 74b7413 commit cbcc638

File tree

2 files changed

+155
-1
lines changed

2 files changed

+155
-1
lines changed

tests/_files/source_with_multiline_constant_return.php

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,140 @@ public function Spaceship(): int
244244
1
245245
;
246246
}
247+
248+
public function nowdocSimpleA(): string
249+
{
250+
return <<<'EOF'
251+
foo
252+
EOF;
253+
}
254+
255+
public function nowdocSimpleB(): string
256+
{
257+
return
258+
<<<'EOF'
259+
foo
260+
EOF;
261+
}
262+
263+
public function nowdocSimpleC(): string
264+
{
265+
return
266+
<<<'EOF'
267+
foo
268+
EOF
269+
;
270+
}
271+
272+
public function nowdocConcatA(): string
273+
{
274+
return '' .
275+
<<<'EOF'
276+
foo
277+
EOF;
278+
}
279+
280+
public function nowdocConcatB(): string
281+
{
282+
return ''
283+
. <<<'EOF'
284+
foo
285+
EOF;
286+
}
287+
288+
public function nowdocConcatC(): string
289+
{
290+
return <<<'EOF'
291+
foo
292+
EOF
293+
. '';
294+
}
295+
296+
public function nowdocConcatNested(): string
297+
{
298+
return (<<<'EOF'
299+
foo
300+
EOF
301+
. <<<'EOF'
302+
foo
303+
EOF)
304+
. (<<<'EOF'
305+
foo
306+
EOF
307+
. <<<'EOF'
308+
foo
309+
EOF);
310+
}
311+
312+
public function complexAssociativityRight(): int
313+
{
314+
return
315+
1
316+
**
317+
2
318+
**
319+
3;
320+
}
321+
322+
public function complexAssociativityLeft(): int
323+
{
324+
return
325+
1
326+
>>
327+
2
328+
>>
329+
3;
330+
}
331+
332+
public function complexAssociativityNa(): bool
333+
{
334+
return
335+
!
336+
!
337+
!
338+
false;
339+
}
340+
341+
public function complexTernary(): int
342+
{
343+
return
344+
1
345+
? (
346+
2
347+
? 3
348+
: 4
349+
)
350+
: 5;
351+
}
352+
353+
public function complexNullCoalescing(): int
354+
{
355+
return
356+
null
357+
??
358+
1
359+
??
360+
null;
361+
}
362+
363+
public function constFromArray(): string
364+
{
365+
return [
366+
'foo',
367+
'bar',
368+
'ro',
369+
'fi',
370+
'omega',
371+
][2];
372+
}
373+
374+
public function withNotConstInTheMiddle(): string
375+
{
376+
return
377+
''
378+
. ''
379+
. phpversion()
380+
. ''
381+
. '';
382+
}
247383
}

tests/tests/Data/RawCodeCoverageDataTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
438438
28,
439439
37,
440440
46,
441+
53,
441442
55,
442443
64,
443444
73,
@@ -446,7 +447,7 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
446447
100,
447448
109,
448449
118,
449-
127,
450+
125,
450451
136,
451452
145,
452453
154,
@@ -460,6 +461,23 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
460461
226,
461462
235,
462463
244,
464+
251,
465+
259,
466+
267,
467+
276,
468+
284,
469+
293,
470+
308,
471+
319,
472+
329,
473+
338,
474+
344,
475+
350,
476+
356,
477+
360,
478+
371,
479+
379,
480+
381,
463481
],
464482
array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingFileAnalyser(true, true))->lineCoverage()[$file])
465483
);

0 commit comments

Comments
 (0)