Skip to content

Commit 4360c73

Browse files
committed
Add regression test for #12390
1 parent 927dd44 commit 4360c73

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,14 @@ public function testBug13537(): void
12721272
$this->analyse([__DIR__ . '/data/bug-13537.php'], $errors);
12731273
}
12741274

1275+
public function testBug12390(): void
1276+
{
1277+
$this->checkThisOnly = false;
1278+
$this->checkUnionTypes = true;
1279+
$this->checkDynamicProperties = true;
1280+
$this->analyse([__DIR__ . '/data/bug-12390.php'], []);
1281+
}
1282+
12751283
public function testBug13539(): void
12761284
{
12771285
$this->checkThisOnly = false;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
function testIssetOnGenericObject(object $obj): void
4+
{
5+
if (isset($obj->foo)) {
6+
}
7+
}
8+
9+
function testChainedIssetOnGenericObject(object $obj): void
10+
{
11+
if (isset($obj->foo) && isset($obj->bar)) {
12+
}
13+
}
14+
15+
function testIssetAfterIsObjectNarrowing(string $date): void
16+
{
17+
if (is_object($obj = json_decode($date))) {
18+
if (isset($obj->crashId) && is_string($obj->crashId)) {
19+
var_dump($obj->crashId);
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)