Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 15, 2022
1 parent f35ea3a commit b64c673
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Expand Up @@ -1140,6 +1140,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/discussion-8447.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7805.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-82.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-4565.php');
}

/**
Expand Down
19 changes: 19 additions & 0 deletions tests/PHPStan/Analyser/data/bug-4565.php
@@ -0,0 +1,19 @@
<?php

namespace Bug4565;

use function PHPStan\Testing\assertType;

function test(array $variables) {
$attributes = ['href' => ''] + $variables['attributes'];
assertType('non-empty-array', $attributes);
if (!empty($variables['button'])) {
assertType('non-empty-array', $attributes);
$attributes['type'] = 'button';
assertType("hasOffsetValue('type', 'button')&non-empty-array", $attributes);
unset($attributes['href']);
assertType("array<mixed~'href', mixed>&hasOffsetValue('type', 'button')", $attributes);
}
assertType('array', $attributes);
return $attributes;
}
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/Variables/UnsetRuleTest.php
Expand Up @@ -86,4 +86,9 @@ public function testBug8113(): void
$this->analyse([__DIR__ . '/data/bug-8113.php'], []);
}

public function testBug4565(): void
{
$this->analyse([__DIR__ . '/../../Analyser/data/bug-4565.php'], []);
}

}

0 comments on commit b64c673

Please sign in to comment.