Skip to content

Commit 45c7cd2

Browse files
authored
Merge pull request #223 from moufmouf/phpstan_fix
Fixing a PHPStan regex that was too wide
2 parents 81e9650 + 8602648 commit 45c7cd2

13 files changed

+30
-14
lines changed

phpstan.neon

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ parameters:
1212
- "#should return array<TheCodingMachine\\\\TDBM\\\\AbstractTDBMObject> but returns array<int, object>#"
1313
#- "#expects array<string>, array<int, int|string> given.#"
1414
- "/Parameter #. \\$types of method Doctrine\\\\DBAL\\\\Connection::.*() expects array<int|string>, array<int, Doctrine\\\\DBAL\\\\Types\\\\Type> given./"
15-
- "#Method TheCodingMachine\\\\TDBM\\\\Schema\\\\ForeignKey::.*() should return .* but returns array<string>|string.#"
1615
- '#Method TheCodingMachine\\TDBM\\NativeWeakrefObjectStorage::get\(\) should return TheCodingMachine\\TDBM\\DbRow\|null but returns object\|null.#'
16+
- '#Method TheCodingMachine\\TDBM\\QueryFactory\\AbstractQueryFactory::.* should return string but returns string\|null.#'
1717
-
1818
message: '#WeakRef#'
1919
path: src/WeakrefObjectStorage.php
@@ -26,6 +26,12 @@ parameters:
2626
-
2727
message: '#is "array". Please provide a more specific .* annotation#'
2828
path: src/Test/Dao/Bean/Generated/PlayerBaseBean.php
29+
-
30+
message: '#Parameter \#1 \$str of method Doctrine\\DBAL\\Platforms\\AbstractPlatform::quoteIdentifier\(\) expects string, string\|null given#'
31+
path: src/ResultIterator.php
32+
-
33+
message: '#Strict comparison using === between int\\|string and null will always evaluate to false#'
34+
path: src/Utils/ScalarBeanPropertyDescriptor.php
2935
#reportUnmatchedIgnoredErrors: false
3036
includes:
3137
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon

src/QueryFactory/AbstractQueryFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected function getColumnsList(string $mainTable, array $additionalTablesFetc
173173

174174
// Let's remove any duplicate
175175
$allFetchedTables = array_unique($allFetchedTables);
176-
176+
177177
// We quote in MySQL because MagicJoin requires MySQL style quotes
178178
$mysqlPlatform = new MySqlPlatform();
179179

@@ -263,7 +263,7 @@ public function getColumnDescriptors() : array
263263
}
264264

265265
/**
266-
* @return string[][] An array of column descriptors. Value is an array with those keys: table, column
266+
* @return array<int, array{table: string, column: string}> An array of column descriptors.
267267
*/
268268
public function getSubQueryColumnDescriptors() : array
269269
{

src/QueryFactory/FindObjectsFromRawSqlQueryFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public function getMagicSqlSubQuery(): string
425425
}
426426

427427
/**
428-
* @return string[][] An array of column descriptors. Value is an array with those keys: table, column
428+
* @return array<int, array{table: string, column: string}> An array of column descriptors.
429429
*/
430430
public function getSubQueryColumnDescriptors(): array
431431
{

src/QueryFactory/FindObjectsFromSqlQueryFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private function getChildrenRelationshipForeignKeysWithoutCache(string $tableNam
161161
return $this->getChildrenRelationshipForeignKeys($fk->getLocalTableName());
162162
}, $children);
163163

164-
$fks = array_merge($children, call_user_func_array('array_merge', $fksTables));
164+
$fks = array_merge($children, ...$fksTables);
165165

166166
return $fks;
167167
} else {

src/QueryFactory/QueryFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getMagicSqlSubQuery() : string;
4444
public function getColumnDescriptors() : array;
4545

4646
/**
47-
* @return string[][] An array of column descriptors. Value is an array with those keys: table, column
47+
* @return array<int, array{table: string, column: string}> An array of column descriptors.
4848
*/
4949
public function getSubQueryColumnDescriptors() : array;
5050
}

src/SafeFunctions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public static function arrayCombine(array $keys, array $values): array
2020
{
2121
$array = array_combine($keys, $values);
2222
if ($array === false) {
23-
throw new RuntimeException(error_get_last()['message']);
23+
$error = error_get_last();
24+
throw new RuntimeException($error['message'] ?? '');
2425
}
2526
return $array;
2627
}

src/Schema/ForeignKey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ForeignKey
2020

2121

2222
/**
23-
* @param array<string, string|array<string>> $foreignKey
23+
* @param array{foreignTable: string, localColumns: string[], foreignColumns: string[]} $foreignKey
2424
*/
2525
public function __construct(array $foreignKey)
2626
{

src/Schema/ForeignKeys.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class ForeignKeys
77
{
88
/**
9-
* @var array
9+
* @var array<string, array{foreignTable: string, localColumns: string[], foreignColumns: string[]}>
1010
*/
1111
private $foreignKeys;
1212

@@ -16,7 +16,7 @@ class ForeignKeys
1616
private $foreignKey;
1717

1818
/**
19-
* @param array<string, array<string, string|array<string>>> $foreignKeys
19+
* @param array<string, array{foreignTable: string, localColumns: string[], foreignColumns: string[]}> $foreignKeys
2020
*/
2121
public function __construct(array $foreignKeys)
2222
{

src/Utils/Logs/LevelFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class LevelFilter extends AbstractLogger
4141
* @param LoggerInterface $logger
4242
* @param string $level \Psr\Log\LogLevel string
4343
*/
44-
public function __construct(LoggerInterface $logger, $level)
44+
public function __construct(LoggerInterface $logger, string $level)
4545
{
4646
$this->logger = $logger;
4747

src/Utils/RootProjectLocator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class RootProjectLocator
88
public static function getRootLocationPath(): string
99
{
1010
$reflection = new \ReflectionClass(\Composer\Autoload\ClassLoader::class);
11-
return dirname($reflection->getFileName(), 3).'/';
11+
$file = $reflection->getFileName();
12+
assert($file !== false);
13+
return dirname($file, 3).'/';
1214
}
1315
}

0 commit comments

Comments
 (0)