Skip to content

Commit

Permalink
Add more regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed Jan 4, 2025
1 parent d4bdaf7 commit 1ee5bfc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,11 @@ public function testBug9399(): void
$this->analyse([__DIR__ . '/data/bug-9399.php'], []);
}

public function testBug9559(): void
{
$this->analyse([__DIR__ . '/data/bug-9559.php'], []);
}

public function testBug9923(): void
{
if (PHP_VERSION_ID < 80000) {
Expand Down
12 changes: 12 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-9559.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types = 1);

namespace Bug9559;

class ZZ {};
function foo(?ZZ $z = null, ?int $a = 0, ?string $b = "x"): string { return "bah"; }

function doit(int $x): void {
$call = [];
if ($x) $call['a'] = 45;
foo(...array_merge($call, [ "b" => "3" ]));
}
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,11 @@ public function testBug8632(): void
$this->analyse([__DIR__ . '/data/bug-8632.php'], []);
}

public function testBug7857(): void
{
$this->analyse([__DIR__ . '/data/bug-7857.php'], []);
}

public function testBug8879(): void
{
$this->analyse([__DIR__ . '/data/bug-8879.php'], []);
Expand Down
17 changes: 17 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-7857.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php declare(strict_types = 1);

namespace Bug7857;

class Paginator
{
/**
* @return array{page: int, perPage?: int}
*/
public function toArray(int $page, ?int $perPage): array
{
return array_merge(
['page' => $page],
$perPage !== null ? ['perPage' => $perPage] : []
);
}
}

0 comments on commit 1ee5bfc

Please sign in to comment.