Skip to content

Commit 933a8ce

Browse files
committed
refactor: added missing types
1 parent 0dc37b5 commit 933a8ce

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

phpmyfaq/src/phpMyFAQ/Instance/Database.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class Database
3131
/**
3232
* Instance.
3333
*
34-
* @var Driver
34+
* @var Driver|null
3535
*/
36-
private static $instance = null;
36+
private static ?Driver $instance = null;
3737

3838
/**
3939
* Database type.
@@ -44,13 +44,13 @@ class Database
4444
/**
4545
* @var Configuration
4646
*/
47-
protected $config;
47+
protected Configuration $config;
4848
/**
4949
* DROP TABLE statements.
5050
*
5151
* @var array
5252
*/
53-
private $dropTableStmts = [
53+
private array $dropTableStmts = [
5454
'DROP TABLE %sfaqadminlog',
5555
'DROP TABLE %sfaqattachment',
5656
'DROP TABLE %sfaqattachment_file',
@@ -102,12 +102,11 @@ private function __construct(Configuration $config)
102102
* Database factory.
103103
*
104104
* @param Configuration $config phpMyFAQ configuration container
105-
* @param string $type Database management system type
106-
*
107-
* @return Driver
105+
* @param string $type Database management system type
106+
* @return Driver|null
108107
* @throws Exception
109108
*/
110-
public static function factory(Configuration $config, $type)
109+
public static function factory(Configuration $config, string $type): ?Driver
111110
{
112111
self::$dbType = $type;
113112

@@ -125,9 +124,9 @@ public static function factory(Configuration $config, $type)
125124
/**
126125
* Returns the single instance.
127126
*
128-
* @return Driver
127+
* @return Driver|null
129128
*/
130-
public static function getInstance()
129+
public static function getInstance(): ?Driver
131130
{
132131
if (null === self::$instance) {
133132
$className = __CLASS__;
@@ -141,10 +140,9 @@ public static function getInstance()
141140
* Executes all DROP TABLE statements.
142141
*
143142
* @param string $prefix
144-
*
145143
* @return bool
146144
*/
147-
public function dropTables($prefix = '')
145+
public function dropTables(string $prefix = ''): bool
148146
{
149147
foreach ($this->dropTableStmts as $stmt) {
150148
$result = $this->config->getDb()->query(sprintf($stmt, $prefix));

phpmyfaq/src/phpMyFAQ/Instance/Database/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ interface Driver
3131
*
3232
* @return bool
3333
*/
34-
public function createTables(string $prefix = '');
34+
public function createTables(string $prefix = ''): bool;
3535
}

phpmyfaq/src/phpMyFAQ/Instance/Database/Mysqli.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Mysqli extends Database implements Driver
3030
/**
3131
* @var array
3232
*/
33-
private $createTableStatements = [
33+
private array $createTableStatements = [
3434
'faqadminlog' => 'CREATE TABLE %sfaqadminlog (
3535
id INT(11) NOT NULL,
3636
time INT(11) NOT NULL,
@@ -52,7 +52,7 @@ class Mysqli extends Database implements Driver
5252
mime_type VARCHAR(255) NULL,
5353
PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci',
5454

55-
'faqattachment file' => 'CREATE TABLE %sfaqattachment_file (
55+
'faqattachment_file' => 'CREATE TABLE %sfaqattachment_file (
5656
virtual_hash CHAR(32) NOT NULL,
5757
contents BLOB NOT NULL,
5858
PRIMARY KEY (virtual_hash)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci',

phpmyfaq/src/phpMyFAQ/Instance/Database/Pgsql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Pgsql extends Database implements Driver
5454
mime_type VARCHAR(255) NULL,
5555
PRIMARY KEY (id))',
5656

57-
'faqattachment file' => 'CREATE TABLE %sfaqattachment_file (
57+
'faqattachment_file' => 'CREATE TABLE %sfaqattachment_file (
5858
virtual_hash CHAR(32) NOT NULL,
5959
contents BYTEA,
6060
PRIMARY KEY (virtual_hash))',

phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlite3.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Sqlite3 extends Database implements Driver
3030
/**
3131
* @var array
3232
*/
33-
private $createTableStatements = [
33+
private array $createTableStatements = [
3434
'faqadminlog' => 'CREATE TABLE %sfaqadminlog (
3535
id INTEGER NOT NULL,
3636
time INTEGER NOT NULL,
@@ -52,7 +52,7 @@ class Sqlite3 extends Database implements Driver
5252
mime_type VARCHAR(255) NULL,
5353
PRIMARY KEY (id))',
5454

55-
'faqattachment file' => 'CREATE TABLE %sfaqattachment_file (
55+
'faqattachment_file' => 'CREATE TABLE %sfaqattachment_file (
5656
virtual_hash CHAR(32) NOT NULL,
5757
contents TEXT NOT NULL,
5858
PRIMARY KEY (virtual_hash))',
@@ -395,7 +395,7 @@ public function __construct(Configuration $config)
395395
*
396396
* @return bool
397397
*/
398-
public function createTables(string $prefix = '')
398+
public function createTables(string $prefix = ''): bool
399399
{
400400
foreach ($this->createTableStatements as $stmt) {
401401
$result = $this->config->getDb()->query(sprintf($stmt, $prefix));

phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlsrv.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* The phpMyFAQ instances database class with CREATE TABLE statements for MS SQL.
4+
* The phpMyFAQ instances database class with CREATE TABLE statements for MS SQL Server.
55
*
66
* This Source Code Form is subject to the terms of the Mozilla Public License,
77
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
@@ -30,7 +30,7 @@ class Sqlsrv extends Database implements Driver
3030
/**
3131
* @var array
3232
*/
33-
private $createTableStatements = [
33+
private array $createTableStatements = [
3434
'faqadminlog' => 'CREATE TABLE %sfaqadminlog (
3535
id INTEGER NOT NULL,
3636
time INTEGER NOT NULL,
@@ -52,7 +52,7 @@ class Sqlsrv extends Database implements Driver
5252
mime_type VARCHAR(255) NULL,
5353
PRIMARY KEY (id))',
5454

55-
'faqattachment file' => 'CREATE TABLE %sfaqattachment_file (
55+
'faqattachment_file' => 'CREATE TABLE %sfaqattachment_file (
5656
virtual_hash CHAR(32) NOT NULL,
5757
contents VARCHAR(MAX) NOT NULL,
5858
PRIMARY KEY (virtual_hash))',

0 commit comments

Comments
 (0)