';
$class = 'row1';
- foreach (array_values($row) as $val)
+ foreach ($row as $val)
{
$class = ($class == 'row1') ? 'row2' : 'row1';
$this->html_hold .= '' . (($val) ? $val : ' ') . ' | ';
@@ -1216,6 +1292,16 @@ abstract class driver implements driver_interface
return true;
}
+ /**
+ * Build db-specific report
+ *
+ * @param string $mode 'start' to add to report, 'fromcache' to output it
+ * @param string $query Query to add to sql report
+ *
+ * @return void
+ */
+ abstract protected function _sql_report(string $mode, string $query = ''): void;
+
/**
* {@inheritDoc}
*/
diff --git a/phpBB/phpbb/db/driver/driver_interface.php b/phpBB/phpbb/db/driver/driver_interface.php
index e269fac585..54e3457d3f 100644
--- a/phpBB/phpbb/db/driver/driver_interface.php
+++ b/phpBB/phpbb/db/driver/driver_interface.php
@@ -180,7 +180,7 @@ interface driver_interface
* Return on error or display error message
*
* @param bool $fail Should we return on errors, or stop
- * @return null
+ * @return void
*/
public function sql_return_on_error($fail = false);
@@ -190,9 +190,9 @@ interface driver_interface
* @param string $query Should be on of the following strings:
* INSERT, INSERT_SELECT, UPDATE, SELECT, DELETE
* @param array $assoc_ary Array with "column => value" pairs
- * @return string A SQL statement like "c1 = 'a' AND c2 = 'b'"
+ * @return string|false A SQL statement like "c1 = 'a' AND c2 = 'b'", false on invalid assoc_ary
*/
- public function sql_build_array($query, $assoc_ary = array());
+ public function sql_build_array($query, $assoc_ary = []);
/**
* Fetch all rows
@@ -291,7 +291,7 @@ interface driver_interface
/**
* Get last inserted id after insert statement
*
- * @return string Autoincrement value of the last inserted row
+ * @return int|false Autoincrement value of the last inserted row
*/
public function sql_nextid();
@@ -299,7 +299,7 @@ interface driver_interface
* Add to query count
*
* @param bool $cached Is this query cached?
- * @return null
+ * @return void
*/
public function sql_add_num_queries($cached = false);
@@ -365,7 +365,7 @@ interface driver_interface
*
* @param mixed $query_id Already executed query result,
* if false, the last query will be used.
- * @return null
+ * @return void
*/
public function sql_freeresult($query_id = false);
diff --git a/phpBB/phpbb/db/driver/factory.php b/phpBB/phpbb/db/driver/factory.php
index b2a5707120..d282aa78e6 100644
--- a/phpBB/phpbb/db/driver/factory.php
+++ b/phpBB/phpbb/db/driver/factory.php
@@ -49,7 +49,9 @@ class factory implements driver_interface
{
if ($this->driver === null)
{
- $this->driver = $this->container->get('dbal.conn.driver');
+ /** @var driver_interface $driver */
+ $driver = $this->container->get('dbal.conn.driver');
+ $this->driver = $driver;
}
return $this->driver;
@@ -238,13 +240,13 @@ class factory implements driver_interface
*/
public function sql_return_on_error($fail = false)
{
- return $this->get_driver()->sql_return_on_error($fail);
+ $this->get_driver()->sql_return_on_error($fail);
}
/**
* {@inheritdoc}
*/
- public function sql_build_array($query, $assoc_ary = array())
+ public function sql_build_array($query, $assoc_ary = [])
{
return $this->get_driver()->sql_build_array($query, $assoc_ary);
}
@@ -326,7 +328,7 @@ class factory implements driver_interface
*/
public function sql_add_num_queries($cached = false)
{
- return $this->get_driver()->sql_add_num_queries($cached);
+ $this->get_driver()->sql_add_num_queries($cached);
}
/**
@@ -374,7 +376,7 @@ class factory implements driver_interface
*/
public function sql_freeresult($query_id = false)
{
- return $this->get_driver()->sql_freeresult($query_id);
+ $this->get_driver()->sql_freeresult($query_id);
}
/**
diff --git a/phpBB/phpbb/db/driver/mssql_base.php b/phpBB/phpbb/db/driver/mssql_base.php
index c48f7d42a6..747df00bee 100644
--- a/phpBB/phpbb/db/driver/mssql_base.php
+++ b/phpBB/phpbb/db/driver/mssql_base.php
@@ -43,19 +43,17 @@ abstract class mssql_base extends \phpbb\db\driver\driver
}
/**
- * Build LIKE expression
- * @access private
+ * {@inheritDoc}
*/
- function _sql_like_expression($expression)
+ protected function _sql_like_expression(string $expression): string
{
return $expression . " ESCAPE '\\'";
}
/**
- * Build NOT LIKE expression
- * @access private
+ * {@inheritDoc}
*/
- function _sql_not_like_expression($expression)
+ protected function _sql_not_like_expression(string $expression): string
{
return $expression . " ESCAPE '\\'";
}
@@ -68,15 +66,6 @@ abstract class mssql_base extends \phpbb\db\driver\driver
return 'CONVERT(BIGINT, ' . $expression . ')';
}
- /**
- * Build db-specific query data
- * @access private
- */
- function _sql_custom_build($stage, $data)
- {
- return $data;
- }
-
/**
* {@inheritDoc}
*/
diff --git a/phpBB/phpbb/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php
index 06cdce7a15..211b98fc7e 100644
--- a/phpBB/phpbb/db/driver/mssql_odbc.php
+++ b/phpBB/phpbb/db/driver/mssql_odbc.php
@@ -24,7 +24,6 @@ namespace phpbb\db\driver;
*/
class mssql_odbc extends \phpbb\db\driver\mssql_base
{
- var $last_query_text = '';
var $connect_error = '';
/**
@@ -112,31 +111,27 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
if ($raw)
{
- return $this->sql_server_version;
+ return (string) $this->sql_server_version;
}
return ($this->sql_server_version) ? 'MSSQL (ODBC)
' . $this->sql_server_version : 'MSSQL (ODBC)';
}
/**
- * SQL Transaction
- * @access private
+ * {@inheritDoc}
*/
- function _sql_transaction($status = 'begin')
+ protected function _sql_transaction(string $status = 'begin'): bool
{
switch ($status)
{
case 'begin':
- return @odbc_exec($this->db_connect_id, 'BEGIN TRANSACTION');
- break;
+ return (bool) @odbc_exec($this->db_connect_id, 'BEGIN TRANSACTION');
case 'commit':
- return @odbc_exec($this->db_connect_id, 'COMMIT TRANSACTION');
- break;
+ return (bool) @odbc_exec($this->db_connect_id, 'COMMIT TRANSACTION');
case 'rollback':
- return @odbc_exec($this->db_connect_id, 'ROLLBACK TRANSACTION');
- break;
+ return (bool) @odbc_exec($this->db_connect_id, 'ROLLBACK TRANSACTION');
}
return true;
@@ -209,9 +204,9 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
}
/**
- * Build LIMIT query
- */
- function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
+ * {@inheritDoc}
+ */
+ protected function _sql_query_limit(string $query, int $total, int $offset = 0, int $cache_ttl = 0)
{
$this->query_result = false;
@@ -303,23 +298,19 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
- return $cache->sql_freeresult($query_id);
+ $cache->sql_freeresult($query_id);
}
-
- if (isset($this->open_queries[(int) $query_id]))
+ else if (isset($this->open_queries[(int) $query_id]))
{
unset($this->open_queries[(int) $query_id]);
- return odbc_free_result($query_id);
+ odbc_free_result($query_id);
}
-
- return false;
}
/**
- * return sql error array
- * @access private
+ * {@inheritDoc}
*/
- function _sql_error()
+ protected function _sql_error(): array
{
if (function_exists('odbc_errormsg'))
{
@@ -340,19 +331,18 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
}
/**
- * Close sql connection
- * @access private
- */
- function _sql_close()
+ * {@inheritDoc}
+ */
+ protected function _sql_close(): bool
{
- return @odbc_close($this->db_connect_id);
+ @odbc_close($this->db_connect_id);
+ return true;
}
/**
- * Build db-specific report
- * @access private
+ * {@inheritDoc}
*/
- function _sql_report($mode, $query = '')
+ protected function _sql_report(string $mode, string $query = ''): void
{
switch ($mode)
{
diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php
index 30ef9d9bc4..62a5f51772 100644
--- a/phpBB/phpbb/db/driver/mssqlnative.php
+++ b/phpBB/phpbb/db/driver/mssqlnative.php
@@ -23,10 +23,12 @@ namespace phpbb\db\driver;
class mssqlnative extends \phpbb\db\driver\mssql_base
{
var $m_insert_id = null;
- var $last_query_text = '';
var $query_options = array();
var $connect_error = '';
+ /** @var string|false Last error result or false if no last error set */
+ private $last_error_result = false;
+
/**
* {@inheritDoc}
*/
@@ -92,24 +94,20 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
}
/**
- * SQL Transaction
- * @access private
+ * {@inheritDoc}
*/
- function _sql_transaction($status = 'begin')
+ protected function _sql_transaction(string $status = 'begin'): bool
{
switch ($status)
{
case 'begin':
return sqlsrv_begin_transaction($this->db_connect_id);
- break;
case 'commit':
return sqlsrv_commit($this->db_connect_id);
- break;
case 'rollback':
return sqlsrv_rollback($this->db_connect_id);
- break;
}
return true;
}
@@ -182,9 +180,9 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
}
/**
- * Build LIMIT query
- */
- function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
+ * {@inheritDoc}
+ */
+ protected function _sql_query_limit(string $query, int $total, int $offset = 0, int $cache_ttl = 0)
{
$this->query_result = false;
@@ -280,7 +278,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
if ($result_id)
{
$row = sqlsrv_fetch_array($result_id);
- $id = $row[0];
+ $id = isset($row[0]) ? (int) $row[0] : false;
sqlsrv_free_stmt($result_id);
return $id;
}
@@ -304,23 +302,19 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
- return $cache->sql_freeresult($query_id);
+ $cache->sql_freeresult($query_id);
}
-
- if (isset($this->open_queries[(int) $query_id]))
+ else if (isset($this->open_queries[(int) $query_id]))
{
unset($this->open_queries[(int) $query_id]);
- return sqlsrv_free_stmt($query_id);
+ sqlsrv_free_stmt($query_id);
}
-
- return false;
}
/**
- * return sql error array
- * @access private
+ * {@inheritDoc}
*/
- function _sql_error()
+ protected function _sql_error(): array
{
if (function_exists('sqlsrv_errors'))
{
@@ -342,7 +336,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
}
else
{
- $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
+ $error = $this->last_error_result ?: '';
}
$error = array(
@@ -362,19 +356,17 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
}
/**
- * Close sql connection
- * @access private
- */
- function _sql_close()
+ * {@inheritDoc}
+ */
+ protected function _sql_close(): bool
{
return @sqlsrv_close($this->db_connect_id);
}
/**
- * Build db-specific report
- * @access private
+ * {@inheritDoc}
*/
- function _sql_report($mode, $query = '')
+ protected function _sql_report(string $mode, string $query = ''): void
{
switch ($mode)
{
diff --git a/phpBB/phpbb/db/driver/mysql_base.php b/phpBB/phpbb/db/driver/mysql_base.php
index 5e0b359134..481d4c7992 100644
--- a/phpBB/phpbb/db/driver/mysql_base.php
+++ b/phpBB/phpbb/db/driver/mysql_base.php
@@ -27,9 +27,9 @@ abstract class mysql_base extends \phpbb\db\driver\driver
}
/**
- * Build LIMIT query
- */
- function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
+ * {@inheritDoc}
+ */
+ protected function _sql_query_limit(string $query, int $total, int $offset = 0, int $cache_ttl = 0)
{
$this->query_result = false;
@@ -103,34 +103,13 @@ abstract class mysql_base extends \phpbb\db\driver\driver
}
/**
- * Build LIKE expression
- * @access private
+ * {@inheritDoc}
*/
- function _sql_like_expression($expression)
+ protected function _sql_custom_build(string $stage, $data)
{
- return $expression;
- }
-
- /**
- * Build NOT LIKE expression
- * @access private
- */
- function _sql_not_like_expression($expression)
- {
- return $expression;
- }
-
- /**
- * Build db-specific query data
- * @access private
- */
- function _sql_custom_build($stage, $data)
- {
- switch ($stage)
+ if ($stage === 'FROM' && is_string($data))
{
- case 'FROM':
- $data = '(' . $data . ')';
- break;
+ $data = '(' . $data . ')';
}
return $data;
diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php
index 1b7f6252f6..e2f6d20033 100644
--- a/phpBB/phpbb/db/driver/mysqli.php
+++ b/phpBB/phpbb/db/driver/mysqli.php
@@ -69,7 +69,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
if ($this->db_connect_id && $this->dbname != '')
{
// Disable loading local files on client side
- @mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, false);
+ @mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, 0);
/*
* As of PHP 8.1 MySQLi default error mode is set to MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT
@@ -143,32 +143,28 @@ class mysqli extends \phpbb\db\driver\mysql_base
}
}
- return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
+ return ($raw) ? (string) $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
}
/**
- * SQL Transaction
- * @access private
+ * {@inheritDoc}
*/
- function _sql_transaction($status = 'begin')
+ protected function _sql_transaction(string $status = 'begin'): bool
{
switch ($status)
{
case 'begin':
return @mysqli_autocommit($this->db_connect_id, false);
- break;
case 'commit':
$result = @mysqli_commit($this->db_connect_id);
@mysqli_autocommit($this->db_connect_id, true);
return $result;
- break;
case 'rollback':
$result = @mysqli_rollback($this->db_connect_id);
@mysqli_autocommit($this->db_connect_id, true);
return $result;
- break;
}
return true;
@@ -293,7 +289,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
*/
function sql_nextid()
{
- return ($this->db_connect_id) ? @mysqli_insert_id($this->db_connect_id) : false;
+ return ($this->db_connect_id) ? (int) @mysqli_insert_id($this->db_connect_id) : false;
}
/**
@@ -310,20 +306,12 @@ class mysqli extends \phpbb\db\driver\mysql_base
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
- return $cache->sql_freeresult($query_id);
+ $cache->sql_freeresult($query_id);
}
-
- if (!$query_id)
+ else if ($query_id && $query_id !== true)
{
- return false;
+ mysqli_free_result($query_id);
}
-
- if ($query_id === true)
- {
- return true;
- }
-
- return mysqli_free_result($query_id);
}
/**
@@ -335,10 +323,9 @@ class mysqli extends \phpbb\db\driver\mysql_base
}
/**
- * return sql error array
- * @access private
+ * {@inheritDoc}
*/
- function _sql_error()
+ protected function _sql_error(): array
{
if ($this->db_connect_id)
{
@@ -366,19 +353,17 @@ class mysqli extends \phpbb\db\driver\mysql_base
}
/**
- * Close sql connection
- * @access private
- */
- function _sql_close()
+ * {@inheritDoc}
+ */
+ protected function _sql_close(): bool
{
return @mysqli_close($this->db_connect_id);
}
/**
- * Build db-specific report
- * @access private
+ * {@inheritDoc}
*/
- function _sql_report($mode, $query = '')
+ protected function _sql_report(string $mode, string $query = ''): void
{
static $test_prof;
diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php
index 04af0a0a9c..ee4ad9b5f5 100644
--- a/phpBB/phpbb/db/driver/oracle.php
+++ b/phpBB/phpbb/db/driver/oracle.php
@@ -18,9 +18,11 @@ namespace phpbb\db\driver;
*/
class oracle extends \phpbb\db\driver\driver
{
- var $last_query_text = '';
var $connect_error = '';
+ /** @var array|false Last error result or false if no last error set */
+ private $last_error_result = false;
+
/**
* {@inheritDoc}
*/
@@ -107,24 +109,20 @@ class oracle extends \phpbb\db\driver\driver
}
/**
- * SQL Transaction
- * @access private
+ * {@inheritDoc}
*/
- function _sql_transaction($status = 'begin')
+ protected function _sql_transaction(string $status = 'begin'): bool
{
switch ($status)
{
case 'begin':
return true;
- break;
case 'commit':
return @oci_commit($this->db_connect_id);
- break;
case 'rollback':
return @oci_rollback($this->db_connect_id);
- break;
}
return true;
@@ -465,9 +463,9 @@ class oracle extends \phpbb\db\driver\driver
}
/**
- * Build LIMIT query
+ * {@inheritDoc}
*/
- function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
+ protected function _sql_query_limit(string $query, int $total, int $offset = 0, int $cache_ttl = 0)
{
$this->query_result = false;
@@ -621,16 +619,13 @@ class oracle extends \phpbb\db\driver\driver
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
- return $cache->sql_freeresult($query_id);
+ $cache->sql_freeresult($query_id);
}
-
- if (isset($this->open_queries[(int) $query_id]))
+ else if (isset($this->open_queries[(int) $query_id]))
{
unset($this->open_queries[(int) $query_id]);
- return oci_free_statement($query_id);
+ oci_free_statement($query_id);
}
-
- return false;
}
/**
@@ -642,28 +637,21 @@ class oracle extends \phpbb\db\driver\driver
}
/**
- * Build LIKE expression
- * @access private
+ * {@inheritDoc}
*/
- function _sql_like_expression($expression)
+ protected function _sql_like_expression(string $expression): string
{
return $expression . " ESCAPE '\\'";
}
/**
- * Build NOT LIKE expression
- * @access private
+ * {@inheritDoc}
*/
- function _sql_not_like_expression($expression)
+ protected function _sql_not_like_expression(string $expression): string
{
return $expression . " ESCAPE '\\'";
}
- function _sql_custom_build($stage, $data)
- {
- return $data;
- }
-
function _sql_bit_and($column_name, $bit, $compare = '')
{
return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : '');
@@ -675,10 +663,9 @@ class oracle extends \phpbb\db\driver\driver
}
/**
- * return sql error array
- * @access private
+ * {@inheritDoc}
*/
- function _sql_error()
+ protected function _sql_error(): array
{
if (function_exists('oci_error'))
{
@@ -692,7 +679,7 @@ class oracle extends \phpbb\db\driver\driver
}
else
{
- $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
+ $error = $this->last_error_result ?: ['message' => '', 'code' => ''];
}
}
else
@@ -707,19 +694,17 @@ class oracle extends \phpbb\db\driver\driver
}
/**
- * Close sql connection
- * @access private
- */
- function _sql_close()
+ * {@inheritDoc}
+ */
+ protected function _sql_close(): bool
{
return @oci_close($this->db_connect_id);
}
/**
- * Build db-specific report
- * @access private
+ * {@inheritDoc}
*/
- function _sql_report($mode, $query = '')
+ protected function _sql_report(string $mode, string $query = ''): void
{
switch ($mode)
{
@@ -795,8 +780,6 @@ class oracle extends \phpbb\db\driver\driver
$success = @oci_execute($result, OCI_DEFAULT);
if ($success)
{
- array();
-
while ($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS))
{
// Take the time spent on parsing rows into account
diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php
index 3ee4b2b00e..63ebdbf994 100644
--- a/phpBB/phpbb/db/driver/postgres.php
+++ b/phpBB/phpbb/db/driver/postgres.php
@@ -20,7 +20,6 @@ namespace phpbb\db\driver;
class postgres extends \phpbb\db\driver\driver
{
var $multi_insert = true;
- var $last_query_text = '';
var $connect_error = '';
/**
@@ -137,28 +136,24 @@ class postgres extends \phpbb\db\driver\driver
}
}
- return ($raw) ? $this->sql_server_version : 'PostgreSQL ' . $this->sql_server_version;
+ return ($raw) ? (string) $this->sql_server_version : 'PostgreSQL ' . $this->sql_server_version;
}
/**
- * SQL Transaction
- * @access private
+ * {@inheritDoc}
*/
- function _sql_transaction($status = 'begin')
+ protected function _sql_transaction(string $status = 'begin'): bool
{
switch ($status)
{
case 'begin':
- return @pg_query($this->db_connect_id, 'BEGIN');
- break;
+ return @pg_query($this->db_connect_id, 'BEGIN') !== false;
case 'commit':
- return @pg_query($this->db_connect_id, 'COMMIT');
- break;
+ return @pg_query($this->db_connect_id, 'COMMIT') !== false;
case 'rollback':
- return @pg_query($this->db_connect_id, 'ROLLBACK');
- break;
+ return @pg_query($this->db_connect_id, 'ROLLBACK') !== false;
}
return true;
@@ -233,18 +228,9 @@ class postgres extends \phpbb\db\driver\driver
}
/**
- * Build db-specific query data
- * @access private
+ * {@inheritDoc}
*/
- function _sql_custom_build($stage, $data)
- {
- return $data;
- }
-
- /**
- * Build LIMIT query
- */
- function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
+ protected function _sql_query_limit(string $query, int $total, int $offset = 0, int $cache_ttl = 0)
{
$this->query_result = false;
@@ -385,16 +371,13 @@ class postgres extends \phpbb\db\driver\driver
$safe_query_id = $this->clean_query_id($query_id);
if ($cache && !is_object($query_id) && $cache->sql_exists($safe_query_id))
{
- return $cache->sql_freeresult($safe_query_id);
+ $cache->sql_freeresult($safe_query_id);
}
-
- if (isset($this->open_queries[$safe_query_id]))
+ else if (isset($this->open_queries[$safe_query_id]))
{
unset($this->open_queries[$safe_query_id]);
- return pg_free_result($query_id);
+ pg_free_result($query_id);
}
-
- return false;
}
/**
@@ -405,24 +388,6 @@ class postgres extends \phpbb\db\driver\driver
return @pg_escape_string($msg);
}
- /**
- * Build LIKE expression
- * @access private
- */
- function _sql_like_expression($expression)
- {
- return $expression;
- }
-
- /**
- * Build NOT LIKE expression
- * @access private
- */
- function _sql_not_like_expression($expression)
- {
- return $expression;
- }
-
/**
* {@inheritDoc}
*/
@@ -440,10 +405,9 @@ class postgres extends \phpbb\db\driver\driver
}
/**
- * return sql error array
- * @access private
+ * {@inheritDoc}
*/
- function _sql_error()
+ protected function _sql_error(): array
{
// pg_last_error only works when there is an established connection.
// Connection errors have to be tracked by us manually.
@@ -463,10 +427,9 @@ class postgres extends \phpbb\db\driver\driver
}
/**
- * Close sql connection
- * @access private
- */
- function _sql_close()
+ * {@inheritDoc}
+ */
+ protected function _sql_close(): bool
{
// Released resources are already closed, return true in this case
if (!is_resource($this->db_connect_id))
@@ -477,10 +440,9 @@ class postgres extends \phpbb\db\driver\driver
}
/**
- * Build db-specific report
- * @access private
+ * {@inheritDoc}
*/
- function _sql_report($mode, $query = '')
+ protected function _sql_report(string $mode, string $query = ''): void
{
switch ($mode)
{
diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php
index 61b87d86b5..0be8b14104 100644
--- a/phpBB/phpbb/db/driver/sqlite3.php
+++ b/phpBB/phpbb/db/driver/sqlite3.php
@@ -83,27 +83,20 @@ class sqlite3 extends \phpbb\db\driver\driver
}
/**
- * SQL Transaction
- *
- * @param string $status Should be one of the following strings:
- * begin, commit, rollback
- * @return bool Success/failure of the transaction query
+ * {@inheritDoc}
*/
- protected function _sql_transaction($status = 'begin')
+ protected function _sql_transaction(string $status = 'begin'): bool
{
switch ($status)
{
case 'begin':
return $this->dbo->exec('BEGIN IMMEDIATE');
- break;
case 'commit':
return $this->dbo->exec('COMMIT');
- break;
case 'rollback':
return @$this->dbo->exec('ROLLBACK');
- break;
}
return true;
@@ -188,16 +181,9 @@ class sqlite3 extends \phpbb\db\driver\driver
}
/**
- * Build LIMIT query
- *
- * @param string $query The SQL query to execute
- * @param int $total The number of rows to select
- * @param int $offset
- * @param int $cache_ttl Either 0 to avoid caching or
- * the time in seconds which the result shall be kept in cache
- * @return mixed Buffered, seekable result handle, false on error
+ * {@inheritDoc}
*/
- protected function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
+ protected function _sql_query_limit(string $query, int $total, int $offset = 0, int $cache_ttl = 0)
{
$this->query_result = false;
@@ -263,12 +249,13 @@ class sqlite3 extends \phpbb\db\driver\driver
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
- return $cache->sql_freeresult($query_id);
+ $cache->sql_freeresult($query_id);
+ return;
}
if ($query_id)
{
- return @$query_id->finalize();
+ @$query_id->finalize();
}
}
@@ -315,11 +302,9 @@ class sqlite3 extends \phpbb\db\driver\driver
}
/**
- * return sql error array
- *
- * @return array
+ * {@inheritDoc}
*/
- protected function _sql_error()
+ protected function _sql_error(): array
{
if (class_exists('SQLite3', false) && isset($this->dbo))
{
@@ -340,24 +325,9 @@ class sqlite3 extends \phpbb\db\driver\driver
}
/**
- * Build db-specific query data
- *
- * @param string $stage Available stages: FROM, WHERE
- * @param mixed $data A string containing the CROSS JOIN query or an array of WHERE clauses
- *
- * @return string The db-specific query fragment
+ * {@inheritDoc}
*/
- protected function _sql_custom_build($stage, $data)
- {
- return $data;
- }
-
- /**
- * Close sql connection
- *
- * @return bool False if failure
- */
- protected function _sql_close()
+ protected function _sql_close(): bool
{
return $this->dbo->close();
}
@@ -365,12 +335,13 @@ class sqlite3 extends \phpbb\db\driver\driver
/**
* Build db-specific report
*
- * @param string $mode Available modes: display, start, stop,
+ * @param string $mode Available modes: display, start, stop,
* add_select_row, fromcache, record_fromcache
- * @param string $query The Query that should be explained
- * @return mixed Either a full HTML page, boolean or null
+ * @param string $query The Query that should be explained
+ *
+ * @return void Either writes HTML to html_hold or outputs a full HTML page
*/
- protected function _sql_report($mode, $query = '')
+ protected function _sql_report(string $mode, string $query = ''): void
{
switch ($mode)
{
diff --git a/phpBB/phpbb/db/extractor/factory.php b/phpBB/phpbb/db/extractor/factory.php
index f27aae720f..7499baba09 100644
--- a/phpBB/phpbb/db/extractor/factory.php
+++ b/phpBB/phpbb/db/extractor/factory.php
@@ -51,25 +51,30 @@ class factory
// Return the appropriate DB extractor
if ($this->db instanceof \phpbb\db\driver\mssql_base)
{
- return $this->container->get('dbal.extractor.extractors.mssql_extractor');
+ $extractor = $this->container->get('dbal.extractor.extractors.mssql_extractor');
}
else if ($this->db instanceof \phpbb\db\driver\mysql_base)
{
- return $this->container->get('dbal.extractor.extractors.mysql_extractor');
+ $extractor = $this->container->get('dbal.extractor.extractors.mysql_extractor');
}
else if ($this->db instanceof \phpbb\db\driver\oracle)
{
- return $this->container->get('dbal.extractor.extractors.oracle_extractor');
+ $extractor = $this->container->get('dbal.extractor.extractors.oracle_extractor');
}
else if ($this->db instanceof \phpbb\db\driver\postgres)
{
- return $this->container->get('dbal.extractor.extractors.postgres_extractor');
+ $extractor = $this->container->get('dbal.extractor.extractors.postgres_extractor');
}
else if ($this->db instanceof \phpbb\db\driver\sqlite3)
{
- return $this->container->get('dbal.extractor.extractors.sqlite3_extractor');
+ $extractor = $this->container->get('dbal.extractor.extractors.sqlite3_extractor');
+ }
+ else
+ {
+ throw new \InvalidArgumentException('Invalid database driver given');
}
- throw new \InvalidArgumentException('Invalid database driver given');
+ /** @var \phpbb\db\extractor\extractor_interface $extractor */
+ return $extractor;
}
}
diff --git a/phpBB/phpbb/db/extractor/mssql_extractor.php b/phpBB/phpbb/db/extractor/mssql_extractor.php
index 64922c1124..264312a4c4 100644
--- a/phpBB/phpbb/db/extractor/mssql_extractor.php
+++ b/phpBB/phpbb/db/extractor/mssql_extractor.php
@@ -20,7 +20,7 @@ class mssql_extractor extends base_extractor
/**
* Writes closing line(s) to database backup
*
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
public function write_end()
@@ -194,12 +194,12 @@ class mssql_extractor extends base_extractor
* Extracts data from database table (for MSSQL Native driver)
*
* @param string $table_name name of the database table
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
protected function write_data_mssqlnative($table_name)
{
- if (!$this->is_initialized)
+ if (!$this->is_initialized || !$this->db instanceof \phpbb\db\driver\mssqlnative)
{
throw new extractor_not_initialized_exception();
}
@@ -310,7 +310,7 @@ class mssql_extractor extends base_extractor
* Extracts data from database table (for ODBC driver)
*
* @param string $table_name name of the database table
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
protected function write_data_odbc($table_name)
diff --git a/phpBB/phpbb/db/extractor/mysql_extractor.php b/phpBB/phpbb/db/extractor/mysql_extractor.php
index 6d230a6e35..386130e4ae 100644
--- a/phpBB/phpbb/db/extractor/mysql_extractor.php
+++ b/phpBB/phpbb/db/extractor/mysql_extractor.php
@@ -86,7 +86,7 @@ class mysql_extractor extends base_extractor
* Extracts data from database table (for MySQLi driver)
*
* @param string $table_name name of the database table
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
protected function write_data_mysqli($table_name)
@@ -176,7 +176,7 @@ class mysql_extractor extends base_extractor
* Extracts database table structure (for MySQLi or MySQL 3.23.20+)
*
* @param string $table_name name of the database table
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
protected function new_write_table($table_name)
@@ -201,7 +201,7 @@ class mysql_extractor extends base_extractor
* Extracts database table structure (for MySQL versions older than 3.23.20)
*
* @param string $table_name name of the database table
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
protected function old_write_table($table_name)
diff --git a/phpBB/phpbb/db/extractor/oracle_extractor.php b/phpBB/phpbb/db/extractor/oracle_extractor.php
index bc43a37b10..879e377043 100644
--- a/phpBB/phpbb/db/extractor/oracle_extractor.php
+++ b/phpBB/phpbb/db/extractor/oracle_extractor.php
@@ -184,12 +184,12 @@ class oracle_extractor extends base_extractor
FROM $table_name";
$result = $this->db->sql_query($sql);
- $i_num_fields = ocinumcols($result);
+ $i_num_fields = oci_num_fields($result);
for ($i = 0; $i < $i_num_fields; $i++)
{
- $ary_type[$i] = ocicolumntype($result, $i + 1);
- $ary_name[$i] = ocicolumnname($result, $i + 1);
+ $ary_type[$i] = oci_field_type($result, $i + 1);
+ $ary_name[$i] = oci_field_name($result, $i + 1);
}
while ($row = $this->db->sql_fetchrow($result))
diff --git a/phpBB/phpbb/db/extractor/postgres_extractor.php b/phpBB/phpbb/db/extractor/postgres_extractor.php
index 2b271104e8..32267ead4a 100644
--- a/phpBB/phpbb/db/extractor/postgres_extractor.php
+++ b/phpBB/phpbb/db/extractor/postgres_extractor.php
@@ -323,7 +323,7 @@ class postgres_extractor extends base_extractor
/**
* Writes closing line(s) to database backup
*
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
public function write_end()
diff --git a/phpBB/phpbb/db/extractor/sqlite3_extractor.php b/phpBB/phpbb/db/extractor/sqlite3_extractor.php
index 92ce9bdcc6..86bb25edde 100644
--- a/phpBB/phpbb/db/extractor/sqlite3_extractor.php
+++ b/phpBB/phpbb/db/extractor/sqlite3_extractor.php
@@ -135,7 +135,7 @@ class sqlite3_extractor extends base_extractor
/**
* Writes closing line(s) to database backup
*
- * @return null
+ * @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
public function write_end()
diff --git a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php
index 407bd39ce6..969b1e227e 100644
--- a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php
+++ b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php
@@ -122,6 +122,8 @@ class soft_delete_mod_convert extends container_aware_migration
*/
protected function get_content_visibility()
{
- return $this->container->get('content.visibility');
+ /** @var \phpbb\content_visibility $content_visibility */
+ $content_visibility = $this->container->get('content.visibility');
+ return $content_visibility;
}
}
diff --git a/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php b/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php
index 7f8acc0cd5..17f4152f05 100644
--- a/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php
+++ b/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php
@@ -49,17 +49,21 @@ class remove_duplicate_migrations extends \phpbb\db\migration\migration
$this->db->sql_freeresult($result);
+ /**
+ * @var string $name
+ * @var array $migration
+ */
foreach ($migration_state as $name => $migration)
{
$prepended_name = ($name[0] == '\\' ? '' : '\\') . $name;
$prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name;
- if ($prepended_name != $name && isset($migration_state[$prepended_name]) && $migration_state[$prepended_name]['migration_depends_on'] == $migration_state[$name]['migration_depends_on'])
+ if ($prepended_name != $name && isset($migration_state[$prepended_name]) && $migration_state[$prepended_name]['migration_depends_on'] == $migration['migration_depends_on'])
{
$duplicate_migrations[] = $name;
unset($migration_state[$prepended_name]);
}
- else if ($prefixless_name != $name && isset($migration_state[$prefixless_name]) && $migration_state[$prefixless_name]['migration_depends_on'] == $migration_state[$name]['migration_depends_on'])
+ else if ($prefixless_name != $name && isset($migration_state[$prefixless_name]) && $migration_state[$prefixless_name]['migration_depends_on'] == $migration['migration_depends_on'])
{
$duplicate_migrations[] = $prefixless_name;
unset($migration_state[$prefixless_name]);
diff --git a/phpBB/phpbb/db/migration/profilefield_base_migration.php b/phpBB/phpbb/db/migration/profilefield_base_migration.php
index bc542a8fed..9ec0e2bb3e 100644
--- a/phpBB/phpbb/db/migration/profilefield_base_migration.php
+++ b/phpBB/phpbb/db/migration/profilefield_base_migration.php
@@ -183,8 +183,8 @@ abstract class profilefield_base_migration extends container_aware_migration
}
/**
- * @param int $start Start of staggering step
- * @return mixed int start of the next step, null if the end was reached
+ * @param int $start Start of staggering step
+ * @return int|null int start of the next step, null if the end was reached
*/
public function convert_user_field_to_custom_field($start)
{
@@ -226,7 +226,7 @@ abstract class profilefield_base_migration extends container_aware_migration
if ($converted_users < $limit)
{
// No more users left, we are done...
- return;
+ return null;
}
return $start + $limit;
diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php
index a351c4858e..77f1d7cfd1 100644
--- a/phpBB/phpbb/db/migration/tool/config.php
+++ b/phpBB/phpbb/db/migration/tool/config.php
@@ -47,7 +47,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
* @param mixed $config_value The value of the config setting
* @param bool $is_dynamic True if it is dynamic (changes very often)
* and should not be stored in the cache, false if not.
- * @return null
+ * @return void
*/
public function add($config_name, $config_value, $is_dynamic = false)
{
@@ -65,7 +65,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
* @param string $config_name The name of the config setting you would
* like to update
* @param mixed $config_value The value of the config setting
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function update($config_name, $config_value)
@@ -87,7 +87,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
* @param string $config_name The name of the config setting you would
* like to update
* @param mixed $config_value The value of the config setting
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function update_if_equals($compare, $config_name, $config_value)
@@ -105,7 +105,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
*
* @param string $config_name The name of the config setting you would
* like to remove
- * @return null
+ * @return void
*/
public function remove($config_name)
{
@@ -161,5 +161,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
{
return call_user_func_array(array(&$this, $call), $arguments);
}
+
+ return null;
}
}
diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php
index 5fe9a25b70..89fa3b9d71 100644
--- a/phpBB/phpbb/db/migration/tool/config_text.php
+++ b/phpBB/phpbb/db/migration/tool/config_text.php
@@ -45,7 +45,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
* @param string $config_name The name of the config_text setting
* you would like to add
* @param mixed $config_value The value of the config_text setting
- * @return null
+ * @return void
*/
public function add($config_name, $config_value)
{
@@ -63,7 +63,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
* @param string $config_name The name of the config_text setting you would
* like to update
* @param mixed $config_value The value of the config_text setting
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function update($config_name, $config_value)
@@ -81,7 +81,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
*
* @param string $config_name The name of the config_text setting you would
* like to remove
- * @return null
+ * @return void
*/
public function remove($config_name)
{
@@ -126,5 +126,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
{
return call_user_func_array(array(&$this, $call), $arguments);
}
+
+ return null;
}
}
diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index f33172a708..407945e6db 100644
--- a/phpBB/phpbb/db/migration/tool/module.php
+++ b/phpBB/phpbb/db/migration/tool/module.php
@@ -162,7 +162,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
* Optionally you may not send 'modes' and it will insert all of the
* modules in that info file.
* path, specify that here
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function add($class, $parent = 0, $data = array())
@@ -339,7 +339,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
* Use false to ignore the parent check and check class wide.
* @param int|string $module The module id|module_langname
* specify that here
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function remove($class, $parent = 0, $module = '')
@@ -350,7 +350,8 @@ class module implements \phpbb\db\migration\tool\tool_interface
if (isset($module['module_langname']))
{
// Manual Method
- return $this->remove($class, $parent, $module['module_langname']);
+ $this->remove($class, $parent, $module['module_langname']);
+ return;
}
// Failed.
@@ -443,6 +444,8 @@ class module implements \phpbb\db\migration\tool\tool_interface
{
return call_user_func_array(array(&$this, $call), $arguments);
}
+
+ return null;
}
/**
@@ -470,7 +473,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
* key - module_id
* value - module_langname
*
- * @return null
+ * @return void
*/
protected function get_categories_list()
{
diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php
index 8628c38f5b..80d64b403a 100644
--- a/phpBB/phpbb/db/migration/tool/permission.php
+++ b/phpBB/phpbb/db/migration/tool/permission.php
@@ -21,7 +21,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
/** @var \phpbb\auth\auth */
protected $auth;
- /** @var \includes\acp\auth\auth_admin */
+ /** @var \auth_admin */
protected $auth_admin;
/** @var \phpbb\cache\service */
@@ -115,7 +115,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* @param bool $global True for checking a global permission setting,
* False for a local permission setting
* @param int|false $copy_from If set, contains the id of the permission from which to copy the new one.
- * @return null
+ * @return void
*/
public function add($auth_option, $global = true, $copy_from = false)
{
@@ -189,7 +189,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* @param string $auth_option The name of the permission (auth) option
* @param bool $global True for checking a global permission setting,
* False for a local permission setting
- * @return null
+ * @return void
*/
public function remove($auth_option, $global = true)
{
@@ -266,13 +266,13 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* @param string $role_type The type (u_, m_, a_)
* @param string $role_description Description of the new role
*
- * @return null
+ * @return int|null Inserted SQL id or null if role already exists
*/
public function role_add($role_name, $role_type, $role_description = '')
{
if ($this->role_exists($role_name))
{
- return;
+ return null;
}
$sql = 'SELECT MAX(role_order) AS max_role_order
@@ -292,7 +292,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
$sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->db->sql_query($sql);
- return $this->db->sql_nextid();
+ return (int) $this->db->sql_nextid();
}
/**
@@ -300,7 +300,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
*
* @param string $old_role_name The old role name
* @param string $new_role_name The new role name
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function role_update($old_role_name, $new_role_name)
@@ -320,7 +320,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* Remove a permission role
*
* @param string $role_name The role name to remove
- * @return null
+ * @return void
*/
public function role_remove($role_name)
{
@@ -411,7 +411,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* @param string $type The type (role|group)
* @param bool $has_permission True if you want to give them permission,
* false if you want to deny them permission
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function permission_set($name, $auth_option, $type = 'role', $has_permission = true)
@@ -506,7 +506,8 @@ class permission implements \phpbb\db\migration\tool\tool_interface
if (count($auth_option))
{
- return $this->permission_set($role_name, $auth_option, 'role', $has_permission);
+ $this->permission_set($role_name, $auth_option, 'role', $has_permission);
+ return;
}
}
@@ -570,7 +571,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* @param string|array $auth_option The auth_option or array of
* auth_options you would like to set
* @param string $type The type (role|group)
- * @return null
+ * @return void
* @throws \phpbb\db\migration\exception
*/
public function permission_unset($name, $auth_option, $type = 'role')
@@ -643,7 +644,8 @@ class permission implements \phpbb\db\migration\tool\tool_interface
throw new \phpbb\db\migration\exception('ROLE_ASSIGNED_NOT_EXIST', $name, $role_id);
}
- return $this->permission_unset($role_name, $auth_option, 'role');
+ $this->permission_unset($role_name, $auth_option, 'role');
+ return;
}
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
@@ -704,9 +706,6 @@ class permission implements \phpbb\db\migration\tool\tool_interface
break;
}
- if ($call)
- {
- return call_user_func_array(array(&$this, $call), $arguments);
- }
+ return $call ? call_user_func_array(array(&$this, $call), $arguments) : null;
}
}
diff --git a/phpBB/phpbb/db/migration/tool/tool_interface.php b/phpBB/phpbb/db/migration/tool/tool_interface.php
index 07cd2435e4..1b66807665 100644
--- a/phpBB/phpbb/db/migration/tool/tool_interface.php
+++ b/phpBB/phpbb/db/migration/tool/tool_interface.php
@@ -31,7 +31,7 @@ interface tool_interface
* First argument is the original call to the class (e.g. add, remove)
* After the first argument, send the original arguments to the function in the original call
*
- * @return null
+ * @return mixed|null Return of function call or null if no valid function call found
*/
public function reverse();
}
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index ef97438cf9..972c2d5107 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -15,6 +15,7 @@ namespace phpbb\db;
use phpbb\config\config;
use phpbb\db\driver\driver_interface;
+use phpbb\db\migration\exception;
use phpbb\db\migration\helper;
use phpbb\db\output_handler\migrator_output_handler_interface;
use phpbb\db\output_handler\null_migrator_output_handler;
@@ -90,7 +91,7 @@ class migrator
*
* 'effectively_installed' set and set to true if the migration was effectively_installed
*
- * @var array|bool
+ * @var array|false
*/
protected $last_run_migration = false;
@@ -157,7 +158,7 @@ class migrator
/**
* Loads all migrations and their application state from the database.
*
- * @return null
+ * @return void
*/
public function load_migration_state()
{
@@ -192,7 +193,7 @@ class migrator
* The array contains 'name', 'class' and 'state'. 'effectively_installed' is set
* and set to true if the last migration was effectively_installed.
*
- * @return array
+ * @return array|false Last run migration information or false if no migration has been run yet
*/
public function get_last_run_migration()
{
@@ -203,7 +204,7 @@ class migrator
* Sets the list of available migration class names to the given array.
*
* @param array $class_names An array of migration class names
- * @return null
+ * @return void
*/
public function set_migrations($class_names)
{
@@ -256,7 +257,7 @@ class migrator
* The update step can either be a schema or a (partial) data update. To
* check if update() needs to be called again use the finished() method.
*
- * @return null
+ * @return void
*/
public function update()
{
@@ -296,7 +297,7 @@ class migrator
/**
* Effectively runs a single update step from the next migration to be applied.
*
- * @return null
+ * @return void
*/
protected function update_do()
{
@@ -329,7 +330,7 @@ class migrator
*
* @param string $name The class name of the migration
* @return bool Whether any update step was successfully run
- * @throws \phpbb\db\migration\exception
+ * @throws exception
*/
protected function try_apply($name)
{
@@ -365,7 +366,7 @@ class migrator
$missing = $this->unfulfillable($depend);
if ($missing !== false)
{
- throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $missing);
+ throw new exception('MIGRATION_NOT_FULFILLABLE', $name, $missing);
}
if (!isset($this->migration_state[$depend]) ||
@@ -480,7 +481,7 @@ class migrator
$this->output_handler->write(array('MIGRATION_DATA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE);
}
}
- catch (\phpbb\db\migration\exception $e)
+ catch (exception $e)
{
// Reset data state and revert the schema changes
$state['migration_data_state'] = '';
@@ -517,7 +518,7 @@ class migrator
* Effectively runs a single revert step from the last migration installed
*
* @param string $migration String migration name to revert (including any that depend on this migration)
- * @return null
+ * @return void
*/
protected function revert_do($migration)
{
@@ -651,8 +652,9 @@ class migrator
* @param array $steps The steps to run
* @param bool|string $state Current state of the migration
* @param bool $revert true to revert a data step
- * @return bool|string migration state. True if completed, serialized array if not finished
- * @throws \phpbb\db\migration\exception
+ * @return bool|array migration state. True if completed, serialized array if not finished
+ * @psalm-return bool|array{result: mixed, step: int}
+ * @throws exception
*/
protected function process_data_step($steps, $state, $revert = false)
{
@@ -692,7 +694,7 @@ class migrator
);
}
}
- catch (\phpbb\db\migration\exception $e)
+ catch (exception $e)
{
// We should try rolling back here
foreach ($steps as $reverse_step_identifier => $reverse_step)
@@ -714,22 +716,23 @@ class migrator
}
/**
- * Run a single step
- *
- * An exception should be thrown if an error occurs
- *
- * @param mixed $step Data step from migration
- * @param mixed $last_result Result to pass to the callable (only for 'custom' method)
- * @param bool $reverse False to install, True to attempt uninstallation by reversing the call
- * @return null
- */
+ * Run a single step
+ *
+ * An exception should be thrown if an error occurs
+ *
+ * @param mixed $step Data step from migration
+ * @param mixed $last_result Result to pass to the callable (only for 'custom' method)
+ * @param bool $reverse False to install, True to attempt uninstallation by reversing the call
+ * @return mixed
+ * @throws exception
+ */
protected function run_step($step, $last_result = 0, $reverse = false)
{
$callable_and_parameters = $this->get_callable_from_step($step, $last_result, $reverse);
if ($callable_and_parameters === false)
{
- return;
+ return null;
}
$callable = $callable_and_parameters[0];
@@ -744,8 +747,9 @@ class migrator
* @param array $step Data step from migration
* @param mixed $last_result Result to pass to the callable (only for 'custom' method)
* @param bool $reverse False to install, True to attempt uninstallation by reversing the call
- * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters
- * @throws \phpbb\db\migration\exception
+ * @return array|false Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters;
+ * false if no callable can be created from data setp
+ * @throws exception
*/
protected function get_callable_from_step(array $step, $last_result = 0, $reverse = false)
{
@@ -767,12 +771,12 @@ class migrator
case 'if':
if (!isset($parameters[0]))
{
- throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step);
+ throw new exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step);
}
if (!isset($parameters[1]))
{
- throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step);
+ throw new exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step);
}
if ($reverse)
@@ -797,7 +801,7 @@ class migrator
case 'custom':
if (!is_callable($parameters[0]))
{
- throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step);
+ throw new exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step);
}
if ($reverse)
@@ -816,17 +820,17 @@ class migrator
default:
if (!$method)
{
- throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step);
+ throw new exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step);
}
if (!isset($this->tools[$class]))
{
- throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step);
+ throw new exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step);
}
if (!method_exists(get_class($this->tools[$class]), $method))
{
- throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step);
+ throw new exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step);
}
// Attempt to reverse operations
@@ -853,7 +857,7 @@ class migrator
*
* @param string $name Name of the migration
* @param array $state
- * @return null
+ * @return void
*/
protected function set_migration_state($name, $state)
{
@@ -991,7 +995,7 @@ class migrator
* THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE!
*
* @param array $migrations Array of migrations (names) to add to the migrations table
- * @return null
+ * @return void
*/
public function populate_migrations($migrations)
{
@@ -1014,7 +1018,7 @@ class migrator
/**
* Creates the migrations table if it does not exist.
- * @return null
+ * @return void
*/
public function create_migrations_table()
{
diff --git a/phpBB/phpbb/db/tools/doctrine.php b/phpBB/phpbb/db/tools/doctrine.php
index 0e5e8ffbf4..e956bcff4b 100644
--- a/phpBB/phpbb/db/tools/doctrine.php
+++ b/phpBB/phpbb/db/tools/doctrine.php
@@ -462,7 +462,8 @@ class doctrine implements tools_interface
}
catch (Exception $e)
{
- return $e->getMessage();
+ // @todo: check if it makes sense to properly handle the exception
+ return false;
}
}
diff --git a/phpBB/phpbb/debug/error_handler.php b/phpBB/phpbb/debug/error_handler.php
index ebd828b97f..f2b00e6365 100644
--- a/phpBB/phpbb/debug/error_handler.php
+++ b/phpBB/phpbb/debug/error_handler.php
@@ -15,8 +15,14 @@ namespace phpbb\debug;
use Symfony\Component\Debug\ErrorHandler;
+/**
+ * @psalm-suppress InvalidExtendClass
+ */
class error_handler extends ErrorHandler
{
+ /**
+ * @psalm-suppress MethodSignatureMismatch
+ */
public function handleError($type, $message, $file, $line)
{
if ($type === E_USER_WARNING || $type === E_USER_NOTICE)
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 20e87e7660..33852ba08c 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -46,7 +46,7 @@ class container_builder
/**
* The container under construction
*
- * @var ContainerBuilder
+ * @var \phpbb_cache_container|ContainerBuilder
*/
protected $container;
@@ -143,6 +143,7 @@ class container_builder
* Build and return a new Container respecting the current configuration
*
* @return \phpbb_cache_container|ContainerBuilder
+ * @throws \Exception
*/
public function get_container()
{
@@ -449,6 +450,7 @@ class container_builder
$ext_container->register('cache.driver', '\\phpbb\\cache\\driver\\dummy');
$ext_container->compile();
+ /** @var \phpbb\config\config $config */
$config = $ext_container->get('config');
if (@is_file($this->phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php'))
{
diff --git a/phpBB/phpbb/di/extension/config.php b/phpBB/phpbb/di/extension/config.php
index 6274f0f020..775de380ec 100644
--- a/phpBB/phpbb/di/extension/config.php
+++ b/phpBB/phpbb/di/extension/config.php
@@ -32,12 +32,12 @@ class config extends Extension
/**
* Loads a specific configuration.
*
- * @param array $config An array of configuration values
+ * @param array $configs An array of configuration values
* @param ContainerBuilder $container A ContainerBuilder instance
*
* @throws \InvalidArgumentException When provided tag is not defined in this extension
*/
- public function load(array $config, ContainerBuilder $container)
+ public function load(array $configs, ContainerBuilder $container)
{
$parameters = array(
'core.adm_relative_path' => $this->config_php->get('phpbb_adm_relative_path') ? $this->config_php->get('phpbb_adm_relative_path') : 'adm/',
diff --git a/phpBB/phpbb/di/ordered_service_collection.php b/phpBB/phpbb/di/ordered_service_collection.php
index 046012ae5b..57b674b986 100644
--- a/phpBB/phpbb/di/ordered_service_collection.php
+++ b/phpBB/phpbb/di/ordered_service_collection.php
@@ -85,13 +85,13 @@ class ordered_service_collection extends service_collection
/**
* Adds a service ID to the collection
*
- * @param string $service_id
+ * @param string $name
* @param int $order
*/
- public function add($service_id, $order = 0)
+ public function add($name, $order = 0)
{
$order = (int) $order;
- $this->service_ids[$order][] = $service_id;
+ $this->service_ids[$order][] = $name;
$this->is_ordered = false;
}
diff --git a/phpBB/phpbb/di/pass/collection_pass.php b/phpBB/phpbb/di/pass/collection_pass.php
index 341f88518d..049337d974 100644
--- a/phpBB/phpbb/di/pass/collection_pass.php
+++ b/phpBB/phpbb/di/pass/collection_pass.php
@@ -27,7 +27,7 @@ class collection_pass implements CompilerPassInterface
* Modify the container before it is passed to the rest of the code
*
* @param ContainerBuilder $container ContainerBuilder object
- * @return null
+ * @return void
*/
public function process(ContainerBuilder $container)
{
diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php
index 71959d81e0..4adb3f10ef 100644
--- a/phpBB/phpbb/event/kernel_exception_subscriber.php
+++ b/phpBB/phpbb/event/kernel_exception_subscriber.php
@@ -66,7 +66,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface
* This listener is run when the KernelEvents::EXCEPTION event is triggered
*
* @param ExceptionEvent $event
- * @return null
+ * @return void
*/
public function on_kernel_exception(ExceptionEvent $event)
{
diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php
index af5eed7867..04e5f91ca2 100644
--- a/phpBB/phpbb/event/md_exporter.php
+++ b/phpBB/phpbb/event/md_exporter.php
@@ -429,7 +429,7 @@ class md_exporter
* Validates a template event name
*
* @param $event_name
- * @return null
+ * @return void
* @throws \LogicException
*/
public function validate_event_name($event_name)
@@ -461,7 +461,8 @@ class md_exporter
* Validate "Changed" Information
*
* @param string $changed
- * @return string
+ * @return array Changed information containing version and description in respective order
+ * @psalm-return array{string, string}
* @throws \LogicException
*/
public function validate_changed($changed)
@@ -481,7 +482,7 @@ class md_exporter
throw new \LogicException("Invalid changed information found for event '{$this->current_event}'");
}
- return array($version, $description);
+ return [$version, $description];
}
/**
@@ -492,7 +493,7 @@ class md_exporter
*/
public function validate_version($version)
{
- return preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?$#', $version);
+ return (bool) preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?$#', $version);
}
/**
@@ -658,13 +659,8 @@ class md_exporter
{
try
{
- $iterator = new \RecursiveIteratorIterator(
- new \phpbb\recursive_dot_prefix_filter_iterator(
- new \RecursiveDirectoryIterator(
- $dir,
- \FilesystemIterator::SKIP_DOTS
- )
- ),
+ $iterator = new \phpbb\finder\recursive_path_iterator(
+ $dir,
\RecursiveIteratorIterator::SELF_FIRST
);
}
diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php
index 720088d3d1..2dfb877fa6 100644
--- a/phpBB/phpbb/event/php_exporter.php
+++ b/phpBB/phpbb/event/php_exporter.php
@@ -84,7 +84,7 @@ class php_exporter
*
* @param string $name Name of the current event (used for error messages)
* @param int $line Line where the current event is placed in
- * @return null
+ * @return void
*/
public function set_current_event($name, $line)
{
@@ -96,7 +96,7 @@ class php_exporter
* Set the content of this file
*
* @param array $content Array with the lines of the file
- * @return null
+ * @return void
*/
public function set_content($content)
{
@@ -148,8 +148,9 @@ class php_exporter
$files = array();
foreach ($iterator as $file_info)
{
- /** @var \RecursiveDirectoryIterator $file_info */
- $relative_path = $iterator->getInnerIterator()->getSubPathname();
+ /** @var \RecursiveDirectoryIterator $inner_iterator */
+ $inner_iterator = $iterator->getInnerIterator();
+ $relative_path = $inner_iterator->getSubPathname();
$files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
}
@@ -789,7 +790,7 @@ class php_exporter
*
* @param array $vars_array Variables found in the array line
* @param array $vars_docblock Variables found in the doc block
- * @return null
+ * @return void
* @throws \LogicException
*/
public function validate_vars_docblock_array($vars_array, $vars_docblock)
diff --git a/phpBB/phpbb/event/recursive_event_filter_iterator.php b/phpBB/phpbb/event/recursive_event_filter_iterator.php
index 64e2e56f6a..22a6861522 100644
--- a/phpBB/phpbb/event/recursive_event_filter_iterator.php
+++ b/phpBB/phpbb/event/recursive_event_filter_iterator.php
@@ -41,7 +41,9 @@ class recursive_event_filter_iterator extends \RecursiveFilterIterator
*/
public function getChildren()
{
- return new self($this->getInnerIterator()->getChildren(), $this->root_path);
+ $inner_iterator = $this->getInnerIterator();
+ assert($inner_iterator instanceof \RecursiveIterator);
+ return new self($inner_iterator->getChildren(), $this->root_path);
}
/**
diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php
index 57a281fdae..c53d27efd1 100644
--- a/phpBB/phpbb/extension/base.php
+++ b/phpBB/phpbb/extension/base.php
@@ -35,7 +35,7 @@ class base implements \phpbb\extension\extension_interface
/** @var string */
protected $extension_path;
- /** @var string[]|bool */
+ /** @var string[]|false */
private $migrations = false;
/**
@@ -69,7 +69,7 @@ class base implements \phpbb\extension\extension_interface
* Single enable step that installs any included migrations
*
* @param mixed $old_state State returned by previous call of this method
- * @return false Indicates no further steps are required
+ * @return bool True if further steps are necessary, otherwise false
*/
public function enable_step($old_state)
{
@@ -95,7 +95,7 @@ class base implements \phpbb\extension\extension_interface
* Single purge step that reverts any included and installed migrations
*
* @param mixed $old_state State returned by previous call of this method
- * @return false Indicates no further steps are required
+ * @return bool True if further steps are necessary, otherwise false
*/
public function purge_step($old_state)
{
@@ -135,8 +135,6 @@ class base implements \phpbb\extension\extension_interface
$this->migrator->set_migrations($migrations);
- $migrations = $this->migrator->get_migrations();
-
- return $migrations;
+ return $this->migrator->get_migrations();
}
}
diff --git a/phpBB/phpbb/extension/di/extension_base.php b/phpBB/phpbb/extension/di/extension_base.php
index 97033e7ddb..fcc358dd79 100644
--- a/phpBB/phpbb/extension/di/extension_base.php
+++ b/phpBB/phpbb/extension/di/extension_base.php
@@ -122,6 +122,7 @@ class extension_base extends Extension
}
}
+ return null;
}
/**
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index c012d9a989..adb6d884d1 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -69,7 +69,7 @@ class manager
/**
* Loads all extension information from the database
*
- * @return null
+ * @return void
*/
public function load_extensions()
{
@@ -254,7 +254,7 @@ class manager
* so never call this in a script that has a max_execution time.
*
* @param string $name The extension's name
- * @return null
+ * @return void
*/
public function enable($name)
{
@@ -302,7 +302,7 @@ class manager
* while so never call this in a script that has a max_execution time.
*
* @param string $name The extension's name
- * @return null
+ * @return void
*/
public function disable($name)
{
@@ -357,7 +357,7 @@ class manager
* so never call this in a script that has a max_execution time.
*
* @param string $name The extension's name
- * @return null
+ * @return void
*/
public function purge($name)
{
@@ -380,11 +380,10 @@ class manager
return $available;
}
- $iterator = new \RecursiveIteratorIterator(
- new \phpbb\recursive_dot_prefix_filter_iterator(
- new \RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS)
- ),
- \RecursiveIteratorIterator::SELF_FIRST
+ $iterator = new \phpbb\finder\recursive_path_iterator(
+ $this->phpbb_root_path . 'ext/',
+ \RecursiveIteratorIterator::SELF_FIRST,
+ \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS
);
$iterator->setMaxDepth(2);
diff --git a/phpBB/phpbb/feed/base.php b/phpBB/phpbb/feed/base.php
index d4be0dc592..4b45168dca 100644
--- a/phpBB/phpbb/feed/base.php
+++ b/phpBB/phpbb/feed/base.php
@@ -329,9 +329,9 @@ abstract class base implements feed_interface
}
/**
- * Returns the SQL query used to retrieve the posts of the feed.
+ * Sets the SQL query used to retrieve the posts of the feed and returns success state
*
- * @return string SQL SELECT query
+ * @return bool True of SQL query was set, false if not
*/
protected abstract function get_sql();
}
diff --git a/phpBB/phpbb/feed/controller/feed.php b/phpBB/phpbb/feed/controller/feed.php
index 941177a1ec..d95cda5248 100644
--- a/phpBB/phpbb/feed/controller/feed.php
+++ b/phpBB/phpbb/feed/controller/feed.php
@@ -298,7 +298,7 @@ class feed
*
* @return Response
*
- * @throws exception\feed_exception
+ * @throws \phpbb\feed\exception\feed_exception
*/
protected function send_feed_do(feed_interface $feed)
{
diff --git a/phpBB/phpbb/feed/feed_interface.php b/phpBB/phpbb/feed/feed_interface.php
index a548e2f5ea..8d2e7ee3f5 100644
--- a/phpBB/phpbb/feed/feed_interface.php
+++ b/phpBB/phpbb/feed/feed_interface.php
@@ -52,7 +52,7 @@ interface feed_interface
/**
* Get the next post in the feed
*
- * @return array
+ * @return array|false Item array or false if no next item exists
*/
public function get_item();
diff --git a/phpBB/phpbb/file_downloader.php b/phpBB/phpbb/file_downloader.php
index f55b825d2d..873bccc9e8 100644
--- a/phpBB/phpbb/file_downloader.php
+++ b/phpBB/phpbb/file_downloader.php
@@ -30,7 +30,7 @@ class file_downloader
* @param int $port Port to connect to; default: 80
* @param int $timeout Connection timeout in seconds; default: 6
*
- * @return mixed File data as string if file can be read and there is no
+ * @return false|string File data as string if file can be read and there is no
* timeout, false if there were errors or the connection timed out
*
* @throws \phpbb\exception\runtime_exception If data can't be retrieved and no error
@@ -77,7 +77,7 @@ class file_downloader
$stream_meta_data = stream_get_meta_data($socket);
- if (!empty($stream_meta_data['timed_out']) || time() >= $timer_stop)
+ if ($stream_meta_data['timed_out'] || time() >= $timer_stop)
{
throw new \phpbb\exception\runtime_exception('FSOCK_TIMEOUT');
}
diff --git a/phpBB/phpbb/files/factory.php b/phpBB/phpbb/files/factory.php
index 84b7cc9449..814bddcc20 100644
--- a/phpBB/phpbb/files/factory.php
+++ b/phpBB/phpbb/files/factory.php
@@ -35,7 +35,7 @@ class factory
*
* @param string $name Service name
*
- * @return object|bool Requested service or false if service could not be
+ * @return object|false Requested service or false if service could not be
* found by the container
*/
public function get($name)
@@ -46,7 +46,7 @@ class factory
try
{
- $service = $this->container->get($name);
+ $service = $this->container->get($name) ?? false;
}
catch (\Exception $e)
{
diff --git a/phpBB/phpbb/files/filespec.php b/phpBB/phpbb/files/filespec.php
index d4f523bf27..3063b5db33 100644
--- a/phpBB/phpbb/files/filespec.php
+++ b/phpBB/phpbb/files/filespec.php
@@ -329,7 +329,7 @@ class filespec
* Get mime type
*
* @param string $filename Filename that needs to be checked
- * @return string Mime type of supplied filename
+ * @return string Mime type of supplied filename or empty string if mimetype could not be guessed
*/
public function get_mimetype($filename)
{
@@ -343,7 +343,7 @@ class filespec
}
}
- return $this->mimetype;
+ return $this->mimetype ?: '';
}
/**
diff --git a/phpBB/phpbb/files/filespec_storage.php b/phpBB/phpbb/files/filespec_storage.php
index 72285305a8..f718d82d74 100644
--- a/phpBB/phpbb/files/filespec_storage.php
+++ b/phpBB/phpbb/files/filespec_storage.php
@@ -99,7 +99,7 @@ class filespec_storage
*
* @param array $upload_ary Upload ary
*
- * @return filespec This instance of the filespec class
+ * @return filespec_storage This instance of the filespec class
*/
public function set_upload_ary($upload_ary)
{
@@ -142,7 +142,7 @@ class filespec_storage
*
* @param upload $namespace Instance of upload class
*
- * @return filespec This instance of the filespec class
+ * @return filespec_storage This instance of the filespec class
*/
public function set_upload_namespace($namespace)
{
@@ -166,7 +166,7 @@ class filespec_storage
*
* @param mixed $error Content for error array
*
- * @return \phpbb\files\filespec This instance of the filespec class
+ * @return filespec_storage This instance of the filespec class
*/
public function set_error($error)
{
@@ -313,7 +313,7 @@ class filespec_storage
* Get mime type
*
* @param string $filename Filename that needs to be checked
- * @return string Mime type of supplied filename
+ * @return string Mime type of supplied filename or empty string if mimetype could not be guessed
*/
public function get_mimetype($filename)
{
@@ -327,7 +327,7 @@ class filespec_storage
}
}
- return $this->mimetype;
+ return $this->mimetype ?: '';
}
/**
diff --git a/phpBB/phpbb/files/types/base.php b/phpBB/phpbb/files/types/base.php
index 3313ad040b..eb00b07672 100644
--- a/phpBB/phpbb/files/types/base.php
+++ b/phpBB/phpbb/files/types/base.php
@@ -27,9 +27,10 @@ abstract class base implements type_interface
/**
* Check if upload exceeds maximum file size
*
- * @param \phpbb\files\filespec $file Filespec object
+ * @template filespec_type of \phpbb\files\filespec|\phpbb\files\filespec_storage
+ * @param filespec_type $file Filespec object
*
- * @return \phpbb\files\filespec Returns same filespec instance
+ * @return filespec_type Returns same filespec instance
*/
public function check_upload_size($file)
{
@@ -47,7 +48,14 @@ abstract class base implements type_interface
$unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
}
- $file->error[] = (empty($max_filesize)) ? $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_NA') : $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, $this->language->lang($unit));
+ if (empty($max_filesize))
+ {
+ $file->error[] = $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_NA');
+ }
+ else
+ {
+ $file->error[] = $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, $this->language->lang($unit));
+ }
}
return $file;
diff --git a/phpBB/phpbb/files/types/form.php b/phpBB/phpbb/files/types/form.php
index a915476191..88d0fab9ad 100644
--- a/phpBB/phpbb/files/types/form.php
+++ b/phpBB/phpbb/files/types/form.php
@@ -18,7 +18,7 @@ use phpbb\files\factory;
use phpbb\files\filespec;
use phpbb\language\language;
use phpbb\plupload\plupload;
-use phpbb\request\request_interface;
+use phpbb\request\request;
class form extends base
{
@@ -28,7 +28,7 @@ class form extends base
/** @var plupload */
protected $plupload;
- /** @var request_interface */
+ /** @var request */
protected $request;
/**
@@ -38,9 +38,9 @@ class form extends base
* @param language $language Language class
* @param IniGetWrapper $php_ini ini_get() wrapper
* @param plupload $plupload Plupload
- * @param request_interface $request Request object
+ * @param request $request Request object
*/
- public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, plupload $plupload, request_interface $request)
+ public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, plupload $plupload, request $request)
{
$this->factory = $factory;
$this->language = $language;
diff --git a/phpBB/phpbb/files/types/form_storage.php b/phpBB/phpbb/files/types/form_storage.php
index 3024dc83e7..03b9f56119 100644
--- a/phpBB/phpbb/files/types/form_storage.php
+++ b/phpBB/phpbb/files/types/form_storage.php
@@ -18,7 +18,7 @@ use phpbb\files\factory;
use phpbb\files\filespec;
use phpbb\language\language;
use phpbb\plupload\plupload;
-use phpbb\request\request_interface;
+use phpbb\request\request;
class form_storage extends base
{
@@ -28,7 +28,7 @@ class form_storage extends base
/** @var plupload */
protected $plupload;
- /** @var request_interface */
+ /** @var request */
protected $request;
/**
@@ -38,9 +38,9 @@ class form_storage extends base
* @param language $language Language class
* @param IniGetWrapper $php_ini ini_get() wrapper
* @param plupload $plupload Plupload
- * @param request_interface $request Request object
+ * @param request $request Request object
*/
- public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, plupload $plupload, request_interface $request)
+ public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, plupload $plupload, request $request)
{
$this->factory = $factory;
$this->language = $language;
diff --git a/phpBB/phpbb/files/types/local.php b/phpBB/phpbb/files/types/local.php
index ca526c1a01..7bcac0bae0 100644
--- a/phpBB/phpbb/files/types/local.php
+++ b/phpBB/phpbb/files/types/local.php
@@ -65,8 +65,8 @@ class local extends base
$upload = $this->get_upload_ary($source_file, $filedata);
/** @var filespec $file */
- $file = $this->factory->get('filespec')
- ->set_upload_ary($upload)
+ $file = $this->factory->get('filespec');
+ $file->set_upload_ary($upload)
->set_upload_namespace($this->upload);
if ($file->init_error())
diff --git a/phpBB/phpbb/files/types/local_storage.php b/phpBB/phpbb/files/types/local_storage.php
index f68d51199e..4329eaf133 100644
--- a/phpBB/phpbb/files/types/local_storage.php
+++ b/phpBB/phpbb/files/types/local_storage.php
@@ -15,7 +15,7 @@ namespace phpbb\files\types;
use bantu\IniGetWrapper\IniGetWrapper;
use phpbb\files\factory;
-use phpbb\files\filespec;
+use phpbb\files\filespec_storage;
use phpbb\language\language;
use phpbb\request\request_interface;
@@ -67,15 +67,15 @@ class local_storage extends base
* @param string $source_file Filename of source file
* @param array|bool $filedata Array with filedata or false
*
- * @return filespec Object "filespec" is returned, all further operations can be done with this object
+ * @return filespec_storage Object "filespec_storage" is returned, all further operations can be done with this object
*/
protected function local_upload($source_file, $filedata = false)
{
$upload = $this->get_upload_ary($source_file, $filedata);
- /** @var filespec $file */
- $file = $this->factory->get('filespec_storage')
- ->set_upload_ary($upload)
+ /** @var filespec_storage $file */
+ $file = $this->factory->get('filespec_storage');
+ $file->set_upload_ary($upload)
->set_upload_namespace($this->upload);
if ($file->init_error())
@@ -85,6 +85,7 @@ class local_storage extends base
}
// PHP Upload file size check
+ /** @var filespec_storage $file */
$file = $this->check_upload_size($file);
if (count($file->error))
{
diff --git a/phpBB/phpbb/files/types/type_interface.php b/phpBB/phpbb/files/types/type_interface.php
index e07078349a..8a20a8eac7 100644
--- a/phpBB/phpbb/files/types/type_interface.php
+++ b/phpBB/phpbb/files/types/type_interface.php
@@ -21,7 +21,7 @@ interface type_interface
* Handle upload for upload types. Arguments passed to this method will be
* handled by the upload type classes themselves.
*
- * @return \phpbb\files\filespec|bool Filespec instance if upload is
+ * @return \phpbb\files\filespec_storage|\phpbb\files\filespec|bool Filespec instance if upload is
* successful or false if not
*/
public function upload();
diff --git a/phpBB/phpbb/files/upload.php b/phpBB/phpbb/files/upload.php
index 1577e67739..9623adec99 100644
--- a/phpBB/phpbb/files/upload.php
+++ b/phpBB/phpbb/files/upload.php
@@ -14,7 +14,7 @@
namespace phpbb\files;
use phpbb\language\language;
-use phpbb\request\request_interface;
+use phpbb\request\request;
/**
* File upload class
@@ -55,7 +55,7 @@ class upload
/** @var language Language class */
protected $language;
- /** @var request_interface Request class */
+ /** @var request Request class */
protected $request;
/**
@@ -64,9 +64,9 @@ class upload
* @param factory $factory Files factory
* @param language $language Language class
* @param \bantu\IniGetWrapper\IniGetWrapper $php_ini ini_get() wrapper
- * @param request_interface $request Request class
+ * @param request $request Request class
*/
- public function __construct(factory $factory, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, request_interface $request)
+ public function __construct(factory $factory, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, request $request)
{
$this->factory = $factory;
$this->language = $language;
@@ -194,7 +194,7 @@ class upload
*
* @param string $errorcode Error code to assign
*
- * @return string Error string
+ * @return string|false Error string or false if error code is not supported
* @access public
*/
public function assign_internal_error($errorcode)
@@ -250,7 +250,7 @@ class upload
/**
* Perform common file checks
*
- * @param filespec_storage $file Instance of filespec class
+ * @param filespec_storage|filespec $file Instance of filespec class
*/
public function common_checks($file)
{
@@ -296,7 +296,7 @@ class upload
/**
* Check for allowed dimension
*
- * @param filespec_storage $file Instance of filespec class
+ * @param filespec_storage|filespec $file Instance of filespec class
*
* @return bool True if dimensions are valid or no constraints set, false
* if not
diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php
index 2931286811..67b25907b3 100644
--- a/phpBB/phpbb/filesystem/filesystem.php
+++ b/phpBB/phpbb/filesystem/filesystem.php
@@ -329,7 +329,7 @@ class filesystem implements filesystem_interface
/**
* {@inheritdoc}
*/
- public function phpbb_chmod($files, $perms = null, $recursive = false, $force_chmod_link = false)
+ public function phpbb_chmod($file, $perms = null, $recursive = false, $force_chmod_link = false)
{
if (is_null($perms))
{
@@ -374,26 +374,26 @@ class filesystem implements filesystem_interface
{
try
{
- foreach ($this->to_iterator($files) as $file)
+ foreach ($this->to_iterator($file) as $current_file)
{
- $file_uid = @fileowner($file);
- $file_gid = @filegroup($file);
+ $file_uid = @fileowner($current_file);
+ $file_gid = @filegroup($current_file);
// Change owner
if ($file_uid !== $this->chmod_info['common_owner'])
{
- $this->chown($file, $this->chmod_info['common_owner'], $recursive);
+ $this->chown($current_file, $this->chmod_info['common_owner'], $recursive);
}
// Change group
if ($file_gid !== $this->chmod_info['common_group'])
{
- $this->chgrp($file, $this->chmod_info['common_group'], $recursive);
+ $this->chgrp($current_file, $this->chmod_info['common_group'], $recursive);
}
clearstatcache();
- $file_uid = @fileowner($file);
- $file_gid = @filegroup($file);
+ $file_uid = @fileowner($current_file);
+ $file_gid = @filegroup($current_file);
}
}
catch (filesystem_exception $e)
@@ -431,9 +431,9 @@ class filesystem implements filesystem_interface
case 'owner':
try
{
- $this->chmod($files, $perms, $recursive, $force_chmod_link);
+ $this->chmod($file, $perms, $recursive, $force_chmod_link);
clearstatcache();
- if ($this->is_readable($files) && $this->is_writable($files))
+ if ($this->is_readable($file) && $this->is_writable($file))
{
break;
}
@@ -445,9 +445,9 @@ class filesystem implements filesystem_interface
case 'group':
try
{
- $this->chmod($files, $perms, $recursive, $force_chmod_link);
+ $this->chmod($file, $perms, $recursive, $force_chmod_link);
clearstatcache();
- if ((!($perms & self::CHMOD_READ) || $this->is_readable($files, $recursive)) && (!($perms & self::CHMOD_WRITE) || $this->is_writable($files, $recursive)))
+ if ((!($perms & self::CHMOD_READ) || $this->is_readable($file, $recursive)) && (!($perms & self::CHMOD_WRITE) || $this->is_writable($file, $recursive)))
{
break;
}
@@ -458,7 +458,7 @@ class filesystem implements filesystem_interface
}
case 'other':
default:
- $this->chmod($files, $perms, $recursive, $force_chmod_link);
+ $this->chmod($file, $perms, $recursive, $force_chmod_link);
break;
}
}
diff --git a/phpBB/phpbb/filesystem/filesystem_interface.php b/phpBB/phpbb/filesystem/filesystem_interface.php
index fa7950dec3..0e7967dcfb 100644
--- a/phpBB/phpbb/filesystem/filesystem_interface.php
+++ b/phpBB/phpbb/filesystem/filesystem_interface.php
@@ -241,7 +241,7 @@ interface filesystem_interface
*
* @param ?string $path Path to resolve
*
- * @return string Resolved path
+ * @return string|false Resolved path or false if path could not be resolved
*/
public function realpath($path);
diff --git a/phpBB/phpbb/filesystem/helper.php b/phpBB/phpbb/filesystem/helper.php
index 0843e077ad..9d1c19057e 100644
--- a/phpBB/phpbb/filesystem/helper.php
+++ b/phpBB/phpbb/filesystem/helper.php
@@ -69,7 +69,7 @@ class helper
* Try to resolve real path when PHP's realpath failes to do so
*
* @param string $path
- * @return bool|string
+ * @return string|false
*/
protected static function phpbb_own_realpath($path)
{
@@ -175,7 +175,7 @@ class helper
*
* @param string $path Path to resolve
*
- * @return string Resolved path
+ * @return string|false Resolved path or false if path could not be resolved
*/
public static function realpath($path)
{
diff --git a/phpBB/phpbb/finder/finder.php b/phpBB/phpbb/finder/finder.php
index 6b0baef19f..9e7f201ea3 100644
--- a/phpBB/phpbb/finder/finder.php
+++ b/phpBB/phpbb/finder/finder.php
@@ -486,13 +486,8 @@ class finder
if (is_dir($path))
{
- $iterator = new \RecursiveIteratorIterator(
- new \phpbb\recursive_dot_prefix_filter_iterator(
- new \RecursiveDirectoryIterator(
- $path,
- \FilesystemIterator::SKIP_DOTS
- )
- ),
+ $iterator = new \phpbb\finder\recursive_path_iterator(
+ $path,
\RecursiveIteratorIterator::SELF_FIRST
);
diff --git a/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php b/phpBB/phpbb/finder/recursive_dot_prefix_filter_iterator.php
similarity index 50%
rename from phpBB/phpbb/recursive_dot_prefix_filter_iterator.php
rename to phpBB/phpbb/finder/recursive_dot_prefix_filter_iterator.php
index 1446551b8b..e4f9ea1d8a 100644
--- a/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php
+++ b/phpBB/phpbb/finder/recursive_dot_prefix_filter_iterator.php
@@ -11,7 +11,7 @@
*
*/
-namespace phpbb;
+namespace phpbb\finder;
/**
* Class recursive_dot_prefix_filter_iterator
@@ -22,9 +22,38 @@ namespace phpbb;
*/
class recursive_dot_prefix_filter_iterator extends \RecursiveFilterIterator
{
- public function accept()
+ /**
+ * Check whether the current element of the iterator is acceptable
+ *
+ * @return bool
+ */
+ public function accept(): bool
{
$filename = $this->current()->getFilename();
return $filename[0] !== '.' || !$this->current()->isDir();
}
+
+ /**
+ * Get sub path
+ *
+ * @return string
+ */
+ public function getSubPath(): string
+ {
+ $directory_iterator = $this->getInnerIterator();
+ assert($directory_iterator instanceof \RecursiveDirectoryIterator);
+ return $directory_iterator->getSubPath();
+ }
+
+ /**
+ * Get sub path and name
+ *
+ * @return string
+ */
+ public function getSubPathname(): string
+ {
+ $directory_iterator = $this->getInnerIterator();
+ assert($directory_iterator instanceof \RecursiveDirectoryIterator);
+ return $directory_iterator->getSubPathname();
+ }
}
diff --git a/phpBB/phpbb/finder/recursive_path_iterator.php b/phpBB/phpbb/finder/recursive_path_iterator.php
new file mode 100644
index 0000000000..f93a240af2
--- /dev/null
+++ b/phpBB/phpbb/finder/recursive_path_iterator.php
@@ -0,0 +1,47 @@
+
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+declare(strict_types=1);
+
+namespace phpbb\finder;
+
+class recursive_path_iterator extends \RecursiveIteratorIterator
+{
+ /**
+ * Constructor
+ *
+ * @param string $path Path to iterate over
+ * @param int $mode Iterator mode
+ * @param int $flags Flags
+ */
+ public function __construct(string $path, int $mode = self::LEAVES_ONLY, int $flags = \FilesystemIterator::SKIP_DOTS)
+ {
+ parent::__construct(
+ new recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($path, $flags)),
+ \RecursiveIteratorIterator::SELF_FIRST
+ );
+ }
+
+ /**
+ * Get inner iterator
+ *
+ * @return recursive_dot_prefix_filter_iterator
+ */
+ public function getInnerIterator(): \RecursiveIterator
+ {
+ $inner_iterator = parent::getInnerIterator();
+
+ assert($inner_iterator instanceof recursive_dot_prefix_filter_iterator);
+ return $inner_iterator;
+ }
+}
diff --git a/phpBB/phpbb/group/helper.php b/phpBB/phpbb/group/helper.php
index 92dd71384f..c56c08c0a4 100644
--- a/phpBB/phpbb/group/helper.php
+++ b/phpBB/phpbb/group/helper.php
@@ -119,6 +119,7 @@ class helper
public function get_name_string($mode, $group_id, $group_name, $group_colour = '', $custom_profile_url = false)
{
$s_is_bots = ($group_name === 'BOTS');
+ $group_name_string = null;
// This switch makes sure we only run code required for the mode
switch ($mode)
diff --git a/phpBB/phpbb/groupposition/legend.php b/phpBB/phpbb/groupposition/legend.php
index 9dcdb10ab6..fd20896473 100644
--- a/phpBB/phpbb/groupposition/legend.php
+++ b/phpBB/phpbb/groupposition/legend.php
@@ -47,8 +47,9 @@ class legend implements \phpbb\groupposition\groupposition_interface
* Returns the group_legend for a given group, if the group exists.
*
* @param int $group_id group_id of the group to be selected
+ *
* @return int position of the group
- * @throws \phpbb\groupposition\exception
+ * @throws exception
*/
public function get_group_value($group_id)
{
@@ -62,7 +63,7 @@ class legend implements \phpbb\groupposition\groupposition_interface
if ($current_value === false)
{
// Group not found.
- throw new \phpbb\groupposition\exception('NO_GROUP');
+ throw new exception('NO_GROUP');
}
return (int) $current_value;
@@ -109,12 +110,13 @@ class legend implements \phpbb\groupposition\groupposition_interface
}
/**
- * Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list.
- *
- * @param int $group_id group_id of the group to be deleted
- * @param bool $skip_group Skip setting the value for this group, to save the query, when you need to update it anyway.
- * @return bool True if the group was deleted successfully
- */
+ * Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list.
+ *
+ * @param int $group_id group_id of the group to be deleted
+ * @param bool $skip_group Skip setting the value for this group, to save the query, when you need to update it anyway.
+ * @return bool True if the group was deleted successfully
+ * @throws exception
+ */
public function delete_group($group_id, $skip_group = false)
{
$current_value = $this->get_group_value($group_id);
@@ -212,11 +214,13 @@ class legend implements \phpbb\groupposition\groupposition_interface
}
/**
- * Get group type language var
- *
- * @param int $group_type group_type from the groups-table
- * @return string name of the language variable for the given group-type.
- */
+ * Get group type language var
+ *
+ * @param int $group_type group_type from the groups-table
+ *
+ * @return string name of the language variable for the given group-type.
+ * @throws exception If invalid group type is supplied
+ */
public static function group_type_language($group_type)
{
switch ($group_type)
@@ -231,6 +235,8 @@ class legend implements \phpbb\groupposition\groupposition_interface
return 'GROUP_SPECIAL';
case GROUP_FREE:
return 'GROUP_OPEN';
+ default:
+ throw new exception('NO_GROUP');
}
}
}
diff --git a/phpBB/phpbb/groupposition/teampage.php b/phpBB/phpbb/groupposition/teampage.php
index fc6373b47b..2358cc9528 100644
--- a/phpBB/phpbb/groupposition/teampage.php
+++ b/phpBB/phpbb/groupposition/teampage.php
@@ -58,8 +58,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the teampage position for a given group, if the group exists.
*
* @param int $group_id group_id of the group to be selected
+ *
* @return int position of the group
- * @throws \phpbb\groupposition\exception
+ * @throws exception
*/
public function get_group_value($group_id)
{
@@ -76,7 +77,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($row === false)
{
// Group not found.
- throw new \phpbb\groupposition\exception('NO_GROUP');
+ throw new exception('NO_GROUP');
}
return (int) $row['teampage_position'];
@@ -86,8 +87,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the row for a given group, if the group exists.
*
* @param int $group_id group_id of the group to be selected
+ *
* @return array Data row of the group
- * @throws \phpbb\groupposition\exception
+ * @throws exception
*/
public function get_group_values($group_id)
{
@@ -104,7 +106,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($row === false)
{
// Group not found.
- throw new \phpbb\groupposition\exception('NO_GROUP');
+ throw new exception('NO_GROUP');
}
return $row;
@@ -114,8 +116,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the teampage position for a given teampage item, if the item exists.
*
* @param int $teampage_id Teampage_id of the selected item
+ *
* @return int Teampage position of the item
- * @throws \phpbb\groupposition\exception
+ * @throws exception
*/
public function get_teampage_value($teampage_id)
{
@@ -129,7 +132,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($current_value === false)
{
// Group not found.
- throw new \phpbb\groupposition\exception('NO_GROUP');
+ throw new exception('NO_GROUP');
}
return (int) $current_value;
@@ -139,8 +142,9 @@ class teampage implements \phpbb\groupposition\groupposition_interface
* Returns the teampage row for a given teampage item, if the item exists.
*
* @param int $teampage_id Teampage_id of the selected item
+ *
* @return array Teampage row of the item
- * @throws \phpbb\groupposition\exception
+ * @throws exception
*/
public function get_teampage_values($teampage_id)
{
@@ -154,7 +158,7 @@ class teampage implements \phpbb\groupposition\groupposition_interface
if ($row === false)
{
// Group not found.
- throw new \phpbb\groupposition\exception('NO_GROUP');
+ throw new exception('NO_GROUP');
}
return $row;
@@ -565,11 +569,13 @@ class teampage implements \phpbb\groupposition\groupposition_interface
}
/**
- * Get group type language var
- *
- * @param int $group_type group_type from the groups-table
- * @return string name of the language variable for the given group-type.
- */
+ * Get group type language var
+ *
+ * @param int $group_type group_type from the groups-table
+ *
+ * @return string name of the language variable for the given group-type.
+ * @throws exception If invalid group type is supplied
+ */
public static function group_type_language($group_type)
{
switch ($group_type)
@@ -584,6 +590,8 @@ class teampage implements \phpbb\groupposition\groupposition_interface
return 'GROUP_SPECIAL';
case GROUP_FREE:
return 'GROUP_OPEN';
+ default:
+ throw new exception('NO_GROUP');
}
}
}
diff --git a/phpBB/phpbb/help/controller/help.php b/phpBB/phpbb/help/controller/help.php
index 3bf6fe3098..557b564da4 100644
--- a/phpBB/phpbb/help/controller/help.php
+++ b/phpBB/phpbb/help/controller/help.php
@@ -124,7 +124,7 @@ class help
* Assigns the help data to the template blocks
*
* @param array $help_data
- * @return null
+ * @return void
*/
protected function assign_to_template(array $help_data)
{
diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php
index b6c11956fe..138f74e74f 100644
--- a/phpBB/phpbb/install/console/command/install/config/show.php
+++ b/phpBB/phpbb/install/console/command/install/config/show.php
@@ -18,6 +18,7 @@ use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
+use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -73,7 +74,7 @@ class show extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return int 0 if everything went fine, or a non-zero exit code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@@ -90,18 +91,18 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
- return;
+ return Command::FAILURE;
}
try
{
- $config = Yaml::parse(file_get_contents($config_file), true, false);
+ $config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
$iohandler->add_error_message('INVALID_YAML_FILE');
- return;
+ return Command::FAILURE;
}
$processor = new Processor();
@@ -115,9 +116,11 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
- return;
+ return Command::FAILURE;
}
- $style->block(Yaml::dump(array('installer' => $config), 10, 4, true, false));
+ $style->block(Yaml::dump(array('installer' => $config), 10, 4, true));
+
+ return Command::SUCCESS;
}
}
diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php
index b48a1acbd4..2682756c13 100644
--- a/phpBB/phpbb/install/console/command/install/config/validate.php
+++ b/phpBB/phpbb/install/console/command/install/config/validate.php
@@ -18,6 +18,7 @@ use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
+use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -73,7 +74,7 @@ class validate extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return int 0 if everything went fine, or a non-zero exit code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@@ -90,18 +91,18 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', array($config_file)));
- return 1;
+ return Command::FAILURE;
}
try
{
- $config = Yaml::parse(file_get_contents($config_file), true, false);
+ $config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
$iohandler->add_error_message('INVALID_YAML_FILE');
- return 1;
+ return Command::FAILURE;
}
$processor = new Processor();
@@ -115,10 +116,10 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
- return 1;
+ return Command::FAILURE;
}
$iohandler->add_success_message('CONFIGURATION_VALID');
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php
index 980586cb0e..84c8aa688a 100644
--- a/phpBB/phpbb/install/console/command/install/install.php
+++ b/phpBB/phpbb/install/console/command/install/install.php
@@ -16,12 +16,14 @@ namespace phpbb\install\console\command\install;
use phpbb\install\exception\installer_exception;
use phpbb\install\helper\install_helper;
use phpbb\install\helper\iohandler\cli_iohandler;
+use phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception;
use phpbb\install\helper\iohandler\factory;
use phpbb\install\installer;
use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
+use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -89,10 +91,11 @@ class install extends \phpbb\console\command\command
*
* Install the board
*
- * @param InputInterface $input An InputInterface instance
+ * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return int 0 if everything went fine, or a non-zero exit code
+ * @throws iohandler_not_implemented_exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@@ -111,25 +114,25 @@ class install extends \phpbb\console\command\command
{
$iohandler->add_error_message('INSTALL_PHPBB_INSTALLED');
- return 1;
+ return Command::FAILURE;
}
if (!is_file($config_file))
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
- return 1;
+ return Command::FAILURE;
}
try
{
- $config = Yaml::parse(file_get_contents($config_file), true, false);
+ $config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
$iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file));
- return 1;
+ return Command::FAILURE;
}
$processor = new Processor();
@@ -143,7 +146,7 @@ class install extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
- return 1;
+ return Command::FAILURE;
}
$this->register_configuration($iohandler, $config);
@@ -151,12 +154,12 @@ class install extends \phpbb\console\command\command
try
{
$this->installer->run();
- return 0;
+ return Command::SUCCESS;
}
catch (installer_exception $e)
{
$iohandler->add_error_message($e->getMessage());
- return 1;
+ return Command::FAILURE;
}
}
diff --git a/phpBB/phpbb/install/console/command/update/config/show.php b/phpBB/phpbb/install/console/command/update/config/show.php
index e462763b5d..85f90e14aa 100644
--- a/phpBB/phpbb/install/console/command/update/config/show.php
+++ b/phpBB/phpbb/install/console/command/update/config/show.php
@@ -18,6 +18,7 @@ use phpbb\install\updater_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
+use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -73,7 +74,7 @@ class show extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return int 0 if everything went fine, or a non-zero exit code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@@ -90,18 +91,18 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
- return;
+ return Command::FAILURE;
}
try
{
- $config = Yaml::parse(file_get_contents($config_file), true, false);
+ $config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
$iohandler->add_error_message('INVALID_YAML_FILE');
- return;
+ return Command::FAILURE;
}
$processor = new Processor();
@@ -115,9 +116,11 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
- return;
+ return Command::FAILURE;
}
- $style->block(Yaml::dump(array('updater' => $config), 10, 4, true, false));
+ $style->block(Yaml::dump(array('updater' => $config), 10, 4, true));
+
+ return Command::SUCCESS;
}
}
diff --git a/phpBB/phpbb/install/console/command/update/config/validate.php b/phpBB/phpbb/install/console/command/update/config/validate.php
index 18de5eab46..69fba0f7a8 100644
--- a/phpBB/phpbb/install/console/command/update/config/validate.php
+++ b/phpBB/phpbb/install/console/command/update/config/validate.php
@@ -18,6 +18,7 @@ use phpbb\install\updater_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
+use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -73,7 +74,7 @@ class validate extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return int 0 if everything went fine, or a non-zero exit code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@@ -90,18 +91,18 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', array($config_file)));
- return 1;
+ return Command::FAILURE;
}
try
{
- $config = Yaml::parse(file_get_contents($config_file), true, false);
+ $config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
$iohandler->add_error_message('INVALID_YAML_FILE');
- return 1;
+ return Command::FAILURE;
}
$processor = new Processor();
@@ -115,10 +116,10 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
- return 1;
+ return Command::FAILURE;
}
$iohandler->add_success_message('CONFIGURATION_VALID');
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php
index d6e89b2477..3c70231c20 100644
--- a/phpBB/phpbb/install/console/command/update/update.php
+++ b/phpBB/phpbb/install/console/command/update/update.php
@@ -22,6 +22,7 @@ use phpbb\install\updater_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
+use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -111,25 +112,25 @@ class update extends \phpbb\console\command\command
{
$iohandler->add_error_message('INSTALL_PHPBB_NOT_INSTALLED');
- return 1;
+ return Command::FAILURE;
}
if (!is_file($config_file))
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
- return 1;
+ return Command::FAILURE;
}
try
{
- $config = Yaml::parse(file_get_contents($config_file), true, false);
+ $config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
$iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file));
- return 1;
+ return Command::FAILURE;
}
$processor = new Processor();
@@ -143,7 +144,7 @@ class update extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
- return 1;
+ return Command::FAILURE;
}
$this->register_configuration($iohandler, $config);
@@ -151,12 +152,12 @@ class update extends \phpbb\console\command\command
try
{
$this->installer->run();
- return 0;
+ return Command::SUCCESS;
}
catch (installer_exception $e)
{
$iohandler->add_error_message($e->getMessage());
- return 1;
+ return Command::FAILURE;
}
}
diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php
index 92506872a3..df6da1e3db 100644
--- a/phpBB/phpbb/install/controller/install.php
+++ b/phpBB/phpbb/install/controller/install.php
@@ -99,6 +99,8 @@ class install
* @return Response|StreamedResponse
*
* @throws http_exception When phpBB is already installed
+ * @throws \phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception
+ * @psalm-suppress InvalidNullableReturnType
*/
public function handle()
{
diff --git a/phpBB/phpbb/install/database_task.php b/phpBB/phpbb/install/database_task.php
index 81864773c5..758e511c1a 100644
--- a/phpBB/phpbb/install/database_task.php
+++ b/phpBB/phpbb/install/database_task.php
@@ -93,9 +93,9 @@ abstract class database_task extends task_base
*
* @param string $sql The SQL.
*
- * @return DriverStmt|Statement The prepared statement object.
+ * @return Statement|null The prepared statement object or null if preparing failed
*/
- protected function create_prepared_stmt(string $sql)
+ protected function create_prepared_stmt(string $sql): ?Statement
{
try
{
@@ -153,13 +153,13 @@ abstract class database_task extends task_base
/**
* Returns the last insert ID.
*
- * @return string|null The last insert ID.
+ * @return int|null The last insert ID.
*/
- protected function get_last_insert_id() : ?string
+ protected function get_last_insert_id() : ?int
{
try
{
- return $this->conn->lastInsertId();
+ return (int) $this->conn->lastInsertId();
}
catch (Exception $e)
{
diff --git a/phpBB/phpbb/install/event/kernel_exception_subscriber.php b/phpBB/phpbb/install/event/kernel_exception_subscriber.php
index dd0d15c72e..79a5bbc8b9 100644
--- a/phpBB/phpbb/install/event/kernel_exception_subscriber.php
+++ b/phpBB/phpbb/install/event/kernel_exception_subscriber.php
@@ -113,14 +113,12 @@ class kernel_exception_subscriber implements EventSubscriberInterface
}
/**
- * Returns an array of events the object is subscribed to
- *
- * @return array Array of events the object is subscribed to
+ * {@inheritDoc}
*/
public static function getSubscribedEvents()
{
- return array(
+ return [
KernelEvents::EXCEPTION => 'on_kernel_exception',
- );
+ ];
}
}
diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php
index e689e44cde..b5869b67d0 100644
--- a/phpBB/phpbb/install/helper/container_factory.php
+++ b/phpBB/phpbb/install/helper/container_factory.php
@@ -75,7 +75,7 @@ class container_factory
*
* @param null|string $service_name Name of the service to return
*
- * @return \Symfony\Component\DependencyInjection\ContainerInterface|Object phpBB's dependency injection container
+ * @return \Symfony\Component\DependencyInjection\ContainerInterface|object|null phpBB's dependency injection container
* or the service specified in $service_name
*
* @throws cannot_build_container_exception When container cannot be built
@@ -91,7 +91,7 @@ class container_factory
$this->build_container();
}
- return ($service_name === null) ? $this->container : $this->container->get($service_name);
+ return $service_name === null ? $this->container : $this->container->get($service_name);
}
/**
diff --git a/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php
index c1044a3a1f..6e4fc2a845 100644
--- a/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php
+++ b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php
@@ -21,7 +21,7 @@ use phpbb\install\helper\update_helper;
class compression_file_updater implements file_updater_interface
{
/**
- * @var \compress|null
+ * @var \compress_zip|\compress_tar|null
*/
protected $compress;
@@ -86,7 +86,10 @@ class compression_file_updater implements file_updater_interface
*/
public function close()
{
- $this->compress->close();
+ if ($this->compress !== null)
+ {
+ $this->compress->close();
+ }
}
/**
diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
index c235b8557a..62ef42108d 100644
--- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
+++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
@@ -83,6 +83,7 @@ class ajax_iohandler extends iohandler_base
/**
* @var resource
+ * @psalm-var resource|closed-resource
*/
protected $file_lock_pointer;
@@ -93,9 +94,9 @@ class ajax_iohandler extends iohandler_base
* @param \phpbb\request\request_interface $request HTTP request interface
* @param \phpbb\template\template $template Template engine
* @param router $router Router
- * @param string $root_path Path to phpBB's root
+ * @param string $root_path Path to phpBB's root
*/
- public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path)
+ public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, string $root_path)
{
$this->path_helper = $path_helper;
$this->request = $request;
@@ -235,7 +236,9 @@ class ajax_iohandler extends iohandler_base
'form_install' => 'installer_form.html',
));
- return $this->template->assign_display('form_install');
+ $compiled_template = $this->template->assign_display('form_install');
+
+ return is_string($compiled_template) ? $compiled_template : '';
}
/**
diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php
index 9553b11d34..5485fb3bfc 100644
--- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php
+++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php
@@ -188,11 +188,11 @@ class cli_iohandler extends iohandler_base
/**
* {@inheritdoc
*/
- public function add_success_message($error_title, $error_description = false)
+ public function add_success_message($success_title, $success_description = false)
{
$this->io->newLine();
- $message = $this->translate_message($error_title, $error_description);
+ $message = $this->translate_message($success_title, $success_description);
$message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : '');
$this->io->success($message_string);
diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php
index 5ea1b93398..56503efdbd 100644
--- a/phpBB/phpbb/install/helper/iohandler/factory.php
+++ b/phpBB/phpbb/install/helper/iohandler/factory.php
@@ -52,7 +52,7 @@ class factory
/**
* Factory getter for iohandler
*
- * @return \phpbb\install\helper\iohandler\iohandler_interface
+ * @return \phpbb\install\helper\iohandler\iohandler_interface|null
*
* @throws iohandler_not_implemented_exception
* When the specified iohandler_interface does not exists
@@ -63,17 +63,16 @@ class factory
{
case 'ajax':
return $this->container->get('installer.helper.iohandler_ajax');
- break;
+
case 'nojs':
// @todo replace this
return $this->container->get('installer.helper.iohandler_ajax');
- break;
+
case 'cli':
return $this->container->get('installer.helper.iohandler_cli');
- break;
+
default:
throw new iohandler_not_implemented_exception();
- break;
}
}
}
diff --git a/phpBB/phpbb/install/helper/update_helper.php b/phpBB/phpbb/install/helper/update_helper.php
index a00731d317..41a9bca206 100644
--- a/phpBB/phpbb/install/helper/update_helper.php
+++ b/phpBB/phpbb/install/helper/update_helper.php
@@ -89,6 +89,7 @@ class update_helper
* @param string $version_number2
* @param string|null $operator
* @return int|bool The returned value is identical to the PHP build-in function version_compare()
+ * @psalm-suppress InvalidNullableReturnType, NullableReturnStatement
*/
public function phpbb_version_compare($version_number1, $version_number2, $operator = null)
{
diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php
index 08906d7830..26c1c8a0f6 100644
--- a/phpBB/phpbb/install/installer.php
+++ b/phpBB/phpbb/install/installer.php
@@ -179,6 +179,7 @@ class installer
try
{
+ /** @psalm-suppress InvalidTemplateParam */
$iterator = $this->installer_modules->getIterator();
if ($module_index < $iterator->count())
diff --git a/phpBB/phpbb/install/module/install_data/task/add_languages.php b/phpBB/phpbb/install/module/install_data/task/add_languages.php
index e8722d8987..3e56d3f69e 100644
--- a/phpBB/phpbb/install/module/install_data/task/add_languages.php
+++ b/phpBB/phpbb/install/module/install_data/task/add_languages.php
@@ -102,7 +102,7 @@ class add_languages extends database_task
]);
$installed_languages = $this->config->get('installed_languages', []);
- array_push($installed_languages, (int) $this->get_last_insert_id());
+ $installed_languages[] = (int) $this->get_last_insert_id();
$this->config->set('installed_languages', $installed_languages);
}
diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
index 5f915c56f3..019553053f 100644
--- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
+++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
@@ -42,7 +42,7 @@ class install_extensions extends database_task
protected $iohandler;
/**
- * @var db
+ * @var \phpbb\config\config
*/
protected $config;
@@ -106,9 +106,9 @@ class install_extensions extends database_task
// Make sure asset version exists in config. Otherwise we might try to
// insert the assets_version setting into the database and cause a
// duplicate entry error.
- if (!isset($this->config['assets_version']))
+ if (!$this->config->offsetExists('assets_version'))
{
- $this->config['assets_version'] = 0;
+ $this->config->offsetSet('assets_version', 0);
}
parent::__construct(
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php
index b6dea1ca30..24581dda4c 100644
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php
@@ -75,6 +75,7 @@ class obtain_update_files extends task_base
// The file should be checked in the requirements, so we assume that it exists
$update_info_file = $this->phpbb_root_path . 'install/update/index.' . $this->php_ext;
include($update_info_file);
+ /** @var array $update_info */
$info = (empty($update_info) || !is_array($update_info)) ? false : $update_info;
// If the file is invalid, abort mission
diff --git a/phpBB/phpbb/install/module/requirements/task/check_update.php b/phpBB/phpbb/install/module/requirements/task/check_update.php
index c15e6eafe2..2bd1841b3d 100644
--- a/phpBB/phpbb/install/module/requirements/task/check_update.php
+++ b/phpBB/phpbb/install/module/requirements/task/check_update.php
@@ -137,6 +137,7 @@ class check_update extends task_base
// Recover version numbers
$update_info = array();
@include($this->phpbb_root_path . 'install/update/index.' . $this->php_ext);
+ /** @var array|false $info */
$info = (empty($update_info) || !is_array($update_info)) ? false : $update_info;
$update_version = false;
diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php
index 4fe065fcb2..e47d23d052 100644
--- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php
+++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php
@@ -45,7 +45,7 @@ class update_extensions extends task_base
protected $update_helper;
/**
- * @var \phpbb\config\db
+ * @var \phpbb\config\config
*/
protected $config;
@@ -111,9 +111,9 @@ class update_extensions extends task_base
// Make sure asset version exists in config. Otherwise we might try to
// insert the assets_version setting into the database and cause a
// duplicate entry error.
- if (!isset($this->config['assets_version']))
+ if (!$this->config->offsetExists('assets_version'))
{
- $this->config['assets_version'] = 0;
+ $this->config->offsetSet('assets_version', 0);
}
parent::__construct(true);
diff --git a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php
index b3325b93ce..49f76a5048 100644
--- a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php
+++ b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php
@@ -224,7 +224,7 @@ class update_files extends task_base
}
$file_updater_method = $this->installer_config->get('file_update_method', '');
- if ($file_updater_method === 'compression' || $file_updater_method === 'ftp')
+ if ($file_updater_method === 'compression' || $file_updater_method === 'ftp' && method_exists($this->file_updater, 'close'))
{
$this->file_updater->close();
}
diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php
index 4464a89716..85ac4506c7 100644
--- a/phpBB/phpbb/install/module_base.php
+++ b/phpBB/phpbb/install/module_base.php
@@ -106,6 +106,7 @@ abstract class module_base implements module_interface
{
// Recover install progress
$task_index = $this->recover_progress();
+ /** @psalm-suppress InvalidTemplateParam */
$iterator = $this->task_collection->getIterator();
if ($task_index < $iterator->count())
diff --git a/phpBB/phpbb/language/language.php b/phpBB/phpbb/language/language.php
index bf82b26b03..6c59e02bba 100644
--- a/phpBB/phpbb/language/language.php
+++ b/phpBB/phpbb/language/language.php
@@ -298,7 +298,7 @@ class language
if ($lang === $key)
{
- return $key;
+ return (string) $key;
}
// If the language entry is a string, we simply mimic sprintf() behaviour
@@ -315,7 +315,7 @@ class language
else if (count($lang) == 0)
{
// If the language entry is an empty array, we just return the language key
- return $key;
+ return (string) $key;
}
// It is an array... now handle different nullar/singular/plural forms
@@ -406,13 +406,6 @@ class language
$number = (int) $number;
$plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1);
- if ($plural_rule > 15 || $plural_rule < 0)
- {
- throw new invalid_plural_rule_exception('INVALID_PLURAL_RULE', array(
- 'plural_rule' => $plural_rule,
- ));
- }
-
/**
* The following plural rules are based on a list published by the Mozilla Developer Network
* https://developer.mozilla.org/en/Localization_and_Plurals
@@ -565,6 +558,9 @@ class language
* 2 - everything else: 0, 2, 3, ... 10, 11, 12, ... 20, 22, ...
*/
return (($number % 10 === 1) && ($number % 100 != 11)) ? 1 : 2;
+
+ default:
+ throw new invalid_plural_rule_exception('INVALID_PLURAL_RULE', ['plural_rule' => $plural_rule]);
}
}
diff --git a/phpBB/phpbb/lock/flock.php b/phpBB/phpbb/lock/flock.php
index 42ec8da030..f3a59f0a86 100644
--- a/phpBB/phpbb/lock/flock.php
+++ b/phpBB/phpbb/lock/flock.php
@@ -27,7 +27,7 @@ class flock
/**
* File pointer for the lock file
- * @var string|bool
+ * @var resource|closed-resource|false
*/
private $lock_fp;
@@ -130,7 +130,7 @@ class flock
* Note: Attempting to release a lock that is already released,
* that is, calling release() multiple times, is harmless.
*
- * @return null
+ * @return void
*/
public function release()
{
diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php
index 3b8caf6832..054e8bdda8 100644
--- a/phpBB/phpbb/log/log.php
+++ b/phpBB/phpbb/log/log.php
@@ -129,7 +129,7 @@ class log implements \phpbb\log\log_interface
* in get_logs()
*
* @param bool $is_in_admin Are we called from within the acp?
- * @return null
+ * @return void
*/
public function set_is_admin($is_in_admin)
{
@@ -150,7 +150,7 @@ class log implements \phpbb\log\log_interface
* Set table name
*
* @param string $log_table Can overwrite the table to use for the logs
- * @return null
+ * @return void
*/
public function set_log_table($log_table)
{
@@ -764,7 +764,14 @@ class log implements \phpbb\log\log_interface
}
$log[$key]['reportee_username'] = $reportee_data_list[$row['reportee_id']]['username'];
- $log[$key]['reportee_username_full'] = get_username_string('full', $row['reportee_id'], $reportee_data_list[$row['reportee_id']]['username'], $reportee_data_list[$row['reportee_id']]['user_colour'], false, $profile_url);
+ $log[$key]['reportee_username_full'] = get_username_string(
+ 'full',
+ $row['reportee_id'],
+ $reportee_data_list[$row['reportee_id']]['username'],
+ $reportee_data_list[$row['reportee_id']]['user_colour'],
+ false,
+ $profile_url
+ );
}
}
diff --git a/phpBB/phpbb/mention/source/base_group.php b/phpBB/phpbb/mention/source/base_group.php
index 58fca4d054..d9b3699f10 100644
--- a/phpBB/phpbb/mention/source/base_group.php
+++ b/phpBB/phpbb/mention/source/base_group.php
@@ -41,8 +41,8 @@ abstract class base_group implements source_interface
/** @var string */
protected $php_ext;
- /** @var string|false */
- protected $cache_ttl = false;
+ /** @var int */
+ protected $cache_ttl = 0;
/** @var array Fetched groups' data */
protected $groups = null;
diff --git a/phpBB/phpbb/mention/source/base_user.php b/phpBB/phpbb/mention/source/base_user.php
index 7e9b41d67d..340abf6848 100644
--- a/phpBB/phpbb/mention/source/base_user.php
+++ b/phpBB/phpbb/mention/source/base_user.php
@@ -34,8 +34,8 @@ abstract class base_user implements source_interface
/** @var string */
protected $php_ext;
- /** @var string|false */
- protected $cache_ttl = false;
+ /** @var int */
+ protected $cache_ttl = 0;
/**
* base_user constructor.
diff --git a/phpBB/phpbb/mention/source/group.php b/phpBB/phpbb/mention/source/group.php
index 11a8e02e94..dd1ee97898 100644
--- a/phpBB/phpbb/mention/source/group.php
+++ b/phpBB/phpbb/mention/source/group.php
@@ -15,7 +15,7 @@ namespace phpbb\mention\source;
class group extends base_group
{
- /** @var string|false */
+ /** @var int */
protected $cache_ttl = 300;
/**
diff --git a/phpBB/phpbb/mention/source/team.php b/phpBB/phpbb/mention/source/team.php
index 02fd8cefbb..5b8e339158 100644
--- a/phpBB/phpbb/mention/source/team.php
+++ b/phpBB/phpbb/mention/source/team.php
@@ -15,7 +15,7 @@ namespace phpbb\mention\source;
class team extends base_user
{
- /** @var string|false */
+ /** @var int */
protected $cache_ttl = 300;
/**
diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php
index 6573a04f8b..c23b168906 100644
--- a/phpBB/phpbb/message/form.php
+++ b/phpBB/phpbb/message/form.php
@@ -118,7 +118,7 @@ abstract class form
* Bind the values of the request to the form
*
* @param \phpbb\request\request_interface $request
- * @return null
+ * @return void
*/
public function bind(\phpbb\request\request_interface $request)
{
@@ -130,7 +130,7 @@ abstract class form
* Submit form, generate the email and send it
*
* @param \messenger $messenger
- * @return null
+ * @return void
*/
public function submit(\messenger $messenger)
{
@@ -162,7 +162,7 @@ abstract class form
* Render the template of the form
*
* @param \phpbb\template\template $template
- * @return null
+ * @return void
*/
public function render(\phpbb\template\template $template)
{
diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php
index 1077d23513..d77f56c73f 100644
--- a/phpBB/phpbb/message/message.php
+++ b/phpBB/phpbb/message/message.php
@@ -65,7 +65,7 @@ class message
* Set the subject of the email
*
* @param string $subject
- * @return null
+ * @return void
*/
public function set_subject($subject)
{
@@ -76,7 +76,7 @@ class message
* Set the body of the email text
*
* @param string $body
- * @return null
+ * @return void
*/
public function set_body($body)
{
@@ -87,7 +87,7 @@ class message
* Set the name of the email template to use
*
* @param string $template
- * @return null
+ * @return void
*/
public function set_template($template)
{
@@ -98,7 +98,7 @@ class message
* Set the array with the "template" data for the email
*
* @param array $template_vars
- * @return null
+ * @return void
*/
public function set_template_vars($template_vars)
{
@@ -109,7 +109,7 @@ class message
* Add a recipient from \phpbb\user
*
* @param array $user
- * @return null
+ * @return void
*/
public function add_recipient_from_user_row(array $user)
{
@@ -132,7 +132,7 @@ class message
* @param int $recipient_notify_type Used notification methods (Jabber, Email, ...)
* @param string $recipient_username User Name (used for AntiAbuse header)
* @param string $recipient_jabber
- * @return null
+ * @return void
*/
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
{
@@ -151,7 +151,7 @@ class message
* Set the senders data from \phpbb\user object
*
* @param \phpbb\user $user
- * @return null
+ * @return void
*/
public function set_sender_from_user($user)
{
@@ -178,7 +178,7 @@ class message
* @param int $sender_id User ID
* @param string $sender_username User Name (used for AntiAbuse header)
* @param string $sender_jabber
- * @return null
+ * @return void
*/
public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '')
{
@@ -195,7 +195,7 @@ class message
* Which notification type should be used? Jabber, Email, ...?
*
* @param int $sender_notify_type
- * @return null
+ * @return void
*/
public function set_sender_notify_type($sender_notify_type)
{
@@ -205,7 +205,7 @@ class message
/**
* Ok, now the same email if CC specified, but without exposing the user's email address
*
- * @return null
+ * @return void
*/
public function cc_sender()
{
@@ -234,7 +234,7 @@ class message
*
* @param \messenger $messenger
* @param string $contact
- * @return null
+ * @return void
*/
public function send(\messenger $messenger, $contact)
{
diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php
index f3ad7f5f41..08d3f19ebf 100644
--- a/phpBB/phpbb/mimetype/content_guesser.php
+++ b/phpBB/phpbb/mimetype/content_guesser.php
@@ -28,6 +28,6 @@ class content_guesser extends guesser_base
*/
public function guess($file, $file_name = '')
{
- return mime_content_type($file);
+ return mime_content_type($file) ?: null;
}
}
diff --git a/phpBB/phpbb/mimetype/extension_guesser.php b/phpBB/phpbb/mimetype/extension_guesser.php
index bb674c024a..44ecfbde7d 100644
--- a/phpBB/phpbb/mimetype/extension_guesser.php
+++ b/phpBB/phpbb/mimetype/extension_guesser.php
@@ -425,7 +425,6 @@ class extension_guesser extends guesser_base
'wb1' => 'application/x-qpro',
'wbmp' => 'image/vnd.wap.wbmp',
'web' => 'application/vnd.xara',
- 'webm' => 'audio/webm',
'webm' => 'video/webm',
'wiz' => 'application/msword',
'wk1' => 'application/x-123',
@@ -505,13 +504,6 @@ class extension_guesser extends guesser_base
{
$extension = pathinfo($file_name, PATHINFO_EXTENSION);
- if (isset($this->extension_map[$extension]))
- {
- return $this->extension_map[$extension];
- }
- else
- {
- return null;
- }
+ return $this->extension_map[$extension] ?? null;
}
}
diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php
index 9b2c184eeb..16084c9a86 100644
--- a/phpBB/phpbb/mimetype/guesser.php
+++ b/phpBB/phpbb/mimetype/guesser.php
@@ -102,7 +102,7 @@ class guesser
* @param string $file Path to file
* @param string $file_name The real file name
*
- * @return string Guess for mimetype of file
+ * @return string|false Guess for mimetype of file or false if file can't be opened
*/
public function guess($file, $file_name = '')
{
@@ -140,13 +140,13 @@ class guesser
* will always overwrite the default application/octet-stream.
*
* @param string $mime_type The current mime type
- * @param string $guess The current mime type guess
+ * @param string|null|false $guess The current mime type guess
*
* @return string The best mime type based on current mime type and guess
*/
public function choose_mime_type($mime_type, $guess)
{
- if ($guess === null || $guess == 'application/octet-stream')
+ if ($guess === false || $guess === null || $guess == 'application/octet-stream')
{
return $mime_type;
}
diff --git a/phpBB/phpbb/mimetype/guesser_interface.php b/phpBB/phpbb/mimetype/guesser_interface.php
index a93e85c7f0..a2dff66617 100644
--- a/phpBB/phpbb/mimetype/guesser_interface.php
+++ b/phpBB/phpbb/mimetype/guesser_interface.php
@@ -28,7 +28,7 @@ interface guesser_interface
* @param string $file Path to file
* @param string $file_name The real file name
*
- * @return string Guess for mimetype of file
+ * @return string|null Guess for mimetype of file
*/
public function guess($file, $file_name = '');
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index 1c44b03507..e25c0f2952 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -13,6 +13,7 @@
namespace phpbb\notification;
+use phpbb\exception\runtime_exception;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -873,9 +874,9 @@ class manager
/**
* Helper to get the list of methods enabled by default
*
- * @return method\method_interface[]
+ * @return string[] Default method types
*/
- public function get_default_methods()
+ public function get_default_methods(): array
{
$default_methods = array();
@@ -894,13 +895,20 @@ class manager
* Helper to get the notifications item type class and set it up
*
* @param string $notification_type_name
- * @param array $data
+ * @param array $data
+ *
* @return type\type_interface
+ * @throws runtime_exception When type name is not o notification type
*/
public function get_item_type_class($notification_type_name, $data = array())
{
$item = $this->load_object($notification_type_name);
+ if (!$item instanceof type\type_interface)
+ {
+ throw new runtime_exception('Supplied type name returned invalid service: ' . $notification_type_name);
+ }
+
$item->set_initial_data($data);
return $item;
@@ -910,18 +918,30 @@ class manager
* Helper to get the notifications method class and set it up
*
* @param string $method_name
+ *
* @return method\method_interface
+ * @throws runtime_exception When object name is not o notification method
*/
public function get_method_class($method_name)
{
- return $this->load_object($method_name);
+ $object = $this->load_object($method_name);
+
+ if (!$object instanceof method\method_interface)
+ {
+ throw new runtime_exception('Supplied method name returned invalid service: ' . $method_name);
+ }
+
+ return $object;
}
/**
* Helper to load objects (notification types/methods)
*
* @param string $object_name
+ *
* @return method\method_interface|type\type_interface
+ * @psalm-suppress NullableReturnStatement Invalid service will result in exception
+ * @throws runtime_exception When object name is not o notification method or type
*/
protected function load_object($object_name)
{
@@ -932,6 +952,11 @@ class manager
$object->set_notification_manager($this);
}
+ if (!$object instanceof method\method_interface && !$object instanceof type\type_interface)
+ {
+ throw new runtime_exception('Supplied object name returned invalid service: ' . $object_name);
+ }
+
return $object;
}
diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php
index 6892d0a7c6..cffd259c0e 100644
--- a/phpBB/phpbb/notification/method/email.php
+++ b/phpBB/phpbb/notification/method/email.php
@@ -117,7 +117,7 @@ class email extends \phpbb\notification\method\messenger_base
$insert_buffer->flush();
- return $this->notify_using_messenger(NOTIFY_EMAIL);
+ $this->notify_using_messenger(NOTIFY_EMAIL);
}
/**
@@ -126,7 +126,7 @@ class email extends \phpbb\notification\method\messenger_base
public function mark_notifications($notification_type_id, $item_id, $user_id, $time = false, $mark_read = true)
{
$sql = 'DELETE FROM ' . $this->notification_emails_table . '
- WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : '1=1') .
+ WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('notification_type_id', is_array($notification_type_id) ? $notification_type_id : [$notification_type_id]) : '1=1') .
($user_id !== false ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '') .
($item_id !== false ? ' AND ' . $this->db->sql_in_set('item_id', $item_id) : '');
$this->db->sql_query($sql);
@@ -138,7 +138,7 @@ class email extends \phpbb\notification\method\messenger_base
public function mark_notifications_by_parent($notification_type_id, $item_parent_id, $user_id, $time = false, $mark_read = true)
{
$sql = 'DELETE FROM ' . $this->notification_emails_table . '
- WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : '1=1') .
+ WHERE ' . ($notification_type_id !== false ? $this->db->sql_in_set('notification_type_id', is_array($notification_type_id) ? $notification_type_id : [$notification_type_id]) : '1=1') .
($user_id !== false ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '') .
($item_parent_id !== false ? ' AND ' . $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : '');
$this->db->sql_query($sql);
diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php
index c0b1b5d596..85461b282d 100644
--- a/phpBB/phpbb/notification/method/messenger_base.php
+++ b/phpBB/phpbb/notification/method/messenger_base.php
@@ -63,7 +63,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
* @param int $notify_method Notify method for messenger (e.g. NOTIFY_IM)
* @param string $template_dir_prefix Base directory to prepend to the email template name
*
- * @return null
+ * @return void
*/
protected function notify_using_messenger($notify_method, $template_dir_prefix = '')
{
diff --git a/phpBB/phpbb/notification/method/method_interface.php b/phpBB/phpbb/notification/method/method_interface.php
index aa13bfde69..2bade743ed 100644
--- a/phpBB/phpbb/notification/method/method_interface.php
+++ b/phpBB/phpbb/notification/method/method_interface.php
@@ -102,7 +102,7 @@ interface method_interface
/**
* Mark notifications read or unread from a parent identifier
*
- * @param string $notification_type_id Type identifier of item types
+ * @param string|int|array $notification_type_id Type identifier of item types
* @param bool|int|array $item_parent_id Item parent id or array of item parent ids. False to mark read for all item parent ids
* @param bool|int|array $user_id User id or array of user ids. False to mark read for all user ids
* @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)
diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php
index 4f3dddba3e..99a758c116 100644
--- a/phpBB/phpbb/notification/type/admin_activate_user.php
+++ b/phpBB/phpbb/notification/type/admin_activate_user.php
@@ -29,8 +29,10 @@ class admin_activate_user extends \phpbb\notification\type\base
}
/**
- * {@inheritdoc}
- */
+ * Language key used to output the text
+ *
+ * @var string
+ */
protected $language_key = 'NOTIFICATION_ADMIN_ACTIVATE_USER';
/**
@@ -68,15 +70,15 @@ class admin_activate_user extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public static function get_item_id($user)
+ public static function get_item_id($type_data)
{
- return (int) $user['user_id'];
+ return (int) $type_data['user_id'];
}
/**
* {@inheritdoc}
*/
- public static function get_item_parent_id($post)
+ public static function get_item_parent_id($type_data)
{
return 0;
}
@@ -84,7 +86,7 @@ class admin_activate_user extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function find_users_for_notification($user, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
@@ -175,11 +177,11 @@ class admin_activate_user extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($user, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('user_actkey', $user['user_actkey']);
- $this->notification_time = $user['user_regdate'];
+ $this->set_data('user_actkey', $type_data['user_actkey']);
+ $this->notification_time = $type_data['user_regdate'];
- parent::create_insert_array($user, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
}
diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php
index e07a5256fe..7c242b75da 100644
--- a/phpBB/phpbb/notification/type/approve_post.php
+++ b/phpBB/phpbb/notification/type/approve_post.php
@@ -67,18 +67,18 @@ class approve_post extends \phpbb\notification\type\post
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from submit_post
+ * @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
- return $this->get_authorised_recipients(array($post['poster_id']), $post['forum_id'], array_merge($options, array(
+ return $this->get_authorised_recipients(array($type_data['poster_id']), $type_data['forum_id'], array_merge($options, array(
'item_type' => static::$notification_option['id'],
)));
}
@@ -89,12 +89,13 @@ class approve_post extends \phpbb\notification\type\post
* and load data, before create_insert_array() is run. The data
* returned from this function will be sent to create_insert_array().
*
- * @param array $post Post data from submit_post
+ * @param array $type_data Post data from submit_post
* @param array $notify_users Notify users list
* Formatted from find_users_for_notification()
+ *
* @return array Whatever you want to send to create_insert_array().
*/
- public function pre_create_insert_array($post, $notify_users)
+ public function pre_create_insert_array($type_data, $notify_users)
{
// In the parent class, this is used to check if the post is already
// read by a user and marks the notification read if it was marked read.
@@ -106,11 +107,11 @@ class approve_post extends \phpbb\notification\type\post
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('post_subject', $post['post_subject']);
+ $this->set_data('post_subject', $type_data['post_subject']);
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
@@ -127,9 +128,7 @@ class approve_post extends \phpbb\notification\type\post
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php
index c5292fa066..c28d94e3f5 100644
--- a/phpBB/phpbb/notification/type/approve_topic.php
+++ b/phpBB/phpbb/notification/type/approve_topic.php
@@ -67,18 +67,18 @@ class approve_topic extends \phpbb\notification\type\topic
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from submit_post
+ * @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
- return $this->get_authorised_recipients(array($post['poster_id']), $post['forum_id'], array_merge($options, array(
+ return $this->get_authorised_recipients(array($type_data['poster_id']), $type_data['forum_id'], array_merge($options, array(
'item_type' => static::$notification_option['id'],
)));
}
@@ -89,12 +89,13 @@ class approve_topic extends \phpbb\notification\type\topic
* and load data, before create_insert_array() is run. The data
* returned from this function will be sent to create_insert_array().
*
- * @param array $post Post data from submit_post
+ * @param array $type_data Post data from submit_post
* @param array $notify_users Notify users list
* Formatted from find_users_for_notification()
+ *
* @return array Whatever you want to send to create_insert_array().
*/
- public function pre_create_insert_array($post, $notify_users)
+ public function pre_create_insert_array($type_data, $notify_users)
{
// In the parent class, this is used to check if the post is already
// read by a user and marks the notification read if it was marked read.
@@ -106,10 +107,10 @@ class approve_topic extends \phpbb\notification\type\topic
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
@@ -126,9 +127,7 @@ class approve_topic extends \phpbb\notification\type\topic
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php
index 46f3650898..54a9319d26 100644
--- a/phpBB/phpbb/notification/type/base.php
+++ b/phpBB/phpbb/notification/type/base.php
@@ -129,7 +129,7 @@ abstract class base implements \phpbb\notification\type\type_interface
*/
public function __get($name)
{
- return (!isset($this->data[$name])) ? null : $this->data[$name];
+ return $this->data[$name] ?? null;
}
@@ -139,13 +139,24 @@ abstract class base implements \phpbb\notification\type\type_interface
* @param mixed $name
* @param mixed $value
*
- * @return null
+ * @return void
*/
public function __set($name, $value)
{
$this->data[$name] = $value;
}
+ /**
+ * Magic method check if a variable is defined and is not null
+ *
+ * @param mixed $name
+ *
+ * @return bool
+ */
+ public function __isset($name)
+ {
+ return isset($this->data[$name]);
+ }
/**
* Magic method to get a string of this notification
@@ -162,12 +173,12 @@ abstract class base implements \phpbb\notification\type\type_interface
/**
* Get special data (only important for the classes that extend this)
*
- * @param string $name Name of the variable to get
+ * @param string|false $name Name of the variable to get, false if all data should be returned
* @return mixed
*/
protected function get_data($name)
{
- return ($name === false) ? $this->data['notification_data'] : ((isset($this->data['notification_data'][$name])) ? $this->data['notification_data'][$name] : null);
+ return ($name === false) ? $this->data['notification_data'] : ($this->data['notification_data'][$name] ?? null);
}
/**
@@ -394,7 +405,6 @@ abstract class base implements \phpbb\notification\type\type_interface
*/
public function load_special($data, $notifications)
{
- return;
}
/**
@@ -407,6 +417,14 @@ abstract class base implements \phpbb\notification\type\type_interface
return true;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function get_email_template()
+ {
+ return false;
+ }
+
/**
* Pre create insert array function (fall back)
*
diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php
index 1b03b5ed13..98a759c300 100644
--- a/phpBB/phpbb/notification/type/bookmark.php
+++ b/phpBB/phpbb/notification/type/bookmark.php
@@ -53,18 +53,19 @@ class bookmark extends \phpbb\notification\type\post
*/
public function is_available()
{
- return $this->config['allow_bookmarks'];
+ return (bool) $this->config['allow_bookmarks'];
}
/**
- * Find the users who want to receive notifications
- *
- * @param array $post Data from submit_post
- * @param array $options Options for finding users for notification
- *
- * @return array
- */
- public function find_users_for_notification($post, $options = array())
+ * Find the users who want to receive notifications
+ *
+ * @param array $type_data Data from submit_post
+ * @param array $options Options for finding users for notification
+ *
+ * @return array
+ * @throws \Exception
+ */
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
@@ -74,8 +75,8 @@ class bookmark extends \phpbb\notification\type\post
$sql = 'SELECT user_id
FROM ' . BOOKMARKS_TABLE . '
- WHERE ' . $this->db->sql_in_set('topic_id', $post['topic_id']) . '
- AND user_id <> ' . (int) $post['poster_id'];
+ WHERE ' . $this->db->sql_in_set('topic_id', $type_data['topic_id']) . '
+ AND user_id <> ' . (int) $type_data['poster_id'];
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
@@ -83,7 +84,7 @@ class bookmark extends \phpbb\notification\type\post
}
$this->db->sql_freeresult($result);
- $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
+ $notify_users = $this->get_authorised_recipients($users, $type_data['forum_id'], $options, true);
if (empty($notify_users))
{
@@ -92,7 +93,7 @@ class bookmark extends \phpbb\notification\type\post
// Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications
$notified_users = $this->notification_manager->get_notified_users($this->get_type(), array(
- 'item_parent_id' => static::get_item_parent_id($post),
+ 'item_parent_id' => static::get_item_parent_id($type_data),
'read' => 0,
));
@@ -102,11 +103,11 @@ class bookmark extends \phpbb\notification\type\post
/** @var bookmark $notification */
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
- $update_responders = $notification->add_responders($post);
+ $update_responders = $notification->add_responders($type_data);
if (!empty($update_responders))
{
$this->notification_manager->update_notification($notification, $update_responders, array(
- 'item_parent_id' => self::get_item_parent_id($post),
+ 'item_parent_id' => self::get_item_parent_id($type_data),
'read' => 0,
'user_id' => $user,
));
@@ -117,9 +118,7 @@ class bookmark extends \phpbb\notification\type\post
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php
index 01a7bb16e8..b7805dd0ec 100644
--- a/phpBB/phpbb/notification/type/disapprove_post.php
+++ b/phpBB/phpbb/notification/type/disapprove_post.php
@@ -127,11 +127,11 @@ class disapprove_post extends \phpbb\notification\type\approve_post
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('disapprove_reason', $post['disapprove_reason']);
+ $this->set_data('disapprove_reason', $type_data['disapprove_reason']);
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
@@ -148,9 +148,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php
index 2c60a75312..5b9d03d238 100644
--- a/phpBB/phpbb/notification/type/disapprove_topic.php
+++ b/phpBB/phpbb/notification/type/disapprove_topic.php
@@ -127,11 +127,11 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('disapprove_reason', $post['disapprove_reason']);
+ $this->set_data('disapprove_reason', $type_data['disapprove_reason']);
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
@@ -148,9 +148,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/forum.php b/phpBB/phpbb/notification/type/forum.php
index 056d78602d..181316e922 100644
--- a/phpBB/phpbb/notification/type/forum.php
+++ b/phpBB/phpbb/notification/type/forum.php
@@ -44,12 +44,12 @@ class forum extends \phpbb\notification\type\post
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from submit_post
+ * @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = [])
+ public function find_users_for_notification($type_data, $options = [])
{
$options = array_merge([
'ignore_users' => [],
@@ -59,9 +59,9 @@ class forum extends \phpbb\notification\type\post
$sql = 'SELECT user_id
FROM ' . FORUMS_WATCH_TABLE . '
- WHERE forum_id = ' . (int) $post['forum_id'] . '
+ WHERE forum_id = ' . (int) $type_data['forum_id'] . '
AND notify_status = ' . NOTIFY_YES . '
- AND user_id <> ' . (int) $post['poster_id'];
+ AND user_id <> ' . (int) $type_data['poster_id'];
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
@@ -69,7 +69,7 @@ class forum extends \phpbb\notification\type\post
}
$this->db->sql_freeresult($result);
- $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
+ $notify_users = $this->get_authorised_recipients($users, $type_data['forum_id'], $options, true);
if (empty($notify_users))
{
@@ -79,7 +79,7 @@ class forum extends \phpbb\notification\type\post
// Try to find the users who already have been notified about replies and have not read them
// Just update their notifications
$notified_users = $this->notification_manager->get_notified_users($this->get_type(), [
- 'item_parent_id' => static::get_item_parent_id($post),
+ 'item_parent_id' => static::get_item_parent_id($type_data),
'read' => 0,
]);
@@ -89,11 +89,11 @@ class forum extends \phpbb\notification\type\post
/** @var post $notification */
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
- $update_responders = $notification->add_responders($post);
+ $update_responders = $notification->add_responders($type_data);
if (!empty($update_responders))
{
$this->notification_manager->update_notification($notification, $update_responders, [
- 'item_parent_id' => self::get_item_parent_id($post),
+ 'item_parent_id' => self::get_item_parent_id($type_data),
'read' => 0,
'user_id' => $user,
]);
@@ -104,9 +104,7 @@ class forum extends \phpbb\notification\type\post
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php
index 34462de2e2..5c07730353 100644
--- a/phpBB/phpbb/notification/type/group_request.php
+++ b/phpBB/phpbb/notification/type/group_request.php
@@ -58,24 +58,24 @@ class group_request extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public static function get_item_id($group)
+ public static function get_item_id($type_data)
{
- return (int) $group['user_id'];
+ return (int) $type_data['user_id'];
}
/**
* {@inheritdoc}
*/
- public static function get_item_parent_id($group)
+ public static function get_item_parent_id($type_data)
{
// Group id is the parent
- return (int) $group['group_id'];
+ return (int) $type_data['group_id'];
}
/**
* {@inheritdoc}
*/
- public function find_users_for_notification($group, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
@@ -84,7 +84,7 @@ class group_request extends \phpbb\notification\type\base
$sql = 'SELECT user_id
FROM ' . USER_GROUP_TABLE . '
WHERE group_leader = 1
- AND group_id = ' . (int) $group['group_id'];
+ AND group_id = ' . (int) $type_data['group_id'];
$result = $this->db->sql_query($sql);
$user_ids = array();
@@ -160,10 +160,10 @@ class group_request extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($group, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('group_name', $group['group_name']);
+ $this->set_data('group_name', $type_data['group_name']);
- parent::create_insert_array($group, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
}
diff --git a/phpBB/phpbb/notification/type/group_request_approved.php b/phpBB/phpbb/notification/type/group_request_approved.php
index 14f222bc1f..d57ab59abf 100644
--- a/phpBB/phpbb/notification/type/group_request_approved.php
+++ b/phpBB/phpbb/notification/type/group_request_approved.php
@@ -34,15 +34,15 @@ class group_request_approved extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public static function get_item_id($group)
+ public static function get_item_id($type_data)
{
- return (int) $group['group_id'];
+ return (int) $type_data['group_id'];
}
/**
* {@inheritdoc}
*/
- public static function get_item_parent_id($group)
+ public static function get_item_parent_id($type_data)
{
return 0;
}
@@ -50,13 +50,13 @@ class group_request_approved extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function find_users_for_notification($group, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$users = array();
- $group['user_ids'] = (!is_array($group['user_ids'])) ? array($group['user_ids']) : $group['user_ids'];
+ $type_data['user_ids'] = (!is_array($type_data['user_ids'])) ? array($type_data['user_ids']) : $type_data['user_ids'];
- foreach ($group['user_ids'] as $user_id)
+ foreach ($type_data['user_ids'] as $user_id)
{
$users[$user_id] = $this->notification_manager->get_default_methods();
}
@@ -83,11 +83,11 @@ class group_request_approved extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($group, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('group_name', $group['group_name']);
+ $this->set_data('group_name', $type_data['group_name']);
- parent::create_insert_array($group, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
/**
diff --git a/phpBB/phpbb/notification/type/mention.php b/phpBB/phpbb/notification/type/mention.php
index fad31b9912..d05742054a 100644
--- a/phpBB/phpbb/notification/type/mention.php
+++ b/phpBB/phpbb/notification/type/mention.php
@@ -59,24 +59,24 @@ class mention extends post
/**
* {@inheritDoc}
*/
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
- $user_ids = $this->helper->get_mentioned_user_ids($post['post_text']);
+ $user_ids = $this->helper->get_mentioned_user_ids($type_data['post_text']);
$user_ids = array_unique($user_ids);
- $user_ids = array_diff($user_ids, [(int) $post['poster_id']]);
+ $user_ids = array_diff($user_ids, [(int) $type_data['poster_id']]);
if (empty($user_ids))
{
return array();
}
- return $this->get_authorised_recipients($user_ids, $post['forum_id'], $options, true);
+ return $this->get_authorised_recipients($user_ids, $type_data['forum_id'], $options, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php
index d7b458dace..276d1984fb 100644
--- a/phpBB/phpbb/notification/type/pm.php
+++ b/phpBB/phpbb/notification/type/pm.php
@@ -67,19 +67,19 @@ class pm extends \phpbb\notification\type\base
/**
* Get the id of the
*
- * @param array $pm The data from the private message
+ * @param array $type_data The data from the private message
*/
- public static function get_item_id($pm)
+ public static function get_item_id($type_data)
{
- return (int) $pm['msg_id'];
+ return (int) $type_data['msg_id'];
}
/**
* Get the id of the parent
*
- * @param array $pm The data from the pm
+ * @param array $type_data The data from the pm
*/
- public static function get_item_parent_id($pm)
+ public static function get_item_parent_id($type_data)
{
// No parent
return 0;
@@ -88,27 +88,27 @@ class pm extends \phpbb\notification\type\base
/**
* Find the users who want to receive notifications
*
- * @param array $pm Data from submit_pm
+ * @param array $type_data Data from submit_pm
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($pm, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
- if (!count($pm['recipients']))
+ if (!count($type_data['recipients']))
{
return array();
}
- unset($pm['recipients'][$pm['from_user_id']]);
+ unset($type_data['recipients'][$type_data['from_user_id']]);
- $this->user_loader->load_users(array_keys($pm['recipients']));
+ $this->user_loader->load_users(array_keys($type_data['recipients']));
- return $this->check_user_notification_options(array_keys($pm['recipients']), $options);
+ return $this->check_user_notification_options(array_keys($type_data['recipients']), $options);
}
/**
@@ -145,9 +145,7 @@ class pm extends \phpbb\notification\type\base
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
@@ -194,12 +192,12 @@ class pm extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($pm, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('from_user_id', $pm['from_user_id']);
+ $this->set_data('from_user_id', $type_data['from_user_id']);
- $this->set_data('message_subject', $pm['message_subject']);
+ $this->set_data('message_subject', $type_data['message_subject']);
- parent::create_insert_array($pm, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
}
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php
index db9ab3b9fe..be8c8d75e9 100644
--- a/phpBB/phpbb/notification/type/post.php
+++ b/phpBB/phpbb/notification/type/post.php
@@ -76,40 +76,42 @@ class post extends \phpbb\notification\type\base
*/
public function is_available()
{
- return $this->config['allow_topic_notify'];
+ return (bool) $this->config['allow_topic_notify'];
}
/**
* Get the id of the item
*
- * @param array $post The data from the post
+ * @param array $type_data The data from the post
+ *
* @return int The post id
*/
- public static function get_item_id($post)
+ public static function get_item_id($type_data)
{
- return (int) $post['post_id'];
+ return (int) $type_data['post_id'];
}
/**
* Get the id of the parent
*
- * @param array $post The data from the post
+ * @param array $type_data The data from the post
+ *
* @return int The topic id
*/
- public static function get_item_parent_id($post)
+ public static function get_item_parent_id($type_data)
{
- return (int) $post['topic_id'];
+ return (int) $type_data['topic_id'];
}
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from submit_post
+ * @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
@@ -119,9 +121,9 @@ class post extends \phpbb\notification\type\base
$sql = 'SELECT user_id
FROM ' . TOPICS_WATCH_TABLE . '
- WHERE topic_id = ' . (int) $post['topic_id'] . '
+ WHERE topic_id = ' . (int) $type_data['topic_id'] . '
AND notify_status = ' . NOTIFY_YES . '
- AND user_id <> ' . (int) $post['poster_id'];
+ AND user_id <> ' . (int) $type_data['poster_id'];
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
@@ -129,7 +131,7 @@ class post extends \phpbb\notification\type\base
}
$this->db->sql_freeresult($result);
- $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
+ $notify_users = $this->get_authorised_recipients($users, $type_data['forum_id'], $options, true);
if (empty($notify_users))
{
@@ -138,7 +140,7 @@ class post extends \phpbb\notification\type\base
// Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications
$notified_users = $this->notification_manager->get_notified_users($this->get_type(), array(
- 'item_parent_id' => static::get_item_parent_id($post),
+ 'item_parent_id' => static::get_item_parent_id($type_data),
'read' => 0,
));
@@ -148,11 +150,11 @@ class post extends \phpbb\notification\type\base
/** @var post $notification */
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
- $update_responders = $notification->add_responders($post);
+ $update_responders = $notification->add_responders($type_data);
if (!empty($update_responders))
{
$this->notification_manager->update_notification($notification, $update_responders, array(
- 'item_parent_id' => self::get_item_parent_id($post),
+ 'item_parent_id' => self::get_item_parent_id($type_data),
'read' => 0,
'user_id' => $user,
));
@@ -236,9 +238,7 @@ class post extends \phpbb\notification\type\base
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
@@ -338,12 +338,13 @@ class post extends \phpbb\notification\type\base
* and load data, before create_insert_array() is run. The data
* returned from this function will be sent to create_insert_array().
*
- * @param array $post Post data from submit_post
+ * @param array $type_data Post data from submit_post
* @param array $notify_users Notify users list
* Formatted from find_users_for_notification()
+ *
* @return array Whatever you want to send to create_insert_array().
*/
- public function pre_create_insert_array($post, $notify_users)
+ public function pre_create_insert_array($type_data, $notify_users)
{
if (!count($notify_users) || !$this->inherit_read_status)
{
@@ -352,7 +353,7 @@ class post extends \phpbb\notification\type\base
$tracking_data = array();
$sql = 'SELECT user_id, mark_time FROM ' . TOPICS_TRACK_TABLE . '
- WHERE topic_id = ' . (int) $post['topic_id'] . '
+ WHERE topic_id = ' . (int) $type_data['topic_id'] . '
AND ' . $this->db->sql_in_set('user_id', array_keys($notify_users));
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
@@ -367,21 +368,21 @@ class post extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('poster_id', $post['poster_id']);
+ $this->set_data('poster_id', $type_data['poster_id']);
- $this->set_data('topic_title', $post['topic_title']);
+ $this->set_data('topic_title', $type_data['topic_title']);
- $this->set_data('post_subject', $post['post_subject']);
+ $this->set_data('post_subject', $type_data['post_subject']);
- $this->set_data('post_username', (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : ''));
+ $this->set_data('post_username', (($type_data['poster_id'] == ANONYMOUS) ? $type_data['post_username'] : ''));
- $this->set_data('forum_id', $post['forum_id']);
+ $this->set_data('forum_id', $type_data['forum_id']);
- $this->set_data('forum_name', $post['forum_name']);
+ $this->set_data('forum_name', $type_data['forum_name']);
- $this->notification_time = $post['post_time'];
+ $this->notification_time = $type_data['post_time'];
// Topics can be "read" before they are public (while awaiting approval).
// Make sure that if the user has read the topic, it's marked as read in the notification
@@ -390,7 +391,7 @@ class post extends \phpbb\notification\type\base
$this->notification_read = true;
}
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
/**
diff --git a/phpBB/phpbb/notification/type/post_in_queue.php b/phpBB/phpbb/notification/type/post_in_queue.php
index eca5f5316d..3d818a1b27 100644
--- a/phpBB/phpbb/notification/type/post_in_queue.php
+++ b/phpBB/phpbb/notification/type/post_in_queue.php
@@ -69,19 +69,19 @@ class post_in_queue extends \phpbb\notification\type\post
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from the post
+ * @param array $type_data Data from the post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
// 0 is for global moderator permissions
- $auth_approve = $this->auth->acl_get_list(false, $this->permission, array($post['forum_id'], 0));
+ $auth_approve = $this->auth->acl_get_list(false, $this->permission, array($type_data['forum_id'], 0));
if (empty($auth_approve))
{
@@ -90,9 +90,9 @@ class post_in_queue extends \phpbb\notification\type\post
$has_permission = array();
- if (isset($auth_approve[$post['forum_id']][$this->permission]))
+ if (isset($auth_approve[$type_data['forum_id']][$this->permission]))
{
- $has_permission = $auth_approve[$post['forum_id']][$this->permission];
+ $has_permission = $auth_approve[$type_data['forum_id']][$this->permission];
}
if (isset($auth_approve[0][$this->permission]))
@@ -101,13 +101,13 @@ class post_in_queue extends \phpbb\notification\type\post
}
sort($has_permission);
- $auth_read = $this->auth->acl_get_list($has_permission, 'f_read', $post['forum_id']);
+ $auth_read = $this->auth->acl_get_list($has_permission, 'f_read', $type_data['forum_id']);
if (empty($auth_read))
{
return array();
}
- return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array(
+ return $this->check_user_notification_options($auth_read[$type_data['forum_id']]['f_read'], array_merge($options, array(
'item_type' => static::$notification_option['id'],
)));
}
@@ -133,9 +133,9 @@ class post_in_queue extends \phpbb\notification\type\post
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
@@ -152,9 +152,7 @@ class post_in_queue extends \phpbb\notification\type\post
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php
index 0f18c7b210..98224917e9 100644
--- a/phpBB/phpbb/notification/type/quote.php
+++ b/phpBB/phpbb/notification/type/quote.php
@@ -64,18 +64,18 @@ class quote extends \phpbb\notification\type\post
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from submit_post
+ * @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
- $usernames = $this->utils->get_outermost_quote_authors($post['post_text']);
+ $usernames = $this->utils->get_outermost_quote_authors($type_data['post_text']);
if (empty($usernames))
{
@@ -91,7 +91,7 @@ class quote extends \phpbb\notification\type\post
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
WHERE ' . $this->db->sql_in_set('username_clean', $usernames) . '
- AND user_id <> ' . (int) $post['poster_id'];
+ AND user_id <> ' . (int) $type_data['poster_id'];
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
@@ -99,7 +99,7 @@ class quote extends \phpbb\notification\type\post
}
$this->db->sql_freeresult($result);
- return $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
+ return $this->get_authorised_recipients($users, $type_data['forum_id'], $options, true);
}
/**
@@ -149,9 +149,7 @@ class quote extends \phpbb\notification\type\post
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php
index 6b92f12bec..f542eccf20 100644
--- a/phpBB/phpbb/notification/type/report_pm.php
+++ b/phpBB/phpbb/notification/type/report_pm.php
@@ -69,12 +69,13 @@ class report_pm extends \phpbb\notification\type\pm
/**
* Get the id of the parent
*
- * @param array $pm The data from the pm
+ * @param array $type_data The data from the pm
+ *
* @return int The report id
*/
- public static function get_item_parent_id($pm)
+ public static function get_item_parent_id($type_data)
{
- return (int) $pm['report_id'];
+ return (int) $type_data['report_id'];
}
/**
@@ -92,41 +93,39 @@ class report_pm extends \phpbb\notification\type\pm
* Find the users who want to receive notifications
* (copied from post_in_queue)
*
- * @param array $post Data from the post
+ * @param array $type_data Data from the post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = [])
+ public function find_users_for_notification($type_data, $options = [])
{
$options = array_merge([
'ignore_users' => [],
], $options);
// Global
- $post['forum_id'] = 0;
+ $type_data['forum_id'] = 0;
- $auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']);
+ $auth_approve = $this->auth->acl_get_list(false, $this->permission, $type_data['forum_id']);
if (empty($auth_approve))
{
return [];
}
- if (($key = array_search($this->user->data['user_id'], $auth_approve[$post['forum_id']][$this->permission])))
+ if (($key = array_search($this->user->data['user_id'], $auth_approve[$type_data['forum_id']][$this->permission])))
{
- unset($auth_approve[$post['forum_id']][$this->permission][$key]);
+ unset($auth_approve[$type_data['forum_id']][$this->permission][$key]);
}
- return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, [
+ return $this->check_user_notification_options($auth_approve[$type_data['forum_id']][$this->permission], array_merge($options, [
'item_type' => static::$notification_option['id'],
]));
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
@@ -246,13 +245,13 @@ class report_pm extends \phpbb\notification\type\pm
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = [])
+ public function create_insert_array($type_data, $pre_create_data = [])
{
$this->set_data('reporter_id', $this->user->data['user_id']);
- $this->set_data('reason_title', strtoupper($post['reason_title']));
- $this->set_data('reason_description', $post['reason_description']);
- $this->set_data('report_text', $post['report_text']);
+ $this->set_data('reason_title', strtoupper($type_data['reason_title']));
+ $this->set_data('reason_description', $type_data['reason_description']);
+ $this->set_data('report_text', $type_data['report_text']);
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
}
diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php
index 8afc48ebd9..06186a868c 100644
--- a/phpBB/phpbb/notification/type/report_pm_closed.php
+++ b/phpBB/phpbb/notification/type/report_pm_closed.php
@@ -64,29 +64,27 @@ class report_pm_closed extends \phpbb\notification\type\pm
/**
* Find the users who want to receive notifications
*
- * @param array $pm Data from submit_pm
+ * @param array $type_data Data from submit_pm
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($pm, $options = [])
+ public function find_users_for_notification($type_data, $options = [])
{
$options = array_merge([
'ignore_users' => [],
], $options);
- if ($pm['reporter'] == $this->user->data['user_id'])
+ if ($type_data['reporter'] == $this->user->data['user_id'])
{
return [];
}
- return $this->check_user_notification_options([$pm['reporter']], $options);
+ return $this->check_user_notification_options([$type_data['reporter']], $options);
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
@@ -161,11 +159,11 @@ class report_pm_closed extends \phpbb\notification\type\pm
/**
* {@inheritdoc}
*/
- public function create_insert_array($pm, $pre_create_data = [])
+ public function create_insert_array($type_data, $pre_create_data = [])
{
- $this->set_data('closer_id', $pm['closer_id']);
+ $this->set_data('closer_id', $type_data['closer_id']);
- parent::create_insert_array($pm, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php
index ac923cdeab..1aeac139eb 100644
--- a/phpBB/phpbb/notification/type/report_post.php
+++ b/phpBB/phpbb/notification/type/report_post.php
@@ -75,14 +75,14 @@ class report_post extends \phpbb\notification\type\post_in_queue
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from the post
+ * @param array $type_data Data from the post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
- $notify_users = parent::find_users_for_notification($post, $options);
+ $notify_users = parent::find_users_for_notification($type_data, $options);
// never notify reporter
unset($notify_users[$this->user->data['user_id']]);
@@ -91,9 +91,7 @@ class report_post extends \phpbb\notification\type\post_in_queue
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
@@ -212,13 +210,13 @@ class report_post extends \phpbb\notification\type\post_in_queue
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
$this->set_data('reporter_id', $this->user->data['user_id']);
- $this->set_data('reason_title', strtoupper($post['reason_title']));
- $this->set_data('reason_description', $post['reason_description']);
- $this->set_data('report_text', $post['report_text']);
+ $this->set_data('reason_title', strtoupper($type_data['reason_title']));
+ $this->set_data('reason_description', $type_data['reason_description']);
+ $this->set_data('report_text', $type_data['report_text']);
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
}
diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php
index d54ba44fbf..e71901a61c 100644
--- a/phpBB/phpbb/notification/type/report_post_closed.php
+++ b/phpBB/phpbb/notification/type/report_post_closed.php
@@ -71,29 +71,27 @@ class report_post_closed extends \phpbb\notification\type\post
/**
* Find the users who want to receive notifications
*
- * @param array $post Data from submit_post
+ * @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($post, $options = [])
+ public function find_users_for_notification($type_data, $options = [])
{
$options = array_merge([
'ignore_users' => [],
], $options);
- if ($post['reporter'] == $this->user->data['user_id'])
+ if ($type_data['reporter'] == $this->user->data['user_id'])
{
return [];
}
- return $this->check_user_notification_options([$post['reporter']], $options);
+ return $this->check_user_notification_options([$type_data['reporter']], $options);
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
@@ -187,11 +185,11 @@ class report_post_closed extends \phpbb\notification\type\post
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = [])
+ public function create_insert_array($type_data, $pre_create_data = [])
{
- $this->set_data('closer_id', $post['closer_id']);
+ $this->set_data('closer_id', $type_data['closer_id']);
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php
index 541bd4955a..7ecb5e6e85 100644
--- a/phpBB/phpbb/notification/type/topic.php
+++ b/phpBB/phpbb/notification/type/topic.php
@@ -76,40 +76,42 @@ class topic extends \phpbb\notification\type\base
*/
public function is_available()
{
- return $this->config['allow_forum_notify'];
+ return (bool) $this->config['allow_forum_notify'];
}
/**
* Get the id of the item
*
- * @param array $post The data from the post
+ * @param array $type_data The data from the post
+ *
* @return int The topic id
*/
- public static function get_item_id($post)
+ public static function get_item_id($type_data)
{
- return (int) $post['topic_id'];
+ return (int) $type_data['topic_id'];
}
/**
* Get the id of the parent
*
- * @param array $post The data from the post
+ * @param array $type_data The data from the post
+ *
* @return int The forum id
*/
- public static function get_item_parent_id($post)
+ public static function get_item_parent_id($type_data)
{
- return (int) $post['forum_id'];
+ return (int) $type_data['forum_id'];
}
/**
* Find the users who want to receive notifications
*
- * @param array $topic Data from the topic
+ * @param array $type_data Data from the topic
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($topic, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
@@ -119,9 +121,9 @@ class topic extends \phpbb\notification\type\base
$sql = 'SELECT user_id
FROM ' . FORUMS_WATCH_TABLE . '
- WHERE forum_id = ' . (int) $topic['forum_id'] . '
+ WHERE forum_id = ' . (int) $type_data['forum_id'] . '
AND notify_status = ' . NOTIFY_YES . '
- AND user_id <> ' . (int) $topic['poster_id'];
+ AND user_id <> ' . (int) $type_data['poster_id'];
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
@@ -129,7 +131,7 @@ class topic extends \phpbb\notification\type\base
}
$this->db->sql_freeresult($result);
- return $this->get_authorised_recipients($users, $topic['forum_id'], $options);
+ return $this->get_authorised_recipients($users, $type_data['forum_id'], $options);
}
/**
@@ -189,9 +191,7 @@ class topic extends \phpbb\notification\type\base
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
@@ -254,12 +254,13 @@ class topic extends \phpbb\notification\type\base
* and load data, before create_insert_array() is run. The data
* returned from this function will be sent to create_insert_array().
*
- * @param array $post Post data from submit_post
+ * @param array $type_data Post data from submit_post
* @param array $notify_users Notify users list
* Formatted from find_users_for_notification()
+ *
* @return array Whatever you want to send to create_insert_array().
*/
- public function pre_create_insert_array($post, $notify_users)
+ public function pre_create_insert_array($type_data, $notify_users)
{
if (!count($notify_users) || !$this->inherit_read_status)
{
@@ -268,7 +269,7 @@ class topic extends \phpbb\notification\type\base
$tracking_data = array();
$sql = 'SELECT user_id, mark_time FROM ' . TOPICS_TRACK_TABLE . '
- WHERE topic_id = ' . (int) $post['topic_id'] . '
+ WHERE topic_id = ' . (int) $type_data['topic_id'] . '
AND ' . $this->db->sql_in_set('user_id', array_keys($notify_users));
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
@@ -283,17 +284,17 @@ class topic extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->set_data('poster_id', $post['poster_id']);
+ $this->set_data('poster_id', $type_data['poster_id']);
- $this->set_data('topic_title', $post['topic_title']);
+ $this->set_data('topic_title', $type_data['topic_title']);
- $this->set_data('post_username', (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : ''));
+ $this->set_data('post_username', (($type_data['poster_id'] == ANONYMOUS) ? $type_data['post_username'] : ''));
- $this->set_data('forum_name', $post['forum_name']);
+ $this->set_data('forum_name', $type_data['forum_name']);
- $this->notification_time = $post['post_time'];
+ $this->notification_time = $type_data['post_time'];
// Topics can be "read" before they are public (while awaiting approval).
// Make sure that if the user has read the topic, it's marked as read in the notification
@@ -302,6 +303,6 @@ class topic extends \phpbb\notification\type\base
$this->notification_read = true;
}
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
}
diff --git a/phpBB/phpbb/notification/type/topic_in_queue.php b/phpBB/phpbb/notification/type/topic_in_queue.php
index 54dc50bcf2..bfdec5278b 100644
--- a/phpBB/phpbb/notification/type/topic_in_queue.php
+++ b/phpBB/phpbb/notification/type/topic_in_queue.php
@@ -69,19 +69,19 @@ class topic_in_queue extends \phpbb\notification\type\topic
/**
* Find the users who want to receive notifications
*
- * @param array $topic Data from the topic
+ * @param array $type_data Data from the topic
* @param array $options Options for finding users for notification
*
* @return array
*/
- public function find_users_for_notification($topic, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
// 0 is for global moderator permissions
- $auth_approve = $this->auth->acl_get_list(false, 'm_approve', array($topic['forum_id'], 0));
+ $auth_approve = $this->auth->acl_get_list(false, 'm_approve', array($type_data['forum_id'], 0));
if (empty($auth_approve))
{
@@ -90,9 +90,9 @@ class topic_in_queue extends \phpbb\notification\type\topic
$has_permission = array();
- if (isset($auth_approve[$topic['forum_id']][$this->permission]))
+ if (isset($auth_approve[$type_data['forum_id']][$this->permission]))
{
- $has_permission = $auth_approve[$topic['forum_id']][$this->permission];
+ $has_permission = $auth_approve[$type_data['forum_id']][$this->permission];
}
if (isset($auth_approve[0][$this->permission]))
@@ -101,13 +101,13 @@ class topic_in_queue extends \phpbb\notification\type\topic
}
sort($has_permission);
- $auth_read = $this->auth->acl_get_list($has_permission, 'f_read', $topic['forum_id']);
+ $auth_read = $this->auth->acl_get_list($has_permission, 'f_read', $type_data['forum_id']);
if (empty($auth_read))
{
return array();
}
- return $this->check_user_notification_options($auth_read[$topic['forum_id']]['f_read'], array_merge($options, array(
+ return $this->check_user_notification_options($auth_read[$type_data['forum_id']]['f_read'], array_merge($options, array(
'item_type' => static::$notification_option['id'],
)));
}
@@ -125,9 +125,9 @@ class topic_in_queue extends \phpbb\notification\type\topic
/**
* {@inheritdoc}
*/
- public function create_insert_array($topic, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- parent::create_insert_array($topic, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
$this->notification_time = time();
}
@@ -144,9 +144,7 @@ class topic_in_queue extends \phpbb\notification\type\topic
}
/**
- * Get email template
- *
- * @return string|bool
+ * {@inheritdoc}
*/
public function get_email_template()
{
diff --git a/phpBB/phpbb/pagination.php b/phpBB/phpbb/pagination.php
index a7086f6691..e07c2988c1 100644
--- a/phpBB/phpbb/pagination.php
+++ b/phpBB/phpbb/pagination.php
@@ -285,11 +285,12 @@ class pagination
*
* @param int $per_page the number of items, posts, etc. per page
* @param int $start the item which should be considered currently active, used to determine the page we're on
+ *
* @return int Current page number
*/
- public function get_on_page($per_page, $start)
+ public function get_on_page(int $per_page, int $start): int
{
- return floor((int) $start / (int) $per_page) + 1;
+ return (int) floor($start / $per_page) + 1;
}
/**
@@ -318,7 +319,7 @@ class pagination
{
if ($start < 0 || $start >= $num_items)
{
- return ($start < 0 || $num_items <= 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page;
+ return ($start < 0 || $num_items <= 0) ? 0 : (int) floor(($num_items - 1) / $per_page) * $per_page;
}
return $start;
diff --git a/phpBB/phpbb/passwords/driver/driver_interface.php b/phpBB/phpbb/passwords/driver/driver_interface.php
index 3974484f13..a50fd02eb6 100644
--- a/phpBB/phpbb/passwords/driver/driver_interface.php
+++ b/phpBB/phpbb/passwords/driver/driver_interface.php
@@ -63,7 +63,7 @@ interface driver_interface
* @param string $hash Password hash
* @param bool $full Return full settings or only settings
* related to the salt
- * @return string String containing the hash settings
+ * @return string|false String containing the hash settings or false if settings are empty or not supported
*/
public function get_settings_only($hash, $full = false);
}
diff --git a/phpBB/phpbb/passwords/helper.php b/phpBB/phpbb/passwords/helper.php
index c2a49202cd..8c9e7ca555 100644
--- a/phpBB/phpbb/passwords/helper.php
+++ b/phpBB/phpbb/passwords/helper.php
@@ -50,8 +50,8 @@ class helper
* @param string $type Data type of the supplied value
* @param string $value Value that should be put into the data array
*
- * @return string|null Return complete combined hash if type is neither
- * 'prefix' nor 'settings', nothing if it is
+ * @return string|false Return complete combined hash if type is neither
+ * 'prefix' nor 'settings', false if it is
*/
public function combine_hash_output(&$data, $type, $value)
{
@@ -70,6 +70,8 @@ class helper
// Return full hash
return $data['prefix'] . $data['settings'] . '$' . $value;
}
+
+ return false;
}
/**
diff --git a/phpBB/phpbb/passwords/manager.php b/phpBB/phpbb/passwords/manager.php
index 574e381d85..aa79150aee 100644
--- a/phpBB/phpbb/passwords/manager.php
+++ b/phpBB/phpbb/passwords/manager.php
@@ -115,7 +115,7 @@ class manager
/**
* Fill algorithm type map
*
- * @param \phpbb\di\service_collection $hashing_algorithms
+ * @param \phpbb\di\service_collection|array $hashing_algorithms
*/
protected function fill_type_map($hashing_algorithms)
{
@@ -154,7 +154,7 @@ class manager
*
* @param string $hash Password hash that should be checked
*
- * @return object|bool The hash type object or false if the specified
+ * @return array|bool|object The hash type object or false if the specified
* type is not supported
*/
public function detect_algorithm($hash)
@@ -206,8 +206,8 @@ class manager
* Hash supplied password
*
* @param string $password Password that should be hashed
- * @param string $type Hash type. Will default to standard hash type if
- * none is supplied
+ * @param string|array $type Hash type. Will default to standard hash type if
+ * none is supplied, array for combined hashing
* @return string|bool Password hash of supplied password or false if
* if something went wrong during hashing
*/
@@ -276,7 +276,7 @@ class manager
// First find out what kind of hash we're dealing with
$stored_hash_type = $this->detect_algorithm($hash);
- if ($stored_hash_type == false)
+ if (!$stored_hash_type)
{
// Still check MD5 hashes as that is what the installer
// will default to for the admin user
diff --git a/phpBB/phpbb/php/ini.php b/phpBB/phpbb/php/ini.php
index 24a5b5ecec..441e3ff7f6 100644
--- a/phpBB/phpbb/php/ini.php
+++ b/phpBB/phpbb/php/ini.php
@@ -137,15 +137,18 @@ class ini
// Already in bytes.
return phpbb_to_numeric($value);
}
- else if (strlen($value) < 2)
+ else if (is_string($value))
{
- // Single character.
- return false;
- }
- else if (strlen($value) < 3 && $value[0] === '-')
- {
- // Two characters but the first one is a minus.
- return false;
+ if (strlen($value) < 2)
+ {
+ // Single character.
+ return false;
+ }
+ else if (strlen($value) < 3 && $value[0] === '-')
+ {
+ // Two characters but the first one is a minus.
+ return false;
+ }
}
$value_lower = strtolower($value);
diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php
index ea8cfef5d0..6ccb141313 100644
--- a/phpBB/phpbb/plupload/plupload.php
+++ b/phpBB/phpbb/plupload/plupload.php
@@ -29,7 +29,7 @@ class plupload
protected $config;
/**
- * @var \phpbb\request\request_interface
+ * @var \phpbb\request\request
*/
protected $request;
@@ -65,12 +65,12 @@ class plupload
*
* @param string $phpbb_root_path
* @param \phpbb\config\config $config
- * @param \phpbb\request\request_interface $request
+ * @param \phpbb\request\request $request
* @param \phpbb\user $user
* @param \bantu\IniGetWrapper\IniGetWrapper $php_ini
* @param \phpbb\mimetype\guesser $mimetype_guesser
*/
- public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \phpbb\mimetype\guesser $mimetype_guesser)
+ public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request $request, \phpbb\user $user, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \phpbb\mimetype\guesser $mimetype_guesser)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->config = $config;
@@ -100,7 +100,7 @@ class plupload
// and handle the file as usual
if ($chunks_expected < 2)
{
- return;
+ return null;
}
$file_name = $this->request->variable('name', '');
@@ -138,6 +138,7 @@ class plupload
'id' => 'id',
'result' => null,
));
+ return null;
}
}
@@ -150,7 +151,7 @@ class plupload
* @param int $forum_id The ID of the forum
* @param int $max_files Maximum number of files allowed. 0 for unlimited.
*
- * @return null
+ * @return void
*/
public function configure(\phpbb\cache\service $cache, \phpbb\template\template $template, $s_action, $forum_id, $max_files)
{
@@ -200,7 +201,7 @@ class plupload
* @param int $code The error code
* @param string $msg The translation string of the message to be sent
*
- * @return null
+ * @return void
*/
public function emit_error($code, $msg)
{
@@ -308,7 +309,7 @@ class plupload
}
}
- return floor($max / 2);
+ return (int) floor($max / 2);
}
protected function temporary_filepath($file_name)
@@ -331,7 +332,7 @@ class plupload
* @param int $chunk Chunk number
* @param string $file_path File path
*
- * @return null
+ * @return void
*/
protected function integrate_uploaded_file($form_name, $chunk, $file_path)
{
@@ -378,7 +379,7 @@ class plupload
/**
* Creates the temporary directory if it does not already exist.
*
- * @return null
+ * @return void
*/
protected function prepare_temporary_directory()
{
@@ -396,7 +397,7 @@ class plupload
/**
* Sets the default directories for uploads
*
- * @return null
+ * @return void
*/
protected function set_default_directories()
{
@@ -410,7 +411,7 @@ class plupload
* @param string $upload_directory Upload directory
* @param string $temporary_directory Temporary directory
*
- * @return null
+ * @return void
*/
public function set_upload_directories($upload_directory, $temporary_directory)
{
diff --git a/phpBB/phpbb/profilefields/lang_helper.php b/phpBB/phpbb/profilefields/lang_helper.php
index 2e353722b2..499a01b7f0 100644
--- a/phpBB/phpbb/profilefields/lang_helper.php
+++ b/phpBB/phpbb/profilefields/lang_helper.php
@@ -126,7 +126,7 @@ class lang_helper
* @param int $field_id Database ID of the field
* @param int $lang_id ID of the language
* @param int $field_value Selected value of the field
- * @return string
+ * @return string|array
*/
public function get($field_id, $lang_id, $field_value = null)
{
diff --git a/phpBB/phpbb/profilefields/type/type_base.php b/phpBB/phpbb/profilefields/type/type_base.php
index 9b4bada26d..80a535cb1f 100644
--- a/phpBB/phpbb/profilefields/type/type_base.php
+++ b/phpBB/phpbb/profilefields/type/type_base.php
@@ -179,12 +179,10 @@ abstract class type_base implements type_interface
*/
public function display_options(&$template_vars, &$field_data)
{
- return;
}
/**
- * Return templated value/field. Possible values for $mode are:
- * change == user is able to set/enter profile values; preview == just show the value
+ * {@inheritDoc}
*/
public function process_field_row($mode, $profile_row)
{
@@ -201,6 +199,7 @@ abstract class type_base implements type_interface
// Assign template variables
$this->generate_field($profile_row, $preview_options);
- return $this->template->assign_display('cp_body');
+ $compiled_template = $this->template->assign_display('cp_body');
+ return is_string($compiled_template) ? $compiled_template : '';
}
}
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index 9c09e27bc4..c795eb27e5 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -232,13 +232,16 @@ class type_bool extends type_base
}
$options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);
- foreach ($options as $option_id => $option_value)
+ if (is_array($options))
{
- $this->template->assign_block_vars('bool.options', array(
- 'OPTION_ID' => $option_id,
- 'CHECKED' => ($value == $option_id) ? ' checked="checked"' : '',
- 'VALUE' => $option_value,
- ));
+ foreach ($options as $option_id => $option_value)
+ {
+ $this->template->assign_block_vars('bool.options', array(
+ 'OPTION_ID' => $option_id,
+ 'CHECKED' => ($value == $option_id) ? ' checked="checked"' : '',
+ 'VALUE' => $option_value,
+ ));
+ }
}
}
}
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index a32de40558..99f8906e76 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -233,13 +233,16 @@ class type_dropdown extends type_base
$this->template->assign_block_vars('dropdown', array_change_key_case($profile_row, CASE_UPPER));
$options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);
- foreach ($options as $option_id => $option_value)
+ if (is_array($options))
{
- $this->template->assign_block_vars('dropdown.options', array(
- 'OPTION_ID' => $option_id,
- 'SELECTED' => ($value == $option_id) ? ' selected="selected"' : '',
- 'VALUE' => $option_value,
- ));
+ foreach ($options as $option_id => $option_value)
+ {
+ $this->template->assign_block_vars('dropdown.options', array(
+ 'OPTION_ID' => $option_id,
+ 'SELECTED' => ($value == $option_id) ? ' selected="selected"' : '',
+ 'VALUE' => $option_value,
+ ));
+ }
}
}
diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php
index 93b9e4b893..abde7f853a 100644
--- a/phpBB/phpbb/profilefields/type/type_interface.php
+++ b/phpBB/phpbb/profilefields/type/type_interface.php
@@ -220,7 +220,7 @@ interface type_interface
*
* @param string $mode Mode for displaying the field (preview|change)
* @param array $profile_row Array with data for this field
- * @return null
+ * @return string
*/
public function process_field_row($mode, $profile_row);
}
diff --git a/phpBB/phpbb/report/controller/report.php b/phpBB/phpbb/report/controller/report.php
index e151d0d291..1af565e6a0 100644
--- a/phpBB/phpbb/report/controller/report.php
+++ b/phpBB/phpbb/report/controller/report.php
@@ -14,6 +14,7 @@
namespace phpbb\report\controller;
use phpbb\exception\http_exception;
+use phpbb\report\report_handler_interface;
use Symfony\Component\HttpFoundation\RedirectResponse;
class report
@@ -61,6 +62,9 @@ class report
/**
* @var \phpbb\report\handler_factory
*/
+ protected $report_factory;
+
+ /** @var report_handler_interface */
protected $report_handler;
/**
@@ -78,7 +82,7 @@ class report
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->captcha_factory = $captcha_factory;
- $this->report_handler = $report_factory;
+ $this->report_factory = $report_factory;
// User interface factory
$this->report_reason_provider = $ui_provider;
@@ -97,7 +101,7 @@ class report
public function handle($id, $mode)
{
// Get report handler
- $this->report_handler = $this->report_handler->get_instance($mode);
+ $this->report_handler = $this->report_factory->get_instance($mode);
$this->user->add_lang('mcp');
@@ -254,7 +258,7 @@ class report
* @param array $error
* @param string $s_hidden_fields
* @param mixed $captcha
- * @return null
+ * @return void
*/
protected function assign_template_data($mode, $id, $reason_id, $report_text, $user_notify, $error = array(), $s_hidden_fields = '', $captcha = false)
{
diff --git a/phpBB/phpbb/report/handler_factory.php b/phpBB/phpbb/report/handler_factory.php
index b25386c4b2..bc371d5944 100644
--- a/phpBB/phpbb/report/handler_factory.php
+++ b/phpBB/phpbb/report/handler_factory.php
@@ -36,21 +36,28 @@ class handler_factory
* Return a new instance of an appropriate report handler
*
* @param string $type
- * @return \phpbb\report\report_handler_interface
+ * @return report_handler_interface
* @throws factory_invalid_argument_exception if $type is not valid
*/
public function get_instance($type)
{
+ $report_handler = null;
switch ($type)
{
case 'pm':
- return $this->container->get('phpbb.report.handlers.report_handler_pm');
+ $report_handler = $this->container->get('phpbb.report.handlers.report_handler_pm');
break;
+
case 'post':
- return $this->container->get('phpbb.report.handlers.report_handler_post');
+ $report_handler = $this->container->get('phpbb.report.handlers.report_handler_post');
break;
}
+ if ($report_handler instanceof report_handler_interface)
+ {
+ return $report_handler;
+ }
+
throw new factory_invalid_argument_exception();
}
}
diff --git a/phpBB/phpbb/report/report_handler.php b/phpBB/phpbb/report/report_handler.php
index ec2f1e035f..6328ed1440 100644
--- a/phpBB/phpbb/report/report_handler.php
+++ b/phpBB/phpbb/report/report_handler.php
@@ -99,6 +99,6 @@ abstract class report_handler implements report_handler_interface
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->db->sql_query($sql);
- return $this->db->sql_nextid();
+ return (int) $this->db->sql_nextid();
}
}
diff --git a/phpBB/phpbb/report/report_reason_list_provider.php b/phpBB/phpbb/report/report_reason_list_provider.php
index 388a61d577..6d9bd7694e 100644
--- a/phpBB/phpbb/report/report_reason_list_provider.php
+++ b/phpBB/phpbb/report/report_reason_list_provider.php
@@ -48,7 +48,7 @@ class report_reason_list_provider
* Sets template variables to render report reasons select HTML input
*
* @param int $reason_id
- * @return null
+ * @return void
*/
public function display_reasons($reason_id = 0)
{
diff --git a/phpBB/phpbb/request/deactivated_super_global.php b/phpBB/phpbb/request/deactivated_super_global.php
index 01e038e8be..ba7111e000 100644
--- a/phpBB/phpbb/request/deactivated_super_global.php
+++ b/phpBB/phpbb/request/deactivated_super_global.php
@@ -100,6 +100,8 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
/**
* Part of the \Countable implementation, will always result in a FATAL error
+ * @return void
+ * @psalm-suppress InvalidReturnType
*/
public function count()
{
@@ -108,6 +110,8 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
/**
* Part of the Traversable/IteratorAggregate implementation, will always result in a FATAL error
+ * @return void
+ * @psalm-suppress InvalidReturnType
*/
public function getIterator()
{
diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php
index e31be57d65..cf81dc42c6 100644
--- a/phpBB/phpbb/request/request.php
+++ b/phpBB/phpbb/request/request.php
@@ -19,18 +19,18 @@ namespace phpbb\request;
* It provides a method to disable access to input data through super globals.
* This should force MOD authors to read about data validation.
*/
-class request implements \phpbb\request\request_interface
+class request implements request_interface
{
/**
* @var array The names of super global variables that this class should protect if super globals are disabled.
*/
protected $super_globals = array(
- \phpbb\request\request_interface::POST => '_POST',
- \phpbb\request\request_interface::GET => '_GET',
- \phpbb\request\request_interface::REQUEST => '_REQUEST',
- \phpbb\request\request_interface::COOKIE => '_COOKIE',
- \phpbb\request\request_interface::SERVER => '_SERVER',
- \phpbb\request\request_interface::FILES => '_FILES',
+ request_interface::POST => '_POST',
+ request_interface::GET => '_GET',
+ request_interface::REQUEST => '_REQUEST',
+ request_interface::COOKIE => '_COOKIE',
+ request_interface::SERVER => '_SERVER',
+ request_interface::FILES => '_FILES',
);
/**
@@ -74,8 +74,8 @@ class request implements \phpbb\request\request_interface
}
// simulate request_order = GP
- $this->original_request = $this->input[\phpbb\request\request_interface::REQUEST];
- $this->input[\phpbb\request\request_interface::REQUEST] = $this->input[\phpbb\request\request_interface::POST] + $this->input[\phpbb\request\request_interface::GET];
+ $this->original_request = $this->input[request_interface::REQUEST];
+ $this->input[request_interface::REQUEST] = $this->input[request_interface::POST] + $this->input[request_interface::GET];
if ($disable_super_globals)
{
@@ -140,10 +140,10 @@ class request implements \phpbb\request\request_interface
* @param string $var_name The name of the variable that shall be overwritten
* @param mixed $value The value which the variable shall contain.
* If this is null the variable will be unset.
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global shall be changed
*/
- public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST)
+ public function overwrite($var_name, $value, $super_global = request_interface::REQUEST)
{
if (!isset($this->super_globals[$super_global]))
{
@@ -181,13 +181,13 @@ class request implements \phpbb\request\request_interface
* This function will always return a value of the same type as the default.
* @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global should be used
*
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
* the same as that of $default. If the variable is not set $default is returned.
*/
- public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST)
+ public function variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST)
{
return $this->_variable($var_name, $default, $multibyte, $super_global, true);
}
@@ -205,13 +205,13 @@ class request implements \phpbb\request\request_interface
* This function will always return a value of the same type as the default.
* @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global should be used
*
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
* the same as that of $default. If the variable is not set $default is returned.
*/
- public function untrimmed_variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST)
+ public function untrimmed_variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST)
{
return $this->_variable($var_name, $default, $multibyte, $super_global, false);
}
@@ -219,7 +219,7 @@ class request implements \phpbb\request\request_interface
/**
* {@inheritdoc}
*/
- public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST)
+ public function raw_variable($var_name, $default, $super_global = request_interface::REQUEST)
{
$path = false;
@@ -276,9 +276,9 @@ class request implements \phpbb\request\request_interface
{
$multibyte = true;
- if ($this->is_set($var_name, \phpbb\request\request_interface::SERVER))
+ if ($this->is_set($var_name, request_interface::SERVER))
{
- return $this->variable($var_name, $default, $multibyte, \phpbb\request\request_interface::SERVER);
+ return $this->variable($var_name, $default, $multibyte, request_interface::SERVER);
}
else
{
@@ -312,7 +312,7 @@ class request implements \phpbb\request\request_interface
*/
public function file($form_name)
{
- return $this->variable($form_name, array('name' => 'none'), true, \phpbb\request\request_interface::FILES);
+ return $this->variable($form_name, array('name' => 'none'), true, request_interface::FILES);
}
/**
@@ -327,7 +327,7 @@ class request implements \phpbb\request\request_interface
*/
public function is_set_post($name)
{
- return $this->is_set($name, \phpbb\request\request_interface::POST);
+ return $this->is_set($name, request_interface::POST);
}
/**
@@ -335,12 +335,12 @@ class request implements \phpbb\request\request_interface
* arrays.
*
* @param string $var Name of the variable
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies the super global which shall be checked
*
* @return bool True if the variable was sent as input
*/
- public function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST)
+ public function is_set($var, $super_global = request_interface::REQUEST)
{
return isset($this->input[$super_global][$var]);
}
@@ -370,13 +370,13 @@ class request implements \phpbb\request\request_interface
/**
* Returns all variable names for a given super global
*
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* The super global from which names shall be taken
*
* @return array All variable names that are set for the super global.
* Pay attention when using these, they are unsanitised!
*/
- public function variable_names($super_global = \phpbb\request\request_interface::REQUEST)
+ public function variable_names($super_global = request_interface::REQUEST)
{
if (!isset($this->input[$super_global]))
{
@@ -397,14 +397,14 @@ class request implements \phpbb\request\request_interface
* This function will always return a value of the same type as the default.
* @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global should be used
* @param bool $trim Indicates whether trim() should be applied to string values.
*
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
* the same as that of $default. If the variable is not set $default is returned.
*/
- protected function _variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST, $trim = true)
+ protected function _variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST, $trim = true)
{
$var = $this->raw_variable($var_name, $default, $super_global);
@@ -424,7 +424,7 @@ class request implements \phpbb\request\request_interface
/**
* {@inheritdoc}
*/
- public function get_super_global($super_global = \phpbb\request\request_interface::REQUEST)
+ public function get_super_global($super_global = request_interface::REQUEST)
{
return $this->input[$super_global];
}
@@ -432,23 +432,23 @@ class request implements \phpbb\request\request_interface
/**
* {@inheritdoc}
*/
- public function escape($var, $multibyte)
+ public function escape($value, $multibyte)
{
- if (is_array($var))
+ if (is_array($value))
{
$result = array();
- foreach ($var as $key => $value)
+ foreach ($value as $key => $array_value)
{
$this->type_cast_helper->set_var($key, $key, gettype($key), $multibyte);
- $result[$key] = $this->escape($value, $multibyte);
+ $result[$key] = $this->escape($array_value, $multibyte);
}
- $var = $result;
+ $value = $result;
}
else
{
- $this->type_cast_helper->set_var($var, $var, 'string', $multibyte);
+ $this->type_cast_helper->set_var($value, $value, 'string', $multibyte);
}
- return $var;
+ return $value;
}
}
diff --git a/phpBB/phpbb/request/request_interface.php b/phpBB/phpbb/request/request_interface.php
index c42c309cc1..9ebd4c25e3 100644
--- a/phpBB/phpbb/request/request_interface.php
+++ b/phpBB/phpbb/request/request_interface.php
@@ -39,10 +39,10 @@ interface request_interface
* @param string $var_name The name of the variable that shall be overwritten
* @param mixed $value The value which the variable shall contain.
* If this is null the variable will be unset.
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global shall be changed
*/
- public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST);
+ public function overwrite($var_name, $value, $super_global = request_interface::REQUEST);
/**
* Central type safe input handling function.
@@ -56,13 +56,13 @@ interface request_interface
* This function will always return a value of the same type as the default.
* @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global shall be changed
*
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
* the same as that of $default. If the variable is not set $default is returned.
*/
- public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST);
+ public function variable($var_name, $default, $multibyte = false, $super_global = request_interface::REQUEST);
/**
* Get a variable without trimming strings and without escaping.
@@ -78,13 +78,13 @@ interface request_interface
* then specifying array("var", 1) as the name will return "a".
* @param mixed $default A default value that is returned if the variable was not set.
* This function will always return a value of the same type as the default.
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global shall be changed
*
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
* the same as that of $default. If the variable is not set $default is returned.
*/
- public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST);
+ public function raw_variable($var_name, $default, $super_global = request_interface::REQUEST);
/**
* Shortcut method to retrieve SERVER variables.
@@ -123,12 +123,12 @@ interface request_interface
* arrays.
*
* @param string $var Name of the variable
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* Specifies which super global shall be changed
*
* @return bool True if the variable was sent as input
*/
- public function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST);
+ public function is_set($var, $super_global = request_interface::REQUEST);
/**
* Checks whether the current request is an AJAX request (XMLHttpRequest)
@@ -147,23 +147,23 @@ interface request_interface
/**
* Returns all variable names for a given super global
*
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* The super global from which names shall be taken
*
* @return array All variable names that are set for the super global.
* Pay attention when using these, they are unsanitised!
*/
- public function variable_names($super_global = \phpbb\request\request_interface::REQUEST);
+ public function variable_names($super_global = request_interface::REQUEST);
/**
* Returns the original array of the requested super global
*
- * @param string $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
+ * @param int $super_global (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE)
* The super global which will be returned
*
* @return array The original array of the requested super global.
*/
- public function get_super_global($super_global = \phpbb\request\request_interface::REQUEST);
+ public function get_super_global($super_global = request_interface::REQUEST);
/**
* Escape a string variable.
diff --git a/phpBB/phpbb/request/type_cast_helper.php b/phpBB/phpbb/request/type_cast_helper.php
index 3f793d1c5d..cebaf06316 100644
--- a/phpBB/phpbb/request/type_cast_helper.php
+++ b/phpBB/phpbb/request/type_cast_helper.php
@@ -72,7 +72,7 @@ class type_cast_helper implements \phpbb\request\type_cast_helper_interface
/**
* Recursively sets a variable to a given type using {@link set_var set_var}
*
- * @param string $var The value which shall be sanitised (passed by reference).
+ * @param mixed $var The value which shall be sanitised (passed by reference).
* @param mixed $default Specifies the type $var shall have.
* If it is an array and $var is not one, then an empty array is returned.
* Otherwise var is cast to the same type, and if $default is an array all
diff --git a/phpBB/phpbb/routing/helper.php b/phpBB/phpbb/routing/helper.php
index 3d38105aa3..b26fc3fd93 100644
--- a/phpBB/phpbb/routing/helper.php
+++ b/phpBB/phpbb/routing/helper.php
@@ -83,7 +83,7 @@ class helper
* @param array $params String or array of additional url parameters
* @param bool $is_amp Is url using & (true) or & (false)
* @param string|bool $session_id Possibility to use a custom session id instead of the global one
- * @param bool|string $reference_type The type of reference to be generated (one of the constants)
+ * @param int $reference_type The type of reference to be generated (one of the constants)
* @return string The URL already passed through append_sid()
*/
public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)
diff --git a/phpBB/phpbb/routing/resources_locator/default_resources_locator.php b/phpBB/phpbb/routing/resources_locator/default_resources_locator.php
index 90c3877007..8cbf089b2a 100644
--- a/phpBB/phpbb/routing/resources_locator/default_resources_locator.php
+++ b/phpBB/phpbb/routing/resources_locator/default_resources_locator.php
@@ -44,9 +44,9 @@ class default_resources_locator implements resources_locator_interface
/**
* Construct method
*
- * @param string $phpbb_root_path phpBB root path
- * @param string $environment Name of the current environment
- * @param manager $extension_manager Extension manager
+ * @param string $phpbb_root_path phpBB root path
+ * @param string $environment Name of the current environment
+ * @param manager|null $extension_manager Extension manager
*/
public function __construct($phpbb_root_path, $environment, manager $extension_manager = null)
{
diff --git a/phpBB/phpbb/routing/router.php b/phpBB/phpbb/routing/router.php
index 18285c06d5..e6f887cca7 100644
--- a/phpBB/phpbb/routing/router.php
+++ b/phpBB/phpbb/routing/router.php
@@ -58,12 +58,12 @@ class router implements RouterInterface
protected $php_ext;
/**
- * @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null
+ * @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface
*/
protected $matcher;
/**
- * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface|null
+ * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface
*/
protected $generator;
diff --git a/phpBB/phpbb/search/backend/fulltext_postgres.php b/phpBB/phpbb/search/backend/fulltext_postgres.php
index efd6ecc148..6c4ac05932 100644
--- a/phpBB/phpbb/search/backend/fulltext_postgres.php
+++ b/phpBB/phpbb/search/backend/fulltext_postgres.php
@@ -1011,7 +1011,7 @@ class fulltext_postgres extends base implements search_backend_interface
}
/**
- * {@inheritdoc}
+ * Computes the stats and store them in the $this->stats associative array
*/
protected function get_stats()
{
diff --git a/phpBB/phpbb/search/backend/fulltext_sphinx.php b/phpBB/phpbb/search/backend/fulltext_sphinx.php
index 709690b4f2..5092f67ae5 100644
--- a/phpBB/phpbb/search/backend/fulltext_sphinx.php
+++ b/phpBB/phpbb/search/backend/fulltext_sphinx.php
@@ -855,6 +855,7 @@ class fulltext_sphinx implements search_backend_interface
generate a config for the index. We use a config value
fulltext_sphinx_id for this, as it should be unique. */
$config_object = new \phpbb\search\backend\sphinx\config();
+ /** @psalm-suppress UndefinedVariable */
$config_data = array(
'source source_phpbb_' . $this->id . '_main' => array(
array('type', $this->dbtype . ' # mysql or pgsql'),
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php
index e89127800d..0d401c86e1 100644
--- a/phpBB/phpbb/session.php
+++ b/phpBB/phpbb/session.php
@@ -215,6 +215,21 @@ class session
return $host;
}
+ /**
+ * Setup basic user-specific items (style, language, ...)
+ *
+ * @param array|string|false $lang_set Lang set(s) to include, false if none shall be included
+ * @param int|false $style_id Style ID to load, false to load default style
+ *
+ * @throws \RuntimeException When called on session and not user instance
+ *
+ * @return void
+ */
+ public function setup($lang_set = false, $style_id = false)
+ {
+ throw new \RuntimeException('Calling setup on session class is not supported.');
+ }
+
/**
* Start session management
*
@@ -1053,8 +1068,6 @@ class session
* @since 3.1.6-RC1
*/
$phpbb_dispatcher->trigger_event('core.session_gc_after');
-
- return;
}
/**
@@ -1124,11 +1137,11 @@ class session
*/
function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false)
{
- global $config, $db, $phpbb_dispatcher;
+ global $db, $phpbb_dispatcher;
if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN'))
{
- return;
+ return false;
}
$banned = false;
@@ -1254,14 +1267,7 @@ class session
if ($banned && !$return)
{
- global $phpbb_root_path, $phpEx;
-
- // If the session is empty we need to create a valid one...
- if (empty($this->session_id))
- {
- // This seems to be no longer needed? - #14971
-// $this->session_create(ANONYMOUS);
- }
+ global $phpEx;
// Initiate environment ... since it won't be set at this stage
$this->setup();
@@ -1295,13 +1301,7 @@ class session
}
// Determine which message to output
- $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : '';
- $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM';
-
- $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx);
- $message = sprintf($this->lang[$message], $till_date, '', '');
- $message .= ($ban_row['ban_give_reason']) ? '
' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : '';
- $message .= '
' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . '';
+ $message = $this->get_ban_message($ban_row, $ban_triggered_by);
// A very special case... we are within the cron script which is not supposed to print out the ban message... show blank page
if (defined('IN_CRON'))
@@ -1345,6 +1345,19 @@ class session
}
}
+ /**
+ * Get ban info message
+ *
+ * @param array $ban_row Ban data row from database
+ * @param string $ban_triggered_by Ban triggered by; allowed 'user', 'ip', 'email'
+ *
+ * @return string
+ */
+ protected function get_ban_message(array $ban_row, string $ban_triggered_by): string
+ {
+ return ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM';
+ }
+
/**
* Check if ip is blacklisted
* This should be called only where absolutely necessary
@@ -1355,7 +1368,7 @@ class session
* @param string $mode register/post - spamcop for example is omitted for posting
* @param string|false $ip the IPv4 address to check
*
- * @return false if ip is not blacklisted, else an array([checked server], [lookup])
+ * @return array|false false if ip is not blacklisted, else an array([checked server], [lookup])
*/
function check_dnsbl($mode, $ip = false)
{
@@ -1680,7 +1693,9 @@ class session
$this->data = array_merge($this->data, $sql_ary);
- if ($this->data['user_id'] != ANONYMOUS && isset($config['new_member_post_limit']) && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts'])
+ if ($this->data['user_id'] != ANONYMOUS && isset($config['new_member_post_limit'])
+ && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts']
+ && $this instanceof user)
{
$this->leave_newly_registered();
}
diff --git a/phpBB/phpbb/storage/controller/attachment.php b/phpBB/phpbb/storage/controller/attachment.php
index 8cfae96905..08cd012290 100644
--- a/phpBB/phpbb/storage/controller/attachment.php
+++ b/phpBB/phpbb/storage/controller/attachment.php
@@ -278,7 +278,7 @@ class attachment extends controller
$response->headers->set('Content-Disposition', $disposition);
// Set expires header for browser cache
- $time = new \Datetime();
+ $time = new \DateTime();
$response->setExpires($time->modify('+1 year'));
return parent::handle($attachment['physical_filename']);
@@ -289,7 +289,7 @@ class attachment extends controller
*/
protected function filenameFallback($filename)
{
- $filename = preg_replace(['/[^\x20-\x7e]/', '/%/', '/\//', '/\\\/'], '', $filename);
+ $filename = preg_replace(['/[^\x20-\x7e]/', '/%/', '/\//', '/\\\\/'], '', $filename);
return (!empty($filename)) ?: 'File';
}
diff --git a/phpBB/phpbb/storage/controller/avatar.php b/phpBB/phpbb/storage/controller/avatar.php
index aaf347fd79..7055961230 100644
--- a/phpBB/phpbb/storage/controller/avatar.php
+++ b/phpBB/phpbb/storage/controller/avatar.php
@@ -107,7 +107,7 @@ class avatar extends controller
$response->headers->set('Content-Disposition', $disposition);
- $time = new \Datetime();
+ $time = new \DateTime();
$response->setExpires($time->modify('+1 year'));
parent::prepare($response, $file);
diff --git a/phpBB/phpbb/storage/exception/exception.php b/phpBB/phpbb/storage/exception/exception.php
index 3a587bea3f..8268530c16 100644
--- a/phpBB/phpbb/storage/exception/exception.php
+++ b/phpBB/phpbb/storage/exception/exception.php
@@ -20,11 +20,11 @@ class exception extends runtime_exception
/**
* Constructor
*
- * @param string $message The Exception message to throw (must be a language variable)
- * @param string $filename The file that caused the error
- * @param array $parameters The parameters to use with the language var
- * @param \Exception $previous The previous runtime_exception used for the runtime_exception chaining
- * @param integer $code The Exception code
+ * @param string $message The Exception message to throw (must be a language variable)
+ * @param string $filename The file that caused the error
+ * @param array $parameters The parameters to use with the language var
+ * @param \Exception|null $previous The previous runtime_exception used for the runtime_exception chaining
+ * @param integer $code The Exception code
*/
public function __construct($message = '', $filename = '', $parameters = [], \Exception $previous = null, $code = 0)
{
diff --git a/phpBB/phpbb/storage/file_info.php b/phpBB/phpbb/storage/file_info.php
index b57faa42ed..2e93846838 100644
--- a/phpBB/phpbb/storage/file_info.php
+++ b/phpBB/phpbb/storage/file_info.php
@@ -43,7 +43,7 @@ class file_info
/**
* Constructor
*
- * @param \Symfony\Component\DependencyInjection\ContainerInterface $adapter
+ * @param adapter_interface $adapter
* @param string $path
*/
public function __construct(adapter_interface $adapter, $path)
diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php
index 5689200569..8e4620ab23 100644
--- a/phpBB/phpbb/storage/storage.php
+++ b/phpBB/phpbb/storage/storage.php
@@ -403,7 +403,7 @@ class storage
*
* @param string $path The file
*
- * @throws \phpbb\storage\exception\not_implemented When the adapter doesnt implement the method
+ * @throws exception When the adapter doesn't implement the method
* When the file doesn't exist
*
* @return \phpbb\storage\file_info Returns file_info object
diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php
index d98d8b6e28..7f83152590 100644
--- a/phpBB/phpbb/template/context.php
+++ b/phpBB/phpbb/template/context.php
@@ -340,7 +340,7 @@ class context
* If key is false the position is set to 0
* If key is true the position is set to the last entry
*
- * @return mixed false if not found, index position otherwise; be sure to test with ===
+ * @return false|int false if not found, index position otherwise; be sure to test with ===
*/
public function find_key_index($blockname, $key)
{
@@ -377,7 +377,7 @@ class context
// Change key to zero (change first position) if false and to last position if true
if (is_bool($key))
{
- return (!$key) ? 0 : count($block) - 1;
+ return (!$key) ? 0 : (count($block) ?? 0) - 1;
}
// Get correct position if array given
diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php
index 742dea8d3e..dcc530f37a 100644
--- a/phpBB/phpbb/template/template.php
+++ b/phpBB/phpbb/template/template.php
@@ -15,14 +15,6 @@ namespace phpbb\template;
interface template
{
-
- /**
- * Clear the cache
- *
- * @return \phpbb\template\template
- */
- public function clear_cache();
-
/**
* Sets the template filenames for handles.
*
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php
index bcffbd06ce..5843cc0762 100644
--- a/phpBB/phpbb/template/twig/environment.php
+++ b/phpBB/phpbb/template/twig/environment.php
@@ -54,9 +54,9 @@ class environment extends \Twig\Environment
* @param \phpbb\filesystem\filesystem $filesystem
* @param \phpbb\path_helper $path_helper phpBB path helper
* @param string $cache_path The path to the cache directory
- * @param \phpbb\extension\manager $extension_manager phpBB extension manager
- * @param \Twig\Loader\LoaderInterface $loader Twig loader interface
- * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object
+ * @param \phpbb\extension\manager|null $extension_manager phpBB extension manager
+ * @param \Twig\Loader\LoaderInterface|null $loader Twig loader interface
+ * @param \phpbb\event\dispatcher_interface|null $phpbb_dispatcher Event dispatcher object
* @param array $options Array of options to pass to Twig
*/
public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig\Loader\LoaderInterface $loader = null, \phpbb\event\dispatcher_interface $phpbb_dispatcher = null, $options = array())
@@ -195,7 +195,7 @@ class environment extends \Twig\Environment
}
/**
- * {@inheritdoc}
+ * Get template with assets
*/
private function display_with_assets($name, array $context = [])
{
@@ -261,7 +261,7 @@ class environment extends \Twig\Environment
*
* @param string $cls The template class associated with the given template name
* @param string $name The template name
- * @param integer $index The index if it is an embedded template
+ * @param integer|null $index The index if it is an embedded template
* @return \Twig\Template A template instance representing the given template name
* @throws \Twig\Error\LoaderError
*/
diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php
index 6dc3bb2994..f745690089 100644
--- a/phpBB/phpbb/template/twig/extension.php
+++ b/phpBB/phpbb/template/twig/extension.php
@@ -53,7 +53,7 @@ class extension extends \Twig\Extension\AbstractExtension
/**
* Returns the token parser instance to add to the existing list.
*
- * @return array An array of \Twig\TokenParser\AbstractTokenParser instances
+ * @return \Twig\TokenParser\TokenParserInterface[] An array of \Twig\TokenParser\AbstractTokenParser instances
*/
public function getTokenParsers()
{
@@ -69,7 +69,7 @@ class extension extends \Twig\Extension\AbstractExtension
/**
* Returns a list of filters to add to the existing list.
*
- * @return array An array of filters
+ * @return \Twig\TwigFilter[] An array of filters
*/
public function getFilters()
{
@@ -85,7 +85,7 @@ class extension extends \Twig\Extension\AbstractExtension
/**
* Returns a list of global functions to add to the existing list.
*
- * @return array An array of global functions
+ * @return \Twig\TwigFunction[] An array of global functions
*/
public function getFunctions()
{
@@ -100,7 +100,7 @@ class extension extends \Twig\Extension\AbstractExtension
/**
* Returns a list of operators to add to the existing list.
*
- * @return array An array of operators
+ * @return array[] An array of operators
*/
public function getOperators()
{
diff --git a/phpBB/phpbb/template/twig/extension/avatar.php b/phpBB/phpbb/template/twig/extension/avatar.php
index d8b27fed9f..fb7ec92655 100644
--- a/phpBB/phpbb/template/twig/extension/avatar.php
+++ b/phpBB/phpbb/template/twig/extension/avatar.php
@@ -30,9 +30,9 @@ class avatar extends AbstractExtension
/**
* Returns a list of global functions to add to the existing list.
*
- * @return array An array of global functions
+ * @return \Twig\TwigFunction[] An array of global functions
*/
- public function getFunctions()
+ public function getFunctions(): array
{
return array(
new \Twig\TwigFunction('avatar', array($this, 'get_avatar')),
diff --git a/phpBB/phpbb/template/twig/extension/config.php b/phpBB/phpbb/template/twig/extension/config.php
index a7f1189d27..e0b8eb440d 100644
--- a/phpBB/phpbb/template/twig/extension/config.php
+++ b/phpBB/phpbb/template/twig/extension/config.php
@@ -43,9 +43,9 @@ class config extends AbstractExtension
/**
* Returns a list of global functions to add to the existing list.
*
- * @return array An array of global functions
+ * @return \Twig\TwigFunction[] An array of global functions
*/
- public function getFunctions()
+ public function getFunctions(): array
{
return array(
new \Twig\TwigFunction('config', array($this, 'get_config')),
@@ -55,7 +55,7 @@ class config extends AbstractExtension
/**
* Retrieves a configuration value for use in templates.
*
- * @return string The configuration value
+ * @return int|string The configuration value
*/
public function get_config()
{
diff --git a/phpBB/phpbb/template/twig/extension/routing.php b/phpBB/phpbb/template/twig/extension/routing.php
index 9c404e55d3..3073675d0c 100644
--- a/phpBB/phpbb/template/twig/extension/routing.php
+++ b/phpBB/phpbb/template/twig/extension/routing.php
@@ -22,7 +22,7 @@ use Twig\TwigFunction;
class routing extends AbstractExtension
{
- /** @var \phpbb\controller\helper */
+ /** @var \phpbb\routing\helper */
protected $helper;
/**
diff --git a/phpBB/phpbb/template/twig/extension/username.php b/phpBB/phpbb/template/twig/extension/username.php
index 83cbebe29a..bf99907232 100644
--- a/phpBB/phpbb/template/twig/extension/username.php
+++ b/phpBB/phpbb/template/twig/extension/username.php
@@ -28,14 +28,12 @@ class username extends AbstractExtension
}
/**
- * Returns a list of global functions to add to the existing list.
- *
- * @return array An array of global functions
+ * {@inheritDoc}
*/
public function getFunctions()
{
return array(
- new \Twig\TwigFunction('username', array($this, 'get_username')),
+ new \Twig\TwigFunction('username', [$this, 'get_username']),
);
}
diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php
index 76bfc6d127..4eddcbcf38 100644
--- a/phpBB/phpbb/template/twig/node/event.php
+++ b/phpBB/phpbb/template/twig/node/event.php
@@ -21,7 +21,7 @@ class event extends \Twig\Node\Node
*/
protected $listener_directory = 'event/';
- /** @var \Twig\Environment */
+ /** @var \phpbb\template\twig\environment */
protected $environment;
public function __construct(\Twig\Node\Expression\AbstractExpression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null)
diff --git a/phpBB/phpbb/template/twig/tokenparser/defineparser.php b/phpBB/phpbb/template/twig/tokenparser/defineparser.php
index ac98dce421..ce394c0896 100644
--- a/phpBB/phpbb/template/twig/tokenparser/defineparser.php
+++ b/phpBB/phpbb/template/twig/tokenparser/defineparser.php
@@ -21,9 +21,8 @@ class defineparser extends \Twig\TokenParser\AbstractTokenParser
*
* @param \Twig\Token $token A Twig\Token instance
*
- * @return \Twig\Node\Node A Twig\Node instance
* @throws \Twig\Error\SyntaxError
- * @throws \phpbb\template\twig\node\definenode
+ * @return \Twig\Node\Node A Twig\Node instance
*/
public function parse(\Twig\Token $token)
{
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index 6f442401ff..1259618175 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -92,27 +92,14 @@ class twig extends \phpbb\template\base
}
// Add admin namespace
- if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/'))
+ if ($this->path_helper->get_adm_relative_path() !== null
+ && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')
+ && $this->loader instanceof \Twig\Loader\FilesystemLoader)
{
$this->loader->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin');
}
}
- /**
- * Clear the cache
- *
- * @return \phpbb\template\template
- */
- public function clear_cache()
- {
- if (is_dir($this->cachepath))
- {
- $this->twig->clearCacheFiles();
- }
-
- return $this;
- }
-
/**
* Get the style tree of the style preferred by the current user
*
diff --git a/phpBB/phpbb/textformatter/s9e/bbcode_merger.php b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php
index 8173037455..17397800e1 100644
--- a/phpBB/phpbb/textformatter/s9e/bbcode_merger.php
+++ b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php
@@ -37,8 +37,8 @@ class bbcode_merger
*
* All of the arrays contain a "usage" element and a "template" element
*
- * @throws InvalidArgumentException if a definition cannot be interpreted
- * @throws RuntimeException if something unexpected occurs
+ * @throws \InvalidArgumentException if a definition cannot be interpreted
+ * @throws \RuntimeException if something unexpected occurs
*
* @param array $without BBCode definition without an attribute
* @param array $with BBCode definition with an attribute
diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php
index 01cc545a72..4256ec85d9 100644
--- a/phpBB/phpbb/textformatter/s9e/factory.php
+++ b/phpBB/phpbb/textformatter/s9e/factory.php
@@ -226,8 +226,9 @@ class factory implements \phpbb\textformatter\cache_interface
* @event core.text_formatter_s9e_configure_before
* @var Configurator configurator Configurator instance
* @since 3.2.0-a1
+ * @psalm-ignore-var
*/
- $vars = array('configurator');
+ $vars = ['configurator'];
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_before', compact($vars)));
// Reset the list of allowed schemes
@@ -375,8 +376,9 @@ class factory implements \phpbb\textformatter\cache_interface
* @event core.text_formatter_s9e_configure_after
* @var Configurator configurator Configurator instance
* @since 3.2.0-a1
+ * @psalm-ignore-var
*/
- $vars = array('configurator');
+ $vars = ['configurator'];
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_after', compact($vars)));
return $configurator;
@@ -444,7 +446,7 @@ class factory implements \phpbb\textformatter\cache_interface
}
catch (\Exception $e)
{
- $this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]);
+ $this->log->add('critical', ANONYMOUS, '', 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]);
}
}
diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php
index cf36879dbe..33f2a0227c 100644
--- a/phpBB/phpbb/textformatter/s9e/parser.php
+++ b/phpBB/phpbb/textformatter/s9e/parser.php
@@ -65,8 +65,9 @@ class parser implements \phpbb\textformatter\parser_interface
* @event core.text_formatter_s9e_parser_setup
* @var \phpbb\textformatter\s9e\parser parser This parser service
* @since 3.2.0-a1
+ * @psalm-ignore-var
*/
- $vars = array('parser');
+ $vars = ['parser'];
extract($dispatcher->trigger_event('core.text_formatter_s9e_parser_setup', compact($vars)));
}
diff --git a/phpBB/phpbb/textformatter/s9e/renderer.php b/phpBB/phpbb/textformatter/s9e/renderer.php
index 29dbf29afc..8328b65a95 100644
--- a/phpBB/phpbb/textformatter/s9e/renderer.php
+++ b/phpBB/phpbb/textformatter/s9e/renderer.php
@@ -117,8 +117,9 @@ class renderer implements \phpbb\textformatter\renderer_interface
* @event core.text_formatter_s9e_renderer_setup
* @var \phpbb\textformatter\s9e\renderer renderer This renderer service
* @since 3.2.0-a1
+ * @psalm-ignore-var
*/
- $vars = array('renderer');
+ $vars = ['renderer'];
extract($dispatcher->trigger_event('core.text_formatter_s9e_renderer_setup', compact($vars)));
}
@@ -147,7 +148,7 @@ class renderer implements \phpbb\textformatter\renderer_interface
*
* @param \phpbb\config\config $config
* @param \phpbb\path_helper $path_helper
- * @return null
+ * @return void
*/
public function configure_smilies_path(\phpbb\config\config $config, \phpbb\path_helper $path_helper)
{
@@ -234,16 +235,16 @@ class renderer implements \phpbb\textformatter\renderer_interface
/**
* {@inheritdoc}
*/
- public function render($xml)
+ public function render($text)
{
if (isset($this->mention_helper))
{
- $xml = $this->mention_helper->inject_metadata($xml);
+ $text = $this->mention_helper->inject_metadata($text);
}
if (isset($this->quote_helper))
{
- $xml = $this->quote_helper->inject_metadata($xml);
+ $text = $this->quote_helper->inject_metadata($text);
}
$renderer = $this;
@@ -253,13 +254,14 @@ class renderer implements \phpbb\textformatter\renderer_interface
*
* @event core.text_formatter_s9e_render_before
* @var \phpbb\textformatter\s9e\renderer renderer This renderer service
- * @var string xml The parsed text, in its XML form
+ * @var string text The parsed text, in its XML form
* @since 3.2.0-a1
+ * @psalm-ignore-var
*/
- $vars = array('renderer', 'xml');
+ $vars = ['renderer', 'text'];
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_before', compact($vars)));
- $html = $this->renderer->render($xml);
+ $html = $this->renderer->render($text);
if (isset($this->censor) && $this->viewcensors)
{
$html = $this->censor->censorHtml($html, true);
@@ -272,8 +274,9 @@ class renderer implements \phpbb\textformatter\renderer_interface
* @var string html The rendered text's HTML
* @var \phpbb\textformatter\s9e\renderer renderer This renderer service
* @since 3.2.0-a1
+ * @psalm-ignore-var
*/
- $vars = array('html', 'renderer');
+ $vars = ['html', 'renderer'];
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_after', compact($vars)));
return $html;
diff --git a/phpBB/phpbb/textformatter/s9e/utils.php b/phpBB/phpbb/textformatter/s9e/utils.php
index 1c77d89976..9e6e367d24 100644
--- a/phpBB/phpbb/textformatter/s9e/utils.php
+++ b/phpBB/phpbb/textformatter/s9e/utils.php
@@ -26,15 +26,15 @@ class utils implements \phpbb\textformatter\utils_interface
*
* NOTE: preserves smilies as text
*
- * @param string $xml Parsed text
+ * @param string $text Parsed text
* @return string Plain text
*/
- public function clean_formatting($xml)
+ public function clean_formatting($text)
{
// Insert a space before and then remove formatting
- $xml = preg_replace('#<[es]>#', ' $0', $xml);
+ $text = preg_replace('#<[es]>#', ' $0', $text);
- return \s9e\TextFormatter\Utils::removeFormatting($xml);
+ return \s9e\TextFormatter\Utils::removeFormatting($text);
}
/**
@@ -94,19 +94,19 @@ class utils implements \phpbb\textformatter\utils_interface
/**
* Get a list of quote authors, limited to the outermost quotes
*
- * @param string $xml Parsed text
+ * @param string $text Parsed text
* @return string[] List of authors
*/
- public function get_outermost_quote_authors($xml)
+ public function get_outermost_quote_authors($text)
{
$authors = array();
- if (strpos($xml, 'loadXML($xml);
+ $dom->loadXML($text);
$xpath = new \DOMXPath($dom);
foreach ($xpath->query('//QUOTE[not(ancestor::QUOTE)]/@author') as $author)
{
@@ -119,25 +119,25 @@ class utils implements \phpbb\textformatter\utils_interface
/**
* Remove given BBCode and its content, at given nesting depth
*
- * @param string $xml Parsed text
+ * @param string $text Parsed text
* @param string $bbcode_name BBCode's name
* @param integer $depth Minimum nesting depth (number of parents of the same name)
* @return string Parsed text
*/
- public function remove_bbcode($xml, $bbcode_name, $depth = 0)
+ public function remove_bbcode($text, $bbcode_name, $depth = 0)
{
- return \s9e\TextFormatter\Utils::removeTag($xml, strtoupper($bbcode_name), $depth);
+ return \s9e\TextFormatter\Utils::removeTag($text, strtoupper($bbcode_name), $depth);
}
/**
* Return a parsed text to its original form
*
- * @param string $xml Parsed text
+ * @param string $text Parsed text
* @return string Original plain text
*/
- public function unparse($xml)
+ public function unparse($text)
{
- return \s9e\TextFormatter\Unparser::unparse($xml);
+ return \s9e\TextFormatter\Unparser::unparse($text);
}
/**
diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php
index bd7b6c9fc9..6ac30a0002 100644
--- a/phpBB/phpbb/textreparser/base.php
+++ b/phpBB/phpbb/textreparser/base.php
@@ -40,8 +40,11 @@ abstract class base implements reparser_interface
abstract protected function get_records_by_range($min_id, $max_id);
/**
- * {@inheritdoc}
- */
+ * Save record
+ *
+ * @param array $record
+ * @return void
+ */
abstract protected function save_record(array $record);
/**
@@ -243,7 +246,8 @@ abstract class base implements reparser_interface
// generate_text_for_edit() and decode_message() actually return the text as HTML. It has to
// be decoded to plain text before it can be reparsed
$text = html_entity_decode($unparsed['text'], ENT_QUOTES, 'UTF-8');
- $bitfield = $flags = null;
+ $bitfield = '';
+ $flags = 0;
generate_text_for_storage(
$text,
$unparsed['bbcode_uid'],
diff --git a/phpBB/phpbb/textreparser/manager.php b/phpBB/phpbb/textreparser/manager.php
index 7ca65d708d..9a7663f938 100644
--- a/phpBB/phpbb/textreparser/manager.php
+++ b/phpBB/phpbb/textreparser/manager.php
@@ -132,9 +132,9 @@ class manager
* If there is no reparser with the specified name, null is returned.
*
* @param string $name Name of the reparser to look up.
- * @return string A reparser service name, or null.
+ * @return string|null A reparser service name, or null.
*/
- public function find_reparser($name)
+ public function find_reparser(string $name)
{
foreach ($this->reparsers as $service => $reparser)
{
diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php
index 647d3a7b14..79be5c8282 100644
--- a/phpBB/phpbb/textreparser/plugins/user_signature.php
+++ b/phpBB/phpbb/textreparser/plugins/user_signature.php
@@ -24,21 +24,21 @@ class user_signature extends \phpbb\textreparser\row_based_plugin
/**
* {@inheritdoc}
*/
- protected function add_missing_fields(array $row)
+ protected function add_missing_fields(array $record)
{
if (!isset($this->keyoptions))
{
$this->save_keyoptions();
}
- $options = $row['user_options'];
- $row += array(
+ $options = $record['user_options'];
+ $record += array(
'enable_bbcode' => phpbb_optionget($this->keyoptions['sig_bbcode'], $options),
'enable_smilies' => phpbb_optionget($this->keyoptions['sig_smilies'], $options),
'enable_magic_url' => phpbb_optionget($this->keyoptions['sig_links'], $options),
);
- return parent::add_missing_fields($row);
+ return parent::add_missing_fields($record);
}
/**
diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php
index b25a91b7b9..3a32710ebc 100644
--- a/phpBB/phpbb/tree/nestedset.php
+++ b/phpBB/phpbb/tree/nestedset.php
@@ -700,7 +700,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface
* @param bool $set_subset_zero Should the parent, left and right id of the items be set to 0, or kept unchanged?
* In case of removing an item from the tree, we should the values to 0
* In case of moving an item, we shouldkeep the original values, in order to allow "+ diff" later
- * @return null
+ * @return void
*/
protected function remove_subset(array $subset_items, array $bounding_item, $set_subset_zero = true)
{
diff --git a/phpBB/phpbb/ucp/controller/reset_password.php b/phpBB/phpbb/ucp/controller/reset_password.php
index 10bc7c2d2f..98ab4ba781 100644
--- a/phpBB/phpbb/ucp/controller/reset_password.php
+++ b/phpBB/phpbb/ucp/controller/reset_password.php
@@ -22,7 +22,7 @@ use phpbb\exception\http_exception;
use phpbb\language\language;
use phpbb\log\log_interface;
use phpbb\passwords\manager;
-use phpbb\request\request_interface;
+use phpbb\request\request;
use phpbb\template\template;
use phpbb\user;
use Symfony\Component\HttpFoundation\Response;
@@ -53,7 +53,7 @@ class reset_password
/** @var manager */
protected $passwords_manager;
- /** @var request_interface */
+ /** @var request */
protected $request;
/** @var template */
@@ -81,7 +81,7 @@ class reset_password
* @param language $language
* @param log_interface $log
* @param manager $passwords_manager
- * @param request_interface $request
+ * @param request $request
* @param template $template
* @param user $user
* @param string $users_table
@@ -90,7 +90,7 @@ class reset_password
*/
public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, helper $helper,
language $language, log_interface $log, manager $passwords_manager,
- request_interface $request, template $template, user $user, string $users_table,
+ request $request, template $template, user $user, string $users_table,
string $root_path, string $php_ext)
{
$this->config = $config;
diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php
index ec3c4b74be..52427d2915 100644
--- a/phpBB/phpbb/user.php
+++ b/phpBB/phpbb/user.php
@@ -108,8 +108,13 @@ class user extends \phpbb\session
/**
* Setup basic user-specific items (style, language, ...)
+ *
+ * @param array|string|false $lang_set Lang set(s) to include, false if none shall be included
+ * @param int|false $style_id Style ID to load, false to load default style
+ *
+ * @return void
*/
- function setup($lang_set = false, $style_id = false)
+ public function setup($lang_set = false, $style_id = false)
{
global $db, $request, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
global $phpbb_dispatcher, $phpbb_container;
@@ -437,8 +442,6 @@ class user extends \phpbb\session
}
$this->is_setup_flag = true;
-
- return;
}
/**
@@ -467,14 +470,18 @@ class user extends \phpbb\session
* @param $number int|float The number we want to get the plural case for. Float numbers are floored.
* @param $force_rule mixed False to use the plural rule of the language package
* or an integer to force a certain plural rule
- * @return int|bool The plural-case we need to use for the number plural-rule combination, false if $force_rule
+ * @return int|false The plural-case we need to use for the number plural-rule combination, false if $force_rule
* was invalid.
*
* @deprecated: 3.2.0-dev (To be removed: 4.0.0)
*/
function get_plural_form($number, $force_rule = false)
{
- return $this->language->get_plural_form($number, $force_rule);
+ try {
+ return $this->language->get_plural_form($number, $force_rule);
+ } catch (\phpbb\language\exception\invalid_plural_rule_exception $e) {
+ return false;
+ }
}
/**
@@ -590,7 +597,7 @@ class user extends \phpbb\session
* Format user date
*
* @param int $gmepoch unix timestamp
- * @param string $format date format in date() notation. | used to indicate relative dates, for example |d m Y|, h:i is translated to Today, h:i.
+ * @param string|false $format date format in date() notation. | used to indicate relative dates, for example |d m Y|, h:i is translated to Today, h:i.
* @param bool $forcedate force non-relative date format.
*
* @return mixed translated date
@@ -614,7 +621,7 @@ class user extends \phpbb\session
* set $format_date_override to new return value
*
* @event core.user_format_date_override
- * @var DateTimeZone utc Is DateTimeZone in UTC
+ * @var \DateTimeZone utc Is DateTimeZone in UTC
* @var array function_arguments is array comprising a function's argument list
* @var string format_date_override Shall we return custom format (string) or not (false)
* @since 3.2.1-RC1
@@ -668,12 +675,11 @@ class user extends \phpbb\session
/**
* Create a \phpbb\datetime object in the context of the current user
*
- * @since 3.1
* @param string $time String in a format accepted by strtotime().
- * @param DateTimeZone|null $timezone Time zone of the time.
+ * @param ?\DateTimeZone $timezone Time zone of the time.
* @return \phpbb\datetime Date time object linked to the current users locale
*/
- public function create_datetime($time = 'now', \DateTimeZone $timezone = null)
+ public function create_datetime(string $time = 'now', ?\DateTimeZone $timezone = null)
{
$timezone = $timezone ?: $this->create_timezone();
return new $this->datetime($this, $time, $timezone);
@@ -684,14 +690,14 @@ class user extends \phpbb\session
*
* @param string $format Format of the entered date/time
* @param string $time Date/time with the timezone applied
- * @param DateTimeZone|null $timezone Timezone of the date/time, falls back to timezone of current user
- * @return int Returns the unix timestamp
+ * @param ?\DateTimeZone $timezone Timezone of the date/time, falls back to timezone of current user
+ * @return string|false Returns the unix timestamp or false if date is invalid
*/
- public function get_timestamp_from_format($format, $time, \DateTimeZone $timezone = null)
+ public function get_timestamp_from_format($format, $time, ?\DateTimeZone $timezone = null)
{
$timezone = $timezone ?: $this->create_timezone();
$date = \DateTime::createFromFormat($format, $time, $timezone);
- return ($date !== false) ? $date->format('U') : false;
+ return $date !== false ? $date->format('U') : false;
}
/**
@@ -760,7 +766,7 @@ class user extends \phpbb\session
* Get option bit field from user options.
*
* @param int $key option key, as defined in $keyoptions property.
- * @param int $data bit field value to use, or false to use $this->data['user_options']
+ * @param int|false $data bit field value to use, or false to use $this->data['user_options']
* @return bool true if the option is set in the bit field, false otherwise
*/
function optionget($key, $data = false)
@@ -774,7 +780,7 @@ class user extends \phpbb\session
*
* @param int $key Option key, as defined in $keyoptions property.
* @param bool $value True to set the option, false to clear the option.
- * @param int $data Current bit field value, or false to use $this->data['user_options']
+ * @param int|false $data Current bit field value, or false to use $this->data['user_options']
* @return int|bool If $data is false, the bit field is modified and
* written back to $this->data['user_options'], and
* return value is true if the bit field changed and
@@ -865,4 +871,22 @@ class user extends \phpbb\session
return $forum_ids;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function get_ban_message(array $ban_row, string $ban_triggered_by): string
+ {
+ global $config, $phpbb_root_path, $phpEx;
+
+ $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : '';
+ $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM';
+
+ $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx);
+ $message = $this->language->lang($message, $till_date, '', '');
+ $message .= ($ban_row['ban_give_reason']) ? '
' . $this->language->lang('BOARD_BAN_REASON', $ban_row['ban_give_reason']) : '';
+ $message .= '
' . $this->language->lang('BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)) . '';
+
+ return $message;
+ }
}
diff --git a/phpBB/phpbb/user_loader.php b/phpBB/phpbb/user_loader.php
index 18aacce349..5d84a843a3 100644
--- a/phpBB/phpbb/user_loader.php
+++ b/phpBB/phpbb/user_loader.php
@@ -132,10 +132,10 @@ class user_loader
* @param bool $query Should we query the database if this user has not yet been loaded?
* Typically this should be left as false and you should make sure
* you load users ahead of time with load_users()
- * @return array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist
+ * @return array|false Row from the database of the user or Anonymous if the user wasn't loaded/does not exist
* or bool False if the anonymous user was not loaded
*/
- public function get_user($user_id, $query = false)
+ public function get_user(int $user_id, bool $query = false)
{
if (isset($this->users[$user_id]))
{
@@ -162,14 +162,14 @@ class user_loader
* colour (for obtaining the user colour)
* full (for obtaining a html string representing a coloured link to the users profile)
* no_profile (the same as full but forcing no profile link)
- * @param string $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then.
- * @param string $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id}
+ * @param string|bool $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then.
+ * @param string|bool $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id}
* @param bool $query Should we query the database if this user has not yet been loaded?
* Typically this should be left as false and you should make sure
* you load users ahead of time with load_users()
* @return string
*/
- public function get_username($user_id, $mode, $guest_username = false, $custom_profile_url = false, $query = false)
+ public function get_username(int $user_id, string $mode, $guest_username = false, $custom_profile_url = false, bool $query = false): string
{
if (!($user = $this->get_user($user_id, $query)))
{
@@ -215,11 +215,11 @@ class user_loader
* you load users ahead of time with load_users()
* @return array Array with keys 'rank_title', 'rank_img', and 'rank_img_src'
*/
- public function get_rank($user_id, $query = false)
+ public function get_rank(int $user_id, bool $query = false): array
{
if (!($user = $this->get_user($user_id, $query)))
{
- return '';
+ return [];
}
if (!function_exists('phpbb_get_user_rank'))
@@ -233,7 +233,7 @@ class user_loader
'rank_img_src',
);
- $user_rank_data = phpbb_get_user_rank($user, (($user['user_id'] == ANONYMOUS) ? false : $user['user_posts']));
+ $user_rank_data = phpbb_get_user_rank($user, ($user['user_id'] == ANONYMOUS ? false : $user['user_posts']));
$rank['rank_title'] = $user_rank_data['title'];
$rank['rank_img'] = $user_rank_data['img'];
$rank['rank_img_src'] = $user_rank_data['img_src'];
diff --git a/psalm.xml b/psalm.xml
index b28f550d48..cb434cfaf8 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -14,5 +14,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/cache/cache_memory.php b/tests/cache/cache_memory.php
index 1f7b31a86b..9d94c080f2 100644
--- a/tests/cache/cache_memory.php
+++ b/tests/cache/cache_memory.php
@@ -23,40 +23,26 @@ class phpbb_cache_memory extends \phpbb\cache\driver\memory
}
/**
- * Fetch an item from the cache
- *
- * @access protected
- * @param string $var Cache key
- * @return mixed Cached data
- */
- function _read($var)
+ * {@inheritDoc}
+ */
+ protected function _read(string $var)
{
return $this->data[$var] ?? false;
}
/**
- * Store data in the cache
- *
- * @access protected
- * @param string $var Cache key
- * @param mixed $data Data to store
- * @param int $ttl Time-to-live of cached data
- * @return bool True if the operation succeeded
+ * {@inheritDoc}
*/
- function _write($var, $data, $ttl = 2592000)
+ protected function _write(string $var, $data, int $ttl = 2592000): bool
{
$this->data[$var] = $data;
return true;
}
/**
- * Remove an item from the cache
- *
- * @access protected
- * @param string $var Cache key
- * @return bool True if the operation succeeded
- */
- function _delete($var)
+ * {@inheritDoc}
+ */
+ protected function _delete(string $var): bool
{
unset($this->data[$var]);
return true;
diff --git a/tests/mock/request.php b/tests/mock/request.php
index 6a32ba0cf1..1253e40915 100644
--- a/tests/mock/request.php
+++ b/tests/mock/request.php
@@ -11,7 +11,7 @@
*
*/
-class phpbb_mock_request implements \phpbb\request\request_interface
+class phpbb_mock_request extends \phpbb\request\request
{
protected $data;
diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php
index aa903df0db..84de6a5c6f 100644
--- a/tests/mock/session_testable.php
+++ b/tests/mock/session_testable.php
@@ -62,7 +62,7 @@ class phpbb_mock_session_testable extends \phpbb\session
}
}
- public function setup()
+ public function setup($lang_set = false, $style_id = false)
{
}
}
diff --git a/tests/notification/ext/test/notification/type/test.php b/tests/notification/ext/test/notification/type/test.php
index 7f3b4a4ef1..f325efba6e 100644
--- a/tests/notification/ext/test/notification/type/test.php
+++ b/tests/notification/ext/test/notification/type/test.php
@@ -28,26 +28,26 @@ class test extends \phpbb\notification\type\base
return 'test';
}
- public static function get_item_id($post)
+ public static function get_item_id($type_data)
{
- return (int) $post['post_id'];
+ return (int) $type_data['post_id'];
}
- public static function get_item_parent_id($post)
+ public static function get_item_parent_id($type_data)
{
- return (int) $post['topic_id'];
+ return (int) $type_data['topic_id'];
}
- public function find_users_for_notification($post, $options = array())
+ public function find_users_for_notification($type_data, $options = array())
{
return $this->check_user_notification_options(array(0), $options);
}
- public function create_insert_array($post, $pre_create_data = array())
+ public function create_insert_array($type_data, $pre_create_data = array())
{
- $this->notification_time = $post['post_time'];
+ $this->notification_time = $type_data['post_time'];
- parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($type_data, $pre_create_data);
}
public function create_update_array($type_data)
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 52c76b13a5..9a06c06dc9 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -110,7 +110,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
+ $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $lang)));
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', $this->template_path);
}
@@ -120,21 +120,11 @@ class phpbb_template_template_test_case extends phpbb_test_case
// Test the engine can be used
$this->setup_engine();
- $this->template->clear_cache();
-
global $phpbb_filesystem;
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
}
- protected function tearDown(): void
- {
- if ($this->template)
- {
- $this->template->clear_cache();
- }
- }
-
protected function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $lang_vars = array())
{
$this->template->set_filenames(array('test' => $file));
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index 6e2de36058..7e35c18332 100644
--- a/tests/text_formatter/s9e/factory_test.php
+++ b/tests/text_formatter/s9e/factory_test.php
@@ -15,6 +15,16 @@ require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php';
class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
{
+ /**
+ * @var phpbb_mock_cache
+ */
+ private $cache;
+
+ /**
+ * @var phpbb_mock_event_dispatcher
+ */
+ private $dispatcher;
+
protected function setUp(): void
{
$this->cache = new phpbb_mock_cache;
@@ -271,7 +281,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
$log = $this->getMockBuilder('phpbb\\log\\log_interface')->getMock();
$log->expects($this->once())
->method('add')
- ->with('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, ['[x !x]{TEXT}[/x]', 'Cannot interpret the BBCode definition']);
+ ->with('critical', ANONYMOUS, '', 'LOG_BBCODE_CONFIGURATION_ERROR', false, ['[x !x]{TEXT}[/x]', 'Cannot interpret the BBCode definition']);
$container = new phpbb_mock_container_builder;
$container->set('log', $log);
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php
index d0ca520ea0..51f4f923b4 100644
--- a/tests/text_formatter/s9e/renderer_test.php
+++ b/tests/text_formatter/s9e/renderer_test.php
@@ -437,8 +437,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
{
return isset($vars['renderer'])
&& $vars['renderer'] instanceof \phpbb\textformatter\s9e\renderer
- && isset($vars['xml'])
- && $vars['xml'] === '...';
+ && isset($vars['text'])
+ && $vars['text'] === '...';
}
public function render_after_event_callback($vars)