Skip to content

Commit 0cf4239

Browse files
committed
adjust copied test for static testing - issue 5551
1 parent 92342eb commit 0cf4239

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,23 @@ public function testBug3777(): void
211211

212212
$this->analyse([__DIR__ . '/data/bug-3777-static.php'], [
213213
[
214-
'Property Bug3777Static\Bar::$foo (Bug3777Static\Foo<stdClass>) does not accept Bug3777Static\Fooo<object>.',
214+
'Static property Bug3777Static\Bar::$foo (Bug3777Static\Foo<stdClass>) does not accept Bug3777Static\Fooo<object>.',
215215
58,
216216
],
217217
[
218-
'Property Bug3777Static\Ipsum::$ipsum (Bug3777Static\Lorem<stdClass, Exception>) does not accept Bug3777Static\Lorem<Exception, stdClass>.',
218+
'Static property Bug3777Static\Ipsum::$ipsum (Bug3777Static\Lorem<stdClass, Exception>) does not accept Bug3777Static\Lorem<Exception, stdClass>.',
219219
95,
220220
],
221221
[
222-
'Property Bug3777Static\Ipsum2::$lorem2 (Bug3777Static\Lorem2<stdClass, Exception>) does not accept Bug3777Static\Lorem2<stdClass, object>.',
222+
'Static property Bug3777Static\Ipsum2::$lorem2 (Bug3777Static\Lorem2<stdClass, Exception>) does not accept Bug3777Static\Lorem2<stdClass, object>.',
223223
129,
224224
],
225225
[
226-
'Property Bug3777Static\Ipsum2::$ipsum2 (Bug3777Static\Lorem2<stdClass, Exception>) does not accept Bug3777Static\Lorem2<Exception, object>.',
226+
'Static property Bug3777Static\Ipsum2::$ipsum2 (Bug3777Static\Lorem2<stdClass, Exception>) does not accept Bug3777Static\Lorem2<Exception, object>.',
227227
131,
228228
],
229229
[
230-
'Property Bug3777Static\Ipsum3::$ipsum3 (Bug3777Static\Lorem3<stdClass, Exception>) does not accept Bug3777Static\Lorem3<Exception, stdClass>.',
230+
'Static property Bug3777Static\Ipsum3::$ipsum3 (Bug3777Static\Lorem3<stdClass, Exception>) does not accept Bug3777Static\Lorem3<Exception, stdClass>.',
231231
168,
232232
],
233233
]);

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ class HelloWorld
99
/**
1010
* @var \SplObjectStorage<\DateTimeImmutable, null>
1111
*/
12-
public $dates;
12+
public static $dates;
1313

1414
public function __construct()
1515
{
16-
$this->dates = new \SplObjectStorage();
17-
assertType('SplObjectStorage<DateTimeImmutable, null>', $this->dates);
16+
static::$dates = new \SplObjectStorage();
17+
assertType('SplObjectStorage<DateTimeImmutable, null>', static::$dates);
1818
}
1919
}
2020

@@ -39,24 +39,24 @@ class Bar
3939
{
4040

4141
/** @var Foo<\stdClass> */
42-
private $foo;
42+
private static $foo;
4343

4444
/** @var Fooo<\stdClass> */
45-
private $fooo;
45+
private static $fooo;
4646

4747
public function __construct()
4848
{
49-
$this->foo = new Foo();
50-
assertType('Bug3777Static\Foo<stdClass>', $this->foo);
49+
static::$foo = new Foo();
50+
assertType('Bug3777Static\Foo<stdClass>', static::$foo);
5151

52-
$this->fooo = new Fooo();
53-
assertType('Bug3777Static\Fooo<stdClass>', $this->fooo);
52+
static::$fooo = new Fooo();
53+
assertType('Bug3777Static\Fooo<stdClass>', static::$fooo);
5454
}
5555

5656
public function doBar()
5757
{
58-
$this->foo = new Fooo();
59-
assertType('Bug3777Static\Fooo<object>', $this->foo);
58+
static::$foo = new Fooo();
59+
assertType('Bug3777Static\Fooo<object>', static::$foo);
6060
}
6161

6262
}
@@ -83,17 +83,17 @@ class Ipsum
8383
{
8484

8585
/** @var Lorem<\stdClass, \Exception> */
86-
private $lorem;
86+
private static $lorem;
8787

8888
/** @var Lorem<\stdClass, \Exception> */
89-
private $ipsum;
89+
private static $ipsum;
9090

9191
public function __construct()
9292
{
93-
$this->lorem = new Lorem(new \stdClass, new \Exception());
94-
assertType('Bug3777Static\Lorem<stdClass, Exception>', $this->lorem);
95-
$this->ipsum = new Lorem(new \Exception(), new \stdClass);
96-
assertType('Bug3777Static\Lorem<Exception, stdClass>', $this->ipsum);
93+
static::$lorem = new Lorem(new \stdClass, new \Exception());
94+
assertType('Bug3777Static\Lorem<stdClass, Exception>', static::$lorem);
95+
static::$ipsum = new Lorem(new \Exception(), new \stdClass);
96+
assertType('Bug3777Static\Lorem<Exception, stdClass>', static::$ipsum);
9797
}
9898

9999
}
@@ -119,17 +119,17 @@ class Ipsum2
119119
{
120120

121121
/** @var Lorem2<\stdClass, \Exception> */
122-
private $lorem2;
122+
private static $lorem2;
123123

124124
/** @var Lorem2<\stdClass, \Exception> */
125-
private $ipsum2;
125+
private static $ipsum2;
126126

127127
public function __construct()
128128
{
129-
$this->lorem2 = new Lorem2(new \stdClass);
130-
assertType('Bug3777Static\Lorem2<stdClass, object>', $this->lorem2);
131-
$this->ipsum2 = new Lorem2(new \Exception());
132-
assertType('Bug3777Static\Lorem2<Exception, object>', $this->ipsum2);
129+
static::$lorem2 = new Lorem2(new \stdClass);
130+
assertType('Bug3777Static\Lorem2<stdClass, object>', static::$lorem2);
131+
static::$ipsum2 = new Lorem2(new \Exception());
132+
assertType('Bug3777Static\Lorem2<Exception, object>', static::$ipsum2);
133133
}
134134

135135
}
@@ -156,17 +156,17 @@ class Ipsum3
156156
{
157157

158158
/** @var Lorem3<\stdClass, \Exception> */
159-
private $lorem3;
159+
private static $lorem3;
160160

161161
/** @var Lorem3<\stdClass, \Exception> */
162-
private $ipsum3;
162+
private static $ipsum3;
163163

164164
public function __construct()
165165
{
166-
$this->lorem3 = new Lorem3(new \stdClass, new \Exception());
167-
assertType('Bug3777Static\Lorem3<stdClass, Exception>', $this->lorem3);
168-
$this->ipsum3 = new Lorem3(new \Exception(), new \stdClass());
169-
assertType('Bug3777Static\Lorem3<Exception, stdClass>', $this->ipsum3);
166+
static::$lorem3 = new Lorem3(new \stdClass, new \Exception());
167+
assertType('Bug3777Static\Lorem3<stdClass, Exception>', static::$lorem3);
168+
static::$ipsum3 = new Lorem3(new \Exception(), new \stdClass());
169+
assertType('Bug3777Static\Lorem3<Exception, stdClass>', static::$ipsum3);
170170
}
171171

172172
}

0 commit comments

Comments
 (0)