8000 Add regression test · phpstan/phpstan-src@c71567d · GitHub
[go: up one dir, main page]

Skip to content

Commit c71567d

Browse files
committed
Add regression test
1 parent 7cc0b0d commit c71567d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,4 +807,9 @@ public function testBug7844b(): void
807807
$this->analyse([__DIR__ . '/data/bug-7844b.php'], []);
808808
}
809809

810+
public function testBug12675(): void
811+
{
812+
$this->analyse([__DIR__ . '/data/bug-12675.php'], []);
813+
}
814+
810815
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Bug12675;
4+
5+
class HelloWorld
6+
{
7+
private string $username = "";
8+
private string $domain = "";
9+
10+
public function with_shift(string $email): void
11+
{
12+
$pieces = explode("@", $email);
13+
if (2 !== count($pieces)) {
14+
15+
throw new \Exception("Bad, very bad...");
16+
}
17+
18+
$this->username = array_shift($pieces);
19+
$this->domain = array_shift($pieces);
20+
21+
echo "{$this->username}@{$this->domain}";
22+
}
23+
24+
public function with_pop(string $email): void
25+
{
26+
$pieces = explode("@", $email);
27+
if (2 !== count($pieces)) {
28+
29+
throw new \Exception("Bad, very bad...");
30+
}
31+
32+
$this->domain = array_pop($pieces);
33+
$this->username = array_pop($pieces);
34+
35+
echo "{$this->username}@{$this->domain}";
36+
}
37+
}

0 commit comments

Comments
 (0)
0