Skip to content

Commit

Permalink
Merge pull request #465 from kamil-tekiela/More-known-types
Browse files Browse the repository at this point in the history
Add native types
  • Loading branch information
MauricioFauth committed Jun 7, 2023
2 parents ee2118c + 384b2f1 commit 332054f
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 34 deletions.
4 changes: 1 addition & 3 deletions src/Statements/CallStatement.php
Expand Up @@ -29,10 +29,8 @@ class CallStatement extends Statement

/**
* Build statement for CALL.
*
* @return string
*/
public function build()
public function build(): string
{
return 'CALL ' . $this->call->name . '('
. ($this->call->parameters ? implode(',', $this->call->parameters->raw) : '') . ')';
Expand Down
5 changes: 1 addition & 4 deletions src/Statements/CreateStatement.php
Expand Up @@ -408,10 +408,7 @@ class CreateStatement extends Statement
*/
public $body = [];

/**
* @return string
*/
public function build()
public function build(): string
{
$fields = '';
if (! empty($this->fields)) {
Expand Down
5 changes: 1 addition & 4 deletions src/Statements/RenameStatement.php
Expand Up @@ -44,10 +44,7 @@ public function before(Parser $parser, TokensList $list, Token $token): void
$list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'TABLE');
}

/**
* @return string
*/
public function build()
public function build(): string
{
return 'RENAME TABLE ' . RenameOperation::build($this->renames);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Statements/TruncateStatement.php
Expand Up @@ -29,10 +29,8 @@ class TruncateStatement extends Statement

/**
* Special build method for truncate statement as Statement::build would return empty string.
*
* @return string
*/
public function build()
public function build(): string
{
return 'TRUNCATE TABLE ' . $this->table . ';';
}
Expand Down
4 changes: 1 addition & 3 deletions src/UtfString.php
Expand Up @@ -290,10 +290,8 @@ public function offsetUnset($offset)
* @see https://tools.ietf.org/html/rfc3629
*
* @param string $byte the byte to be analyzed
*
* @return int
*/
public static function getCharLength($byte)
public static function getCharLength($byte): int
{
// Use the default ASCII map as queries are mostly ASCII chars
// ord($byte) has a performance cost
Expand Down
15 changes: 3 additions & 12 deletions src/Utils/CLI.php
Expand Up @@ -92,10 +92,7 @@ public function parseHighlight(): array|false
return $params;
}

/**
* @return int
*/
public function runHighlight()
public function runHighlight(): int
{
$params = $this->parseHighlight();
if ($params === false) {
Expand Down Expand Up @@ -159,10 +156,7 @@ public function parseLint(): array|false
return $params;
}

/**
* @return int
*/
public function runLint()
public function runLint(): int
{
$params = $this->parseLint();
if ($params === false) {
Expand Down Expand Up @@ -234,10 +228,7 @@ public function parseTokenize(): array|false
return $params;
}

/**
* @return int
*/
public function runTokenize()
public function runTokenize(): int
{
$params = $this->parseTokenize();
if ($params === false) {
Expand Down
3 changes: 1 addition & 2 deletions src/Utils/Formatter.php
Expand Up @@ -766,10 +766,9 @@ public static function getGroupLength($list)
*
* @param Token $token the token to be checked
*
* @return int|false
* @psalm-return 1|2|false
*/
public static function isClause($token)
public static function isClause($token): int|false
{
if (
($token->type === Token::TYPE_KEYWORD && isset(Parser::$statementParsers[$token->keyword]))
Expand Down
4 changes: 1 addition & 3 deletions src/Utils/Query.php
Expand Up @@ -738,10 +738,8 @@ public static function getClause($statement, $list, $clause, $type = 0, $skipFir
* it is considered to be equal with `$old`.
* @param bool $onlyType whether only the type of the clause should
* be replaced or the entire clause
*
* @return string
*/
public static function replaceClause($statement, $list, $old, $new = null, $onlyType = false)
public static function replaceClause($statement, $list, $old, $new = null, $onlyType = false): string
{
// TODO: Update the tokens list and the statement.

Expand Down

0 comments on commit 332054f

Please sign in to comment.