Skip to content

Commit

Permalink
used PhpStorm Language attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 29, 2023
1 parent 92b8e60 commit 60b63e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
}
],
"require": {
"php": "8.0 - 8.3"
"php": "8.0 - 8.3",
"jetbrains/phpstorm-attributes": "dev-master"
},
"require-dev": {
"tracy/tracy": "^2.9",
Expand Down
19 changes: 10 additions & 9 deletions src/Dibi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Dibi;

use JetBrains\PhpStorm\Language;
use Traversable;


Expand Down Expand Up @@ -209,7 +210,7 @@ final public function getDriver(): Driver
* Generates (translates) and executes SQL query.
* @throws Exception
*/
final public function query(mixed ...$args): Result
final public function query(#[Language('GenericSQL')] mixed ...$args): Result
{
return $this->nativeQuery($this->translate(...$args));
}
Expand All @@ -219,7 +220,7 @@ final public function query(mixed ...$args): Result
* Generates SQL query.
* @throws Exception
*/
final public function translate(mixed ...$args): string
final public function translate(#[Language('GenericSQL')] mixed ...$args): string
{
if (!$this->driver) {
$this->connect();
Expand All @@ -232,7 +233,7 @@ final public function translate(mixed ...$args): string
/**
* Generates and prints SQL query.
*/
final public function test(mixed ...$args): bool
final public function test(#[Language('GenericSQL')] mixed ...$args): bool
{
try {
Helpers::dump($this->translate(...$args));
Expand All @@ -254,7 +255,7 @@ final public function test(mixed ...$args): bool
* Generates (translates) and returns SQL query as DataSource.
* @throws Exception
*/
final public function dataSource(mixed ...$args): DataSource
final public function dataSource(#[Language('GenericSQL')] mixed ...$args): DataSource
{
return new DataSource($this->translate(...$args), $this);
}
Expand All @@ -264,7 +265,7 @@ final public function dataSource(mixed ...$args): DataSource
* Executes the SQL query.
* @throws Exception
*/
final public function nativeQuery(string $sql): Result
final public function nativeQuery(#[Language('SQL')] string $sql): Result
{
if (!$this->driver) {
$this->connect();
Expand Down Expand Up @@ -593,7 +594,7 @@ public function translateObject(object $object): ?Expression
* Executes SQL query and fetch result - shortcut for query() & fetch().
* @throws Exception
*/
public function fetch(mixed ...$args): ?Row
public function fetch(#[Language('GenericSQL')] mixed ...$args): ?Row
{
return $this->query($args)->fetch();
}
Expand All @@ -604,7 +605,7 @@ public function fetch(mixed ...$args): ?Row
* @return Row[]|array[]
* @throws Exception
*/
public function fetchAll(mixed ...$args): array
public function fetchAll(#[Language('GenericSQL')] mixed ...$args): array
{
return $this->query($args)->fetchAll();
}
Expand All @@ -614,7 +615,7 @@ public function fetchAll(mixed ...$args): array
* Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
* @throws Exception
*/
public function fetchSingle(mixed ...$args): mixed
public function fetchSingle(#[Language('GenericSQL')] mixed ...$args): mixed
{
return $this->query($args)->fetchSingle();
}
Expand All @@ -624,7 +625,7 @@ public function fetchSingle(mixed ...$args): mixed
* Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
* @throws Exception
*/
public function fetchPairs(mixed ...$args): array
public function fetchPairs(#[Language('GenericSQL')] mixed ...$args): array
{
return $this->query($args)->fetchPairs();
}
Expand Down

0 comments on commit 60b63e3

Please sign in to comment.