Skip to content

Commit

Permalink
Regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 24, 2023
1 parent 01294d8 commit 377fe5c
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1416,4 +1416,9 @@ public function testBug2508(): void
$this->analyse([__DIR__ . '/data/bug-2508.php'], []);
}

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

}
33 changes: 33 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-6175.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Bug6715Functions;

trait T
{
/** @return array<mixed> */
public function getCreateTableSQL(): array
{
$sqls = array_merge(
$this->a(),
parent::b() // @phpstan-ignore-line
);

return $sqls;
}
}

class A {
public function a(): mixed {
throw new \Exception();
}

/** @return null */
public function b() {
throw new \Exception();
}
}

class B extends A
{
use T;
}
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -944,4 +944,9 @@ public function testBug6856(): void
$this->analyse([__DIR__ . '/data/bug-6856.php'], []);
}

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

}
36 changes: 36 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-6175.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Bug6175;

class A {}
class B extends A {}
class C extends B {}

trait RefsTrait
{
/**
* @return B|C
*/
public function foo()
{
return new A(); // @phpstan-ignore-line
}

public function dumpType(): void
{
\PHPStan\dumpType($this->foo());
}
}

class Model
{
use RefsTrait;

/**
* @return B|C
*/
public function foo2()
{
return new A(); // @phpstan-ignore-line
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,9 @@ public function testBug6158(): void
$this->analyse([__DIR__ . '/data/bug-6158.php'], []);
}

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

}
20 changes: 20 additions & 0 deletions tests/PHPStan/Rules/TooWideTypehints/data/bug-6175.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Bug6175TooWide;

trait SomeTrait {
private function sayHello(): ?string // @phpstan-ignore-line
{
return $this->value;
}
}

class HelloWorld2
{
use SomeTrait;
private string $value = '';
public function sayIt(): void
{
echo $this->sayHello();
}
}

0 comments on commit 377fe5c

Please sign in to comment.