You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppress for statement produces @noinspection OnlyWritesOnParameterInspection at statement which then is marked as redundant. Suppress for file/method work without producing new issues.
Expected behaviour
Either Suppress for statement should not be available in this case, or the result should not be marked as redundant.
Test case
<?php
declare(strict_types=1);
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
class ReadonlyArrayAccess implements ArrayAccess
{
/** @param array<mixed> $data */
public function __construct(private array $data)
{
}
public function offsetExists(mixed $offset): bool
{
return isset($this->data[$offset]);
}
public function offsetGet(mixed $offset): mixed
{
return $this->data[$offset] ?? null;
}
public function offsetSet(mixed $offset, mixed $value): void
{
throw new Exception('not allowed');
}
public function offsetUnset(mixed $offset): void
{
throw new Exception('not allowed');
}
}
#[CoversClass(ReadonlyArrayAccess::class)]
class ReadonlyAccessTest extends TestCase
{
public function testArrayAccessSet(): void
{
$data = new ReadonlyArrayAccess([]);
$this->expectExceptionObject(new Exception('not allowed'));
$data['foo'] = 'bar'; // This line triggers "Parameter/variable is not used" inspection
}
}
The text was updated successfully, but these errors were encountered:
Current behaviour
Suppress for statement produces @noinspection OnlyWritesOnParameterInspection at statement which then is marked as redundant. Suppress for file/method work without producing new issues.
Expected behaviour
Either Suppress for statement should not be available in this case, or the result should not be marked as redundant.
Test case
The text was updated successfully, but these errors were encountered: