Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
Closes #4854
  • Loading branch information
ondrejmirtes committed Jul 10, 2021
1 parent cd02bf8 commit 5eb5eaa
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/PHPStan/Rules/Methods/MethodSignatureRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,11 @@ public function testBug4729(): void
$this->analyse([__DIR__ . '/data/bug-4729.php'], []);
}

public function testBug4854(): void
{
$this->reportMaybes = true;
$this->reportStatic = true;
$this->analyse([__DIR__ . '/data/bug-4854.php'], []);
}

}
66 changes: 66 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-4854.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Bug4854;

/**
* @extends \IteratorAggregate<int>
* @extends \ArrayAccess<int,int>
*/
interface DomainsAvailabilityInterface extends \IteratorAggregate, \ArrayAccess
{
public const AVAILABLE = 1;
public const UNAVAILABLE = 2;
public const UNKNOWN = 3;
}

abstract class AbstractDomainsAvailability implements DomainsAvailabilityInterface
{
/**
* @var int[]
*/
protected array $domains;

/**
* {@inheritdoc}
*/
public function getIterator()
{
return new \ArrayIterator($this->domains);
}

/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value): void
{
if ($offset === null) {
$this->domains[] = $value;
} else {
$this->domains[$offset] = $value;
}
}

/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return isset($this->domains[$offset]);
}

/**
* {@inheritdoc}
*/
public function offsetUnset($offset): void
{
unset($this->domains[$offset]);
}

/**
* {@inheritdoc}
*/
public function offsetGet($offset): int
{
return $this->domains[$offset];
}
}

0 comments on commit 5eb5eaa

Please sign in to comment.