1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 17:27:28 +01:00
psalm/tests/Config/Plugin/Hook/SqlStringProvider.php
LeSuisse f29826b958 Fully qualify constants and function calls (#1849)
This should give a small performance boost.
Part of #1837.

The change is enforced via phpcs and can be autofixed
with phpcbf.
2019-06-26 16:52:29 -04:00

27 lines
699 B
PHP

<?php
namespace Psalm\Test\Config\Plugin\Hook;
use Psalm\Plugin\Hook\StringInterpreterInterface;
use Psalm\Type\Atomic\TLiteralString;
use function stripos;
class SqlStringProvider implements StringInterpreterInterface
{
public static function getTypeFromValue(string $value) : ?TLiteralString
{
if (stripos($value, 'select ') !== false) {
try {
$parser = new \PhpMyAdmin\SqlParser\Parser($value);
if (!$parser->errors) {
return new StringProvider\TSqlSelectString($value);
}
} catch (\Throwable $e) {
// fall through
}
}
return null;
}
}