Skip to content

Commit

Permalink
Level 9 regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 28, 2022
1 parent 089d4c6 commit 0dd3d0c
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
Expand Up @@ -2384,4 +2384,22 @@ public function testBug6118(): void
$this->analyse([__DIR__ . '/data/bug-6118.php'], []);
}

public function testBug6464(): void
{
$this->checkThisOnly = false;
$this->checkNullables = true;
$this->checkUnionTypes = true;
$this->checkExplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-6464.php'], []);
}

public function testBug6423(): void
{
$this->checkThisOnly = false;
$this->checkNullables = true;
$this->checkUnionTypes = true;
$this->checkExplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-6423.php'], []);
}

}
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php
Expand Up @@ -603,4 +603,22 @@ public function testBug6589(): void
]);
}

public function testBug6418(): void
{
$this->checkExplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-6418.php'], []);
}

public function testBug6230(): void
{
$this->checkExplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-6230.php'], []);
}

public function testBug5860(): void
{
$this->checkExplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-5860.php'], []);
}

}
20 changes: 20 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-5860.php
@@ -0,0 +1,20 @@
<?php

namespace Bug5860;

class Foo
{

/**
* @template T
* @param T $t
* @return T
*/
function test($t) {
if ($t === null) {
return $t;
}
return $t;
}

}
43 changes: 43 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-6230.php
@@ -0,0 +1,43 @@
<?php

namespace Bug6230;

class Foo
{

/**
* @param ?iterable<mixed> $it
* @return ?iterable<mixed>
*/
function test($it): ?iterable
{
return $it;
}

}

/**
* @template T
*/
class Example
{
/**
* @var ?iterable<T>
*/
private $input;


/**
* @param iterable<T> $input
*/
public function __construct(iterable $input)
{
$this->input = $input;
}

/** @return ?iterable<T> */
public function get(): ?iterable
{
return $this->input;
}
}
19 changes: 19 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-6418.php
@@ -0,0 +1,19 @@
<?php

namespace Bug6418;

class Foo
{

/**
* @template T
*
* @param T&\DateTimeInterface $p
* @return T
*/
function test($p) {
return $p;
}

}
34 changes: 34 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-6423.php
@@ -0,0 +1,34 @@
<?php

namespace Bug6423;

class Foo
{


/**
* @param null|list<mixed> $foos
*/
function doFoo(?array $foos = null): void {}

/**
* @return list<string>
*/
function doBar(): array
{
return [
'hello',
'world',
];
}

function doBaz()
{
$this->doFoo([
'foo',
'bar',
...$this->doBar(),
]);
}

}
20 changes: 20 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-6464.php
@@ -0,0 +1,20 @@
<?php

namespace Bug6464;

interface Foo
{
/** @param \Generator<int, mixed, mixed, void> $g */
public function foo(\Generator $g): void;
}

class Bar
{

function test(Foo $foo): void {
$foo->foo((function(string $str) {
yield $str;
})('hello'));
}

}

0 comments on commit 0dd3d0c

Please sign in to comment.