Skip to content

Commit

Permalink
Merge branch refs/heads/1.12.x into 2.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Jan 24, 2025
2 parents 9d1239b + 2f74584 commit 449ca0a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Reflection/Php/PhpClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla

$resolvedPhpDoc = $this->phpDocInheritanceResolver->resolvePhpDocForMethod(
$docComment,
$fileDeclaringClass->getFileName(),
$fileDeclaringClass,
$actualDeclaringClass->getFileName(),
$actualDeclaringClass,
$declaringTraitName,
$methodReflection->getName(),
$positionalParameterNames,
Expand Down
11 changes: 11 additions & 0 deletions tests/PHPStan/Rules/Methods/MethodSignatureRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,15 @@ public function testBug3580(): void
$this->analyse([__DIR__ . '/data/bug-3580.php'], []);
}

public function testOverridenAbstractTraitMethodPhpDoc(): void
{
if (PHP_VERSION_ID < 80000) {
$this->markTestSkipped('Test requires PHP 8.0.');
}

$this->reportMaybes = true;
$this->reportStatic = true;
$this->analyse([__DIR__ . '/data/overriden-abstract-trait-method-phpdoc.php'], []);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace OverridenAbstractTraitMethodPhpDoc;

/**
* @template DataArray of array<string, mixed>
*/
trait FooTrait
{
/**
* Offset checker
*
* @phpstan-param Offset $offset
* @return bool
* @template Offset of key-of<DataArray>
*/
abstract public function offsetExists(mixed $offset): bool;
}

/**
* @template DataArray of array<string, mixed>
* @phpstan-type DataKey key-of<DataArray>
* @phpstan-type DataValue DataArray[DataKey]
*/
class FooClass
{

/** @phpstan-use FooTrait<DataArray> */
use FooTrait;

/** @phpstan-var DataArray|array{} */
public array $data = [];


/**
* Data checker
*
* @phpstan-param Offset $offset
* @return bool
* @template Offset of key-of<DataArray>
*/
public function offsetExists(mixed $offset): bool
{
return array_key_exists($offset, $this->data);
}
}

0 comments on commit 449ca0a

Please sign in to comment.