Skip to content

Commit 35d0b02

Browse files
committed
regression test
1 parent e2805d7 commit 35d0b02

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/PHPStan/Rules/Arrays/DuplicateKeysInLiteralArraysRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,9 @@ public function testBug13013(): void
101101
$this->analyse([__DIR__ . '/data/bug-13013.php'], []);
102102
}
103103

104+
public function testBug13022(): void
105+
{
106+
$this->analyse([__DIR__ . '/data/bug-13022.php'], []);
107+
}
108+
104109
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug13022;
4+
5+
class RootClass
6+
{
7+
function getId(): int
8+
{
9+
return 1;
10+
}
11+
}
12+
13+
class SomeClass extends RootClass{
14+
15+
}
16+
17+
function test(RootClass $object): void
18+
{
19+
20+
$searchId = $object instanceof SomeClass ? 'uid' : 'aid';
21+
$targetId = $object instanceof SomeClass ? 'aid' : 'uid';
22+
23+
$array = [
24+
$searchId => $object->getId(),
25+
$targetId => 'info',
26+
];
27+
28+
// sql()->insert('tablename', $array); - example how this will be used
29+
}

0 commit comments

Comments
 (0)