Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_bool_false.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(bool|false $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_dnf_permuted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface A {} interface B {} function f((A&B)|(B&A) $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_dnf_subset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface A {} interface B {} function f((A&B)|A $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_dnf_subset_reversed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface A {} interface B {} function f(A|(A&B) $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_dnf_superset_group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface A {} interface B {} interface C2 {} function f((A&B)|(A&B&C2) $x): void {}

function main() {}
5 changes: 5 additions & 0 deletions phpunit/code/type_rule_dup_class_union.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
class Foo {}
function f(Foo|Foo $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_dup_union.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(int|string|int $x): void {}

function main() {}
5 changes: 5 additions & 0 deletions phpunit/code/type_rule_implements_dup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
interface Ia {}
class C implements Ia, Ia {}

function main() {}
5 changes: 5 additions & 0 deletions phpunit/code/type_rule_intersect_dup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
interface Ix {}
function f(Ix&Ix $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_intersect_scalar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(int&string $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_iterable_array.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(iterable|array $x): void {}

function main() {}
11 changes: 11 additions & 0 deletions phpunit/code/type_rule_keyword_beside_dnf_valid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
interface Ia {} interface Ib {} class B {}
class C extends B implements Ia, Ib
{
public function m((Ia&Ib)|self $a, (Ia&Ib)|parent $b): (Ia&Ib)|static
{
return $this;
}
}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_mixed_union.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(mixed|int $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_nullable_mixed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(?mixed $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_object_class_union.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
class Foo {} function f(object|Foo $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_object_class_union_reversed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
class Foo {} function f(Foo|object $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_object_dnf_union.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface A {} interface B {} function f(object|(A&B) $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_object_interface_union.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ifc {} function f(Ifc|object $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_parent_dnf_const.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class Other {} class B {} class C extends B { public const (parent&Ix)|Other X = null; }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_parent_dnf_method.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class Other {} class B {} class C extends B { public function m((parent&Ix)|Other $x): void {} }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_parent_no_parent_method.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
class C { public function m(parent $x): void {} }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_parent_no_parent_property.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
class C { public parent $p; }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_parent_param_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(parent $x): void {}

function main() {}
47 changes: 47 additions & 0 deletions phpunit/code/type_rule_scope_valid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
class ParentClass {}

class ChildClass extends ParentClass
{
public self $again;

public const self|int MARKER = 1;

public function m(self $a, ?parent $b): self|static
{
return $this;
}
}

trait LateBound
{
public function pass(parent $x): parent
{
return $x;
}
}

interface SelfContract
{
public function m(self $x): self;
}

enum SelfEnum: int
{
case One = 1;

public function pick(self $other): self
{
return $other;
}
}

function closureKeepsRuntimeScope(): int
{
$f = function (self $x): self {
return $x;
};
return 1;
}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_dnf_method.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class Other {} class C { public function m((self&Ix)|Other $x): void {} }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_dnf_param_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface A {} interface B {} function f((A&B)|self $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_dnf_promoted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class Other {} class C { public function __construct(public (self&Ix)|Other $p) {} }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_dnf_property.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class Other {} class C { public (self&Ix)|Other $p; }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_intersect_method.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class C { public function m(self&Ix $x): void {} }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_nullable_param_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(?self $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_param_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(self $x): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_return_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(): self {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_self_union_return_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function g(): self|stdClass { return new stdClass(); }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_static_dnf_return.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class Other {} class C { public function m(): (static&Ix)|Other { return $this; } }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_static_intersect_return.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
interface Ix {} class C { public function m(): static&Ix { return $this; } }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_static_return_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(): static {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_static_union_return_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function g(): int|static { return 1; }

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_true_false.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(true|false $x): void {}

function main() {}
8 changes: 8 additions & 0 deletions phpunit/code/type_rule_valid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
interface Ia {}
interface Ib {}
class TypeOk { public int|string $u; public function m(int|false $a, iterable $c, (Ia&Ib)|string $d): static { return $this; } }
class Other {}
function acceptsDistinctClasses(TypeOk|Other $x, (Ia&Ib)|Other $y, (Ia&Ib)|null $z): void {}

function main() {}
4 changes: 4 additions & 0 deletions phpunit/code/type_rule_void_union.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
function f(): void|int {}

function main() {}
6 changes: 3 additions & 3 deletions phpunit/src/ClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -812,17 +812,17 @@ public function testParentCanBePartOfUnionType()

public function testSelfCannotBePartOfIntersectionType()
{
$this->exec("Type 'self' cannot be part of an intersection type", 'intersection_type_self_not_allowed.php');
$this->exec('Type `self` cannot be part of an intersection type', 'intersection_type_self_not_allowed.php');
}

public function testParentCannotBePartOfIntersectionType()
{
$this->exec("Type 'parent' cannot be part of an intersection type", 'intersection_type_parent_not_allowed.php');
$this->exec('Type `parent` cannot be part of an intersection type', 'intersection_type_parent_not_allowed.php');
}

public function testStaticCannotBePartOfIntersectionType()
{
$this->exec("Type 'static' cannot be part of an intersection type", 'intersection_type_static_not_allowed.php');
$this->exec('Type `static` cannot be part of an intersection type', 'intersection_type_static_not_allowed.php');
}

public function testConstructorCannotDeclareReturnType()
Expand Down
Loading
Loading