Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 16, 2021
1 parent efa6aa6 commit 346444a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Expand Up @@ -415,6 +415,7 @@ public function dataFileAsserts(): iterable

yield from $this->gatherAssertTypes(__DIR__ . '/data/empty-array-shape.php');
yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Methods/data/bug-5089.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3158.php');
}

/**
Expand Down
32 changes: 32 additions & 0 deletions tests/PHPStan/Analyser/data/bug-3158.php
@@ -0,0 +1,32 @@
<?php

namespace Bug3158;


use function PHPStan\Testing\assertType;

/**
* @template T as object
* @param class-string<T> $className
* @param \Closure(T):void $outmaker
* @return T
*/
function createProxy(
string $className,
\Closure $outmaker
) : object {
$t = new $className();
$outmaker($t);
return $t;
}

class AParent {}

class A extends AParent {
public function bar() : void {}
}

function (): void {
$proxy = createProxy(A::class, function(AParent $o):void {});
assertType(A::class, $proxy);
};

0 comments on commit 346444a

Please sign in to comment.