]> git.mxchange.org Git - friendica.git/commitdiff
And some more static warnings removed
authorMichael <heluecht@pirati.ca>
Sat, 26 Aug 2017 10:01:50 +0000 (10:01 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 26 Aug 2017 10:01:50 +0000 (10:01 +0000)
include/Contact.php
include/dba.php
include/dbm.php
include/items.php
include/ostatus.php
include/socgraph.php
src/App.php
src/Core/System.php

index 95c7979aaccf420a6325b8d934d17705bc9aad26..7d480ab020759e7f979ece2bf5f84395d09701f9 100644 (file)
@@ -523,7 +523,7 @@ function contacts_not_grouped($uid,$start = 0,$count = 0) {
  * @return integer Contact ID
  */
 function get_contact($url, $uid = 0, $no_update = false) {
-       logger("Get contact data for url ".$url." and user ".$uid." - ".App::callstack(), LOGGER_DEBUG);
+       logger("Get contact data for url ".$url." and user ".$uid." - ".System::callstack(), LOGGER_DEBUG);
 
        $data = array();
        $contact_id = 0;
index ab93598cdd60e3e3684f6a15480d166744c48fcb..c945228297a22cf685f4258ec2767ef7ebf059a0 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+use \Friendica\Core\System;
+
 require_once("dbm.php");
 require_once('include/datetime.php');
 
@@ -228,7 +230,7 @@ class dba {
                $orig_sql = $sql;
 
                if (x($a->config,'system') && x($a->config['system'], 'db_callstack')) {
-                       $sql = "/*".$a->callstack()." */ ".$sql;
+                       $sql = "/*".System::callstack()." */ ".$sql;
                }
 
                $columns = 0;
@@ -549,7 +551,7 @@ class dba {
                $orig_sql = $sql;
 
                if (x($a->config,'system') && x($a->config['system'], 'db_callstack')) {
-                       $sql = "/*".$a->callstack()." */ ".$sql;
+                       $sql = "/*".System::callstack()." */ ".$sql;
                }
 
                self::$dbo->error = '';
@@ -679,7 +681,7 @@ class dba {
                        $errorno = self::$dbo->errorno;
 
                        logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n".
-                               $a->callstack(8)."\n".self::replace_parameters($sql, $params));
+                               System::callstack(8)."\n".self::replace_parameters($sql, $params));
 
                        self::$dbo->error = $error;
                        self::$dbo->errorno = $errorno;
@@ -742,7 +744,7 @@ class dba {
                        $errorno = self::$dbo->errorno;
 
                        logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n".
-                               $a->callstack(8)."\n".self::replace_parameters($sql, $params));
+                               System::callstack(8)."\n".self::replace_parameters($sql, $params));
 
                        self::$dbo->error = $error;
                        self::$dbo->errorno = $errorno;
@@ -914,7 +916,7 @@ class dba {
         *
         * @return integer Last inserted id
         */
-       function lastInsertId() {
+       public static function lastInsertId() {
                switch (self::$dbo->driver) {
                        case 'pdo':
                                $id = self::$dbo->db->lastInsertId();
index de4aef7d2b196cf89a5bcb5578da6e98b45285bf..1be1647a4633f798ecf9da0420f5cfebed037ca4 100644 (file)
@@ -107,6 +107,6 @@ class dbm {
                        $timestamp = -62135596800;
                }
 
-               return date('Y-m-d H:i:s', $timestamp);
+               return date('Y-m-d H:i:s', (int)$timestamp);
        }
 }
index e8ec81277c8d5e48b563368c6371be88b038be4a..7bcd00aada139004578d1c064c788e5327f50be0 100644 (file)
@@ -666,7 +666,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
        }
 
        if (($arr['author-link'] == "") && ($arr['owner-link'] == "")) {
-               logger("Both author-link and owner-link are empty. Called by: " . App::callstack(), LOGGER_DEBUG);
+               logger("Both author-link and owner-link are empty. Called by: " . System::callstack(), LOGGER_DEBUG);
        }
 
        if ($arr['plink'] == "") {
index cd626201fcde4e0d04065445290b3285cea2bc3c..809a48cd0260d73f9b8a3e45c1a64a3c8d673c98 100644 (file)
@@ -1650,7 +1650,7 @@ class ostatus {
         *
         * @return string activity
         */
-       function construct_verb($item) {
+       private static function construct_verb($item) {
                if ($item['verb'])
                        return $item['verb'];
                return ACTIVITY_POST;
@@ -1663,7 +1663,7 @@ class ostatus {
         *
         * @return string Object type
         */
-       function construct_objecttype($item) {
+       private static function construct_objecttype($item) {
                if (in_array($item['object-type'], array(ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT)))
                        return $item['object-type'];
                return ACTIVITY_OBJ_NOTE;
index 0a28a177f85ae74efb749a5deb8172f1716de486..d3f70075b2ffe1cf2b8ab3e3051df4ad538fee29 100644 (file)
@@ -2013,7 +2013,7 @@ function clean_contact_url($url) {
        }
 
        if ($new_url != $url) {
-               logger("Cleaned contact url ".$url." to ".$new_url." - Called by: ".App::callstack(), LOGGER_DEBUG);
+               logger("Cleaned contact url ".$url." to ".$new_url." - Called by: ".System::callstack(), LOGGER_DEBUG);
        }
 
        return $new_url;
@@ -2028,7 +2028,7 @@ function fix_alternate_contact_address(&$contact) {
        if (($contact["network"] == NETWORK_OSTATUS) && poco_alternate_ostatus_url($contact["url"])) {
                $data = probe_url($contact["url"]);
                if ($contact["network"] == NETWORK_OSTATUS) {
-                       logger("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".App::callstack(), LOGGER_DEBUG);
+                       logger("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
                        $contact["url"] = $data["url"];
                        $contact["addr"] = $data["addr"];
                        $contact["alias"] = $data["alias"];
@@ -2049,7 +2049,7 @@ function get_gcontact_id($contact) {
        $doprobing = false;
 
        if (in_array($contact["network"], array(NETWORK_PHANTOM))) {
-               logger("Invalid network for contact url ".$contact["url"]." - Called by: ".App::callstack(), LOGGER_DEBUG);
+               logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
                return false;
        }
 
@@ -2290,7 +2290,7 @@ function update_gcontact_from_probe($url) {
        $data = probe_url($url);
 
        if (in_array($data["network"], array(NETWORK_PHANTOM))) {
-               logger("Invalid network for contact url ".$data["url"]." - Called by: ".App::callstack(), LOGGER_DEBUG);
+               logger("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
                return;
        }
 
index a5c6f34227e7216713301712736912d6bb89c691..67dfacf7a3fb891d0409da759b1768703cbe9c28 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Friendica;
 
+use Friendica\Core\System;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 
@@ -683,7 +684,7 @@ class App {
                $this->performance[$value] += (float) $duration;
                $this->performance['marktime'] += (float) $duration;
 
-               $callstack = $this->callstack();
+               $callstack = System::callstack();
 
                if (!isset($this->callstack[$value][$callstack])) {
                        // Prevent ugly E_NOTICE
@@ -736,30 +737,6 @@ class App {
                q('DELETE FROM `process` WHERE `pid` = %d', intval(getmypid()));
        }
 
-       /**
-        * @brief Returns a string with a callstack. Can be used for logging.
-        *
-        * @return string
-        */
-       function callstack($depth = 4) {
-               $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth + 2);
-
-               // We remove the first two items from the list since they contain data that we don't need.
-               array_shift($trace);
-               array_shift($trace);
-
-               $callstack = array();
-               foreach ($trace AS $func) {
-                       if (!empty($func['class'])) {
-                               $callstack[] = $func['class'].'::'.$func['function'];
-                       } else {
-                               $callstack[] = $func['function'];
-                       }
-               }
-
-               return implode(', ', $callstack);
-       }
-
        function get_useragent() {
                return
                        FRIENDICA_PLATFORM . " '" .
index c64739a427054fc178dde546b2b93813144856d2..36870af6d2cc2b7437e80f50ee4ab0df498f2581 100644 (file)
@@ -46,11 +46,35 @@ class System {
         *
         * @return string The cleaned url
         */
-        function removedBaseUrl($orig_url) {
+       public static function removedBaseUrl($orig_url) {
                self::init();
                return self::$a->remove_baseurl($orig_url);
        }
 
+       /**
+        * @brief Returns a string with a callstack. Can be used for logging.
+        *
+        * @return string
+        */
+       public static function callstack($depth = 4) {
+               $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth + 2);
+
+               // We remove the first two items from the list since they contain data that we don't need.
+               array_shift($trace);
+               array_shift($trace);
+
+               $callstack = array();
+               foreach ($trace AS $func) {
+                       if (!empty($func['class'])) {
+                               $callstack[] = $func['class'].'::'.$func['function'];
+                       } else {
+                               $callstack[] = $func['function'];
+                       }
+               }
+
+               return implode(', ', $callstack);
+       }
+
        /// @todo Move the following functions from boot.php
        /*
        function get_guid($size = 16, $prefix = "")