Missing class import via use statement (line '24', column '37').
$this->connection = new PDO($this->dsn, $this->username, $this->password);
Avoid unused private fields such as '$database'.
private string $database = DB_NAME;
The method __construct() contains an exit expression.
die($e->getMessage());
Avoid unused private fields such as '$servername'.
private string $servername = DB_HOST;
syntax error, unexpected '?', expecting function (T_FUNCTION) or const (T_CONST)
private static ?DB $instance = null;
Each class must be in a namespace of at least one level (a top-level vendor name)
class DB
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 7 and the first side effect is on line 2.
<?php
Avoid classes with short names like DB. Configured minimum length is 3.
class DB
{
private static ?DB $instance = null;
private PDO $connection;
Method name "DB::execute_query" is not in camel caps format
public function execute_query(string $sql, array $values): bool
Method name "DB::get_scalar" is not in camel caps format
public function get_scalar(string $query): string
Method name "DB::get_query" is not in camel caps format
public function get_query(string $query, array $params = []): array
The method get_query is not named in camelCase.
public function get_query(string $query, array $params = []): array
{
$result = null;
try {
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
The method get_scalar is not named in camelCase.
public function get_scalar(string $query): string
{
$result = null;
$statement = null;
try {
The method execute_query is not named in camelCase.
public function execute_query(string $sql, array $values): bool
{
try {
$result = $this->connection->prepare($sql)->execute($values);
if (IS_DEVELOPMENT) {
There are no issues that match your filters.