Skip to content
Snippets Groups Projects
Commit b568ff01 authored by mondrake's avatar mondrake
Browse files

fix PdoTrait PHPDocs

parent f06bf6c0
No related branches found
No related tags found
4 merge requests!11355Create the database driver for MySQLi #3259709,!10263Closes #3488467,!10207Replace \PDO::FETCH_* constants to indicate fetch mode with an enumeration,!5247Enable dynamic queries to produce SQL with positional placeholders
......@@ -9,6 +9,15 @@
*/
trait PdoTrait {
/**
* Converts a FetchAs mode to a \PDO::FETCH_* constant value.
*
* @param \Drupal\Core\Database\FetchAs $mode
* The FetchAs mode.
*
* @return int
* A \PDO::FETCH_* constant value.
*/
protected function fetchAsToPdo(FetchAs $mode): int {
return match ($mode) {
FetchAs::Associative => \PDO::FETCH_ASSOC,
......@@ -19,6 +28,15 @@ protected function fetchAsToPdo(FetchAs $mode): int {
};
}
/**
* Converts a \PDO::FETCH_* constant value to a FetchAs mode.
*
* @param int $mode
* The \PDO::FETCH_* constant value.
*
* @return \Drupal\Core\Database\FetchAs
* A FetchAs mode.
*/
protected function pdoToFetchAs(int $mode): FetchAs {
return match ($mode) {
\PDO::FETCH_ASSOC => FetchAs::Associative,
......@@ -170,7 +188,7 @@ protected function clientFetchObject(?string $class = NULL, array $constructorAr
* @return array<array<scalar|null>|object|scalar|null>
* An array of results.
*/
// phpcs:ignore Drupal.Commenting.FunctionComment.InvalidReturn
// phpcs:ignore Drupal.Commenting.FunctionComment.InvalidReturn, Drupal.Commenting.FunctionComment.Missing
protected function clientFetchAll(?FetchAs $mode = NULL, int|string|null $columnOrClass = NULL, array|null $constructorArguments = NULL): array {
return match ($mode) {
FetchAs::Column => $this->getClientStatement()->fetchAll(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment