Skip to content

Commit a9a2b60

Browse files
committed
Fix hasOffsetValueType on nested expression after unsetting
1 parent f3fe245 commit a9a2b60

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

tests/PHPStan/Analyser/data/composer-array-bug.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ public function doFoo(): void
1919
foreach ($this->config['authors'] as $key => $author) {
2020
if (!is_array($author)) {
2121
$this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
22-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
22+
assertType("mixed", $this->config['authors']);
2323
unset($this->config['authors'][$key]);
24-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
24+
assertType("mixed", $this->config['authors']);
2525
continue;
2626
}
27-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
27+
assertType("mixed", $this->config['authors']);
2828
foreach (['homepage', 'email', 'name', 'role'] as $authorData) {
2929
if (isset($author[$authorData]) && !is_string($author[$authorData])) {
3030
$this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
3131
unset($this->config['authors'][$key][$authorData]);
3232
}
3333
}
3434
if (isset($author['homepage'])) {
35-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
35+
assertType("mixed", $this->config['authors']);
3636
unset($this->config['authors'][$key]['homepage']);
37-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
37+
assertType("mixed", $this->config['authors']);
3838
}
3939
if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
4040
unset($this->config['authors'][$key]['email']);
@@ -44,8 +44,8 @@ public function doFoo(): void
4444
}
4545
}
4646

47-
assertType("array&hasOffsetValue('authors', mixed~0|0.0|''|'0'|false|null)", $this->config);
48-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
47+
assertType("array", $this->config);
48+
assertType("mixed", $this->config['authors']);
4949

5050
if (empty($this->config['authors'])) {
5151
unset($this->config['authors']);

tests/PHPStan/Analyser/data/composer-non-empty-array-after-unset.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public function doFoo()
1515
if (!empty($this->config['authors'])) {
1616
assertType("mixed~0|0.0|''|'0'|array{}|false|null", $this->config['authors']);
1717
foreach ($this->config['authors'] as $key => $author) {
18-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
18+
assertType("mixed", $this->config['authors']);
1919
if (!is_array($author)) {
2020
unset($this->config['authors'][$key]);
21-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
21+
assertType("mixed", $this->config['authors']);
2222
continue;
2323
}
2424
foreach (['homepage', 'email', 'name', 'role'] as $authorData) {
@@ -33,13 +33,13 @@ public function doFoo()
3333
unset($this->config['authors'][$key]['email']);
3434
}
3535
if (empty($this->config['authors'][$key])) {
36-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
36+
assertType("mixed", $this->config['authors']);
3737
unset($this->config['authors'][$key]);
38-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
38+
assertType("mixed", $this->config['authors']);
3939
}
40-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
40+
assertType("mixed", $this->config['authors']);
4141
}
42-
assertType("mixed~0|0.0|''|'0'|false|null", $this->config['authors']);
42+
assertType("mixed", $this->config['authors']);
4343
}
4444
}
4545

tests/PHPStan/Rules/Variables/data/bug-7417.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ function doFoo() {
2424
unset($extensions['theme']['test_basetheme']);
2525
unset($extensions['theme']['test_subsubtheme']);
2626
unset($extensions['theme']['test_subtheme']);
27-
assertType("hasOffsetValue('theme', mixed)&non-empty-array", $extensions);
27+
assertType("array", $extensions);
2828
}

0 commit comments

Comments
 (0)