From 383dc29ba5ba2b0b8139c68979af9813a3c26104 Mon Sep 17 00:00:00 2001 From: tracer Date: Wed, 26 Jan 2022 15:18:46 +0100 Subject: [PATCH] added missing named parameters, added strict_types Signed-off-by: tracer --- src/Controller/ApiKeys.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Controller/ApiKeys.php b/src/Controller/ApiKeys.php index dc9dc7d..45479b1 100644 --- a/src/Controller/ApiKeys.php +++ b/src/Controller/ApiKeys.php @@ -1,4 +1,4 @@ -databaseConnection->getConnection()->query($sql); + $statement = $this->databaseConnection->getConnection()->query(statement: $sql); return $statement->fetchAll(mode: PDO::FETCH_ASSOC); } catch (PDOException $e) { exit($e->getMessage()); @@ -47,7 +47,7 @@ class ApiKeys "; try { - $statement = $this->databaseConnection->getConnection()->prepare($sql); + $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement->bindParam(param: ':id', var: $id); $statement->execute(); return $statement->fetch(mode: PDO::FETCH_ASSOC); @@ -70,7 +70,7 @@ class ApiKeys WHERE api_token_prefix = :prefix"; try { - $statement = $this->databaseConnection->getConnection()->prepare($sql); + $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement->bindParam(param: ':prefix', var: $prefix); $statement->execute(); return $statement->fetch(mode: PDO::FETCH_ASSOC); @@ -88,7 +88,7 @@ class ApiKeys $tokenPrefix = uniqid(); $result['tokenPrefix'] = $tokenPrefix; try { - $key = bin2hex(random_bytes(length: 24)); + $key = bin2hex(string: random_bytes(length: 24)); $result['key'] = $key; } catch (Exception $e) { echo $e->getMessage() . PHP_EOL; @@ -101,7 +101,7 @@ class ApiKeys VALUES (:name, :token_prefix, :token)"; try { - $statement = $this->databaseConnection->getConnection()->prepare($sql); + $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement->bindParam(param: ':token_prefix', var: $tokenPrefix); $statement->bindParam(param: ':token', var: $token); $statement->bindParam(param: ':name', var: $name); @@ -127,7 +127,7 @@ class ApiKeys WHERE id = :id"; try { - $statement = $this->databaseConnection->getConnection()->prepare($sql); + $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement->bindParam(param: 'id', var: $id); $statement->execute(); return $statement->rowCount();