Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add 10686 test
  • Loading branch information
mvorisek committed Aug 27, 2024
commit ea8767227a5038ce3d7083455100042c0fab2ac0
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,11 @@ public function testGenericsInCallableInConstructor(): void
$this->analyse([__DIR__ . '/data/generics-in-callable-in-constructor.php'], []);
}

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

public function testBug11275(): void
{
if (PHP_VERSION_ID < 80000) {
Expand Down
33 changes: 33 additions & 0 deletions tests/PHPStan/Rules/Properties/data/bug-10686.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Bug10686;

class Model {}

/**
* @template T of object|array<mixed>
*/
class WeakAnalysingMap
{
/** @var list<T> */
public array $values = [];
}

class Reference
{
/** @var WeakAnalysingMap<Model> */
private static WeakAnalysingMap $analysingTheirModelMap;

public function createAnalysingTheirModel(): Model
{
if ((self::$analysingTheirModelMap ?? null) === null) {
self::$analysingTheirModelMap = new WeakAnalysingMap();
}

$theirModel = new Model();

self::$analysingTheirModelMap->values[] = $theirModel;

return end(self::$analysingTheirModelMap->values);
}
}