Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jan 19, 2024
1 parent 9509e86 commit 4ada555
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/Template/ClassTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4265,6 +4265,69 @@ public function enqueue($value): void {}
/** @psalm-suppress InvalidArgument */
$a->enqueue("str");
'
],
'testSatisfies2' => [
'code' => '<?php
/**
* @template TValue as mixed = never
*/
class FutureSplQueue {
/**
* @template TNewValue as satisfied-by<TValue>
*
* @param TNewValue $value
*
* @psalm-this-out self<(TValue|TNewValue): satisfied-by<TValue>>
*/
public function enqueue($value): void {}
/** @return list<TValue> */
public function ret(): array {
return [];
}
}
/** @param FutureSplQueue<int> $a */
function take(FutureSplQueue $a): int {
foreach ($a->ret() as $v) {
return $v;
}
return 0;
}
function takeInt(int $a): int {
return $a;
}
/** @param 1|2 $a */
function takeIntExact(int $a): int {
return $a;
}
/** @var FutureSplQueue<never: int> */
$a = new FutureSplQueue;
/** @psalm-check-type-exact $a = FutureSplQueue<never: int> */;
$a->enqueue(1);
/** @psalm-check-type-exact $a = FutureSplQueue<1: int> */;
$a->enqueue(2);
/** @psalm-check-type-exact $a = FutureSplQueue<1|2: int> */;
foreach ($a->ret() as $v) {
takeInt($v);
takeIntExact($v);
}
/** @psalm-check-type-exact $a = FutureSplQueue<1|2: int> */;
take($a);
/** @psalm-check-type-exact $a = FutureSplQueue<int> */;
'
]
];
}
Expand Down

0 comments on commit 4ada555

Please sign in to comment.