Skip to content

Commit 845028b

Browse files
committed
Fixing PHPStan
1 parent 2e6a20c commit 845028b

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
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: 3
2+
level: 2
33
ignoreErrors:
44
- "#Mouf\\\\MoufManager#"
55
- "#Mouf\\\\MoufInstanceDescriptor#"

src/Mouf/Database/MagicQuery/Twig/SqlTwigEnvironmentFactory.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Mouf\Database\MagicQuery\Twig;
44

5+
use Twig_Extension_Core;
6+
57
/**
68
* Class in charge of creating the Twig environment.
79
*/
@@ -28,7 +30,10 @@ public static function getTwigEnvironment()
2830

2931
// Default escaper will throw an exception. This is because we want to use SQL parameters instead of Twig.
3032
// This has a number of advantages, especially in terms of caching.
31-
$twig->getExtension('Twig_Extension_Core')->setEscaper('sql', function () {
33+
34+
/** @var Twig_Extension_Core $twigExtensionCore */
35+
$twigExtensionCore = $twig->getExtension('Twig_Extension_Core');
36+
$twigExtensionCore->setEscaper('sql', function () {
3237
throw new ForbiddenTwigParameterInSqlException('You cannot use Twig expressions (like "{{ id }}"). Instead, you should use SQL parameters (like ":id"). Twig integration is limited to Twig statements (like "{% for .... %}"');
3338
});
3439

src/Mouf/Database/QueryWriter/QueryResult.php

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

33
namespace Mouf\Database\QueryWriter;
44

5+
use function method_exists;
56
use Mouf\Database\QueryWriter\Utils\DbHelper;
67
use Mouf\Utils\Value\ValueUtils;
78
use SQLParser\Query\Select;
@@ -114,7 +115,9 @@ public function sort($key, $direction = SortableInterface::ASC)
114115
if (method_exists($columnObj, 'setAlias')) {
115116
$columnObj->setAlias(null);
116117
}
117-
$columnObj->setDirection($direction);
118+
if (method_exists($columnObj, 'setDirection')) {
119+
$columnObj->setDirection($direction);
120+
}
118121
} else {
119122
$columnObj = new ColRef();
120123
$columnObj->setColumn($key);

src/SQLParser/Node/Expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function toInstanceDescriptor(MoufManager $moufManager)
199199
* @param number $indent
200200
* @param int $conditionsMode
201201
*
202-
* @return string
202+
* @return string|null
203203
*/
204204
public function toSql(array $parameters = array(), Connection $dbConnection = null, $indent = 0, $conditionsMode = self::CONDITION_APPLY, bool $extrapolateParameters = true)
205205
{

0 commit comments

Comments
 (0)