Skip to content

Commit c3c01c6

Browse files
committed
Test
1 parent 2017318 commit c3c01c6

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ public function testBug3777(): void
182182
'Property Bug3777\Ipsum2::$ipsum2 (Bug3777\Lorem2<stdClass, Exception>) does not accept Bug3777\Lorem2<Exception, object>.',
183183
131,
184184
],
185+
[
186+
'Property Bug3777\Ipsum3::$ipsum3 (Bug3777\Lorem3<stdClass, Exception>) does not accept Bug3777\Lorem3<Exception, stdClass>.',
187+
168,
188+
],
185189
]);
186190
}
187191

tests/PHPStan/Rules/Properties/data/bug-3777.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,40 @@ public function __construct()
133133
}
134134

135135
}
136+
137+
/**
138+
* @template T of object
139+
* @template U of object
140+
*/
141+
class Lorem3
142+
{
143+
144+
/**
145+
* @param T $t
146+
* @param U $u
147+
*/
148+
public function __construct($t, $u)
149+
{
150+
151+
}
152+
153+
}
154+
155+
class Ipsum3
156+
{
157+
158+
/** @var Lorem3<\stdClass, \Exception> */
159+
private $lorem3;
160+
161+
/** @var Lorem3<\stdClass, \Exception> */
162+
private $ipsum3;
163+
164+
public function __construct()
165+
{
166+
$this->lorem3 = new Lorem3(new \stdClass, new \Exception());
167+
assertType('Bug3777\Lorem3<stdClass, Exception>', $this->lorem3);
168+
$this->ipsum3 = new Lorem3(new \Exception(), new \stdClass());
169+
assertType('Bug3777\Lorem3<Exception, stdClass>', $this->ipsum3);
170+
}
171+
172+
}

0 commit comments

Comments
 (0)