More specific phpstan ignore rules.

This commit is contained in:
flash 2025-04-02 10:41:10 +00:00
parent 6efd02465f
commit 42adbe5da8
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
8 changed files with 35 additions and 35 deletions

View file

@ -1 +1 @@
0.2504.11235
0.2504.21040

View file

@ -1,7 +1,7 @@
<?php
// Dependencies.php
// Created: 2025-01-18
// Updated: 2025-03-22
// Updated: 2025-04-02
namespace Index;
@ -213,7 +213,7 @@ class Dependencies {
if(!array_key_exists($class, $this->objects))
return null;
$object = XArray::first($this->objects[$class], $predicate); // @phpstan-ignore-line: IDC
$object = XArray::first($this->objects[$class], $predicate); // @phpstan-ignore argument.type
if($object === null || !is_a($object, $class))
return null;
@ -254,8 +254,8 @@ class Dependencies {
return [];
if($predicate === null)
return $this->objects[$class]; // @phpstan-ignore-line: trust me
return $this->objects[$class]; // @phpstan-ignore return.type
return XArray::where($this->objects[$class], $predicate); // @phpstan-ignore-line: this is fine
return XArray::where($this->objects[$class], $predicate); // @phpstan-ignore argument.type, return.type
}
}

View file

@ -1,7 +1,7 @@
<?php
// HttpRequest.php
// Created: 2022-02-08
// Updated: 2025-03-20
// Updated: 2025-04-02
namespace Index\Http;
@ -360,16 +360,15 @@ class HttpRequest extends HttpMessage implements ServerRequestInterface, HttpPar
return new HttpRequest(
$request->getProtocolVersion(),
// @phpstan-ignore-next-line: interface erroneously defines as string[][] instead of array<string, string[]>
$request->getHeaders(),
$request->getHeaders(), // @phpstan-ignore argument.type
$request->getBody(),
[],
$request->getMethod(),
HttpUri::castUri($request->getUri()),
$queryParams,
$cookieParams,
$request->getParsedBody(), // @phpstan-ignore-line: dont care
$request->getUploadedFiles(), // @phpstan-ignore-line: dont care
$request->getParsedBody(), // @phpstan-ignore argument.type
$request->getUploadedFiles(), // @phpstan-ignore argument.type
);
}

View file

@ -1,7 +1,7 @@
<?php
// XArray.php
// Created: 2022-02-02
// Updated: 2025-01-21
// Updated: 2025-04-02
namespace Index;
@ -10,6 +10,7 @@ use InvalidArgumentException;
use Countable;
use Iterator;
use IteratorAggregate;
use Traversable;
/**
* Provides various helper methods for collections.
@ -480,7 +481,7 @@ final class XArray {
if($iterable instanceof Iterator)
return $iterable;
if($iterable instanceof IteratorAggregate)
return $iterable->getIterator(); // @phpstan-ignore-line
return self::extractIterator($iterable->getIterator()); // @phpstan-ignore return.type
if(is_array($iterable))
return new ArrayIterator($iterable);

View file

@ -1,7 +1,7 @@
<?php
// BencodeSerialisableTest.php
// Created: 2024-09-29
// Updated: 2025-01-18
// Updated: 2025-04-02
declare(strict_types=1);
@ -53,9 +53,9 @@ final class BencodeSerialisableTest extends TestCase {
#[BencodeProperty(omitIfNull: false)]
public mixed $nullValPresent = null;
/** @var array<?scalar> */
#[BencodeProperty]
/** @var scalar[] */
public array $scalarVals = [null, 0, 1234, 12.34, 'str', true, false]; // @phpstan-ignore-line: idgi??
public array $scalarVals = [null, 0, 1234, 12.34, 'str', true, false];
#[BencodeProperty('stringVal_method')]
public function getStringVal(): string {
@ -112,8 +112,8 @@ final class BencodeSerialisableTest extends TestCase {
return null;
}
#[BencodeProperty] // @phpstan-ignore-line: idgi??
/** @return scalar[] */
/** @return array<?scalar> */
#[BencodeProperty]
public function getScalarVals(): array {
return [null, 0, 1234, 12.34, 'str', true, false];
}
@ -156,11 +156,11 @@ final class BencodeSerialisableTest extends TestCase {
use BencodeSerializableCommon;
#[BencodeProperty('test1')]
#[BencodeProperty('test2')] // @phpstan-ignore-line: this is meant to test the dupe exception
#[BencodeProperty('test2')] // @phpstan-ignore attribute.nonRepeatable
public string $stringVal = 'string value';
#[BencodeProperty('test3')]
#[BencodeProperty('test4')] // @phpstan-ignore-line: this is meant to test the dupe exception
#[BencodeProperty('test4')] // @phpstan-ignore attribute.nonRepeatable
public function getIntVal(): int {
return 1234;
}

View file

@ -1,7 +1,7 @@
<?php
// BencodeTest.php
// Created: 2023-07-21
// Updated: 2024-12-02
// Updated: 2025-04-02
declare(strict_types=1);
@ -35,15 +35,15 @@ final class BencodeTest extends TestCase {
$this->assertIsObject($decoded);
$this->assertObjectHasProperty('announce', $decoded);
$this->assertEquals('https://tracker.flashii.net/announce.php/meow', $decoded->announce); // @phpstan-ignore-line: checked above
$this->assertEquals('https://tracker.flashii.net/announce.php/meow', $decoded->announce); // @phpstan-ignore property.notFound
$this->assertObjectHasProperty('creation date', $decoded);
$this->assertEquals(1689973664, $decoded->{'creation date'}); // @phpstan-ignore-line: checked above
$this->assertEquals(1689973664, $decoded->{'creation date'}); // @phpstan-ignore property.notFound
$this->assertObjectHasProperty('comment', $decoded);
$this->assertEquals('this is the comments field', $decoded->comment); // @phpstan-ignore-line: checked above
$this->assertEquals('this is the comments field', $decoded->comment); // @phpstan-ignore property.notFound
$this->assertObjectHasProperty('info', $decoded);
$this->assertIsObject($decoded->info); // @phpstan-ignore-line: checked above
$this->assertIsObject($decoded->info); // @phpstan-ignore property.notFound
$this->assertObjectHasProperty('private', $decoded->info);
$this->assertEquals(1, $decoded->info->private); // @phpstan-ignore-line: checked above
$this->assertEquals(1, $decoded->info->private); // @phpstan-ignore property.notFound
}
public function testEncode(): void {

View file

@ -1,7 +1,7 @@
<?php
// DbConfigTest.php
// Created: 2023-10-20
// Updated: 2025-01-18
// Updated: 2025-04-02
declare(strict_types=1);
@ -17,8 +17,8 @@ use Index\Db\{DbBackends,DbConnection};
#[CoversClass(GetValueInfoCommon::class)]
#[CoversClass(GetValuesCommon::class)]
final class DbConfigTest extends TestCase {
private DbConnection $dbConn; // @phpstan-ignore-line: defined by PHPunit in setUp()
private DbConfig $config; // @phpstan-ignore-line: defined by PHPunit in setUp()
private DbConnection $dbConn; // @phpstan-ignore property.uninitialized
private DbConfig $config; // @phpstan-ignore property.uninitialized
private const VALUES = [
'private.allow_password_reset' => 'b:1;',

View file

@ -1,7 +1,7 @@
<?php
// JsonSerializableTest.php
// Created: 2024-09-29
// Updated: 2025-01-18
// Updated: 2025-04-02
declare(strict_types=1);
@ -51,9 +51,9 @@ final class JsonSerializableTest extends TestCase {
#[JsonProperty(omitIfNull: false)]
public mixed $nullValPresent = null;
/** @var array<?scalar> */
#[JsonProperty]
/** @var scalar[] */
public array $scalarVals = [null, 0, 1234, 12.34, 'str', true, false]; // @phpstan-ignore-line: idgi??
public array $scalarVals = [null, 0, 1234, 12.34, 'str', true, false];
#[JsonProperty('stringVal_method')]
public function getStringVal(): string {
@ -110,8 +110,8 @@ final class JsonSerializableTest extends TestCase {
return null;
}
#[JsonProperty] // @phpstan-ignore-line: idgi??
/** @return scalar[] */
/** @return array<?scalar> */
#[JsonProperty]
public function getScalarVals(): array {
return [null, 0, 1234, 12.34, 'str', true, false];
}
@ -154,11 +154,11 @@ final class JsonSerializableTest extends TestCase {
use JsonSerializableCommon;
#[JsonProperty('test1')]
#[JsonProperty('test2')] // @phpstan-ignore-line: this is meant to test the dupe exception
#[JsonProperty('test2')] // @phpstan-ignore attribute.nonRepeatable
public string $stringVal = 'string value';
#[JsonProperty('test3')]
#[JsonProperty('test4')] // @phpstan-ignore-line: this is meant to test the dupe exception
#[JsonProperty('test4')] // @phpstan-ignore attribute.nonRepeatable
public function getIntVal(): int {
return 1234;
}