Skip to content

Commit af88971

Browse files
committed
Reached PHPStan level 7!
1 parent d827907 commit af88971

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 6
2+
level: 7
33
inferPrivatePropertyTypeFromConstructor: true
44
ignoreErrors:
55
- "#Mouf\\\\MoufManager#"

src/Mouf/Database/MagicQuery.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Mouf\Database;
44

5+
use Doctrine\DBAL\Connection;
56
use Doctrine\DBAL\Platforms\MySqlPlatform;
67
use function array_filter;
78
use function array_keys;
@@ -175,7 +176,7 @@ public function parse($sql)
175176
public function toSql(NodeInterface $sqlNode, array $parameters = array(), bool $extrapolateParameters = true)
176177
{
177178
$platform = $this->connection ? $this->connection->getDatabasePlatform() : new MySqlPlatform();
178-
return $sqlNode->toSql($parameters, $platform, 0, SqlRenderInterface::CONDITION_GUESS, $extrapolateParameters);
179+
return (string) $sqlNode->toSql($parameters, $platform, 0, SqlRenderInterface::CONDITION_GUESS, $extrapolateParameters);
179180
}
180181

181182
/**
@@ -286,15 +287,15 @@ private function getSchemaAnalyzer()
286287
throw new MagicQueryMissingConnectionException('In order to use MagicJoin, you need to configure a DBAL connection.');
287288
}
288289

289-
$this->schemaAnalyzer = new SchemaAnalyzer($this->connection->getSchemaManager(), $this->cache, $this->getConnectionUniqueId());
290+
$this->schemaAnalyzer = new SchemaAnalyzer($this->connection->getSchemaManager(), $this->cache, $this->getConnectionUniqueId($this->connection));
290291
}
291292

292293
return $this->schemaAnalyzer;
293294
}
294295

295-
private function getConnectionUniqueId()
296+
private function getConnectionUniqueId(Connection $connection)
296297
{
297-
return hash('md4', $this->connection->getHost().'-'.$this->connection->getPort().'-'.$this->connection->getDatabase().'-'.$this->connection->getDriver()->getName());
298+
return hash('md4', $connection->getHost().'-'.$connection->getPort().'-'.$connection->getDatabase().'-'.$connection->getDriver()->getName());
298299
}
299300

300301
/**

src/Mouf/Database/QueryWriter/QueryResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function val()
8383
/**
8484
* Returns the SQL for this query-result (without pagination, but with parameters accounted for).
8585
*
86-
* @return string
86+
* @return string|null
8787
*/
8888
public function toSql()
8989
{

src/SQLParser/Node/UnquotedParameter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class UnquotedParameter extends Parameter
5555
public function toSql(array $parameters, AbstractPlatform $platform, int $indent = 0, $conditionsMode = self::CONDITION_APPLY, bool $extrapolateParameters = true): ?string
5656
{
5757
$name = parent::toSql($parameters, $platform, $indent, $conditionsMode, $extrapolateParameters);
58-
$name = str_replace("'", '', $name);
58+
$name = str_replace("'", '', $name ?? '');
5959

6060
return $name;
6161
}

src/SQLParser/Query/Select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,15 @@ public function toSql(array $parameters, AbstractPlatform $platform, int $indent
377377
throw new \Exception('There is no offset if no limit is provided. An error may have occurred during SQLParsing.');
378378
} elseif (!empty($this->limit)) {
379379
$limit = NodeFactory::toSql($this->limit, $platform, $parameters, ',', false, $indent + 2, $conditionsMode, $extrapolateParameters);
380-
if ($limit === '' || ($extrapolateParameters && substr(trim($limit), 0, 1) == ':')) {
380+
if ($limit === '' || ($extrapolateParameters && substr(trim($limit ?? ''), 0, 1) == ':')) {
381381
$limit = null;
382382
}
383383
if (!$extrapolateParameters && $this->limit instanceof UnquotedParameter && !isset($parameters[$this->limit->getName()])) {
384384
$limit = null;
385385
}
386386
if (!empty($this->offset)) {
387387
$offset = NodeFactory::toSql($this->offset, $platform, $parameters, ',', false, $indent + 2, $conditionsMode, $extrapolateParameters);
388-
if ($offset === '' || ($extrapolateParameters && substr(trim($offset), 0, 1) == ':')) {
388+
if ($offset === '' || ($extrapolateParameters && substr(trim($offset ?? ''), 0, 1) == ':')) {
389389
$offset = null;
390390
}
391391
if (!$extrapolateParameters && $this->offset instanceof UnquotedParameter && !isset($parameters[$this->offset->getName()])) {

0 commit comments

Comments
 (0)