Skip to content

Commit

Permalink
Merge pull request #4873 from morozov/phpstan-lvl-8
Browse files Browse the repository at this point in the history
Bump PHPStan level to 8
  • Loading branch information
derrabus authored Oct 15, 2021
2 parents cbd8cd8 + 2205b2b commit a4eacec
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ private function bindTypedParameters(): void
$streams = $values = [];
$types = $this->types;

assert($this->_bindedValues !== null);

foreach ($this->_bindedValues as $parameter => $value) {
assert(is_int($parameter));

Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le

if ($type === ParameterType::LARGE_OBJECT) {
$lob = oci_new_descriptor($this->_dbh, OCI_D_LOB);

assert($lob !== false);

$lob->writeTemporary($variable, OCI_TEMP_BLOB);

$variable =& $lob;
Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/DBAL/DriverManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use function array_keys;
use function array_merge;
use function assert;
use function class_implements;
use function in_array;
use function is_string;
Expand Down Expand Up @@ -337,8 +336,6 @@ private static function parseDatabaseUrl(array $params): array

// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
$url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']);
assert(is_string($url));

$url = parse_url($url);

if ($url === false) {
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Portability/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ protected function fixRow($row, $iterateRow, $fixCase)
}

if ($fixCase) {
assert($this->case !== null);
$row = array_change_key_case($row, $this->case);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public function getExistingSchemaSearchPaths()
$this->determineExistingSchemaSearchPaths();
}

assert($this->existingSchemaPaths !== null);

return $this->existingSchemaPaths;
}

Expand Down
2 changes: 0 additions & 2 deletions lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Doctrine\DBAL\Types\Type;

use function assert;
use function is_string;
use function preg_replace;

/**
Expand Down Expand Up @@ -231,7 +230,6 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null
protected function _getPortableViewDefinition($view)
{
$definition = preg_replace('/^.*\s+as\s+SELECT(.*)/i', 'SELECT$1', $view['view_def']);
assert(is_string($definition));

return new View($view['table_name'], $definition);
}
Expand Down
20 changes: 19 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 8
paths:
- %currentWorkingDirectory%/lib
reportUnmatchedIgnoredErrors: false
Expand Down Expand Up @@ -130,3 +130,21 @@ parameters:
message: '~^Circular definition detected in type alias (Override)?Params\.$~'
paths:
- %currentWorkingDirectory%/lib/Doctrine/DBAL/DriverManager.php

# TODO: remove in 4.0.0
-
message: '~^Parameter #2 \$table of class Doctrine\\DBAL\\Event\\SchemaIndexDefinitionEventArgs constructor expects string, string\|null given\.$~'
paths:
- %currentWorkingDirectory%/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php

# https://github.com/phpstan/phpstan/issues/1901
-
message: '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string\|null\.$~'
paths:
- %currentWorkingDirectory%/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php

# https://github.com/phpstan/phpstan/issues/4679
-
message: '~^Cannot call method writeTemporary\(\) on OCILob\|null\.$~'
paths:
- %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
8 changes: 8 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@
<file name="lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php"/>
</errorLevel>
</PossiblyNullIterator>
<PossiblyFalseReference>
<errorLevel type="suppress">
<!--
oci_new_descriptor() returns OCI-Lob|false on PHP 7 and OCILob|null on PHP 8
-->
<file name="lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php"/>
</errorLevel>
</PossiblyFalseReference>
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<!-- See https://github.com/psalm/psalm-plugin-phpunit/issues/107 -->
Expand Down

0 comments on commit a4eacec

Please sign in to comment.