Statically used methods should be defined statically as well

This commit is contained in:
Michael 2017-08-25 15:56:08 +00:00
parent 959d6ae15e
commit b0c26921ad
6 changed files with 49 additions and 49 deletions

View File

@ -16,7 +16,7 @@ class Emailer {
* @param additionalMailHeader additions to the smtp mail header * @param additionalMailHeader additions to the smtp mail header
* @param optional uid user id of the destination user * @param optional uid user id of the destination user
*/ */
static public function send($params) { public static function send($params) {
call_hooks('emailer_send_prepare', $params); call_hooks('emailer_send_prepare', $params);

View File

@ -187,11 +187,11 @@ class Smilies {
return $s; return $s;
} }
private function encode($m) { private static function encode($m) {
return(str_replace($m[1],base64url_encode($m[1]),$m[0])); return(str_replace($m[1],base64url_encode($m[1]),$m[0]));
} }
private function decode($m) { private static function decode($m) {
return(str_replace($m[1],base64url_decode($m[1]),$m[0])); return(str_replace($m[1],base64url_decode($m[1]),$m[0]));
} }
@ -204,7 +204,7 @@ class Smilies {
* *
* @todo: Rework because it doesn't work correctly * @todo: Rework because it doesn't work correctly
*/ */
private function preg_heart($x) { private static function preg_heart($x) {
if(strlen($x[1]) == 1) if(strlen($x[1]) == 1)
return $x[0]; return $x[0];
$t = ''; $t = '';

View File

@ -42,7 +42,7 @@ class Cache {
* *
* @return integer The cache duration in seconds * @return integer The cache duration in seconds
*/ */
private function duration($level) { private static function duration($level) {
switch($level) { switch($level) {
case CACHE_MONTH; case CACHE_MONTH;
$seconds = 2592000; $seconds = 2592000;

View File

@ -476,7 +476,7 @@ class dba {
* @param array $args The parameters that are to replace the ? placeholders * @param array $args The parameters that are to replace the ? placeholders
* @return string The replaced SQL query * @return string The replaced SQL query
*/ */
static private function replace_parameters($sql, $args) { private static function replace_parameters($sql, $args) {
$offset = 0; $offset = 0;
foreach ($args AS $param => $value) { foreach ($args AS $param => $value) {
if (is_int($args[$param]) || is_float($args[$param])) { if (is_int($args[$param]) || is_float($args[$param])) {
@ -516,7 +516,7 @@ class dba {
* @param string $sql SQL statement * @param string $sql SQL statement
* @return object statement object * @return object statement object
*/ */
static public function p($sql) { public static function p($sql) {
$a = get_app(); $a = get_app();
$stamp1 = microtime(true); $stamp1 = microtime(true);
@ -711,7 +711,7 @@ class dba {
* @param string $sql SQL statement * @param string $sql SQL statement
* @return boolean Was the query successfull? False is returned only if an error occurred * @return boolean Was the query successfull? False is returned only if an error occurred
*/ */
static public function e($sql) { public static function e($sql) {
$a = get_app(); $a = get_app();
$stamp = microtime(true); $stamp = microtime(true);
@ -761,7 +761,7 @@ class dba {
* *
* @return boolean Are there rows for that condition? * @return boolean Are there rows for that condition?
*/ */
static public function exists($table, $condition) { public static function exists($table, $condition) {
if (empty($table)) { if (empty($table)) {
return false; return false;
} }
@ -793,7 +793,7 @@ class dba {
* @param string $sql SQL statement * @param string $sql SQL statement
* @return array first row of query * @return array first row of query
*/ */
static public function fetch_first($sql) { public static function fetch_first($sql) {
$params = self::getParam(func_get_args()); $params = self::getParam(func_get_args());
$stmt = self::p($sql, $params); $stmt = self::p($sql, $params);
@ -814,7 +814,7 @@ class dba {
* *
* @return int Number of rows * @return int Number of rows
*/ */
static public function affected_rows() { public static function affected_rows() {
return self::$dbo->affected_rows; return self::$dbo->affected_rows;
} }
@ -824,7 +824,7 @@ class dba {
* @param object Statement object * @param object Statement object
* @return int Number of rows * @return int Number of rows
*/ */
static public function num_rows($stmt) { public static function num_rows($stmt) {
if (!is_object($stmt)) { if (!is_object($stmt)) {
return 0; return 0;
} }
@ -845,7 +845,7 @@ class dba {
* @param object $stmt statement object * @param object $stmt statement object
* @return array current row * @return array current row
*/ */
static public function fetch($stmt) { public static function fetch($stmt) {
if (!is_object($stmt)) { if (!is_object($stmt)) {
return false; return false;
} }
@ -895,7 +895,7 @@ class dba {
* *
* @return boolean was the insert successfull? * @return boolean was the insert successfull?
*/ */
static public function insert($table, $param, $on_duplicate_update = false) { public static function insert($table, $param, $on_duplicate_update = false) {
$sql = "INSERT INTO `".self::$dbo->escape($table)."` (`".implode("`, `", array_keys($param))."`) VALUES (". $sql = "INSERT INTO `".self::$dbo->escape($table)."` (`".implode("`, `", array_keys($param))."`) VALUES (".
substr(str_repeat("?, ", count($param)), 0, -2).")"; substr(str_repeat("?, ", count($param)), 0, -2).")";
@ -938,7 +938,7 @@ class dba {
* *
* @return boolean was the lock successful? * @return boolean was the lock successful?
*/ */
static public function lock($table) { public static function lock($table) {
// See here: https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html // See here: https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html
self::e("SET autocommit=0"); self::e("SET autocommit=0");
$success = self::e("LOCK TABLES `".self::$dbo->escape($table)."` WRITE"); $success = self::e("LOCK TABLES `".self::$dbo->escape($table)."` WRITE");
@ -955,7 +955,7 @@ class dba {
* *
* @return boolean was the unlock successful? * @return boolean was the unlock successful?
*/ */
static public function unlock() { public static function unlock() {
// See here: https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html // See here: https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html
self::e("COMMIT"); self::e("COMMIT");
$success = self::e("UNLOCK TABLES"); $success = self::e("UNLOCK TABLES");
@ -969,7 +969,7 @@ class dba {
* *
* @return boolean Was the command executed successfully? * @return boolean Was the command executed successfully?
*/ */
static public function transaction() { public static function transaction() {
if (!self::e('COMMIT')) { if (!self::e('COMMIT')) {
return false; return false;
} }
@ -985,7 +985,7 @@ class dba {
* *
* @return boolean Was the command executed successfully? * @return boolean Was the command executed successfully?
*/ */
static public function commit() { public static function commit() {
if (!self::e('COMMIT')) { if (!self::e('COMMIT')) {
return false; return false;
} }
@ -998,7 +998,7 @@ class dba {
* *
* @return boolean Was the command executed successfully? * @return boolean Was the command executed successfully?
*/ */
static public function rollback() { public static function rollback() {
if (!self::e('ROLLBACK')) { if (!self::e('ROLLBACK')) {
return false; return false;
} }
@ -1013,7 +1013,7 @@ class dba {
* *
* This process must only be started once, since the value is cached. * This process must only be started once, since the value is cached.
*/ */
static private function build_relation_data() { private static function build_relation_data() {
$definition = db_definition(); $definition = db_definition();
foreach ($definition AS $table => $structure) { foreach ($definition AS $table => $structure) {
@ -1037,7 +1037,7 @@ class dba {
* *
* @return boolean|array was the delete successfull? When $in_process is set: deletion data * @return boolean|array was the delete successfull? When $in_process is set: deletion data
*/ */
static public function delete($table, $param, $in_process = false, &$callstack = array()) { public static function delete($table, $param, $in_process = false, &$callstack = array()) {
$commands = array(); $commands = array();
@ -1200,7 +1200,7 @@ class dba {
* *
* @return boolean was the update successfull? * @return boolean was the update successfull?
*/ */
static public function update($table, $fields, $condition, $old_fields = array()) { public static function update($table, $fields, $condition, $old_fields = array()) {
$table = self::$dbo->escape($table); $table = self::$dbo->escape($table);
@ -1274,7 +1274,7 @@ class dba {
* *
* $data = dba::select($table, $fields, $condition, $params); * $data = dba::select($table, $fields, $condition, $params);
*/ */
static public function select($table, $fields = array(), $condition = array(), $params = array()) { public static function select($table, $fields = array(), $condition = array(), $params = array()) {
if ($table == '') { if ($table == '') {
return false; return false;
} }
@ -1341,7 +1341,7 @@ class dba {
* @param object $stmt statement object * @param object $stmt statement object
* @return array Data array * @return array Data array
*/ */
static public function inArray($stmt, $do_close = true) { public static function inArray($stmt, $do_close = true) {
if (is_bool($stmt)) { if (is_bool($stmt)) {
return $stmt; return $stmt;
} }
@ -1362,7 +1362,7 @@ class dba {
* @param object $stmt statement object * @param object $stmt statement object
* @return boolean was the close successfull? * @return boolean was the close successfull?
*/ */
static public function close($stmt) { public static function close($stmt) {
if (!is_object($stmt)) { if (!is_object($stmt)) {
return false; return false;
} }

View File

@ -1027,7 +1027,7 @@ class Diaspora {
* *
* @return the replaced string * @return the replaced string
*/ */
public function replace_people_guid($body, $author_link) { public static function replace_people_guid($body, $author_link) {
$return = preg_replace_callback("&\[url=/people/([^\[\]]*)\](.*)\[\/url\]&Usi", $return = preg_replace_callback("&\[url=/people/([^\[\]]*)\](.*)\[\/url\]&Usi",
function ($match) use ($author_link) { function ($match) use ($author_link) {
// $match // $match

View File

@ -43,7 +43,7 @@ class ostatus {
* *
* @return array Array of author related entries for the item * @return array Array of author related entries for the item
*/ */
private function fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch) { private static function fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch) {
$author = array(); $author = array();
$author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue; $author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
@ -758,7 +758,7 @@ class ostatus {
* *
* @param object $actor The actor object that contains the contact data * @param object $actor The actor object that contains the contact data
*/ */
private function conv_fetch_actor($actor) { private static function conv_fetch_actor($actor) {
// We set the generation to "3" since the data here is not as reliable as the data we get on other occasions // We set the generation to "3" since the data here is not as reliable as the data we get on other occasions
$contact = array("network" => NETWORK_OSTATUS, "generation" => 3); $contact = array("network" => NETWORK_OSTATUS, "generation" => 3);
@ -814,7 +814,7 @@ class ostatus {
* *
* @return string The conversation url * @return string The conversation url
*/ */
private function fetch_conversation($self, $conversation_id = "") { private static function fetch_conversation($self, $conversation_id = "") {
if ($conversation_id != "") { if ($conversation_id != "") {
$elements = explode(":", $conversation_id); $elements = explode(":", $conversation_id);
@ -856,7 +856,7 @@ class ostatus {
* *
* @return object The shared object * @return object The shared object
*/ */
private function shared_object($id, $conversation) { private static function shared_object($id, $conversation) {
if (!is_array($conversation->items)) { if (!is_array($conversation->items)) {
return false; return false;
} }
@ -877,7 +877,7 @@ class ostatus {
* *
* @return array Array with actor details * @return array Array with actor details
*/ */
private function get_actor_details($actor, $uid, $contact_id) { private static function get_actor_details($actor, $uid, $contact_id) {
$details = array(); $details = array();
@ -921,7 +921,7 @@ class ostatus {
* *
* @return integer The item id of the posted item array * @return integer The item id of the posted item array
*/ */
private function completion($conversation_url, $uid, $item = array(), $self = "") { private static function completion($conversation_url, $uid, $item = array(), $self = "") {
/// @todo This function is totally ugly and has to be rewritten totally /// @todo This function is totally ugly and has to be rewritten totally
@ -1335,7 +1335,7 @@ class ostatus {
* @param integer $itemid The id of the item * @param integer $itemid The id of the item
* @param string $conversation_url The uri of the conversation * @param string $conversation_url The uri of the conversation
*/ */
private function store_conversation($itemid, $conversation_url) { private static function store_conversation($itemid, $conversation_url) {
$conversation_url = self::convert_href($conversation_url); $conversation_url = self::convert_href($conversation_url);
@ -1363,7 +1363,7 @@ class ostatus {
* *
* @return string The guid if the post is a reshare * @return string The guid if the post is a reshare
*/ */
private function get_reshared_guid($item) { private static function get_reshared_guid($item) {
$body = trim($item["body"]); $body = trim($item["body"]);
// Skip if it isn't a pure repeated messages // Skip if it isn't a pure repeated messages
@ -1399,7 +1399,7 @@ class ostatus {
* *
* @return string The cleaned body * @return string The cleaned body
*/ */
private function format_picture_post($body) { private static function format_picture_post($body) {
$siteinfo = get_attached_data($body); $siteinfo = get_attached_data($body);
if (($siteinfo["type"] == "photo")) { if (($siteinfo["type"] == "photo")) {
@ -1434,7 +1434,7 @@ class ostatus {
* *
* @return object header root element * @return object header root element
*/ */
private function add_header($doc, $owner) { private static function add_header($doc, $owner) {
$a = get_app(); $a = get_app();
@ -1506,7 +1506,7 @@ class ostatus {
* @param object $root XML root element where the hub links are added * @param object $root XML root element where the hub links are added
* @param array $item Data of the item that is to be posted * @param array $item Data of the item that is to be posted
*/ */
private function get_attachment($doc, $root, $item) { private static function get_attachment($doc, $root, $item) {
$o = ""; $o = "";
$siteinfo = get_attached_data($item["body"]); $siteinfo = get_attached_data($item["body"]);
@ -1571,7 +1571,7 @@ class ostatus {
* *
* @return object author element * @return object author element
*/ */
private function add_author($doc, $owner) { private static function add_author($doc, $owner) {
$r = q("SELECT `homepage`, `publish` FROM `profile` WHERE `uid` = %d AND `is-default` LIMIT 1", intval($owner["uid"])); $r = q("SELECT `homepage`, `publish` FROM `profile` WHERE `uid` = %d AND `is-default` LIMIT 1", intval($owner["uid"]));
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
@ -1678,7 +1678,7 @@ class ostatus {
* *
* @return object Entry element * @return object Entry element
*/ */
private function entry($doc, $item, $owner, $toplevel = false) { private static function entry($doc, $item, $owner, $toplevel = false) {
$repeated_guid = self::get_reshared_guid($item); $repeated_guid = self::get_reshared_guid($item);
if ($repeated_guid != "") if ($repeated_guid != "")
$xml = self::reshare_entry($doc, $item, $owner, $repeated_guid, $toplevel); $xml = self::reshare_entry($doc, $item, $owner, $repeated_guid, $toplevel);
@ -1703,7 +1703,7 @@ class ostatus {
* *
* @return object Source element * @return object Source element
*/ */
private function source_entry($doc, $contact) { private static function source_entry($doc, $contact) {
$source = $doc->createElement("source"); $source = $doc->createElement("source");
xml::add_element($doc, $source, "id", $contact["poll"]); xml::add_element($doc, $source, "id", $contact["poll"]);
xml::add_element($doc, $source, "title", $contact["name"]); xml::add_element($doc, $source, "title", $contact["name"]);
@ -1727,7 +1727,7 @@ class ostatus {
* *
* @return array Contact array * @return array Contact array
*/ */
private function contact_entry($url, $owner) { private static function contact_entry($url, $owner) {
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` IN (0, %d) ORDER BY `uid` DESC LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` IN (0, %d) ORDER BY `uid` DESC LIMIT 1",
dbesc(normalise_link($url)), intval($owner["uid"])); dbesc(normalise_link($url)), intval($owner["uid"]));
@ -1774,7 +1774,7 @@ class ostatus {
* *
* @return object Entry element * @return object Entry element
*/ */
private function reshare_entry($doc, $item, $owner, $repeated_guid, $toplevel) { private static function reshare_entry($doc, $item, $owner, $repeated_guid, $toplevel) {
if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) {
logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG);
@ -1840,7 +1840,7 @@ class ostatus {
* *
* @return object Entry element with "like" * @return object Entry element with "like"
*/ */
private function like_entry($doc, $item, $owner, $toplevel) { private static function like_entry($doc, $item, $owner, $toplevel) {
if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) {
logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG);
@ -1877,7 +1877,7 @@ class ostatus {
* *
* @return object author element * @return object author element
*/ */
private function add_person_object($doc, $owner, $contact) { private static function add_person_object($doc, $owner, $contact) {
$object = $doc->createElement("activity:object"); $object = $doc->createElement("activity:object");
xml::add_element($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON); xml::add_element($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON);
@ -1923,7 +1923,7 @@ class ostatus {
* *
* @return object Entry element * @return object Entry element
*/ */
private function follow_entry($doc, $item, $owner, $toplevel) { private static function follow_entry($doc, $item, $owner, $toplevel) {
$item["id"] = $item["parent"] = 0; $item["id"] = $item["parent"] = 0;
$item["created"] = $item["edited"] = date("c"); $item["created"] = $item["edited"] = date("c");
@ -1985,7 +1985,7 @@ class ostatus {
* *
* @return object Entry element * @return object Entry element
*/ */
private function note_entry($doc, $item, $owner, $toplevel) { private static function note_entry($doc, $item, $owner, $toplevel) {
if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) {
logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG);
@ -2012,7 +2012,7 @@ class ostatus {
* *
* @return string The title for the element * @return string The title for the element
*/ */
private function entry_header($doc, &$entry, $owner, $toplevel) { private static function entry_header($doc, &$entry, $owner, $toplevel) {
/// @todo Check if this title stuff is really needed (I guess not) /// @todo Check if this title stuff is really needed (I guess not)
if (!$toplevel) { if (!$toplevel) {
$entry = $doc->createElement("entry"); $entry = $doc->createElement("entry");
@ -2048,7 +2048,7 @@ class ostatus {
* @param string $verb The activity verb * @param string $verb The activity verb
* @param bool $complete Add the "status_net" element? * @param bool $complete Add the "status_net" element?
*/ */
private function entry_content($doc, $entry, $item, $owner, $title, $verb = "", $complete = true) { private static function entry_content($doc, $entry, $item, $owner, $title, $verb = "", $complete = true) {
if ($verb == "") if ($verb == "")
$verb = self::construct_verb($item); $verb = self::construct_verb($item);
@ -2086,7 +2086,7 @@ class ostatus {
* @param array $owner Contact data of the poster * @param array $owner Contact data of the poster
* @param $complete * @param $complete
*/ */
private function entry_footer($doc, $entry, $item, $owner, $complete = true) { private static function entry_footer($doc, $entry, $item, $owner, $complete = true) {
$mentioned = array(); $mentioned = array();