Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ public function reconnectWithConfig(array $config): void
}


#[\NoDiscard]
public function getDriver(): IDriver
{
return $this->driver;
}


/** @inheritdoc */
#[\NoDiscard]
public function getConfig(): array
{
return $this->config;
Expand Down Expand Up @@ -144,6 +146,7 @@ public function queryByQueryBuilder(QueryBuilder $queryBuilder): Result


/** @inheritdoc */
#[\NoDiscard]
public function getLastInsertedId(string|Fqn|null $sequenceName = null)
{
if (!$this->connected) {
Expand All @@ -154,6 +157,7 @@ public function getLastInsertedId(string|Fqn|null $sequenceName = null)


/** @inheritdoc */
#[\NoDiscard]
public function getAffectedRows(): int
{
if (!$this->connected) {
Expand All @@ -164,6 +168,7 @@ public function getAffectedRows(): int


/** @inheritdoc */
#[\NoDiscard]
public function getPlatform(): IPlatform
{
if ($this->platform === null) {
Expand All @@ -175,6 +180,7 @@ public function getPlatform(): IPlatform


/** @inheritdoc */
#[\NoDiscard]
public function createQueryBuilder(): QueryBuilder
{
return new QueryBuilder($this->getPlatform());
Expand Down Expand Up @@ -254,6 +260,7 @@ public function rollbackTransaction(): void


/** @inheritdoc */
#[\NoDiscard]
public function getTransactionNestedIndex(): int
{
return $this->nestedTransactionIndex;
Expand Down Expand Up @@ -291,6 +298,7 @@ public function rollbackSavepoint(string $name): void


/** @inheritdoc */
#[\NoDiscard]
Comment thread
hrach marked this conversation as resolved.
Outdated
public function ping(): bool
{
if (!$this->connected) {
Expand Down
8 changes: 8 additions & 0 deletions src/IConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public function reconnect(): void;
public function reconnectWithConfig(array $config): void;


#[\NoDiscard]
public function getDriver(): IDriver;


/**
* Returns connection configuration.
* @return array<string, mixed>
*/
#[\NoDiscard]
public function getConfig(): array;


Expand Down Expand Up @@ -103,18 +105,22 @@ public function queryByQueryBuilder(QueryBuilder $queryBuilder): Result;
*
* @return int|string|null
*/
#[\NoDiscard]
public function getLastInsertedId(string|Fqn|null $sequenceName = null);


/**
* Returns number of affected rows.
*/
#[\NoDiscard]
public function getAffectedRows(): int;


#[\NoDiscard]
public function getPlatform(): IPlatform;


#[\NoDiscard]
public function createQueryBuilder(): QueryBuilder;


Expand Down Expand Up @@ -158,6 +164,7 @@ public function rollbackTransaction(): void;
* 1 = basic transaction
* >1 = nested transaction through save-points
*/
#[\NoDiscard]
public function getTransactionNestedIndex(): int;


Expand Down Expand Up @@ -189,6 +196,7 @@ public function rollbackSavepoint(string $name): void;
* $connection->reconnect();
* }
*/
#[\NoDiscard]
Comment thread
hrach marked this conversation as resolved.
Outdated
public function ping(): bool;


Expand Down
1 change: 1 addition & 0 deletions src/Platforms/Data/Fqn.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(
}


#[\NoDiscard]
public function getUnescaped(): string
{
if ($this->schema === '') {
Expand Down
17 changes: 17 additions & 0 deletions src/Platforms/IPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface IPlatform
/**
* Returns platform name.
*/
#[\NoDiscard]
public function getName(): string;


Expand All @@ -30,33 +31,38 @@ public function getName(): string;
* If no schema is provided, it uses the current schema name (search path).
* @return array<string, Table>
*/
#[\NoDiscard]
public function getTables(?string $schema = null): array;


/**
* Returns list of table columns metadata, indexed by column name.
* @return array<string, Column>
*/
#[\NoDiscard]
public function getColumns(string $table, ?string $schema = null): array;


/**
* Returns list of table foreign keys, indexed by column name.
* @return array<string, ForeignKey>
*/
#[\NoDiscard]
public function getForeignKeys(string $table, ?string $schema = null): array;


/**
* Returns primary sequence name for the table.
* If not supported nor present, returns a null.
*/
#[\NoDiscard]
public function getPrimarySequenceName(string $table, ?string $schema = null): ?string;


/**
* Formats string value to SQL string.
*/
#[\NoDiscard]
public function formatString(string $value): string;


Expand All @@ -65,67 +71,78 @@ public function formatString(string $value): string;
* @param int $mode -1 = left, 0 = both, 1 = right
* @return mixed
*/
#[\NoDiscard]
public function formatStringLike(string $value, int $mode);


/**
* Formats Json value to SQL string.
*/
#[\NoDiscard]
public function formatJson(mixed $value): string;


/**
* Formats boolean to SQL string.
*/
#[\NoDiscard]
public function formatBool(bool $value): string;


/**
* Formats column or dot separated identifier to SQL string.
*/
#[\NoDiscard]
public function formatIdentifier(string $value): string;


/**
* Formats time-zone aware DateTimeInterface instance to SQL string.
*/
#[\NoDiscard]
public function formatDateTime(DateTimeInterface $value): string;


/**
* Formats local DateTimeInterface instance to SQL string.
*/
#[\NoDiscard]
public function formatLocalDateTime(DateTimeInterface $value): string;


/**
* Formats local date from DateTimeInterface instance to SQL string.
*/
#[\NoDiscard]
public function formatLocalDate(DateTimeInterface $value): string;


/**
* Formats DateInterval to SQL string.
*/
#[\NoDiscard]
public function formatDateInterval(DateInterval $value): string;


/**
* Formats blob value to SQL string.
*/
#[\NoDiscard]
public function formatBlob(string $value): string;


/**
* Formats LIMIT & OFFSET values to SQL string.
*/
#[\NoDiscard]
public function formatLimitOffset(?int $limit, ?int $offset): string;


/**
* Returns SQL file parser
* !!!This function requires nextras/multi-query-parser dependency!!!
*/
#[\NoDiscard]
public function createMultiQueryParser(): IMultiQueryParser;


Expand Down
6 changes: 6 additions & 0 deletions src/Result/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@
}


#[\NoDiscard]
public function getAdapter(): IResultAdapter
{
return $this->adapter;
}


#[\NoDiscard]
Comment thread
hrach marked this conversation as resolved.
Outdated
public function fetch(): ?Row
{
$data = $this->adapter->fetch();
Expand Down Expand Up @@ -111,6 +113,7 @@
/**
* @return mixed|null
*/
#[\NoDiscard]
public function fetchField(int $column = 0)
{
if (($row = $this->fetch()) !== null) { // = intentionally
Expand All @@ -124,6 +127,7 @@
/**
* @return Row[]
*/
#[\NoDiscard]
public function fetchAll(): array
{
return iterator_to_array($this);
Expand All @@ -133,6 +137,7 @@
/**
* @return array<mixed>
*/
#[\NoDiscard]
public function fetchPairs(?string $key = null, ?string $value = null): array
{
if ($key === null && $value === null) {
Expand Down Expand Up @@ -164,6 +169,7 @@
* Returns list of column names in result.
* @return list<string>
*/
#[\NoDiscard]
public function getColumns(): array
{
return array_map(
Expand All @@ -190,7 +196,7 @@

public function next(): void
{
$this->fetch();

Check failure on line 199 in src/Result/Result.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5)

Call to method Nextras\Dbal\Result\Result::fetch() on a separate line discards return value.
}


Expand All @@ -203,7 +209,7 @@
public function rewind(): void
{
$this->seek(0);
$this->fetch();

Check failure on line 212 in src/Result/Result.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5)

Call to method Nextras\Dbal\Result\Result::fetch() on a separate line discards return value.
}


Expand Down
2 changes: 2 additions & 0 deletions src/Result/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(array $data)
/**
* @return array<string, mixed>
*/
#[\NoDiscard]
public function toArray(): array
{
return (array) $this;
Expand All @@ -36,6 +37,7 @@ public function __get(string $name): mixed
}


#[\NoDiscard]
public function getNthField(int $offset): mixed
{
$slice = array_slice((array) $this, $offset, 1);
Expand Down
Loading
Loading