Skip to content

Commit f0a5b50

Browse files
Slamdunksebastianbergmann
authored andcommitted
Add union types, intersection types, DNS types cases
1 parent c025bba commit f0a5b50

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

tests/_files/source_for_branched_exec_lines_php80.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@
3333
// Nullsafe Operator
3434
$ymd = $date?->format('Ymd'); // +1
3535
++$var; // +1
36+
37+
// Union types
38+
interface MyUnion
39+
{
40+
public function getNameIdentifier(): ?string;
41+
public function hasClaim(bool|string $type, mixed $value): bool;
42+
}

tests/_files/source_for_branched_exec_lines_php81.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,11 @@ enum BackedSuit: string
2424

2525
BasicSuit::Diamonds->shape(); // +1
2626
BackedSuit::Clubs; // +1
27+
28+
29+
// Intersection types
30+
interface MyIntersection
31+
{
32+
public function check(MyIntOne&MyIntTwo $intersection);
33+
public function neverReturn(): never;
34+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
// Disjunctive Normal Form (DNF)
4+
class MyDnf
5+
{
6+
public function bar((A&B)|null $entity)
7+
{
8+
return $entity; // +1
9+
}
10+
}

tests/tests/StaticAnalysis/ExecutableLinesFindingVisitorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public function testExecutableLinesAreGroupedByBranchPhp81(): void
5252
$this->doTestSelfDescribingAsset(TEST_FILES_PATH . 'source_for_branched_exec_lines_php81.php');
5353
}
5454

55+
/**
56+
* @requires PHP 8.2
57+
*/
58+
public function testExecutableLinesAreGroupedByBranchPhp82(): void
59+
{
60+
$this->doTestSelfDescribingAsset(TEST_FILES_PATH . 'source_for_branched_exec_lines_php82.php');
61+
}
62+
5563
private function doTestSelfDescribingAsset(string $filename): void
5664
{
5765
$source = file_get_contents($filename);

0 commit comments

Comments
 (0)