Skip to content

Commit

Permalink
Add static return type
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Jun 27, 2021
1 parent 97204d7 commit 3b20562
Show file tree
Hide file tree
Showing 28 changed files with 463 additions and 402 deletions.
4 changes: 2 additions & 2 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ protected function makeConfig(array $config) : array
*
* @throws Exception
*
* @return $this
* @return static
*/
protected function connect(
array | string $username,
string $password = null,
string $schema = null,
string $host = 'localhost',
int $port = 3306
) {
) : static {
if ( ! \is_array($username)) {
$username = [
'host' => $host,
Expand Down
16 changes: 8 additions & 8 deletions src/Definition/AlterSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class AlterSchema extends Statement
/**
* @param string $schemaName
*
* @return $this
* @return static
*/
public function schema(string $schemaName)
public function schema(string $schemaName) : static
{
$this->sql['schema'] = $schemaName;
return $this;
Expand All @@ -45,9 +45,9 @@ protected function renderSchema() : ?string
/**
* @param string $charset
*
* @return $this
* @return static
*/
public function charset(string $charset)
public function charset(string $charset) : static
{
$this->sql['charset'] = $charset;
return $this;
Expand All @@ -65,9 +65,9 @@ protected function renderCharset() : ?string
/**
* @param string $collation
*
* @return $this
* @return static
*/
public function collate(string $collation)
public function collate(string $collation) : static
{
$this->sql['collation'] = $collation;
return $this;
Expand All @@ -83,9 +83,9 @@ protected function renderCollate() : ?string
}

/**
* @return $this
* @return static
*/
public function upgrade()
public function upgrade() : static
{
$this->sql['upgrade'] = true;
return $this;
Expand Down
36 changes: 18 additions & 18 deletions src/Definition/AlterTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
class AlterTable extends Statement
{
/**
* @return $this
* @return static
*/
public function online()
public function online() : static
{
$this->sql['online'] = true;
return $this;
Expand All @@ -39,9 +39,9 @@ protected function renderOnline() : ?string
}

/**
* @return $this
* @return static
*/
public function ignore()
public function ignore() : static
{
$this->sql['ignore'] = true;
return $this;
Expand All @@ -58,9 +58,9 @@ protected function renderIgnore() : ?string
/**
* @param string $tableName
*
* @return $this
* @return static
*/
public function table(string $tableName)
public function table(string $tableName) : static
{
$this->sql['table'] = $tableName;
return $this;
Expand All @@ -77,9 +77,9 @@ protected function renderTable() : string
/**
* @param int $seconds
*
* @return $this
* @return static
*/
public function wait(int $seconds)
public function wait(int $seconds) : static
{
$this->sql['wait'] = $seconds;
return $this;
Expand All @@ -101,9 +101,9 @@ protected function renderWait() : ?string
/**
* @param callable $definition
*
* @return $this
* @return static
*/
public function add(callable $definition)
public function add(callable $definition) : static
{
$this->sql['add'] = $definition;
return $this;
Expand All @@ -122,9 +122,9 @@ protected function renderAdd() : ?string
/**
* @param callable $definition
*
* @return $this
* @return static
*/
public function change(callable $definition)
public function change(callable $definition) : static
{
$this->sql['change'] = $definition;
return $this;
Expand All @@ -143,9 +143,9 @@ protected function renderChange() : ?string
/**
* @param callable $definition
*
* @return $this
* @return static
*/
public function modify(callable $definition)
public function modify(callable $definition) : static
{
$this->sql['modify'] = $definition;
return $this;
Expand All @@ -164,9 +164,9 @@ protected function renderModify() : ?string
/**
* @param callable $definition
*
* @return $this
* @return static
*/
public function dropColumns(callable $definition)
public function dropColumns(callable $definition) : static
{
$this->sql['drop_columns'] = $definition;
return $this;
Expand All @@ -175,9 +175,9 @@ public function dropColumns(callable $definition)
/**
* @param callable $definition
*
* @return $this
* @return static
*/
public function drop(callable $definition)
public function drop(callable $definition) : static
{
$this->sql['drop'] = $definition;
return $this;
Expand Down
20 changes: 10 additions & 10 deletions src/Definition/CreateSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
class CreateSchema extends Statement
{
/**
* @return $this
* @return static
*/
public function orReplace()
public function orReplace() : static
{
$this->sql['or_replace'] = true;
return $this;
Expand All @@ -37,9 +37,9 @@ protected function renderOrReplace() : ?string
}

/**
* @return $this
* @return static
*/
public function ifNotExists()
public function ifNotExists() : static
{
$this->sql['if_not_exists'] = true;
return $this;
Expand All @@ -61,9 +61,9 @@ protected function renderIfNotExists() : ?string
/**
* @param string $schemaName
*
* @return $this
* @return static
*/
public function schema(string $schemaName)
public function schema(string $schemaName) : static
{
$this->sql['schema'] = $schemaName;
return $this;
Expand All @@ -80,9 +80,9 @@ protected function renderSchema() : string
/**
* @param string $charset
*
* @return $this
* @return static
*/
public function charset(string $charset)
public function charset(string $charset) : static
{
$this->sql['charset'] = $charset;
return $this;
Expand All @@ -100,9 +100,9 @@ protected function renderCharset() : ?string
/**
* @param string $collation
*
* @return $this
* @return static
*/
public function collate(string $collation)
public function collate(string $collation) : static
{
$this->sql['collation'] = $collation;
return $this;
Expand Down
20 changes: 10 additions & 10 deletions src/Definition/CreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class CreateTable extends Statement
*
* WARNING: This feature is MariaDB only. It is not compatible with MySQL.
*
* @return $this
* @return static
*/
public function orReplace()
public function orReplace() : static
{
$this->sql['or_replace'] = true;
return $this;
Expand All @@ -47,9 +47,9 @@ protected function renderOrReplace() : ?string
}

/**
* @return $this
* @return static
*/
public function temporary()
public function temporary() : static
{
$this->sql['temporary'] = true;
return $this;
Expand All @@ -64,9 +64,9 @@ protected function renderTemporary() : ?string
}

/**
* @return $this
* @return static
*/
public function ifNotExists()
public function ifNotExists() : static
{
$this->sql['if_not_exists'] = true;
return $this;
Expand All @@ -88,9 +88,9 @@ protected function renderIfNotExists() : ?string
/**
* @param string $tableName
*
* @return $this
* @return static
*/
public function table(string $tableName)
public function table(string $tableName) : static
{
$this->sql['table'] = $tableName;
return $this;
Expand All @@ -107,9 +107,9 @@ protected function renderTable() : string
/**
* @param callable $definition
*
* @return $this
* @return static
*/
public function definition(callable $definition)
public function definition(callable $definition) : static
{
$this->sql['definition'] = $definition;
return $this;
Expand Down
8 changes: 4 additions & 4 deletions src/Definition/DropSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
class DropSchema extends Statement
{
/**
* @return $this
* @return static
*/
public function ifExists()
public function ifExists() : static
{
$this->sql['if_exists'] = true;
return $this;
Expand All @@ -39,9 +39,9 @@ protected function renderIfExists() : ?string
/**
* @param string $schemaName
*
* @return $this
* @return static
*/
public function schema(string $schemaName)
public function schema(string $schemaName) : static
{
$this->sql['schema'] = $schemaName;
return $this;
Expand Down
20 changes: 10 additions & 10 deletions src/Definition/DropTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
class DropTable extends Statement
{
/**
* @return $this
* @return static
*/
public function temporary()
public function temporary() : static
{
$this->sql['temporary'] = true;
return $this;
Expand All @@ -38,9 +38,9 @@ protected function renderTemporary() : ?string
}

/**
* @return $this
* @return static
*/
public function ifExists()
public function ifExists() : static
{
$this->sql['if_exists'] = true;
return $this;
Expand All @@ -57,9 +57,9 @@ protected function renderIfExists() : ?string
/**
* @param string $comment
*
* @return $this
* @return static
*/
public function commentToSave(string $comment)
public function commentToSave(string $comment) : static
{
$this->sql['comment'] = $comment;
return $this;
Expand All @@ -78,9 +78,9 @@ protected function renderCommentToSave() : ?string
* @param string $table
* @param string ...$tables
*
* @return $this
* @return static
*/
public function table(string $table, string ...$tables)
public function table(string $table, string ...$tables) : static
{
$this->sql['tables'] = $tables ? \array_merge([$table], $tables) : [$table];
return $this;
Expand All @@ -103,9 +103,9 @@ protected function renderTables() : string
/**
* @param int $seconds
*
* @return $this
* @return static
*/
public function wait(int $seconds)
public function wait(int $seconds) : static
{
$this->sql['wait'] = $seconds;
return $this;
Expand Down
Loading

0 comments on commit 3b20562

Please sign in to comment.