Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Rules/Classes/NewStaticRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

foreach ($classReflection->getImmediateInterfaces() as $interface) {
foreach ($classReflection->getInterfaces() as $interface) {
if ($interface->hasConstructor()) {
return [];
}
Expand Down
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/Classes/NewStaticRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ public function testBug10722(): void
$this->analyse([__DIR__ . '/data/bug-10722.php'], []);
}

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

}
69 changes: 69 additions & 0 deletions tests/PHPStan/Rules/Classes/data/bug-10274.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php declare(strict_types = 1); // lint >= 8.0

namespace Bug10274;

/**
* @template T
*/
class AbstractArray {
/**
* @var array<array-key, T>
*/
public array $data;

/**
* @param array<array-key, T> $data
*/
public function __construct(array $data = [])
{
$this->data = $data;
}
}

interface BaseCollectionInterface {}


/**
* @template T
* @extends AbstractArray<T>
*/
abstract class AbstractCollection extends AbstractArray implements BaseCollectionInterface {}

/**
* @template T
*/
interface ConstructorDefiningInterface extends BaseCollectionInterface {
/**
* @param array<array-key, T> $data
*/
public function __construct(array $data = []);
}

/**
* @template T
* @extends AbstractCollection<T>
* @implements ConstructorDefiningInterface<T>
*/
abstract class IntermediateCollection extends AbstractCollection implements ConstructorDefiningInterface {}

/**
* @template T
* @extends IntermediateCollection<T>
*/
class SpecificCollection extends IntermediateCollection {
public static function create(): static
{
return new static();
}
}

/**
* @template T
* @extends SpecificCollection<T>
*/
class DeeplyNestedCollection extends SpecificCollection {
public static function create(): static
{
return new static();
}
}
Loading