Skip to content

Commit 2539ab7

Browse files
committed
1 parent eded2c3 commit 2539ab7

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

Diff for: tests/PHPStan/Rules/Methods/MethodSignatureRuleTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -568,4 +568,37 @@ public function testGenericStaticType(): void
568568
$this->analyse([__DIR__ . '/data/method-signature-generic-static-type.php'], []);
569569
}
570570

571+
public function testBug10240(): void
572+
{
573+
if (PHP_VERSION_ID < 80000) {
574+
$this->markTestSkipped('Test requires PHP 8.0.');
575+
}
576+
577+
$this->reportMaybes = true;
578+
$this->reportStatic = true;
579+
$this->analyse([__DIR__ . '/data/bug-10240.php'], []);
580+
}
581+
582+
public function testBug10488(): void
583+
{
584+
if (PHP_VERSION_ID < 80000) {
585+
$this->markTestSkipped('Test requires PHP 8.0.');
586+
}
587+
588+
$this->reportMaybes = true;
589+
$this->reportStatic = true;
590+
$this->analyse([__DIR__ . '/data/bug-10488.php'], []);
591+
}
592+
593+
public function testBug12073(): void
594+
{
595+
if (PHP_VERSION_ID < 80000) {
596+
$this->markTestSkipped('Test requires PHP 8.0.');
597+
}
598+
599+
$this->reportMaybes = true;
600+
$this->reportStatic = true;
601+
$this->analyse([__DIR__ . '/data/bug-12073.php'], []);
602+
}
603+
571604
}

Diff for: tests/PHPStan/Rules/Methods/data/bug-10240.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php // lint >= 8.0
2+
3+
namespace Bug10240;
4+
5+
interface MyInterface
6+
{
7+
/**
8+
* @phpstan-param truthy-string $truthyStrParam
9+
*/
10+
public function doStuff(
11+
string $truthyStrParam,
12+
): void;
13+
}
14+
15+
trait MyTrait
16+
{
17+
/**
18+
* @phpstan-param truthy-string $truthyStrParam
19+
*/
20+
abstract public function doStuff(
21+
string $truthyStrParam,
22+
): void;
23+
}
24+
25+
class MyClass implements MyInterface
26+
{
27+
use MyTrait;
28+
29+
public function doStuff(
30+
string $truthyStrParam,
31+
): void
32+
{
33+
// ...
34+
}
35+
}

Diff for: tests/PHPStan/Rules/Methods/data/bug-10488.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php // lint >= 8.0
2+
3+
namespace Bug10488;
4+
5+
trait Bar
6+
{
7+
/**
8+
* @param array<string,mixed> $data
9+
*/
10+
11+
abstract protected function test(array $data): void;
12+
}
13+
14+
abstract class Foo
15+
{
16+
use Bar;
17+
}

Diff for: tests/PHPStan/Rules/Methods/data/bug-12073.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug12073;
4+
5+
trait HasFieldBuildersTrait
6+
{
7+
/**
8+
* @param array<string,mixed> $field
9+
*/
10+
abstract public function field(array $field): static;
11+
}
12+
13+
class GroupBuilder
14+
{
15+
use HasFieldBuildersTrait;
16+
17+
/** @var array<string,mixed> */
18+
private array $group = [];
19+
20+
private function __construct()
21+
{
22+
}
23+
24+
/**
25+
* @param array<string,mixed> $field
26+
*/
27+
public function field(array $field): static
28+
{
29+
if (! is_array($this->group['fields'] ?? null)) {
30+
$this->group['fields'] = [];
31+
}
32+
33+
$this->group['fields'][] = $field;
34+
35+
return $this;
36+
}
37+
}

0 commit comments

Comments
 (0)