Skip to content

Commit

Permalink
Add more tests for native intersection types in class properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ohader committed Feb 19, 2024
1 parent c488d40 commit c022deb
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/NativeIntersectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,64 @@ function test(A&B $in): void {
'ignored_issues' => [],
'php_version' => '8.1',
],
'nativeTypeIntersectionAsClassProperty' => [
'code' => '<?php
interface A {}
interface B {}
class C implements A, B {}
class D {
private A&B $intersection;
public function __construct()
{
$this->intersection = new C();
}
}
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.1',
],
'nativeTypeIntersectionAsClassPropertyUsingProcessedInterfaces' => [
'code' => '<?php
interface A {}
interface B {}
class AB implements A, B {}
class C {
private A&B $other;
public function __construct()
{
$this->other = new AB();
}
}
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.1',
],
'nativeTypeIntersectionAsClassPropertyUsingUnprocessedInterfaces' => [
'code' => '<?php
class StringableJson implements \Stringable, \JsonSerializable {
public function jsonSerialize(): array
{
return [];
}
public function __toString(): string
{
return json_encode($this);
}
}
class C {
private \Stringable&\JsonSerializable $other;
public function __construct()
{
$this->other = new StringableJson();
}
}
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.1',
],
];
}

Expand Down

0 comments on commit c022deb

Please sign in to comment.