Skip to content

Commit 582955c

Browse files
authored
[11.x] chore: update to PHPStan Level 1 (#51956)
* chore: update to phpstan level 1 * chore: update facades to use @mixin * fix: HasAttributes::relationsToArray isset logic
1 parent cac7d24 commit 582955c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+135
-104
lines changed

phpstan.src.neon.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
parameters:
2-
level: 0
2+
level: 1
33
paths:
44
- src
55
excludePaths:
66
- src/Illuminate/Testing/ParallelRunner.php
7+
- src/*/views/*
78
ignoreErrors:
89
- "#\\(void\\) is used#"
910
- "#Access to an undefined property#"

src/Illuminate/Auth/Access/Gate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ protected function callBeforeCallbacks($user, $ability, array $arguments)
575575
* @param \Illuminate\Contracts\Auth\Authenticatable $user
576576
* @param string $ability
577577
* @param array $arguments
578-
* @param bool $result
578+
* @param bool|null $result
579579
* @return bool|null
580580
*/
581581
protected function callAfterCallbacks($user, $ability, array $arguments, $result)

src/Illuminate/Bus/PendingBatch.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,7 @@ protected function dispatchExistingBatch($batch)
358358
try {
359359
$batch = $batch->add($this->jobs);
360360
} catch (Throwable $e) {
361-
if (isset($batch)) {
362-
$batch->delete();
363-
}
361+
$batch->delete();
364362

365363
throw $e;
366364
}

src/Illuminate/Cache/RetrievesMultipleKeys.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function many(array $keys)
2121
})->all();
2222

2323
foreach ($keys as $key => $default) {
24+
/** @phpstan-ignore arguments.count (some clients don't accept a default) */
2425
$return[$key] = $this->get($key, $default);
2526
}
2627

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public function hasAny($key)
604604
/**
605605
* Concatenate values of a given key as a string.
606606
*
607-
* @param callable|string $value
607+
* @param callable|string|null $value
608608
* @param string|null $glue
609609
* @return string
610610
*/

src/Illuminate/Database/Connectors/ConnectionFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ protected function createPdoResolverWithHosts(array $config)
188188
}
189189
}
190190

191-
throw $e;
191+
if (isset($e)) {
192+
throw $e;
193+
}
192194
};
193195
}
194196

src/Illuminate/Database/Connectors/MySqlConnector.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ protected function getSocketDsn(array $config)
7777
*/
7878
protected function getHostDsn(array $config)
7979
{
80-
extract($config, EXTR_SKIP);
81-
82-
return isset($port)
83-
? "mysql:host={$host};port={$port};dbname={$database}"
84-
: "mysql:host={$host};dbname={$database}";
80+
return isset($config['port'])
81+
? "mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}"
82+
: "mysql:host={$config['host']};dbname={$config['database']}";
8583
}
8684

8785
/**

src/Illuminate/Database/Connectors/PostgresConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function getDsn(array $config)
127127
// Sometimes - users may need to connect to a database that has a different
128128
// name than the database used for "information_schema" queries. This is
129129
// typically the case if using "pgbouncer" type software when pooling.
130-
$database = $connect_via_database ?? $database;
130+
$database = $connect_via_database ?? $database ?? null;
131131
$port = $connect_via_port ?? $port ?? null;
132132

133133
$dsn = "pgsql:{$host}dbname='{$database}'";

src/Illuminate/Database/Console/DatabaseInspectionCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function getConnectionCount(ConnectionInterface $connection)
5858
/**
5959
* Get the connection configuration details for the given connection.
6060
*
61-
* @param string $database
61+
* @param string|null $database
6262
* @return array
6363
*/
6464
protected function getConfigFromDatabase($database)

src/Illuminate/Database/Eloquent/Attributes/ObservedBy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ObservedBy
1313
* @param array|string $classes
1414
* @return void
1515
*/
16-
public function __construct(array|string $classes)
16+
public function __construct(public array|string $classes)
1717
{
1818
}
1919
}

0 commit comments

Comments
 (0)